フィルターのクリア

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 Center および File ExchangeGenetic Algorithm についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by