MATLAB: Constraints in Genetic Algorithm – Not Just Input Constraints

gagenetic algorithmGlobal Optimization ToolboxMATLABoptimization

Is it possible to specify constraints that are not just reliant on the input variable? I.e. a constrain that may be a function of the output or an intermediate variable.
NOTE: The output of this system is calculated from a "black box" (it's a PSS SINCAL simulation).
At this stage I've been using a workaround – making the result of the fitness function a very high value when the output is not within the constraints. Looking for a more elegant solution.
Thank you
Elvis

Best Answer

Nonlinear constraint functions allow you to express any constraint at all, as long as MATLAB can calculate what you need to decide if a point is feasible.
For nonlinear inequality constraints, the mechanism assumes that the constraint is of the form
c(x) <= 0
where c(x) is a smooth function. So, for example, if you want to constrain x to be within the circle
norm(x) <= 5
you would write the constraint
c(x) = norm(x) - 5;
This way, when norm(x) is a bit greater than 5, the solver knows it is infeasible, but also knows that it is close to being feasible.
What I am saying is, don't just set the objective value to an arbitrary high value when the nonlinear constraint is not met, but use a nonlinear constraint function, and set it to a positive value when the constraint is not met, but one that goes smoothly to negative as the constraint becomes satisfied.
Good luck,
Alan Weiss
MATLAB mathematical toolbox documentation