How does optimize() work?

23 views
Skip to first unread message

XB G

unread,
Sep 19, 2018, 3:47:27 PM9/19/18
to YALMIP
Just curious, we define sdpvar variables (e.g. `x`) in the main function, before calling `optimize()`, `value(x)` returns `NaN`. After solving the problem using `optimize()`, `value(x)` gives the optimal value.

How does YALMIP achieve this? 
Message has been deleted

XB G

unread,
Sep 19, 2018, 3:52:03 PM9/19/18
to YALMIP
More specifically, `x` is not input or output of function optimize(). How is `x` (defined in the main function) involved in the operations in `optimize()`?

Johan Löfberg

unread,
Sep 19, 2018, 4:47:01 PM9/19/18
to YALMIP
As I've already explained, the name of a variable is completely uninteeresting.

A variable is built from internal variables which have indicies, and these will be associated with values when a problem is solved

yalmip('clear');
banana = sdpvar(1);getvariables(banana)
apple = sdpvar(1);getvariables(apple)
optimize([],(apple-4)^2+(banana-7)^2)

value(recover(1))
value(recover(2))
Reply all
Reply to author
Forward
0 new messages