How to use binary bits in genetic algorithm for integer constraints?

6 views (last 30 days)
I have five different integer constraints. But when I select bit string option in matlab ga toolbox, I get the below error:
Optimization running. Error running optimization. Problem has integer constraints. PopulationType must be set to 'doubleVector'.
Also, I am not allowed to use single point/two point crossover. By default matlab is using scattered crossover when there are integer constraints. If it is possible to use binary bits for integer constraints in matlab ga toolbox, where may I set the size of the binary bits? Please help.

Accepted Answer

Walter Roberson
Walter Roberson on 28 Feb 2017
When you use bitstring all variables are single bit binary that for performance reasons are stored as double.
You can use the other crossover with bitstring.
https://www.mathworks.com/help/gads/genetic-algorithm-options.html#f14223
  10 Comments
Walter Roberson
Walter Roberson on 1 Mar 2017
When you use bitstring as the population type, the elements will only ever be assigned 0.0 or 1.0.
You should not be using bitstring for integer ranges without using custom functions. Well, other than the possibility of binary numbers where you want crossover and mutation to happen at any bit boundaries.
For integer ranges like -5 to 15 you should either use intcons or custom functions.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!