필터 지우기
필터 지우기

How I can impliment my objective function inside this GA?

조회 수: 1 (최근 30일)
Sourasis Chattopadhyay
Sourasis Chattopadhyay 2022년 12월 11일
댓글: Star Strider 2022년 12월 13일
How I can impliment my objective function inside this GA?

채택된 답변

Star Strider
Star Strider 2022년 12월 11일
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)
Optimization terminated: average change in the fitness value less than options.FunctionTolerance.
B = 1×3
2.6924 4.9718 0.6663
fval = 2.7118
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.
.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Genetic Algorithm에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by