Index problem with Yalmip

317 views
Skip to first unread message

Michael@PolyU

unread,
Feb 2, 2020, 10:47:04 PM2/2/20
to YALMIP
Dear Prof. John,

Thank you very much for your relentless support. As I said earlier, I am a newbie to yalmip, the problem I'm encountering in my model is index problem exceeding matrix dimensions. Please, how can I rectify this, the attached file is the code I developed. you can make v=1, and Ta=25, for the testing.

Thanks, 
Michael
MES model.txt

Johan Löfberg

unread,
Feb 3, 2020, 2:27:35 AM2/3/20
to yal...@googlegroups.com
Don't send code which requires input of data...(i.e. edit the file so that it runs)

and fix the glaring problems

>> Warning: Strict inequalities will only (if at all) be supported on binvar/intvar variables in future versions of YALMIP. 

>> Most likely you meant to write a + b, but you wrote a +b
This can easily lead to bugs, as [a +b] is a vector with two elements
If you really want to use unitary plus, you will have to edit sdpvar/uplus
and delete this message

and regarding the question, have you even tried to debug?

K>> PWt(k,:)
Error using sdpvar/subsref (line 161)
Error using sdpvar/subsref>subsref2d (line 271)
Index exceeds matrix dimensions. 
K>> PWt
Linear scalar (real, integer, 1 variable)
Coefficients range: 20 to 20
K>> k
k =
     2


Michael@PolyU

unread,
Feb 3, 2020, 3:29:02 AM2/3/20
to YALMIP
Thanks for your reply.. i have checked the model again but i don't really understand whats wrong, nHours=24, and i defined the affected decision variables as sdpvar(nHours, 1) e.g PWt=sdpvar(nHours,1) while k = i:nHours.

Please, how can i rectify those errors? the attached file is the modified code but is still showing some warnings that i don't understand where things are wrong (still on the learning process of Yalmip)

Thannks
MES model.txt

Johan Löfberg

unread,
Feb 3, 2020, 3:50:36 AM2/3/20
to YALMIP
PWt=nwt*Pwind
Linear scalar (real, integer, 1 variable)
Coefficients range: 20 to 20

and you should install the most recent version of YALMIP, where you will get even stronger warnings to fix some issues

and regarding the a+b vs a +b warning, you are doing

 = [1+2...
      +3]

thinking it will return 1+2+3 but MATLAB will return [3 3]


Michael@PolyU

unread,
Feb 3, 2020, 4:49:08 AM2/3/20
to YALMIP
Thank you Prof.

i have done the necessary corrections as suggested, but I encountered another problem again, 'solver not applicable' using CPLEX, and the problem is a MILP.

the attached file is the modified code.

Thanks
MES model.txt

Johan Löfberg

unread,
Feb 3, 2020, 5:10:00 AM2/3/20
to YALMIP
No, it is not a MILP

>> Batstored_constr1
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|    ID|                            Constraint|   Coefficient range|
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|    #1|   Equality constraint (bilinear) 24x1|      0.02 to 1.0417|
|    #2|          Element-wise inequality 24x1|              1 to 1|

Michael@PolyU

unread,
Feb 3, 2020, 6:13:34 AM2/3/20
to YALMIP
Prof. Johan,

Thanks for your reply... i have corrected the code, but i still have the same error 'solver not applicable'

The attached file is the modified code
MES model.txt

Johan Löfberg

unread,
Feb 3, 2020, 6:56:34 AM2/3/20
to YALMIP
You're still ding the same thing...

>> capacity_constr
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|    ID|                                Constraint|   Coefficient range|
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|    #1|    Element-wise inequality (integer) 24x1|        0.01728 to 1|
|    #2|               Element-wise inequality 2x1|           1 to 1500|
|    #3|   Element-wise inequality (bilinear) 24x1|              1 to 1|

Michael@PolyU

unread,
Feb 3, 2020, 7:24:42 AM2/3/20
to YALMIP
Thank you very much for the reply, please, how can i eliminate the bilinear error?

Thanks,
Michael

Johan Löfberg

unread,
Feb 3, 2020, 7:26:16 AM2/3/20
to YALMIP
I don't see any way of getting rid of the bilinearity, beyond a piecewise affine approximation

Michael@PolyU

unread,
Feb 3, 2020, 7:44:36 AM2/3/20
to YALMIP
Thanks Johan, i have found a way to modified the problem, but i run into an infeasible problems by CPLEX.

The attached file is the code file. Please, help me have a look
MES model.txt

Johan Löfberg

unread,
Feb 3, 2020, 8:51:23 AM2/3/20
to YALMIP
Your code does not run

Error using  ==  (line 15)
Error using  -  (line 195)
Matrix dimensions must agree.
Error in xcvxcvxcv (line 339)
power_balance = [power_balance,
PVt(k,:)+PWt(k,:)+Prce(k,:)+Pice(k,:)+Psofc(k,:)+Pmofc(k,:)+Ppemfc(k,:)-Pbch(k,:)+Pbdch(k,:)+Pgrid(k,:)-Psell(k,:)==Pecin(k,:)+Pashp(k,:)+Pwshp(k,:)+Pelez(k,:)+LD']; 

Michael@PolyU

unread,
Feb 3, 2020, 9:29:33 AM2/3/20
to YALMIP
i have done the correction in the attached file, but is still showing infeasible problem.

Thanks
MES model.txt

Johan Löfberg

unread,
Feb 3, 2020, 9:35:17 AM2/3/20
to YALMIP
Already optimize(power_balance) is infeasible...

Johan Löfberg

unread,
Feb 3, 2020, 9:36:58 AM2/3/20
to YALMIP
and violently trivially so as it is infeasible already with

power_balance=[];
k=1

Michael@PolyU

unread,
Feb 3, 2020, 9:38:28 AM2/3/20
to YALMIP
you mean the problem is in the power balance constraint?

please how can i correct it?

Johan Löfberg

unread,
Feb 3, 2020, 9:40:10 AM2/3/20
to YALMIP
at least parts of the problems are there, since already that alone is infeasible

you correct it by finding out why you are asking for something impossible

Johan Löfberg

unread,
Feb 3, 2020, 9:42:38 AM2/3/20
to YALMIP
my guess you want LD(k), because now the lhs is a scalar and the rhs is a vector
Reply all
Reply to author
Forward
0 new messages