Effacer les filtres
Effacer les filtres

certain number of variables for genetic algorithm to change

5 vues (au cours des 30 derniers jours)
Artur Iskhakov
Artur Iskhakov le 16 Juil 2020
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

Réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by