I want to implement a dynamic penalty strategy to an optimization program. For "dynamic" I mean that the penalty function depends on the number of the current generation during the optimization routine. This penalty function is computed inside my fitness function (fitness_function.m), which is called by the ga command.
I read that genetic algorithm in Matlab has a state field called state.Generation, which is the one I want. When I try to pass it to my parametrized fitness function by typing:
ga(@(x) fitness_function(x, state.Generation) ...)
an (obvious) error comes up: Failure in initial user-supplied fitness function evaluation. GA cannot continue.
Does anyone know if there is a workaround for this?
Thanks for your help.