Using genetic algorithm (ga) function for integer and linear inequality constrained optimization. Candidate solutions are violating the inequality constraints
Show older comments
I am using the ga() function in the Global Optimisation Toolbox. The problem is constrained by a linear inequality and all the optimisation variables must be integers:
problem.Aineq=[1 1 1 1 1 1];
problem.bineq = 12;
problem.intcon=[1 2 3 4 5 6];
However by looking at the population at various points through the evolution I can see that there are some candidate solutions being generated that violate the inequality constraint.
E.g. A candidate_solution might be: [3 2 2 2 2 2]
I am concerned that the ga() function is "wasting" computing time by evaluating the fitness of solutions that are outside the constrained solution space. Can anyone confirm if this is the case?
From reading the MATLAB documentation for ga() and constrained optimisation it states: "All the linear constraints and bounds are satisfied throughout the optimization." https://uk.mathworks.com/help/gads/examples/constrained-minimization-using-the-genetic-algorithm.html.
Am I misusing ga() if it is violating the constraints?
Thanks
3 Comments
By what means are you observing the population "at various points through the evolution"?
My best guess, for now, is that you are observing the population at a point prior to some weed-out step where ga discards the candidates not satisfying the linear constraints. I don't think the fitness function is ever actually evaluated at the discarded candidates.
Bob Hickish
on 17 Jan 2017
Bob Hickish
on 17 Jan 2017
Accepted Answer
More Answers (1)
You can specify the mutation function in the Mutation function (MutationFcn) field in the Mutation options pane. Do not use with integer problems. You can choose from the following functions:
I guess the various options available for mutation don't apply when integer constraints are in play.
The existence on unfeasible candidates in the population is not necessarily a problem for me, IF they are not passed to the fitness function for evaluation. Can anyone tell me if this is the case, or a possible fix.
If you are worried about efficiency, I would simply insert a constraint check into the fitness function. In other words, test whether the input satisfies the linear constraints at the very beginning of the fitness function routine and abort all subsequent computations (returning a fitness value of Inf) if it does not. If this slows down execution significantly, it's a pretty good sign that ga is already doing this for you.
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!