Using CVX with multiple RHS


#1

I want to minimize a system of equation that has multiple right hand side (RHS). In the following piece of code, I defined my minimization function, which takes different RHS to compute the minimized solution and I have to loop through the entire RHSs.

For the problem I am dealing with ntime = 1000, n = 4000, and m = 50. x is different for each timeframe corresponding to its RHS. In other words, the solution x_all is of size ntime×n. Since the only thing that changes in the above code is the RHS, is there anyway to input all the RHSs to CVX and eliminate the for-loop and make the whole process more efficient?


(Mark L. Stone) #2

I don’t know whether the following, which involves only a single pass through cvx_begin … cvx_end., would be more or less efficient than your current code.

Presuming that you have enough memory, stack all ntime x vectors into one x, stack the b vectors, form matrices with A and L on the block diagonals, and use these in a single objective function instead of your current formulation.

Alternatively, you could build up the objective function as an expression in a for loop, which adds the objective functions for each RHS, as suggested by me at Large measurements b matrix .

Either way, I believe you will be solving what decomposes into ntime “independent” optimization problems, which are the same as your current problems. But it will be submitted as a single problem.


#3

Thanks Mark. I had tried augmenting all the RHS together to solve a huge system of equations, which was not faster. Also seems like summing objecting functions (as suggested by you in the link) is not faster either. Solving for each timestep for my case looks like the fastest among these methods.

If I use CVX in other environments rather than MATLAB, would it help?


(Mark L. Stone) #4

CVX only runs under MATLAB.

In any event, CVX is optimized for ease of modeling, rather than speed of execution. So if you want something to run fast, you may need to look at an alternative.


#5

May I know your suggestions for realtime-applications?


(Denis Rosset) #6

You can always interface the solver directly, without using CVX.

Get inspiration from what CVX passes to the solver (using the solver_dump option), and format the input data yourself. Your problem has a simple enough structure for this to be worthwhile.

CVX will be really helpful so that you can compare different solvers before deciding on one (switching solvers while using CVX is incredibly easy).


#7

Sounds very interesting to see what CVX passes to the solver. However, I was not able to find any information on solver_dump option in the documentation. I also found this thread . Would you post an example how solver_dump works?


(Denis Rosset) #8

Add this before calling cvx_solve:

cvx_solver_settings('dumpfile', 'file.mat')

and file.mat will contain the solver input.

Note: to understand the contents of file.mat, you will have to dig in the corresponding solver documentation.