I need to maximize an objective function using genetic algorithm but the toolbox fails to do so. Can you help ?
Show older comments
My objective function contains 93 integer variables including 16 binary variables. I have used fx = - Fmax to maximize it but unfortunately, the result I get is positive. That is, the value of Fmax comes out to be negative whereas solving the same code in LINGO gives me an accurate result. Also, when I try to input the Initial population as the one I got from LINGO optimization, it produces the exact same result as LINGO. I am confused here. How is it possible that when GA starts on its own, it goes to the negative side of the function even though it is undergoing maximization. I have tried changing the following parameters to see any improvements but none solved the issue.
1. Migration - 'both side' instead of 'forward'
2. setting lower bound of variables as zero.
3. changing the creation function to feasible population or constraint dependent
It is getting very hard to find the cause of this randomness.
Answers (1)
Alan Weiss
on 9 Apr 2018
0 votes
Is your problem inherently nonlinear? If you can express your objective and constraints as linear functions, then you would doubtless have much better results by using intlinprog.
But if you must use ga, then perhaps these guidelines will help.
- Read the documentation on integer ga. For example, you cannot set a creation function; as documented, ga overrides your setting.
- Read the documentation on options. In particular there is no benefit in setting any migration options.
- It is very difficult for ga to solve an integer problem with about a hundred variables. To have a chance, take a large population size ( PopulationSize option), perhaps 1e4 or 1e5. ga will run slowly, and there are no guarantees that you will get a good solution.
- To have the best chance of getting a good solution, give ga a wide variety of initial feasible points. It can be hard to come up with feasible points, but that is the best thing that you can do. See Population Diversity, which unfortunately is not geared toward integer problems.
Good luck,
Alan Weiss
MATLAB mathematical toolbox documentation
2 Comments
Parikshit Agrawal
on 9 Apr 2018
Alan Weiss
on 10 Apr 2018
Our built-in integer ga implementation is not particularly fast or robust in high dimensions. The workaround for equality constraints in particular is not robust, as documented. And, like all genetic algorithm solvers, the algorithm's behavior is stochastic, so you are never guaranteed to get a good result.
Use intlinprog for integer-constrained problems with linear constraints and linear objective. Using ga on such a problem is not recommended. If you want to investigate algorithmic behavior, feel free, but don't be surprised when non-recommended approaches give poor results.
Alan Weiss
MATLAB mathematical toolbox documentation
Categories
Find more on Genetic Algorithm in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!