How to apply multiple runs (essentially loop it) on optimization (such as GA and PSO)
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Josiah Jarenee Comia
am 25 Apr. 2021
Kommentiert: Josiah Jarenee Comia
am 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 Kommentare
Akzeptierte Antwort
Walter Roberson
am 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
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Genetic Algorithm finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!