How to use nested function in main program as constraint for a Genetic Algorithm that optimizes the main?

This is my main program:
function CDG=fuzz(a,b)
CDG=10*sum(b);
%code%
[a,b,c]=function flow(a,b)
[d,e,f]=function shrt(b)
end
The flow(a,b) and shrt(b) functions are in separate function-files. I'm using simple GA to minimize CDG. How to do this considering that a,b,c,d,e and f must be passed as constraint to the GA. The GA population vector is b.

Risposte (1)

If you are looking for information about how to pass parameters, see this section. If you are looking for something else, feel free to ask again.
Alan Weiss
MATLAB mathematical toolbox documentation

5 Commenti

the link you've posted is not for GA. I have to pass constraints to the GA but my constraints are of the form g(f(x)) while Matlab requires them to be f(x), where f is the objective function and x is a chromosome.
Is there a workaround to this given that the functions i have to use as constraints are nested into the function I have to minimize?
It is difficult for me to understand what you are asking, so please forgive me if my answers are not relevant.
For information on avoiding double-evaluation of objective and constraint functions, see this section. And, as the previous link I gave you, it is in Optimization Toolbox, but in fact both links are relevant to GA as well as to other Optimization Toolbox functions.
If these answers are not helpful to you, then please try asking again, taking into account that so far I have had a great deal of trouble understanding what you have been asking. In particular, I have no idea what you mean when you write "How to do this considering that a,b,c,d,e and f must be passed as constraint to the GA. The GA population vector is b." I also have no idea what you mean when you write "I'm using simple GA to minimize CDG."
Alan Weiss
MATLAB mathematical toolbox documentation
My bad, I corrected the code. CDG is the output of my objective function. I'm minimizing CDG using the simple genetic algorithm from the global optimization toolbox. Problem is all examples from matlab are in this form: minimize f(x) and constrain x according to equations such as x-1<0 for example. My constraints are functions of x e.g g(x); i have no explicit relations for x (like x<0 etc..). On top of that the functions (g(x)) are nested within my objective function.
Again, I am having trouble understanding you. You say your constraints are functions of x such as g(x). To me, g(x) is a function, not a constraint. A constraint would be something like g(x) < 0. Therefore, it sounds to me as if you have a nonlinear constraint g(x) < 0. This is a supported type of constraint; see this section of the documentation.
Again, I urge you to look at the link on avoiding double evaluation of the objective and constraints.
Good luck,
Alan Weiss
MATLAB mathematical toolbox documentation
Thanks, your suggestion did help me although the problem still remains. Deb's NSGA-II paper mentions a scheme for handling constraints (i.e. not just bound constraints on the decision variables, but "constraint functions"). This is what I'm talking about. Matlab's gamultiobj is supposed to be NSGA-II based, why doesn't it have a 'constraint functions' options? Further the simple GA can have integer variables but gamultiobj doesn't. This is queer.

Accedi per commentare.

Richiesto:

il 18 Mar 2013

Community Treasure Hunt

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

Start Hunting!

Translated by