Genetic Algorithm 'bitstring' not accepting constrains
4 ビュー (過去 30 日間)
古いコメントを表示
i use the following code to generate binary values using genetic algorith:
options = optimoptions(@ga, 'PopulationType', 'bitstring', 'Generations', 100, 'Display', 'iter', 'StallGenLimit', 10);
[x, fval, exitflag, output] = ga(SAIDI, n1, [], [], [], [], lb, ub, @nonlcon, options);
but i get a waring that : 'bitstring' ignore all constrain,
i want only 20 values of x to be 1 and the rest is 0 , i tried this constrain but it failed
function [c, ceq] = nonlcon(x)
c = [];
ceq = sum(x) - 20;
end
is there is way to achive my constrain without changing my fitness function ?
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Genetic Algorithm についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!