How to set a boundary condition to my solution of the fitness function? (MATLAB genetic algorithm)

6 visualizaciones (últimos 30 días)
I have the following problem:
I am optimizing three design parameters. For a more efficient and automated optimization I use the genetic algorithm in MATLAB. For each iteration the three design paramers are varied to find the optimal solution. The problem is that i want to restrict the solution of the fitness function to be between certain values. For that i need to get the solution and if it's not in the range, i need to discard it from the current population and to redo the simulation with another parameters till my solutions falls in the required range. Therefore i can create an output function and evaluate it every iteration but there must be some internal functions of the genetic algorithm which are doing this automatically. I cound't find anything yet how to create a loop or statement to discard the value from the current population and redo the simulation. Does anyone have an idea or any suggestions? Also some links would help.
%Output function
function [state,options,optchanged] = ga_output_function(options,state,flag)
if strcmp(flag,'iter') %if ga is in iteration
p = state.Population;
s = state.Score;
%test and change things
else
%something else
end
end

Respuestas (1)

Alan Weiss
Alan Weiss el 2 de Jun. de 2021
I believe that your optimization will work much better using patternsearch as the solver instead of ga, or even using surrogateopt if you have a relatively recent MATLAB version.
You can include a nonlinear constraint function to test whether the result is in the range you want. You don't need to use an output function for that.
You can also try setting your objective function to return NaN as the objective function value for infeasible points.
Good luck,
Alan Weiss
MATLAB mathematical toolbox documentation

Categorías

Más información sobre Genetic Algorithm en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by