필터 지우기
필터 지우기

certain number of variables for genetic algorithm to change

조회 수: 5 (최근 30일)
Artur Iskhakov
Artur Iskhakov 2020년 7월 16일
Hello! I'm trying to use genetic algorithm toolbox in order to find minimum of fitness function. My function F depends on the vector of input variables (integers ranging from 0 to 1) X = [some values that GA will change in order to find minimum of fitness funciton].
The question is "how can I make GA set only certain number of variables in X vector (for example only three 1s X = [0 0 0 1 0 1 0 1 0 0])?" I tried to use while loop inside the function, but when I call a GA using
[X,fval] = ga(@F,6,[],[],[],[],[0 0 0 0 0 0],[1 1 1 1 1 1],[],IntCon)
it seems like it is a infinite looop.
Could anybody help me with that?
Here's the while loop that I tried to use inside my function:
while sum(nonzeros(X))<=3
%some code
end

답변 (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