MATLAB Answers

0

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

Asked by Zhida DENG on 23 May 2016
Latest activity Commented on by Zhida DENG on 23 May 2016
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.

  0 Comments

Sign in to comment.

2 Answers

Answer by Alan Weiss
on 23 May 2016
 Accepted Answer

If you are asking how to do mixed-integer programming using ga, see the documentation.
Alan Weiss
MATLAB mathematical toolbox documentation

  1 Comment

Sign in to comment.


Answer by Todd Leonhardt on 23 May 2016
Edited by Todd Leonhardt on 23 May 2016

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

  0 Comments

Sign in to comment.