How can I get the model built by cvx?


(Jianqiao Huang) #1

Hi,

I set “cvx_solver mosek”. Can I get the model that is built by cvx? I mean the model that Mosek uses from cvx. I use ADMM-SDP, so I will run the model a lot of iterations. Each time I just change my model a little bit, but it takes cvx a lot of time to build the model from scratch.


(Mark L. Stone) #2


dumpfile may not necessarily meet your needs, but is about all you can do with CVX

help cvx_solver_settings

... 
    cvx_solver_settings( 'dumpfile', <filename> ) is a setting supported by
    all solvers. If set, it will save a .MAT file containing the exact
    input arguments delivered to the solver. This file will be created
    immediately before the solver is called, so you will be able to examine
    their contents even if the solver fails with an error. This feature is
    to be used primarily by solver developers.

(Jianqiao Huang) #3

Thanks. I tired “cvx_solver_settings( ‘dumpfile’, ‘filename’)”. Now get the file dumped from cvx. Can I run mosek directly from the dumped file? If I still need to use cvx, can I utilize the dumped file to reduce modeling time for cvx?


(Mark L. Stone) #4

I will defer to one of the Mosek guys who visit the forum to answer your question about Mosek.

If you figure out how to use the dumped file, at that point you would not longer be using CVX. There is no way to eliminate the “modeling” time when running CVX for multiple problems. Techniques such as vectorization may minimize modeling time, but not in any special way for multiplee instances of a problem vs. one instance.


(Michal Adamaszek) #5

If it really “will save a .MAT file containing the exact input arguments delivered to the solver” then it probably saves the “prob” structure which can be used in mosekopt, that is Mosek direct interface in Matlab. If you can figure out how your data was transformed by cvx then perhaps you can also figure out how and where to change that “prob” for varying data. That sounds like a terrible hack though.


(Jianqiao Huang) #6

Hi Mark and Michal,

I can successfully dumped file for some models, but not every model. And I get the following error information.

Error using cell2struct
Number of field names must match number of fields in new structure.

Error in cvx_run_solver (line 68)
_ dstruct = cell2struct( [ inputs, varargout, output ], [ inp_names, otp_names, ‘output’ ], 2 ); %#ok_

Error in cvx_mosek

Error in cvxprob/solve (line 429)
_ [ x, status, tprec, iters ] = shim.solve( At, b, c, cones, quiet, prec, solv.settings, eargs{:} );_

Error in cvx_end (line 88)
_ solve( prob );_

Error in distr_ADMM_8500_3depth_VirtualMeasTest (line 1740)
_ cvx_end_

Someone posted this problem on 2016, but it has not been solved yet. I still can get dumped file with only command, prob, param. When I dumped the file successfully in the other models, I can get prob, param,rr, res, output. What’s more, I didn’t type “cvx_begin quiet”, but I can’t get screen output.

When I comment “cvx_solver_settings( ‘dumpfile’, ‘filename’)”, cvx and MOSEK work properly. I don’t know why dumping file affect cvx and MOSEK. Is it possible that cvx dump file before screening out the results? I guess something is wrong when mosek return the solution to cvx or when cvx output the task file.

I feed the not successfully dumped file to MOSEK by [r,res]=mosekopt(Md.command,Md.prob,Md.param). I get matrix variable by “V(id)=res.sol.itr.barx”. From what I read, the lower triangular of matrix variables are stacked column-by-column into an array. The Matrix variable V here is the same as the matrix variable from cvx when commenting “cvx_solver_settings( ‘dumpfile’, ‘filename’)”. But once the error appears, the code will stop, and I can’t run the following iterations.

How can I solve the problem?

Thanks,
Jianqiao Huang


(Mark L. Stone) #7

I think you will have to just try whatever workarounds you ca n come up with. Unfortunately, CVX is not in a very active state of development now, so I don;t think you can expect bugs such as you have encountered to necessarily be fixed. On the other hand, CVX source code is available in your installation, so you can feel free to inspect it and try to determine fixes yourself, in which case you should feel free to post whatever fixes or workarounds you come up with.

Good luck.