Reference for Solution Value

1 view (last 30 days)
Micah Mungal
Micah Mungal on 13 Aug 2020
Hi, I am looking at solving optimizaton problems using MATLAB to model the problem and CPLEX as the solver. Everything works and I am able to get my solution. However lets say I have 3 optimization variables all of different sizes, when I obtain the solution, I get the values of all the variables in 1 variable which I now have to sought through to get the values for each inidivual variable. Now if I were doing this in python and one of my variables is x, I would just use value.x to get the value of the x variable. Is there a similar way to get the values for the individual optimization variables without have to manually sought it out myself. This is what I use to obtain my solution:
options = cplexoptimset('cplex');
options.timelimit = 300;
[sol3,fval3, exitflag3, output3] = cplexmiqp(PP.H, PP.f, PP.Aineq, PP.bineq, ...
PP.Aeq, PP.beq,[], [], [], PP.lb, PP.ub, ctype, [], options);
If I had 3 optim. variables x1, x2 and x3 which are not scalar but arrays, my solution is stored in sol3 as [x1 x2 x3]. I want to just reference each variable without doing it manually.

Answers (0)

Products


Release

R2020a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!