Can you help me with the output of my optimizer?
1 view (last 30 days)
Show older comments
I have this program from
par0 = [0.1,0.0001,100];% initial values
history = [];
fun_objetivo = @(par,pfrac)FunObjetivo(par);
options = optimset('MaxIter',3000,'MaxFunEvals',3000,'Display','iter','OutputFcn', @myoutput);
%We use here the Nelder-Mead method
par_optimos = fminsearch(fun_objetivo, par0, options);
function stop = myoutput(par_optimos,optimvalues,state);
stop = false;
if isequal(state,'iter')
history = [history;par_optimos];
end
end
but I can´t make it give me the value of my vector par_optimos for each iteration, can someone help me?
0 Comments
Answers (2)
Sulaymon Eshkabilov
on 1 Jun 2021
You'd need define a math formulation of fun_objetivo = @(par,pfrac)FunObjetivo(par);
Once it is done, you can run via loop iteration, i.e.: for ... end
0 Comments
Alan Weiss
on 2 Jun 2021
Alan Weiss
MATLAB mathematical toolbox documentation
2 Comments
Walter Roberson
on 3 Jun 2021
Edited: Walter Roberson
on 3 Jun 2021
You did not nest the function like suggested.
history = do_the_work;
function hist = do_the_work()
fun_objetivo = @(par,pfrac)FunObjetivo(par);
history=[];
options = optimset('MaxIter',3000,'MaxFunEvals',3000,'Display','iter','OutputFcn', @myoutput);;%,'PlotFcns',@optimplotfval);
%We use here the Nelder-Mead method
par_optimos = fminsearch(fun_objetivo, par0, options);
hist = history;
function stop = myoutput(par_optimos,optimvalues,state);
stop = false;
if isequal(state,'iter')
history = [history;par_optimos];
end
end
end
See Also
Categories
Find more on Optimization 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!