The robust optimization problem

651 views
Skip to first unread message

yongjie wang

unread,
May 15, 2014, 2:26:31 AM5/15/14
to yal...@googlegroups.com
Hi,Johan,when i run a LP robust optimization problem with cplex,mosek or gurobi,it went wrong, the problem as follows:
***** Starting YALMIP robustification module. *********************
 - Detected 2 uncertain variables
 - Detected 2 independent group(s) of uncertain variables
 - Complicating terms in w encountered. Trying to eliminate by forcing some decision variables to 0
Error using filter_eliminatation (line 15)
Cannot get rid of nonlinear uncertainty in uncertain constraint

Error in robustify (line 124)
[F_eq_left,F_eliminate_equality] = filter_eliminatation(F_eq,w,0,ops);

Error in solverobust (line 64)
[F,h,failure] = robustify(varargin{:});

Error in solvesdp (line 186)
        diagnostic =
        solverobust(F(find(~unc_declarations)),h,options,recover(getvariables(sdpvar(F(find(unc_declarations))))));
        
Error in socpstylelinearabentawangsunxiugai (line 90)
sol=solvesdp(con,obj,ops);
 
So,there are only two uncertain variables,and with LP problem,equality constraints and inequa constraints,the two uncertain variables are all in equality constraints.What is the reason,it trouble me a lot,thanks.

Johan Löfberg

unread,
May 15, 2014, 2:31:13 AM5/15/14
to yal...@googlegroups.com
You will have to show us the model (as simple as possible but still reproducing this issue)

yongjie wang

unread,
May 15, 2014, 2:50:15 AM5/15/14
to yal...@googlegroups.com
It is an electrical problem,about  power flow in radial distribution system,the model is complex,can i send my .m file to you???

Johan Löfberg

unread,
May 15, 2014, 2:54:39 AM5/15/14
to yal...@googlegroups.com
Yes

Johan Löfberg

unread,
May 15, 2014, 3:02:50 AM5/15/14
to yal...@googlegroups.com
BTW, a simple way to reproduce your issues is

 C = [uncertain(w), x+w^3 <= 1, A*w<=b]

This will give the same failure. This case cannot be dealt with by YALMIP, since the uncertainty enters in a way that doesn't fit into any of the classes that are supported by YALMIP (there is no simple robust counterpart). See the Automatic robust programming paper to see what classes are supported)

yongjie wang

unread,
May 15, 2014, 3:18:38 AM5/15/14
to yal...@googlegroups.com
It is the form like x+y+z=w,uncertain(w),y^2=p,where p,x,y,z is variables,but i make the y^2 linearization,so all the formulation are linear,the problem happened.

Johan Löfberg

unread,
May 15, 2014, 4:05:42 AM5/15/14
to
The crash says otherwise, so you have to supply the model

Johan Löfberg

unread,
May 15, 2014, 4:35:09 AM5/15/14
to yal...@googlegroups.com
BTW, it makes no sense to say x+y+z=w when w is uncertain. How can an equality hold for a range of right-hand sides?

You probably try to model a situation where x,y, and z are allowed to depend on w, i.e, conceptually, x(w)+y(w)+z(w)=w, or perhaps that some of the variables x y z is a function of w and the other

sdpvar x y w
z
= w-x-y;

or a parameterization of the feasible space

sdpvar u1 u2
xyz
= [1/3;1/3;1/3]*w + null([1 1 1])*[u1;u2]
x
= xyz(1);y = xyz(2);z = xyz(3);



yongjie wang

unread,
May 15, 2014, 4:52:53 AM5/15/14
to yal...@googlegroups.com
Sorry,Johan,I try to send you my .m file,but it did not work,so I will send by the email.how about sending by email?

Johan Löfberg

unread,
May 15, 2014, 4:56:50 AM5/15/14
to yal...@googlegroups.com
Sure

Omid

unread,
Aug 28, 2014, 9:51:56 AM8/28/14
to yal...@googlegroups.com
Dear Johan,

I have a question regarding having an equality constraints in robust optimization in YALMIP. I got an error for the following simple example where Pg is variable, Pw is uncertainty and Pd is parameter. It seems that the first equality constraint is the reason of the error. I guess something is wrong in the way that I wrote these constraints. I would be grateful if you let me know how to do it correctly. Thanks !

Pd = [2;3;1];
Cpg = [1;3;2];
Pg = sdpvar(3,1);
Pw = sdpvar(1,1);
Objective = sum(Cpg .* Pg);
Constraints = [
   sum(Pg) + Pw == sum(Pd),... 
   0 <= Pg <= 3*ones(3,1), ...
   0 <= Pw <= 2
   uncertain(Pw) 
];
sol = solvesdp(Constraints,Objective);

Johan Löfberg

unread,
Aug 28, 2014, 11:00:25 AM8/28/14
to yal...@googlegroups.com
I think you are missing the conceptual difference between an equality, and an assignment, and the difference between a decision variable and a function of a decision variable.

Simplified problem: Please give values of the two decision variables x and y, such that x+y == w for any w between 0 and 1.

Johan Löfberg

unread,
Sep 1, 2014, 7:33:58 AM9/1/14
to yal...@googlegroups.com
You never replied to my hint, so here is the full answer.

It does not make sense to write x+y==w, instead, you probably mean that x is a function of y and w (or y a function of x and w), i.e., you make the assignment x = w-y before setting up constraint and objectives etc.

Hence, your code is probably meant to be something along the lines of (here, assuming the first element of Pg is a function of the second and third)

Pd = [2;3;1];
Cpg = [1;3;2];
Pg23 = sdpvar(2,1);
Pw = sdpvar(1,1);
Objective = sum(Cpg .* Pg);
Pg = [sum(Pd) + Pw-sum(Pg23);Pg23];
Constraints = [  

Omid

unread,
Sep 29, 2014, 10:40:04 AM9/29/14
to yal...@googlegroups.com
Dear Johan,

Thank you very much for your answers and really sorry for not replying to your valuable points earlier (*). 

What you have proposed me is very interesting but it assigns all of the uncertainty to Pg(1). Is there any way to share the uncertainty among the Pg(1:3) ?
Also, I would like to obtain the value of Pg(1:3) as the output of this robust optimization, however, in the model you have sent me I miss Pg(1) since it is not a variable and this value is assigned for it sum(Pd) + Pw-sum(Pg23) where the output of optimization is NaN for it. Shall I define Pg as a variable and assign the new equation to another variable like this  "Plsd = sum(Pd) - sum(Pg) -  sum(Pw) " ?

Thanks !
Omid

(*) I didn't choose the box for "Email updates to me".

Johan Löfberg

unread,
Sep 29, 2014, 11:05:03 AM9/29/14
to yal...@googlegroups.com
If a variable involves an uncertainty, it does not have a value, as the uncertainty has no value but is a set. The worst-case value is never explicitly computed and will never be available.

Of course you can make more general parametrization. All you require is that the equality is satisfied. E.g.,

z = sdpvar(2,1);
Pg = null([1 1 1])*z+[1/3;1/3;1/3]*(sum(Pd)-Pw);

z is the new basis, i.e., the decision variable

caoyiqi

unread,
Apr 10, 2017, 9:21:34 AM4/10/17
to YALMIP
Hi Johan
      there is a question base on this topic, and i write the  code approximate my problem. as follow
 Pd = [1;3;1;2];%4 diat system
 Cpg = [1;3];
 Pw = sdpvar(2,1); %wind power(uncertain)
 wind_power = sdpvar(4,1)%4 diat system
 %% there are two wind farm in diat 2 and diat 4
 wind_power(2,1) = Pw(1);
 wind_power(4,1) = Pw(2);
 Pg23 = sdpvar(1,1)
 Pg = [sum(Pd) + sum(Pw) - sum(Pg23);Pg23];%2 generator
 %% there are two generator in diat 1 and diat 3
 generate_pg = zeros(4,1);
 generate_pg(1,1) = Pg(1);
 generate_pg(3,1) = Pg(2);
%% equality constraint
 C1 = [generate_pg - Pd - wind_power == 0]
 C2 = [wind_power(1,1) == 0, wind_power(3,1) ==0,  generate_pg(2,1) ==0,  generate_pg(4,1) ==0 ];
 Objective = sum(Pg.*Cpg,1);
 Constraints = [0 <= Pg <= 2*ones(2,1),0.2 <= Pw <= 2.2,uncertain(Pw)];
 sol = solvesdp(Constraints+C1+C2,Objective);

and the error Error using filter_eliminatation (line 15)
Cannot get rid of nonlinear uncertainty in uncertain constraint

Error in robustify (line 148)
[F_eq_left,F_eliminate_equality] = filter_eliminatation(F_eq,w,0,ops);

Error in solverobust (line 64)
[F,h,failure] = robustify(varargin{:});

Error in solvesdp (line 177)
        diagnostic = solverobust(F(find(~unc_declarations)),h,options,recover(getvariables(sdpvar(F(find(unc_declarations))))));

Error in robust_test (line 20)
 sol = solvesdp(Constraints+C1+C2,Objective);

Johan Löfberg

unread,
Apr 10, 2017, 9:27:02 AM4/10/17
to YALMIP
First, your code will fail as generate_pg will be a matric eith NaNs

generate_pg =

   NaN
     0
   NaN
     0


Second, you can not have uncertainty in an equality (this is why the code fails). If you claim that is possible, please give me the value of y which satisfies x+y==1 for all -1<=x<=1

caoyiqi

unread,
Apr 10, 2017, 9:42:09 PM4/10/17
to YALMIP
thanks for your reply this question, forgive me list a bad example, and i also understand equality constraints can not contain uncertain variables, maybe i did not describe the problem clearly enough. and then summarize my question in a word: A vector can be implemented in which several elements are uncertain variables,and the others is certain parameters?
    

Johan Löfberg

unread,
Apr 11, 2017, 1:55:02 AM4/11/17
to YALMIP
myvector = [stuff;otherstuff;someuncertain;morestuff] or myvector = something + somethingelse etc. Standard MATLAB code applies, with the caveat that you cannot define a double first, and then insert sdpvars into it with assignment

caoyiqi

unread,
Apr 17, 2017, 8:55:42 AM4/17/17
to YALMIP
thank you johan, you help me a lot

Reza Gholizadeh

unread,
Sep 3, 2018, 9:46:15 AM9/3/18
to YALMIP
I have a question regarding equality constraint with an uncertain parameter.
consider a constraint as (ax+by=d); d is uncertain; d has a set as (d_minus < d < d_plus); the problem is invest planning and d is demand; we now that worst case of d is d_plus;
my question is: is it possible to solve such a problem with robust optimization?

Johan Löfberg

unread,
Sep 3, 2018, 9:50:19 AM9/3/18
to YALMIP
Let us simplify the question

According to you, what is the solution x to the uncertain equation to x = d where d is uncertain [-1 <= d <= 1]

Or put in another way. Let x be the amount of money I will have in my wallet. Select the amount of money to bring in the wallet so it exactly matches the price d of 1 beer, where I only now that 1 beer cost between $2 and $5.


Reza Gholizadeh

unread,
Sep 3, 2018, 9:58:02 AM9/3/18
to YALMIP
Thank you Johan for the reply. I do agree with you. It does not make sense. However, as far as I know robust optimization tries to consider the worst case and give a solution for the worst case. So, one beer will cost $5 considering the worst case. Am I right?

Johan Löfberg

unread,
Sep 3, 2018, 9:59:49 AM9/3/18
to YALMIP
But then you are not looking at equalities, but inequalities d_min <= ax+by<=d_plus

Reza Gholizadeh

unread,
Sep 3, 2018, 10:06:26 AM9/3/18
to YALMIP
Exactly.
So, does it make sense to consider d_plus (the worst case) and solve the problem with equality constraint as (ax+by=d_plus).

Johan Löfberg

unread,
Sep 3, 2018, 11:37:31 AM9/3/18
to YALMIP
No. Having an equality between decision variables and uncertainty is just impossible, it makes no sense.

Perhaps this is not what you have but you actually mean to say that x and y can be selected based on the value of d, and that choice should lead to satisfaction of that equality, i.e. you are looking for a policy x(d) and y(d), and not fixed decisions x and y?

Reza Gholizadeh

unread,
Sep 4, 2018, 12:50:18 AM9/4/18
to YALMIP
Thank you Johan. I ended up that it is impossible to consider RO for an equality constraint. My problem is power distribution network investment planning with linear power flow equations as constraints and I don't know how to model decision variables dependent to uncertain parameter.

Johan Löfberg

unread,
Sep 4, 2018, 1:46:26 AM9/4/18
to YALMIP
As I said, that means you are looking for policies/decision rules. That is generically an intractable problem, but some simple solution can easily be implemented

% Fixed
x = (1/a)*(d/2)
y = (1/b)*(d/2)

% Less fixed where z is a new decision variable
x = (1/a)*(z + d/2)
y = (1/b)*(-z + d/2)

% Even less fixed where z,t1,t2 area new decision variable
x = (1/a)*(z + t1*d)
y = (1/b)*(-z + t2*d)
Model = [t1 + t2 == 1];

% And so you can go on (but beyond linear you can typically not solve the uncertain program that arise
x = (1/a)*(z + t1*d + s1*d^2)
y = (1/b)*(-z + t2*d + s2*d^2)
Model = [t1 + t2 == 1, s1+s2 == 1];







Reply all
Reply to author
Forward
Message has been deleted
0 new messages