Chosing the step between lower bound and upper bound in genetic algorithm

6 views (last 30 days)
I am doing the optimization of the membership function of a fuzzy logic controller using genetic algorithm. I would like to control the step between the lower bound and the upper bound. For instance, instead of verifying the number 0.235689745121, it should go from 0.23 to 0.24. Meaning, with a step of 0.01. Any idea how I can achieve that?

Answers (1)

John D'Errico
John D'Errico on 23 Sep 2021
Actually, this is simple. even trivial.
Can you force a variable to take on integer valiues in GA? (yes)
In the help for GA, I see it has a variable intcon. intcon allows you to specify that some of the variables will be held to integer values. So you can specify that x(1) is forced to take on only integer values. Why does this help? Easy. Suppose that x(1) must run from 0.23 to 0.24, with a step of 0.001? (I ASSUME YOU MEANT A STEP OF 0.001, NOT 0.01.)
All you need to do is specify that x(1) must lie in the interval [230, 240] using the bound constraints, AND must be an integer. Now, inside your objective function, divide x(1) by 1000.
(230:240)/1000
ans = 1×11
0.2300 0.2310 0.2320 0.2330 0.2340 0.2350 0.2360 0.2370 0.2380 0.2390 0.2400
The result will be a value that can take on all 11 possible increments of 0.001 between 0.23 and 0.24.
Case closed. (Sorry that nobody answered this before, but at least @Sushil Poudel can benefit from this answer.)

Community Treasure Hunt

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

Start Hunting!