Optimization problem not finding the actual optimal value

조회 수: 10 (최근 30일)
Pascual Ferrans Ramírez
Pascual Ferrans Ramírez 2022년 3월 14일
댓글: Matt J 2022년 3월 15일
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
Torsten
Torsten 2022년 3월 14일
What do you get back if you call your objective with the initial guess for x ?
Pascual Ferrans Ramírez
Pascual Ferrans Ramírez 2022년 3월 15일
Hi Torsten, thank you for your message. i get the actual value that Im looking for, 7.5

댓글을 달려면 로그인하십시오.

채택된 답변

Matt J
Matt J 2022년 3월 14일
편집: Matt J 2022년 3월 14일
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
Pascual Ferrans Ramírez
Pascual Ferrans Ramírez 2022년 3월 15일
Thank you both for your messages. That is exactly what was happening. fminbnd() is working fine. Thanks.
Matt J
Matt J 2022년 3월 15일
Glad it's working, but then please Accept-click the answer to indicate so.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Problem-Based Optimization Setup에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by