I don’t know how to use the optimized variable value after CVX optimization in the next operation. Is it necessary to assign a value, or is it automatically assigned to the optimization variable. After a successful CVX optimization, my code still uses the initial value of the optimization variable.
variable p(6) nonnegative;%非负
variable m(6,6) nonnegative;%非负
Obj = 0;
Obj = Obj + (F(j)+V)/r*(3r-3B(j)-log(1+p(j)L/(3q))/log(2))-3F(j)c +(E(j)+V)p(j)+E(j)e(j)+(V(1-n)-E(j))m1(j)+nE(j)m2(j);
if CVX completes successfully, all CVX variables are at their optimal value after CVX concludes.
However, this is not necessarily so for CVX expressions, which is anything other than something declared with a variable statement. This includes declared expressions, sch as m1 and m2. it also includes undeclared expressions, such as f,B,F,E. In order to ensure you are using the optimal values of CVX expressions, you must calculate them after CVX concludes, starting from declared CVX variables.
Note that, in contrast, YALMIP automatically ensures expressions are at their optimal value if the value command is used after optimization successfully concludes.The YALMIP behavior is nicer and avoids confusion. If I had a dollar for every time someone fell victim to this CVX “quirk”, I wouldn’t be rich, but I wouldn’t be poor.
The program’s only CVX variables are p and m. Only they are guaranteed to be at their optimal value after CVX successfully concludes. Everything else is an expression, for which the optimal value can only be known by computing them starting from CVX variables.
Internally, CVX correctly accounts for expressions when performing the optimization. So the preceding only pertains to finding out what the optimal value of the expressions are.after CVX concludes.