How to access the generation of the population in fitness function while using gamultiobj in Matlab?

조회 수: 5 (최근 30일)
I have been using gamultiobj in Matlab to run my optimization setup. When the GA calls the fitness function it only sends the population to the fitness function as its input. But, I need also the generation to which the population belong. How could that be done as I am not able to edit the Matlab inbuilt functions.

답변 (1개)

Umang Pandey
Umang Pandey 2023년 9월 26일
Hi Rajan,
As per my understanding, you wish to get the number of generations until which the "gamultiobj" function executes before returning the Pareto front. It is indeed possible to get the number of generations as an output of the "gamultiobj" function. Refer the following example:
% Defining a sample fitness function
fitnessfcn = @(x)[norm(x)^2,0.5*norm(x(:)-[2;-1])^2+2];
% Using the gamultiobj function
[x,fval,exitFlag,output] = gamultiobj(fitnessfcn,2);
% Getting the number of Generations
gen = output.generations;
The output argument "output" returned by the "gamultiobj" function is a structure consisting of various fields like the type of problem("problemtype"), number of generations("generations"), total number of function evaluations("funccount"), etc.
Refer the documentation for more information:
Best,
Umang

카테고리

Help CenterFile Exchange에서 Multiobjective Optimization에 대해 자세히 알아보기

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by