필터 지우기
필터 지우기

How to find a part of function value in Genetic Algorithm after each iteration cycle

조회 수: 3 (최근 30일)
Hello everyone,
I am doing optimization using genetic algorithm. In a nutshell, the fitness function consists of 3 terms, A and B are normal function terms whereas C is an additional penalty term.
function XYZ = Ackley(x)
XYZ = A + B + C
end
After applying GA parameters. The final code is below.. Where nit = number of iterations (I am running 30 iterations minimum)
for i=1:nit
[x,fval,exitflag,output,population,score] = GAcode(nvars,lb,ub,InitialPopulationRange_Data,PopulationSize_Data,EliteCount_Data,CrossoverFraction_Data,MaxGenerations_Data,FunctionTolerance_Data,ConstraintTolerance_Data);
ZH1(i,1)=fval;
ZH2(i,:)=x;
end
The code works perfectly fine for getting final function value 'fval' (XYZ) and unknowns 'x' after each iteration... Is it possible to get individual values of A,B and C as well after each iteration.?
Thanks for your help.

채택된 답변

Alan Weiss
Alan Weiss 2021년 8월 31일
I think that you can write a Custom Output Function for Genetic Algorithm and use it to calculate what you want and store them in an array returned to the workspace. This probably will involve rewriting the objective function in the output function in a way that returns the values you want.
Alan Weiss
MATLAB mathematical toolbox documentation

추가 답변 (0개)

카테고리

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

제품


릴리스

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by