Optimization problem not finding the actual optimal value

16 Ansichten (letzte 30 Tage)
Hello!
I am trying to solve an optimization problem in the Problem-Based mode and I am having problems finding the local optimum. The function I am looking to optimize is located in a .m file developed by me, in which a single output Y value is calculated, which depends on the simulation and run of a computational model of my own. I am defining the objective of my problem with fcn2optimexpr and the optimization method I am using is fmincon. No matter what initial value X (a single variable) I assign to the problem, the program always tells me that it has already found the local optimum at the initial point assigned to X, without further iterations. I have already tried to modify the program tolerances (step size, objetive and contraint) and it keeps throwing the same result. Also, I tried changing the searching algoritm and nothing has worked out. Any idea what I can be doing wrong? Thank you very much. Below is the code used to define the problem and the text obtained in response.
prob = optimproblem("Description", "Optimization SUDS", "ObjectiveSense", "maximize");
x = optimvar('x');
x.LowerBound = 0;
x.UpperBound = 1;
obj = fcn2optimexpr(@opti, x);
prob.Objective = obj;
initialGuess.x = 0.1;
options = optimoptions("fmincon","Display","iter", "PlotFcn",["optimplotx",...
"optimplotfval","optimplotstepsize"]);
[sol, fval, exitflag, output] = solve(prob, initialGuess, "Options",options);
Initial Point is a local minimum that satisfies the constraints.
Optimizacion completed because at the initial point, the objetive function is non-decreasing in feasible directions to within the value of the optimality tolerance, and contraints are satisfied to within the value of the contraint tolerance
  2 Kommentare
Torsten
Torsten am 14 Mär. 2022
What do you get back if you call your objective with the initial guess for x ?
Pascual Ferrans Ramírez
Pascual Ferrans Ramírez am 15 Mär. 2022
Hi Torsten, thank you for your message. i get the actual value that Im looking for, 7.5

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Matt J
Matt J am 14 Mär. 2022
Bearbeitet: Matt J am 14 Mär. 2022
Making sure you don't have any round(), ceil(), floor() or other discretization operations in your simulation code. Also, make sure you have read the guidelines on optimizing a simulation here,
Finally, since your problem only has a single unknown, I would use fminbnd().
  3 Kommentare
Pascual Ferrans Ramírez
Pascual Ferrans Ramírez am 15 Mär. 2022
Thank you both for your messages. That is exactly what was happening. fminbnd() is working fine. Thanks.
Matt J
Matt J am 15 Mär. 2022
Glad it's working, but then please Accept-click the answer to indicate so.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Problem-Based Optimization Setup finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by