How I can impliment my objective function inside this GA?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Sourasis Chattopadhyay
am 11 Dez. 2022
Kommentiert: Star Strider
am 13 Dez. 2022
How I can impliment my objective function inside this GA?
0 Kommentare
Akzeptierte Antwort
Star Strider
am 11 Dez. 2022
Since ‘objective function’ implies curve fitting, try something like this —
x = 1:0.1:10;
y = 2.5*exp(-(x-5).^2/2)+randn(size(x))*0.25;
objfcn = @(b,x) b(1).*exp(-(x-b(2)).^2*b(3));
fitnessfcn = @(b) norm(y-objfcn(b,x));
Parms = 3;
[B,fval] = ga(fitnessfcn, Parms)
figure
plot(x, y, '.')
hold on
plot(x, objfcn(B,x), '-r')
hold off
grid
The parameter estimates here (2.69, 4.97, 0.666) are reasonably accurate when compared to the actual parameters (2.5, 5.0, 0.5) in this relatively simple problem. The norm of the residuals is 2.71.
.
2 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Genetic Algorithm 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!