How to ask Matlab ga to continously regenerate individuals until they all satisfy user defined constraints prior to fitness evaluation

1 view (last 30 days)
Dear all,
I am currently using matlab ga to set up an optimisation process, with a FE solver used for fitness value calculation. In my model, the design variables of each individual must satisfy a nonlinear constraint to ensure the FE model being successfully built and running okay in the evaluation phase for all generations.
I then wrote an nonlinear constraint function to do this but I found that not all individuals satisfy the constraint I've defined. For intances, if the population size is 100, there might be only 20 individuals that satisfy the constarint. I therefore wonder if there would be a way to ask matlab ga to continously generate individual until all individuals in the population satisfy the user defined constraints or pre-checking functions?
Any help is appreciated.

Accepted Answer

Matt J
Matt J on 7 Mar 2024
Edited: Matt J on 7 Mar 2024
The way to handle that is to have the fitness function skip the FE modeling and return Inf (or some large penalizing value) if the constraints are not satisfied.
  1 Comment
fei yu
fei yu on 8 Mar 2024
Thanks for your advice, Matt. It works alright for now.
It seems that matlab ga can somehow adjust the value of design variables to enable more more individuals in the subsequent generations to meet the constraint I defined. Besides, this also leads to an increase in the total runtime for the following generations as the optimisation proceeds, due to the growing number of "good" individuals.

Sign in to comment.

More Answers (0)

Products


Release

R2019b

Community Treasure Hunt

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

Start Hunting!