The difference between "solvemp" and "solvesdp"?

1,032 views
Skip to first unread message

yu wang

unread,
Aug 15, 2013, 4:44:33 AM8/15/13
to yal...@googlegroups.com
Hi Everyone,

I am fresh to Yalmip and trying to learn it. When I read the tutorial in the website, I got one point not sure.

If I have a linear problem like:

min f(x)
s.t. F(x,z)>B

Do I need to use solvemp, because the constraints are not only related to variable "x"?

That is, if the problem has only one variable, we use solvesdp; if the problem has more than one variable, even some variables are not objective variables, we still need to use solvemp?

Thank you for your help.

Best Regards,
Yu Wang

yu wang

unread,
Aug 15, 2013, 5:29:07 AM8/15/13
to yal...@googlegroups.com
I feel that if the MPT is used, the solvemp should be used. However, if I use "cplex" as the solver, do I still need to claim the non-decision variable? Or I just need to use solvesdp instead of solvemp, and let the cplex to do other things?

Johan Löfberg

unread,
Aug 15, 2013, 6:27:55 AM8/15/13
to yal...@googlegroups.com
solvemp is used when you want to solve a multi-parametric problem, i.e., you want to compute what the optimal solution of x looks like as a function of, e.g., B, i.e., x(B). That is most likely not anything you want.

Johan Löfberg

unread,
Aug 15, 2013, 6:28:44 AM8/15/13
to yal...@googlegroups.com
What do you mean with a non-decision variable. It is either a fixed constant, or something you can decide (or it is a parameter in a parametric problem, which I don't think you have)

Johan Löfberg

unread,
Aug 15, 2013, 6:29:27 AM8/15/13
to yal...@googlegroups.com
solvesdp is used for an arbitrary amount of decision variables

yu wang

unread,
Aug 15, 2013, 7:54:16 AM8/15/13
to yal...@googlegroups.com
I would like to take an example here:

min 3*x1+x2
s.t.
      x1+2*x2>=y1+y2;
      2*x1+x2>=y1+y2;
      y1+y2<=3;
      y1+y2>=1;
      x,y>=0

In this problem, x is the decision variable, which is the objective of this problem. y is non-decision variable, which is not in the objective. However, it is clear x has certain relation with y. 

If I write this problem like:

x = sdpvar(1,2);
y = sdpvar(1,2);
A = [3 1];
objective = A*x';
C1 = [1 2];
C2 = [2 1];
C3 = [1 1];

ct1 = set(C1*x'>=C3*y');
ct2 = set(C2*x'>=C3*y');
ct3 = set(x>=0);
ct4 = set(y>=0);
ct5 = set(C3*y'<=3);
ct6 = set(C3*y'>=1);

constraints = ct1+ct2+ct3+ct4+ct5+ct6;
option = sdpsettings('solver','cplex','verbose',1);

Should I use 1) or 2):
1)
solvesdp(constraints, objective);

2)
solvemp(constraints, objective, [], y);

Which one is right?

Thank you very much.

Johan Löfberg

unread,
Aug 15, 2013, 9:00:41 AM8/15/13
to yal...@googlegroups.com
The fact that a variable only appears in the constraint does not mean it is not a decision variable. It is a variable which has to be decided by the solver, hence it is a decision variable.

Consider the following problem: Johan and Yu gets $10 from Bill. Johan now wants to share the money among Johan and Yu while getting as much as possible him self.

Hence

maximize johan

s.t. johan+yu == 10, johan >=0, yu >= 0

Obviously both johan yu are decision variables, but only johan appear in the objective.


Regarding your model. First, SET is obsolete, don't use it

Secondly, you can write everything directly, you don't have to define matrices etc. That is the whole reason for using a modeling language (although here, it might be relevant to define the matrices since they occur multiple times)

x = sdpvar(1,2);
y = sdpvar(1,2);
A = [3 1];
%objective = A*x';
objective =3*x(1)+x(2);

%ct1 = C1*x'>=C3*y';
%ct2 = C2*x'>=C3*y';
%ct3 = x>=0;
%ct4 = y>=0;
%ct5 = C3*y'<=3;
%ct6 = C3*y'>=1;
%constraints = ct1+ct2+ct3+ct4+ct5+ct6;

constraints = [x(1) +2*x(2) >=y(1)+y(2),
                     2*x(1)+x(2)  >=
y(1)+y(2),
                   x>=0,y>=0,...]

option = sdpsettings('solver','cplex','verbose
',1);
solvesdp(constraints,objective)


yu wang

unread,
Aug 15, 2013, 9:16:32 PM8/15/13
to yal...@googlegroups.com
Got it. Thank you very much.

Multi-parameteric Problem:

Overall, multiparametric programming is a technique for solving any optimization problem, where the objective is to minimize or maximize a performance criterion subject to a given set of constraints and where some of the parameters vary between specified lower and upper bounds.

The advantage of using multiparametric programming to address these problems is that for problems pertaining to plant operations, such as for process planning, scheduling, and control, one can obtain a complete map of all the optimal solutions. Hence, as the operating conditions vary, one does not have to reoptimize for the new set of conditions, since the optimal solution is already available as a function of the operating conditions.

The solution of this kind of problem still has a variable left there regarding to some condition.
Reply all
Reply to author
Forward
0 new messages