how to get optimal solution corresponding to the variables that I defined with sdpvar() and binvar() after using export()?

77 views
Skip to first unread message

Xinwei Shen

unread,
Aug 3, 2017, 6:47:20 AM8/3/17
to YALMIP
how to get optimal solution corresponding to the variables that I defined with sdpvar() and binvar() after using export() and solving it with Cplexmilp?

I used export() to get a Cplex model after formulation with yalmip, so that I can adjust some new parameters in Cplex 12.7.0 to do Benders Decomposition. 
However, when I get the optimal solution x with cplexmilp(), how can I make x corresponding to variables defined with sdpvar() and binvar() ? They are all in x and seems the same.

[MODEL,RECOVERYMODEL,DIAGNOSTIC,INTERNAL] = export(Constraints,Obj,ops);
MODEL.options.benders.strategy=3; % benders decomposition paramters
[x,fval,exitflag,output]=cplexmilp(MODEL.f,MODEL.Aineq,MODEL.bineq,MODEL.Aeq,MODEL.beq,[],[],[],MODEL.lb,MODEL.ub,MODEL.ctype',MODEL.x0,MODEL.options);


Johan Löfberg

unread,
Aug 3, 2017, 7:07:16 AM8/3/17
to YALMIP
should be something like

[model,map] = export(...)
...
assign
(recover(map.used_variables),numericalsolution)



Amanda Chen

unread,
Dec 5, 2018, 8:35:27 AM12/5/18
to YALMIP
Dear professor,

I’ve used the same way.
After I calculate
[MODEL,RECOVERYMODEL,DIAGNOSTIC,INTERNAL] = export(Constraints,Obj,ops);

I found in my problem the size of recoverymodel.used_variables, which is 1*6819, is less than the variables in model, which is 1*7629.

Then I used the code:
[x,fval,exitflag,output]=cplexmilp(MODEL.f,MODEL.Aineq,MODEL.bineq,MODEL.Aeq,MODEL.beq,[],[],[],MODEL.lb,MODEL.ub,MODEL.ctype',MODEL.x0,MODEL.options);
assign(recover(recoverymodel.used_variables,x);

and it occurred that the variables cannot be recovered. it’s necessary that Both arguments must have same size when using assign function.

Could you give me some suggestions in solving such a problem? How to recover the variable when the size of recoverymodel.used_variables is less than the variables in model?

Johan Löfberg

unread,
Dec 5, 2018, 9:30:03 AM12/5/18
to YALMIP
you would have to supply a minimal reproducible example
Reply all
Reply to author
Forward
0 new messages