MATLAB: Setting-up input variable in genetic algorithm

gagenetic algorithminput variablessignificant-digits

How can I set up an input variable in my ga that varies from 1 to 2 with steps of 0,1?
The results of my ga has too many significant digits after comma ( precisely 4).
Thank you

Best Answer

You need to use Mixed Integer ga Optimization in one of several ways.
  • Internally to your objective function, change your integer variable x to x/10. Or,
  • Make a list of allowable values in a variable indexvar. Have your objective function evaluate indexvar(x), where x is your integer-valued variable. This is more flexible, in that you can have any list of allowable values.
See Solving a Mixed Integer Engineering Design Problem Using the Genetic Algorithm and in particular the section Add Discrete Non-Integer Variable Constraints.
Alan Weiss
MATLAB mathematical toolbox documentation