How to apply multiple runs (essentially loop it) on optimization (such as GA and PSO)
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Josiah Jarenee Comia
il 25 Apr 2021
Commentato: Josiah Jarenee Comia
il 25 Apr 2021
I want to loop an optimization solution that i've done so that I could generate at least 25 answers (and be it stored in an array) and find the lowest among them. I understand that inside the optimization, it already gives me the optimized answer, but our professor wants us to find the lowest value among certain number of iterations.
I just want to apply loop in this block, then be it stored in an array.
% For Fminsearch
initguess=[1,2];
options=optimset('MaxIter',2000,'MaxFunEvals',2000);
[c,fmin]=fminsearch(OFVL,initguess,options);
% For Genetic Algorithm
options2=optimoptions('ga','MaxStallGenerations',5000, 'MaxGenerations',5000, 'TolFun', 1e-12);
[c_ga,fmin_ga]=ga(OFVL,2,[],[],[],[],[],[],[],options2);
%For PSO
options3 = optimoptions('particleswarm', 'MaxStallIterations',5000, 'MaxIteration', 5000, 'TolFun', 1e-12);
[c_pso, fmin_pso]=particleswarm(OFVL,2,[],[],options3);
0 Commenti
Risposta accettata
Walter Roberson
il 25 Apr 2021
for count = 1 : 3
% For Fminsearch
initguess=[1,2]+rand(1,2);
options=optimset('MaxIter',2000,'MaxFunEvals',2000);
[c(count,:),fmin(count,:)]=fminsearch(OFVL,initguess,options);
% For Genetic Algorithm
options2=optimoptions('ga','MaxStallGenerations',5000, 'MaxGenerations',5000, 'TolFun', 1e-12);
[c_ga(count,:),fmin_ga(count,:)]=ga(OFVL,2,[],[],[],[],[],[],[],options2);
%For PSO
options3 = optimoptions('particleswarm', 'MaxStallIterations',5000, 'MaxIteration', 5000, 'TolFun', 1e-12);
[c_pso(count,:), fmin_pso(count,:)]=particleswarm(OFVL,2,[],[],options3);
end
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Genetic Algorithm in Help Center e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!