Constraining Dependent Variables in ga Optimization
3 views (last 30 days)
Show older comments
Hi,
I am trying to constrain my optimization for min f(x) by restricting the range allowed for a dependent variable h(x). I am using a the ga optimizer from the Optimization Toolbox. Do I need to write a penalty or barrier function into by objective function, or is there another simpler way that I can apply the constraint? I tried using the nonlcon input in the ga function, however have been unable to get it to converge. The documentation suggests that nonlcon can only take x (independent variable vector) as an input and so I think that reading in dependent variables may be a misuse of the function.
Please help! Any guidance would be greatly appreciated.
0 Comments
Accepted Answer
Matt J
on 23 Jan 2015
Edited: Matt J
on 23 Jan 2015
The documentation suggests that nonlcon can only take x (independent variable vector) as an input and so I think that reading in dependent variables may be a misuse of the function.
Well, nonlcon should be written to accept a vector in the space of x as input, not a vector in the space of h. However, since h is a function of x, that should be straightforward. Something like this,
function [c,ceq] = nonlcon(x)
ub=... %upper bounds
lb=... %lower bounds
hx=h(x);
c=[hx(:)-ub(:); lb(:)-hx(:) ];
ceq=[];
end
Are you sure it's not converging, or might it just be converging to something you don't like? With nonlinear constraints, it can be difficult to find a good initial population, especially if the constraints define a set with several disconnected regions.
3 Comments
Matt J
on 23 Jan 2015
and so I am unable to calculate it from the independent variables alone.
I assume that means that there are additional problem constants that the calculation of h(x) depends on. If so, that is covered in Passing Extra Parameters.
More Answers (0)
See Also
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!