surrogateopt: output function
6 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Geopaul
am 9 Aug. 2022
Kommentiert: Alan Weiss
am 11 Aug. 2022
How do we create a customize output function for the 'surrogateopt' that will show the solution at every iteration. I need am example for better understanding. Thank you.
0 Kommentare
Akzeptierte Antwort
Alan Weiss
am 9 Aug. 2022
Try this.
lb = [-3 -3];
ub = -lb;
opts = optimoptions('surrogateopt','OutputFcn',@listout);
obj = @(x)100*(x(2) - x(1)^2)^2 + (1 - x(1))^2;
[sol,fval] = surrogateopt(obj,lb,ub,opts)
function stop = listout(x,optimValues,state)
stop = false;
switch state
case 'iter'
nval = optimValues.funccount;
y = optimValues.currentX;
fprintf("Number of fevals = %g, x = [%g,%g]\n",nval,y(1),y(2))
end
end
Alan Weiss
MATLAB mathematical toolbox documentation
3 Kommentare
Alan Weiss
am 11 Aug. 2022
For an example (uses different syntax, be careful) see https://www.mathworks.com/help/gads/custom-output-function-for-genetic-algorithm.html.
Alan Weiss
MATLAB mathematical toolbox documentation
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Surrogate Optimization finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!