Scaling Optimization Variables and Constraints

855 views
Skip to first unread message

arey

unread,
Jan 6, 2018, 2:41:25 PM1/6/18
to YALMIP
I've been using MOSEK and YALMIP to solve a particular class of convex optimization problem, and recently decided to try and use the ECOS solver as it seems to produce faster results when dealing with relatively small problems. However, when I change the solver with sdpsettings('solver','ecos'), the problem fails to converge. I originally thought that this was because the problem I'm trying to solve was poorly scaled and MOSEK used some form of variable re-scaling before solving the problem, whereas ECOS did not. Because of this I tried doing my own re-scaling, but ECOS still fails to converge, and as such I was hoping to check if my re-scaling attempt was actually implemented correctly.

As an example of re-scaling equality constraints, I simply multiplied the left- and right-hand side of each constraint by the same scaling factor in order to bring each value in the vector close to 1:
length_scale*r(:,t+1) == length_scale*y(1:3,t+1);
velocity_scale*v(:,t+1) == velocity_scale*y(4:6,t+1);
mass_scale*mc(t+1) == mass_scale*y(7,t+1);
force_scale*tau(:,t+1) == force_scale*u(1:3,t+1);

Similarly, re-scaling inequality constraints was done as follows,
force_scale*sig <= force_scale*(T_max.*exp(-mck).*(1-(mc-mck)));

where length_scale, velocity_scale, mass_scale and force_scale were used to re-scale the lengths, velocities, masses and forces to values around 1, respectively. Finally, since the problem was trying to maximize the final mass, I re-scaled the objective function using mass_scale,
objective = mass_scale*(-mc(N))

The error I get is,
Error using  -  (line 54)
Adding NaN to an SDPVAR makes no sense.
Error in Convex_Opt_Scaled (line 214)
force_scale*sig <= force_scale*(T_max.*exp(-mck).*(1-(mc-mck)));

I was wondering if these errors occurred because my re-scaling attempts were incorrect, or if there could be another problem with my code completely unrelated to scaling issues.
           

Johan Löfberg

unread,
Jan 6, 2018, 3:15:27 PM1/6/18
to YALMIP
something in that expression is a nan. hence, you will have to look at the data and see which one you've messed up with and scaled to nan

arey

unread,
Jan 6, 2018, 4:18:05 PM1/6/18
to YALMIP
Thanks Johan, aside from the NaN result, do my re-scaling attempts look like they're correctly implemented (i.e. simply multiplying both sides of the equality/inequality constraints and objective function by an appropriate scaling factor)? I tried solving the above manually re-scaled problem in MOSEK and got the same results as the default un-scaled problem that I originally wrote, which makes me think that the re-scaling isn't producing a divide by zero error. As an aside, I tried solving the problem using SDPT3 which also gave me the exact same error as ECOS. Looking at the output from ECOS, it looks like constraints are being violated, which makes me wonder how MOSEK can handle such constraints but SDPT3 and ECOS can't. I'll have to dig a little deeper into this one.

Johan Löfberg

unread,
Jan 6, 2018, 5:05:56 PM1/6/18
to YALMIP
impossible to answer, there is no standard way to scale a problem. all solvers will have various internal heuristics also. try to have decision variables and data nice, that is the only general thing one can say.

Erling D. Andersen

unread,
Jan 8, 2018, 4:14:02 AM1/8/18
to YALMIP
MOSEK does a lot presolve/preprocessing. In case of small problems it may not be worthwhile. However, that might also help you solving nasty problems. Maybe that is what you are seeing.
Reply all
Reply to author
Forward
0 new messages