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

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.

 Respuesta aceptada

Walter Roberson
Walter Roberson el 28 de Feb. de 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 comentarios

Thanks for replying. Actually I want to use binary bits for my problem (integer constraint) so that I could use single point or two point crossover. I don't want to use real coded GA. But apparently if you have integer variables, GA Tool Box overrides with its default sets. Please suggest.
Do not ask for integer constraints when population type is set to bitstring, and do not specify any constraints like lb or ub. Just give the population type as bitstring and give your choice of crossover. All variables will be configured as integer 0 or 1.
If you want use mixed integer with some variables that happen to be binary, or want to use all integer but some of them happen to be binary and you want special crossover, then that is a different situation than choosing population type bitstring, which is strictly for the case all bits are single bit binary.
For mixed integer or all integer cases where you want something different than the crossover provided automatically when you give intcons, then what you have to do is not tell it that you are using intcons or bitstring, and instead provide custom population and crossover and mutation functions that all just happen to only create integer values in appropriate positions
Ok. Thanks again. Let me try then.
Dear Walter, It's working. Thanks. Can you suggest me some reference material on the same? I want to study and see how is it actually works? Like how is it assigning 0 and 1 to integer variables and other stuff. Regards,
Ripunjoy
Which arrangement did you end up using?
The one with not asking for integer constraints. The first one. I haven't specified any bounds.
To confirm, you used population type bitstring ?
Yes, I have used population type as bit string (my constraints are only integers). But please tell me one thing, if I don't provide the bounds, how does is it know its bounds as I have bounds e.g. 5<x<15 (all integers). Actually these are some of the questions that I have. Also, how is it assigning 0 and 1 to integer variables, like are they single bit or 2 bits or so on. Please reply and if possible give me some links/files to refer. Thank you.
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.

Iniciar sesión para comentar.

Más respuestas (0)

Etiquetas

Preguntada:

el 28 de Feb. de 2017

Comentada:

el 1 de Mzo. de 2017

Community Treasure Hunt

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

Start Hunting!

Translated by