MATLAB Answers

Refreshment of the objective function with FMINCON

3 ビュー (過去 30 日間)
José Rodrigo Ramírez
José Rodrigo Ramírez 2021 年 9 月 27 日
Hi, I need to update the objective function in each iteration.
It seems the fmincon function combined with the objective function do not allow to refresh the objective function every iteration.
in the main software I have the options for the fmincon and the command to execute it:
the 'code' function is as fiollows (and it seems I can't add more arguments to refresh the function every iteration:
function [x] = code(x0,lb,ub,MaxIterations_Data,OptimalityTolerance_Data,StepTolerance_Data,DiffMinChange_Data)
%% This is an auto generated MATLAB file from Optimization Tool.
%% Start with the default options
options = optimoptions('fmincon');
%% Modify options setting
options = optimoptions(options,'Display', 'off');
options = optimoptions(options,'MaxIterations', MaxIterations_Data);
options = optimoptions(options,'OptimalityTolerance', OptimalityTolerance_Data);
options = optimoptions(options,'FunctionTolerance', OptimalityTolerance_Data);
options = optimoptions(options,'StepTolerance', StepTolerance_Data);
options = optimoptions(options,'Algorithm', 'sqp');
options = optimoptions(options,'DiffMinChange', DiffMinChange_Data);
options = optimoptions(options,'FiniteDifferenceType', 'central');
[x] = ...
Then, the objective function is as follows:
function [m,gm]=fobjetivoTGA(X)
finter is another function, it gives no problem because it uses the info on X.
I need to introduce ys1 and ys2 in every iteration, refreshed, but I do not find the way.
Could you please help me with this?

回答 (1 件)

Alan Weiss
Alan Weiss 2021 年 9 月 27 日
I think that you have a mistaken view of what fmincon does. All optimization solvers take a fixed objective function and iterate to find a local minimum of that objective function. In general, you are not allowed to change the objective function definition in the middle of an optimization.
I do not understand your application. It is possible that you are looking for a different kind of algorithm, not an optimization algorithm but instead a control system that helps you track a changing target. Are you looking for a PID controller?
Good luck,
Alan Weiss
MATLAB mathematical toolbox documentation
  3 件のコメント
José Rodrigo Ramírez
José Rodrigo Ramírez 2021 年 9 月 27 日
That could work even better.
Thanks Walter, I believe this is what I was looking for.





Community Treasure Hunt

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

Start Hunting!

Translated by