Decision variables in sin/cos functions when using optimizer.

32 views
Skip to first unread message

Gustav Holm

unread,
Dec 4, 2019, 4:47:54 AM12/4/19
to YALMIP
Hi 
I'm trying to solve a MPC regulations problem using YALMIPs optimizer function.
The time varying reference trajectory (reference model) depends on sine and cosine terms, which in my version of Yalmip is not allowed.
(Im not using the latest version)
Is this something thats implemented in later versions of Yalmip(I can't find any documentation about this) or do I need to stick to optimize when solving my problem?

Error using optimizer (line 303)
Parameters are currently only allowed to enter function such as exp, sin etc as exp(a), sin(b) etc.

Error in Prog12 (line 146)
controller = optimizer(constraints, objective ,options,parameters_in,solutions_out);

Johan Löfberg

unread,
Dec 4, 2019, 4:52:10 AM12/4/19
to YALMIP
I think it is partially supported in the last version

However, more efficient is to simply define sin(parameter) as your new parameter

% Might work but a lot of overhead
P = optimizer(a*sin(b)== 1,[],[],b,a)
P(1)

% Simply do this instead
P = optimizer(a*c== 1,[],[],c,a)
P(sin(1))

Gustav Holm

unread,
Dec 4, 2019, 4:54:08 AM12/4/19
to YALMIP
Thank you for a quick reply, I will try that out.
Reply all
Reply to author
Forward
0 new messages