Got Questions? Get Answers.
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
GA objective and constraint evaluation sequence

Subject: GA objective and constraint evaluation sequence

From: August

Date: 8 Oct, 2013 21:11:07

Message: 1 of 5

I'm running a Genetic Algorithm whose objective and constraint functions use data from the same analysis. However, I don't understand the sequence that the ga() function uses to evaluate the objective and constraint.

Does it run through all of the objective evaluations, then all of the constraint evaluations for each generation? Is there any way to make the GA evaluate the objective and constraint together for each design point?

Thanks

Subject: GA objective and constraint evaluation sequence

From: Paul Kerr-Delworth

Date: 10 Oct, 2013 10:32:05

Message: 2 of 5

"August " <atnoever@gmail.com> wrote in message <l31sdb$8nq$1@newscl01ah.mathworks.com>...
> I'm running a Genetic Algorithm whose objective and constraint functions use data from the same analysis. However, I don't understand the sequence that the ga() function uses to evaluate the objective and constraint.
>
> Does it run through all of the objective evaluations, then all of the constraint evaluations for each generation? Is there any way to make the GA evaluate the objective and constraint together for each design point?
>
> Thanks

Hi,

For a given population member, x, GA evaluates the objective at point x followed by an evaluation of the constraint. As such it is possible to write the objective and constraint functions in such a way that they can both access the evalution of a common function. There is a section in the documentation which outlines how to do this

http://www.mathworks.com/help/optim/ug/objective-and-nonlinear-constraints-in-the-same-function.html

Hope this helps.

Best regards,

Paul

p.s. Note that if you have integer constraints in the problem, the objective is evaluated at all points followed by the constraints at all points. To use the technique above when there are integer constraints, you need to set Vectorized to 'on'.

Subject: GA objective and constraint evaluation sequence

From: August

Date: 11 Oct, 2013 02:49:05

Message: 3 of 5

Hi Paul,

Thanks for the help, I hadn't come across that page before. I am using integer constraints so I have to deal with all of the objective evaluations coming before the constraint evaluations.

I think I found what you're talking about with using the GA vectorize option: http://www.mathworks.com/help/matlab/matlab_prog/vectorization.html#btl4t3x

Having the GA pass in all the Xs for the current population should be pretty easy to deal with. My analysis involves a Finite Element Analysis call and has to load stored data. Should be pretty easy to index and store the objective and constraint evaluations if all the Xs are coming in at once.

Subject: GA objective and constraint evaluation sequence

From: August

Date: 11 Oct, 2013 13:27:06

Message: 4 of 5

One annoying nuance that I've come across is that the GA evaluates the constraint function for a single design point before evaluating the constraints and objectives of the 1st population. Does anyone know what this single constraint evaluation is doing?

Subject: GA objective and constraint evaluation sequence

From: Steven Lord

Date: 11 Oct, 2013 14:56:25

Message: 5 of 5


"August " <atnoever@gmail.com> wrote in message
news:l38uba$rv6$1@newscl01ah.mathworks.com...
> One annoying nuance that I've come across is that the GA evaluates the
> constraint function for a single design point before evaluating the
> constraints and objectives of the 1st population. Does anyone know what
> this single constraint evaluation is doing?

http://www.mathworks.com/matlabcentral/newsreader/view_thread/327322#911476

"From R2012b onwards, the fitness and constraint functions that are passed
to GA are evaluated at a single point *on the client* before the main GA
algorithm commences. This allows GA to check whether the fitness and
constraint functions can be evaluated. Furthermore, this change was made to
be consistent with other functions in the Optimization and Global
Optimization Toolboxes."

While this message was written in a thread about running GA in parallel, I
suspect that this "can these functions be evaluated" check also occurs when
using GA in serial.

--
Steve Lord
slord@mathworks.com
To contact Technical Support use the Contact Us link on
http://www.mathworks.com

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us