what changes should i make in final optimised value with opt time vector
Show older comments
Any modifications to be done in the final optimized value that specify a combination of step size (Ts) and number of iterations (N)?
I am getting a higher optimized value in a problem based optimization problem ,should i make any changes in the final Fval since
opt Time=5*60=300 chosen in my problem?
2 Comments
Image Analyst
on 26 Sep 2021
Can you just run through a brute force trial of all possible combinations?
NN
on 26 Sep 2021
Answers (1)
Use prob2struct
s=prob2struct(prob);
s.f0
The value of s.f0 will be the discrepancy between a problem-based linear optimization and a solver-based linear optimization.
4 Comments
NN
on 26 Sep 2021
Yes, it is possible. The fval returned in both the problem-based and solver-based solvers can always be trusted to agree up to an additive constant. However, the problem-based framework allows you to specify a linear program objective function of the form f.'*x + f0, whereas the solver-based linear program solvers do not. If you feed a problem description structure to a solver-based solver, it will always ignore the f0 that you specify and assume f0=0. That is why there is a difference of 2.7 in the fvals in the example below.
x=optimvar('x',2,'LowerBound',0);
objective=dot(x,-[5,4])+2.7;
constraints.con1=sum(x)<=3;
constraints.con2=dot(x,[2,7])<=pi;
prob=optimproblem('Objective',objective,'Constraints',constraints);
%%%%% Problem based
[sol,fval1]=solve(prob);
x1=sol.x,fval1
%%%%%% Solver-based equivalent
s=prob2struct(prob);
[x2,fval2]=linprog(s)
difference=fval1-fval2
NN
on 27 Sep 2021
Matt J
on 27 Sep 2021
I am not sitting beside you at your computer. I cannot see what you entered...
Categories
Find more on Get Started with Optimization Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!