How to set the variables of genetic algorithm toolbox changing 1 or 0?

1 回表示 (過去 30 日間)
Zhida DENG
Zhida DENG 2016 年 5 月 23 日
コメント済み: Zhida DENG 2016 年 5 月 23 日
Hi,
It would be much appropriated that if anybody can tell me how to let the variables changing 1 or 0 by using genetic algorithm toolbox.
x = ga(fitnessfcn,nvars)
how to make the output 'x' change either 1 or 0.

採用された回答

Alan Weiss
Alan Weiss 2016 年 5 月 23 日
If you are asking how to do mixed-integer programming using ga, see the documentation.
Alan Weiss
MATLAB mathematical toolbox documentation

その他の回答 (1 件)

Todd Leonhardt
Todd Leonhardt 2016 年 5 月 23 日
編集済み: Todd Leonhardt 2016 年 5 月 23 日
If the output x is between 0 and 1 then you can simply do:
round(x);
If not, then you can define a threshold and do:
x = 0;
if x > threshold
x = 1;
end

カテゴリ

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