Can genetic algorithm be nested?

조회 수: 6 (최근 30일)
alaa zarif
alaa zarif 2019년 6월 27일
댓글: Stephan 2019년 7월 1일
i want to have a code that does double optimization
i want the ga to first assume a vector q of 1s and 0s, then for each member in the population before calculating the fitness i want it to assume another vector which is the coefficients of q or if possible, only the elements that are assumed to be 1 in vector q. is a double optimization in the genetic algorithm possible ??
can i put a line that calls the ga toolbox in the fitness function for example ??

답변 (1개)

Stephan
Stephan 2019년 6월 28일
편집: Stephan 2019년 6월 28일
It should be possible in one single call of ga. In this case nvars would be 2*numel(q) and you have to set the correct bounds and intcon correctly.
Then in the first half set of variables ga assumes 0/1 for q and the second half set is used for the assumed coefficients that are multiplied by the assumed q-values. Since some of them are 0 the multiplication with a coefficient would still be zero.
See this example:
function myfitness = myFitness(x)
q = x(1):x(numel(x)/2);
coeffs = x((numel(x)/2)+1):x(end);
q_coeffs = coeffs.*q;
% Caculate your fitness value
myfitness = q_coeffs * something - m*c^2; % Your fitness calculation...
end
What would happen for this example:
ga assumes:
x(1) = 1
x(2) = 0
x(3) = 1
x(4) = 0.1
x(5) = 0.5
x(6) = 0.25
q_coeffs = [0.1*1, 0.5*0, 0.25*1] = [0.1 0 0.25]
  댓글 수: 2
alaa zarif
alaa zarif 2019년 7월 1일
isnt there another way to assume coefficients for the values in q assumed to be 1 only ?? as like that i will have many unneccessary variables
in my problem i have a 64 variables to be assigned 0s and 1s, if i double them the code will consume so much time
Stephan
Stephan 2019년 7월 1일
The problem is, that you need to know the number of vars before starting ga. But i doubt that it takes less time to start ga twice. 128 decision variables is not a big optimization problem. I would try this way, since it is easy to program and to understand. If you program it in a vectorized manner, this part should run quickly.

댓글을 달려면 로그인하십시오.

카테고리

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