Problems when passing a cell of matrices

22 views
Skip to first unread message

Eugenio Alcalá Baselga

unread,
Nov 16, 2017, 5:28:09 AM11/16/17
to YALMIP

Hi Johan,


I have an issue and hence a doubt.

I define a set of sdpvar matrices as follows:
Ac_pred = sdpvar(repmat(6,Hp),repmat(6,Hp));

So I want to create Hp matrices of 6 by 6 size and pass them to the optimizer object but this returns:
The parameters must be SDPVAR objects. Parameter #5 is a CELL

I understand that if I use that definition I obtain a cell of sdpvar matrices, but how can I obtain a sdpvar of sdpvar matrices?

I have been seeing many examples but all of them are very much simple.


Thank you so much.



Answer:

AC_pred is a cell of SDPVARs, which is precisely what optimizer wants when you have more than 1 parameter, so I don't see where you have problems. If you placed Ac_pred in a cell, you have to do parameters = {otherparameters, AC_pred{:}} so that it is a cell of sdpvars. For further assistance, please use the YALMIP Google groups support forum.



Thank you. Until here I agree with you. But, when you built the input dell to be passed to the controller object inside the simulation loop then you have to pass each one of the matrices one by one like this:


inputs = { Ac_pred(:,:,1), Ac_pred(:,:,2), Ac_pred(:,:,3), Ac_pred(:,:,4),...

                 Ac_pred(:,:,5), Ac_pred(:,:,6), Ac_pred(:,:,7), Ac_pred(:,:,8),...

                 Ac_pred(:,:,9), Ac_pred(:,:,10), Ac_pred(:,:,11), Ac_pred(:,:,12)};

[solutions,diagnostics] = controller{inputs}; 


If not, the optimizer detects that you are trying to introduce a cell that contains a cell of matrices and the optimizer function does not like this.


Johan Löfberg

unread,
Nov 16, 2017, 5:37:26 AM11/16/17
to YALMIP
The most natural would be that you work with the data and parameters in the same format, and then create the parameter list in the same way. Now you work with cells on one and ndarrays on the other, hence you code will be different. Most conveniently, you convert your ndarray to a cell of matrices so you don't have to manually list them as you do now

Johan Löfberg

unread,
Nov 16, 2017, 5:40:10 AM11/16/17
to YALMIP
I.e. the most logical would be to have your parameter as Ac_pred = sdpvar(6,6,Hp,'full'), since that is the format the data is in
Reply all
Reply to author
Forward
0 new messages