Can optimizer() take cell array as decision variables?

68 views
Skip to first unread message

XB G

unread,
Nov 21, 2018, 6:36:15 PM11/21/18
to YALMIP
Hi Johan,
I'm trying to solve a problem using optimizer object, my decision variables are x and y, parameter is the variable `para`;
y is a n-by-1 vector and x is defined as a cell array (following your suggestions in my previous question).

I tried to build an optimizer object, but got the following error

Capture.PNG


It seems to be caused by the x variable, which is a cell array.

Any possibilities to use optimizer in this case?

Code is attached too.

Thanks!


test_optimizer.m

XB G

unread,
Nov 21, 2018, 9:05:02 PM11/21/18
to YALMIP
it looks like I can do this way:

problem = optimizer(constr,1,[],para,{x{:},y});

Johan Löfberg

unread,
Nov 22, 2018, 1:56:09 AM11/22/18
to YALMIP
you have a cell of cells of sdpvars. That's not supported, only cells of sdpvars

NAOYA KUMAGAI

unread,
Oct 15, 2022, 3:02:06 AM10/15/22
to YALMIP
I actually stumbled upon the same [problem, only XGB's solution doesn't work in my case since I have multiple cells of cells of sdpvars that I want to retrieve from the optimizer. 

Dr. Lofberg, you mention that cell of cells of sdpvars are not supported, but cells of sdpvars are supported; how would I create the latter? 
The code in "Getting Started", for example, creates a cell of cells of sdpvars, and I cannot find a way to create a simple cell of sdpvars. 

Johan Löfberg

unread,
Oct 15, 2022, 3:14:50 AM10/15/22
to YALMIP
as descried above, stuff like {x{:},u{:}} or {[x{:}],[u{:}]} depending on whether you want to flatten each cell first

I don't know of any example working with cells of cells of sdpvars. x=sdpvar([5 5 5],[1 1 1]) is a cell of sdpvars, and [x{:}] would flatten it to a 5x3 sdpvar

NAOYA KUMAGAI

unread,
Oct 15, 2022, 3:11:42 PM10/15/22
to YALMIP
Thank you. I got it to work using what you told me above!

The cell of cells was a misconception :)

Reply all
Reply to author
Forward
0 new messages