MATLAB Answers

Is it possible to use a different fitness function for certain population members in the Genetic Algorithm?

1 view (last 30 days)
Doug Rank
Doug Rank on 20 Feb 2018
Edited: Doug Rank on 5 Oct 2018
I am using the genetic algorithm to solve a integer (binary) problem with linear constraints.
Because the solution space is so large (~400 binary solution vector) and I do not have a lot of time to run the algorithm, I inject a handful of strategic solutions into the initial population. This way the GA is refining those solutions rather than starting randomly (and hence, better solutions are found quicker).
The problem is that the fitness function is a bottleneck on run time. The initial generation takes upwards of 30 minutes to evaluate 500 random feasible solutions. After the first generation, crossover turns the population mostly infeasible (and infeasible solutions are not evaluated by the fitness function - so the generations progress much more quickly). Over time, feasible solutions begin to emerge and the population becomes (almost) completely feasible.
(Note: The mathworks documentation on this is currently incorrect. Crossover DOES produce infeasible solutions in certain uses of the GA).
Since the random solutions are uniformly "fit" after the first generation, I don't want to waste precious time running each of them through the fitness function in the initial generation.
Is there a way to tell the fitness function to ignore certain population members? Such as population(100:end,:) if Generation < 1? As far as I can tell, there's no straightforward way to pass which population member is being evaluated to the fitness function. (Even if you can pass other parameters).
My other thought it to use the output function to change the fitness function. For the first generation, it could use a very simple function. Then after the first crossover, I can use the output function to inject the strategic solutions into the population and switch over to the better fitness function.
Does anyone have any thoughts on this?
Doug Rank
Doug Rank on 5 Oct 2018
If I did that, I would only be left with about 5 or so "smart" starting points that are generated by a custom algorithm to inject in the initial population. These starting points are used to give the GA a head start, as I have to use time as the stopping criteria.
I do want those other random solutions in the population for diversity - I just don't particularly care about their initial scores because they are much much worse than the starting points.

Sign in to comment.

Answers (0)

Community Treasure Hunt

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

Start Hunting!