Genetic Algorithm (ga) - Constraint computed inside the fitness function

8 views (last 30 days)
Hi everyone, I need to run a "ga" minimization constrained on some quantity that depends non-trivially on the parameters and which is therefore computed inside the fitness function. Is there any way of doing this apart from cheating the solver with some very high value in case the condition is not met.
Also I couldn't find any mean of extracting quantities computed within the fitness function apart from defining global variables. Is there any clean way of doing this?
Thanks a lot for your help.

Answers (1)

Alan Weiss
Alan Weiss on 20 Oct 2015
Optimization Toolbox documentation addresses this case. I do not know whether the technique described there will work for ga, in terms of increasing efficiency, because ga computes things differently than other solvers (it is a population-based solver, so doesn't really have a single current point).
However, you can probably manage to extract the constraints from the fitness function using a vector or matrix of parameters that contain the quantity of interest for the current population. You also might want to use vectorized function evaluation, which I believe has a chance of increasing the efficiency of the process.
It is a bad idea to cheat by setting the fitness function to an arbitrary high value if your nonlinear constraints are violated. This confuses the solver, because it has no idea whether it is close or far from a feasible point. It is much better to give a true nonlinear constraint function that is positive when the constraint is violated, negative when feasible, and the size of the violation or feasibility is reflected in the function.
Good luck,
Alan Weiss
MATLAB mathematical toolbox documentation

Products

Community Treasure Hunt

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

Start Hunting!