certain number of variables for genetic algorithm to change

5 次查看(过去 30 天)
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