A question on formulation of bilevel programming with YALMIP

119 views
Skip to first unread message

Κωνσταντίνος Πετρίδης

unread,
Dec 23, 2013, 12:38:38 PM12/23/13
to yal...@googlegroups.com
Hello

My name is Konstantinos Petridis and I am new to YALMIP modeling.
I use mostly GAMS and now I have to develop a model regarding  forest production and management.

The reason I turned to YALMIP is because on a very simple example (http://users.isy.liu.se/johanl/yalmip/pmwiki.php?n=Tutorials.BilevelProgramming),  and YALMIP yielded better solutions than GAMS (using EMP solver, JAMS).

I am based on the following paper:

www.sciencedirect.com/science/article/pii/S1389934113001718

I know how to "pass"  a constraint of the following type in GAMS, but how do I model it in YALMIP?

ΣiQikl<=Xkl

Thank you in advance

Konstantinos Petridis

Johan Löfberg

unread,
Dec 23, 2013, 12:48:11 PM12/23/13
to yal...@googlegroups.com
So you have Q which is a 3d array and X is a standard 2d array (matrix)?

MATLAB syntax (and thus YALMIP syntax) would be

Q = sdpvar(2,3,4);
X
= sdpvar(3,4);
sum
(Q,1) <= X
Error using ndsdpvar/le (line 22)
Error using sdpvar/minus (line 174)
Matrix dimensions must agree.

However, that fails as the size of the summed matrix in MATLAB is 1x3x4 which is incomparable with a 3x4 matrix in MATLAB
sum(randn(2,3,4),1) <= randn(3,4)
Error using  <=
Number of array dimensions must match for binary array op.

To come around that, we can use the MATLAB command squeeze
 squeeze(sum(Q,1)) <= X
++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|   ID|      Constraint|                           Type|
++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|   #1|   Numeric value|   Element-wise inequality 12x1|
++++++++++++++++++++++++++++++++++++++++++++++++++++++++

or vectorize it
temp = sum(Q,1);  
temp
(:) <= X(:)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|   ID|      Constraint|                           Type|
++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|   #1|   Numeric value|   Element-wise inequality 12x1|
++++++++++++++++++++++++++++++++++++++++++++++++++++++++




Κωνσταντίνος Πετρίδης

unread,
Dec 23, 2013, 1:05:49 PM12/23/13
to yal...@googlegroups.com

Dear Professor Löfberg

Thank you for your instant response.

When formulating my model can I count on your help?

Johan Löfberg

unread,
Dec 23, 2013, 1:08:04 PM12/23/13
to yal...@googlegroups.com
Of course, but it depends on the problem. Lots of info on the Wiki, which you obviously already have found

Reply all
Reply to author
Forward
0 new messages