How to get all the history of local solvers when using multi starting point search (MultiStart)
5 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
SEO BOIL
le 13 Août 2021
Réponse apportée : Walter Roberson
le 13 Août 2021
Hi, guys.
I want to save all the history of local solver on MultiStart.
I use the code for 'OutputFcn' based on the matlab documentation like
function stop = outfun(in,optimValues,state)
persistent history fhistory
stop = false;
switch state
case 'init'
history = [];
fhistory = [];
case 'iter'
% Concatenate current point and objective function
% value with history. in must be a row vector.
fhistory = [fhistory; optimValues.fval];
history = [history; in(:)']; % Ensure in is a row vector
case 'done'
assignin('base','optimhistory',history);
assignin('base','functionhistory',fhistory);
otherwise
end
end
My optimization problem setting is
options = optimoptions('fmincon', 'TolFun', 1e-8, 'TolX', 1e-8, 'Display', 'iter', 'OutputFcn', @outfun);
problem = createOptimProblem('fmincon',...
'x0', x0, 'objective', @objf_energy_density, 'lb', Lb, 'ub', Ub,...
'Aeq', Aeq, 'beq', beq, 'nonlcon', @conf, 'options', options);
ms = MultiStart;
[x, F, Exitflag, Output, allmins] = run(ms, problem, 20)
When I run the optimization, I can only get the history of 'the last local solver' on MultiStart, not all the history of local solvers.
Is there any way to get all the history of local solvers when using MultiStart?
Thank you for reading my question.
0 commentaires
Réponse acceptée
Walter Roberson
le 13 Août 2021
history = [];
fhistory = [];
Do not do those.
If you want to reset the entire history for another run, then
clear outfun
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Global or Multiple Starting Point Search dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!