Genetic Algorithm Solver
A generational genetic algorithm (GA) solver with elitism for simulation optimization.
Each call to mainIteration produces one generation: the best eliteCount solutions are carried forward unchanged; parents are chosen by the selectionOperator; offspring are produced by the crossoverOperator (gated by crossoverRate) and the mutationOperator (gated by the per-individual mutationRate); the whole offspring set is evaluated in a single batch oracle call (via the inherited requestEvaluations); and the next generation is the best of the elites plus the offspring. The best solution found is tracked automatically by the base class through the currentSolution setter.
All randomness is drawn through the solver's single random number stream (rnStream); the genetic operators draw from it as well, so a run is reproducible for a fixed stream number.
Parameters
the problem being solved
the evaluator responsible for assessing the quality of solutions
the random number stream number; 0 (the default) means the next available stream
the provider of random number streams; defaults to a fresh RNStreamProvider
the number of individuals per generation
the parent-selection strategy; defaults to TournamentSelection
the recombination strategy; defaults to BlendCrossover
the mutation strategy; defaults to GaussianMutation
the maximum number of generations
strategy to determine the number of replications per evaluation
used to detect convergence (no-improvement). The default is InputsAndConfidenceIntervalEquality.
an optional name for the solver
Constructors
Constructs a genetic algorithm solver using a fixed number of replications per evaluation.
Properties
Structured, ordered snapshot of the solver's configuration — the same fields the toString implementations expose, in a form that downstream consumers can iterate (reporting, machine-readable summary artifacts, "compare two runs" tooling).
The recombination (crossover) strategy. Cannot be changed while the solver is running.
The probability that a selected pair of parents is recombined via crossover (otherwise the parents are copied). Must be in 0,1.
The number of best individuals carried forward unchanged into the next generation. Must be
The mutation strategy. Cannot be changed while the solver is running.
The probability that an offspring individual is mutated — i.e. that the mutation operator is applied to it at all. Must be in 0,1.
If supplied, this function determines the per-individual mutation rate, overriding mutationRate.
A read-only, best-first ordered view of the current population.
The number of individuals per generation. Must be at least defaultMinPopulationSize.
If supplied, this function determines the population size, overriding populationSize.
The parent-selection strategy. Cannot be changed while the solver is running.
Used to check whether the most recent best solutions have converged (no improvement).
Functions
A hook for subclasses to inject their specific internal state metrics into the snapshot without having to override the entire makeSolverStateSnapshot method.
Subclasses may implement this function to prepare the solver before running the first iteration. Generally, it is sufficient to just implement the startingPoint() function.
Subclasses should implement this function to determine if the solver should continue running iterations. This will likely include some implementation of stopping criteria. This function should implement stopping criteria based on the quality of the solution. The number of iterations, compared to the maximum number of iterations, is automatically checked after each step in the iterative process. Unless overridden, this function returns false by default, which indicates that the solution quality criteria have not been satisfied. This will cause the solver to iterate through all iterations of the solution process up to the maximum number of iterations. Alternatively, the user can specify an instance of the SolutionQualityEvaluatorIfc interface to determine if the solution quality has been reached.
This function should contain the logic that iteratively executes until the maximum number of iterations is reached or until the stopping criteria is met. The base implementation calls nextPoint() to determine the next point to evaluate, requests an evaluation of the point, and then updates the current solution if the resulting solution is better than the current solution. Generally, implementing startingPoint() and nextPoint() should be adequate. The property iterationCounter represents the current iteration within the mainIteration() function. That is, the value of iterationCounter is incremented prior to the execution of the mainIteration() function.
The effective per-individual mutation rate: the value from mutationRateFn if supplied, otherwise mutationRate.
The effective population size: the value from populationSizeFn if supplied, otherwise populationSize.