Class AdaptiveEvolutionaryAlgorithm<T extends Copyable<T>>
 Type Parameters:
T
 The type of object under optimization.
 All Implemented Interfaces:
Splittable<TrackableSearch<T>>
,Metaheuristic<T>
,ReoptimizableMetaheuristic<T>
,TrackableSearch<T>
Rather than specifying crossover and mutation rates, this adaptive evolutionary algorithm evolves these during the search. Each member of the population consists of an encoding of a candidate solution to the problem, along with a crossover rate C_{i}, a mutation rate M_{i}, and a parameter σ_{i}. During a generation, parents are paired at random. Consider that i and j are parents. One of these is chosen arbitrarily. For example, consider that i was chosen. With probability C_{i} the crossover operator is applied to the parents, and otherwise it is not. Then, the mutation operator is applied to each member of the population i with probability M_{i}. Note that this class implements an evolutionary algorithm for the general case, and not strictly bit strings, so the M_{i} is not a perbit rate. Rather, it is the probability of a single application of whatever the mutation operator is.
After applying the genetic operators, all of the C_{i} and M_{i} are themselves mutated. Specifically, each is mutated with a Gaussian mutation with standard deviation σ_{i}. The σ_{i} are then also mutated by a Gaussian mutation with standard deviation of 0.01. The C_{i} and M_{i} are initialized randomly at the start such that they are each in the interval [0.1, 1.0], and the Gaussian mutation is implemented to ensure that they remain in that interval (e.g., reset to 0.1 if it is ever too low, and to 1.0 if it is ever too high). The σ_{i} are initialized randomly in the interval [0.05, 0.15], and constrained to the interval [0.01, 0.2].
This specific form of adaptive control parameters is based on the approach described in the
following paper:
Vincent A. Cicirello. Genetic Algorithm Parameter
Control: Application to Scheduling with SequenceDependent Setups. In Proceedings of the
9th International Conference on Bioinspired Information and Communications Technologies,
pages 136143. December 2015.
The crossover, mutation, and selection operators are completely configurable by passing
instances of classes that implement the CrossoverOperator
, MutationOperator
, and
SelectionOperator
classes to one of the constructors. The EA implemented by this class
can also be configured to use elitism, if desired, such that a specified number of the best
solutions in the population survive the generation unaltered.

Constructor Summary
ConstructorDescriptionAdaptiveEvolutionaryAlgorithm
(int n, MutationOperator<T> mutation, CrossoverOperator<T> crossover, Initializer<T> initializer, FitnessFunction.Double<T> f, SelectionOperator selection) Constructs and initializes the evolutionary algorithm.AdaptiveEvolutionaryAlgorithm
(int n, MutationOperator<T> mutation, CrossoverOperator<T> crossover, Initializer<T> initializer, FitnessFunction.Double<T> f, SelectionOperator selection, int eliteCount) Constructs and initializes the evolutionary algorithm.AdaptiveEvolutionaryAlgorithm
(int n, MutationOperator<T> mutation, CrossoverOperator<T> crossover, Initializer<T> initializer, FitnessFunction.Double<T> f, SelectionOperator selection, int eliteCount, ProgressTracker<T> tracker) Constructs and initializes the evolutionary algorithm.AdaptiveEvolutionaryAlgorithm
(int n, MutationOperator<T> mutation, CrossoverOperator<T> crossover, Initializer<T> initializer, FitnessFunction.Double<T> f, SelectionOperator selection, ProgressTracker<T> tracker) Constructs and initializes the evolutionary algorithm.AdaptiveEvolutionaryAlgorithm
(int n, MutationOperator<T> mutation, CrossoverOperator<T> crossover, Initializer<T> initializer, FitnessFunction.Integer<T> f, SelectionOperator selection) Constructs and initializes the evolutionary algorithm.AdaptiveEvolutionaryAlgorithm
(int n, MutationOperator<T> mutation, CrossoverOperator<T> crossover, Initializer<T> initializer, FitnessFunction.Integer<T> f, SelectionOperator selection, int eliteCount) Constructs and initializes the evolutionary algorithm.AdaptiveEvolutionaryAlgorithm
(int n, MutationOperator<T> mutation, CrossoverOperator<T> crossover, Initializer<T> initializer, FitnessFunction.Integer<T> f, SelectionOperator selection, int eliteCount, ProgressTracker<T> tracker) Constructs and initializes the evolutionary algorithm.AdaptiveEvolutionaryAlgorithm
(int n, MutationOperator<T> mutation, CrossoverOperator<T> crossover, Initializer<T> initializer, FitnessFunction.Integer<T> f, SelectionOperator selection, ProgressTracker<T> tracker) Constructs and initializes the evolutionary algorithm. 
Method Summary
Modifier and TypeMethodDescriptionGets a reference to the problem that this search is solving.final ProgressTracker<T>
Gets theProgressTracker
object that is in use for tracking search progress.long
Gets the total run length in number of fitness evaluations.final SolutionCostPair<T>
optimize
(int numGenerations) Runs the evolutionary algorithm beginning from a randomly generated population.final SolutionCostPair<T>
reoptimize
(int numGenerations) Runs the evolutionary algorithm continuing from the final population from the most recent call to eitherMetaheuristic.optimize(int)
orReoptimizableMetaheuristic.reoptimize(int)
, or from a random population if this is the first call to either method.final void
setProgressTracker
(ProgressTracker<T> tracker) Sets theProgressTracker
object that is in use for tracking search progress.split()
Generates a functionally identical copy of this object, for use in multithreaded implementations of search algorithms.

Constructor Details

AdaptiveEvolutionaryAlgorithm
public AdaptiveEvolutionaryAlgorithm(int n, MutationOperator<T> mutation, CrossoverOperator<T> crossover, Initializer<T> initializer, FitnessFunction.Double<T> f, SelectionOperator selection, int eliteCount, ProgressTracker<T> tracker) Constructs and initializes the evolutionary algorithm. This constructor supports fitness functions with fitnesses of type double, theFitnessFunction.Double
interface. Parameters:
n
 The population size.mutation
 The mutation operator.crossover
 The crossover operator.initializer
 An initializer for generating random initial population members.f
 The fitness function.selection
 The selection operator.eliteCount
 The number of elite population members. Pass 0 for no elitism. eliteCount must be less than n.tracker
 A ProgressTracker. Throws:
IllegalArgumentException
 if n is less than 1.IllegalArgumentException
 if eliteCount is greater than or equal to n.NullPointerException
 if any of mutation, crossover, initializer, f, selection, or tracker are null.

AdaptiveEvolutionaryAlgorithm
public AdaptiveEvolutionaryAlgorithm(int n, MutationOperator<T> mutation, CrossoverOperator<T> crossover, Initializer<T> initializer, FitnessFunction.Integer<T> f, SelectionOperator selection, int eliteCount, ProgressTracker<T> tracker) Constructs and initializes the evolutionary algorithm. This constructor supports fitness functions with fitnesses of type int, theFitnessFunction.Integer
interface. Parameters:
n
 The population size.mutation
 The mutation operator.crossover
 The crossover operator.initializer
 An initializer for generating random initial population members.f
 The fitness function.selection
 The selection operator.eliteCount
 The number of elite population members. Pass 0 for no elitism. eliteCount must be less than n.tracker
 A ProgressTracker. Throws:
IllegalArgumentException
 if n is less than 1.IllegalArgumentException
 if eliteCount is greater than or equal to n.NullPointerException
 if any of mutation, crossover, initializer, f, selection, or tracker are null.

AdaptiveEvolutionaryAlgorithm
public AdaptiveEvolutionaryAlgorithm(int n, MutationOperator<T> mutation, CrossoverOperator<T> crossover, Initializer<T> initializer, FitnessFunction.Double<T> f, SelectionOperator selection, ProgressTracker<T> tracker) Constructs and initializes the evolutionary algorithm. This constructor supports fitness functions with fitnesses of type double, theFitnessFunction.Double
interface. Parameters:
n
 The population size.mutation
 The mutation operator.crossover
 The crossover operator.initializer
 An initializer for generating random initial population members.f
 The fitness function.selection
 The selection operator.tracker
 A ProgressTracker. Throws:
IllegalArgumentException
 if n is less than 1.NullPointerException
 if any of mutation, crossover, initializer, f, selection, or tracker are null.

AdaptiveEvolutionaryAlgorithm
public AdaptiveEvolutionaryAlgorithm(int n, MutationOperator<T> mutation, CrossoverOperator<T> crossover, Initializer<T> initializer, FitnessFunction.Integer<T> f, SelectionOperator selection, ProgressTracker<T> tracker) Constructs and initializes the evolutionary algorithm. This constructor supports fitness functions with fitnesses of type int, theFitnessFunction.Integer
interface. Parameters:
n
 The population size.mutation
 The mutation operator.crossover
 The crossover operator.initializer
 An initializer for generating random initial population members.f
 The fitness function.selection
 The selection operator.tracker
 A ProgressTracker. Throws:
IllegalArgumentException
 if n is less than 1.NullPointerException
 if any of mutation, crossover, initializer, f, selection, or tracker are null.

AdaptiveEvolutionaryAlgorithm
public AdaptiveEvolutionaryAlgorithm(int n, MutationOperator<T> mutation, CrossoverOperator<T> crossover, Initializer<T> initializer, FitnessFunction.Double<T> f, SelectionOperator selection, int eliteCount) Constructs and initializes the evolutionary algorithm. This constructor supports fitness functions with fitnesses of type double, theFitnessFunction.Double
interface. Parameters:
n
 The population size.mutation
 The mutation operator.crossover
 The crossover operator.initializer
 An initializer for generating random initial population members.f
 The fitness function.selection
 The selection operator.eliteCount
 The number of elite population members. Pass 0 for no elitism. eliteCount must be less than n. Throws:
IllegalArgumentException
 if n is less than 1.IllegalArgumentException
 if eliteCount is greater than or equal to n.NullPointerException
 if any of mutation, crossover, initializer, f, or selection are null.

AdaptiveEvolutionaryAlgorithm
public AdaptiveEvolutionaryAlgorithm(int n, MutationOperator<T> mutation, CrossoverOperator<T> crossover, Initializer<T> initializer, FitnessFunction.Integer<T> f, SelectionOperator selection, int eliteCount) Constructs and initializes the evolutionary algorithm. This constructor supports fitness functions with fitnesses of type int, theFitnessFunction.Integer
interface. Parameters:
n
 The population size.mutation
 The mutation operator.crossover
 The crossover operator.initializer
 An initializer for generating random initial population members.f
 The fitness function.selection
 The selection operator.eliteCount
 The number of elite population members. Pass 0 for no elitism. eliteCount must be less than n. Throws:
IllegalArgumentException
 if n is less than 1.IllegalArgumentException
 if eliteCount is greater than or equal to n.NullPointerException
 if any of mutation, crossover, initializer, f, or selection are null.

AdaptiveEvolutionaryAlgorithm
public AdaptiveEvolutionaryAlgorithm(int n, MutationOperator<T> mutation, CrossoverOperator<T> crossover, Initializer<T> initializer, FitnessFunction.Double<T> f, SelectionOperator selection) Constructs and initializes the evolutionary algorithm. This constructor supports fitness functions with fitnesses of type double, theFitnessFunction.Double
interface. Parameters:
n
 The population size.mutation
 The mutation operator.crossover
 The crossover operator.initializer
 An initializer for generating random initial population members.f
 The fitness function.selection
 The selection operator. Throws:
IllegalArgumentException
 if n is less than 1.NullPointerException
 if any of mutation, crossover, initializer, f, or selection are null.

AdaptiveEvolutionaryAlgorithm
public AdaptiveEvolutionaryAlgorithm(int n, MutationOperator<T> mutation, CrossoverOperator<T> crossover, Initializer<T> initializer, FitnessFunction.Integer<T> f, SelectionOperator selection) Constructs and initializes the evolutionary algorithm. This constructor supports fitness functions with fitnesses of type int, theFitnessFunction.Integer
interface. Parameters:
n
 The population size.mutation
 The mutation operator.crossover
 The crossover operator.initializer
 An initializer for generating random initial population members.f
 The fitness function.selection
 The selection operator. Throws:
IllegalArgumentException
 if n is less than 1.NullPointerException
 if any of mutation, crossover, initializer, f, or selection are null.


Method Details

split
Description copied from interface:Splittable
Generates a functionally identical copy of this object, for use in multithreaded implementations of search algorithms. The state of the object that is returned may or may not be identical to that of the original. Thus, this is a distinct concept from the functionality of theCopyable
interface. Classes that implement this interface must ensure that the object returned performs the same functionality, and that it does not share any state data that would be either unsafe or inefficient for concurrent access by multiple threads. The split method is allowed to simply return the this reference, provided that it is both safe and efficient for multiple threads to share a single copy of the Splittable object. The intention is to provide a multithreaded search with the capability to provide spawned threads with their own distinct search operators. Such multithreaded algorithms can call the split method for each thread it spawns to generate a functionally identical copy of the operator, but with independent state. Specified by:
split
in interfaceMetaheuristic<T extends Copyable<T>>
 Specified by:
split
in interfaceReoptimizableMetaheuristic<T extends Copyable<T>>
 Specified by:
split
in interfaceSplittable<T extends Copyable<T>>
 Returns:
 A functionally identical copy of the object, or a reference to this if it is both safe and efficient for multiple threads to share a single instance of this Splittable object.

optimize
Runs the evolutionary algorithm beginning from a randomly generated population. If this method is called multiple times, each call begins at a new randomly generated population. Specified by:
optimize
in interfaceMetaheuristic<T extends Copyable<T>>
 Parameters:
numGenerations
 The number of generations to run. Returns:
 The best solution found during this set of generations, which may or may not be the
same as the solution contained in the
ProgressTracker
, which contains the best across all calls to optimize as well asReoptimizableMetaheuristic.reoptimize(int)
. Returns null if the run did not execute, such as if the ProgressTracker already contains the theoretical best solution.

reoptimize
Runs the evolutionary algorithm continuing from the final population from the most recent call to eitherMetaheuristic.optimize(int)
orReoptimizableMetaheuristic.reoptimize(int)
, or from a random population if this is the first call to either method. Specified by:
reoptimize
in interfaceReoptimizableMetaheuristic<T extends Copyable<T>>
 Parameters:
numGenerations
 The number of generations to run. Returns:
 The best solution found during this set of generations, which may or may not be the
same as the solution contained in the
ProgressTracker
, which contains the best across all calls to optimize as well asMetaheuristic.optimize(int)
. Returns null if the run did not execute, such as if the ProgressTracker already contains the theoretical best solution.

getProgressTracker
Description copied from interface:TrackableSearch
Gets theProgressTracker
object that is in use for tracking search progress. The object returned by this method contains the best solution found during the search (including across multiple concurrent runs if the search is multithreaded, or across multiple restarts if the run methods were called multiple times), as well as cost of that solution, among other information. See theProgressTracker
documentation for more information about the search data tracked by this object. Specified by:
getProgressTracker
in interfaceTrackableSearch<T extends Copyable<T>>
 Returns:
 the
ProgressTracker
in use by this metaheuristic.

setProgressTracker
Description copied from interface:TrackableSearch
Sets theProgressTracker
object that is in use for tracking search progress. Any previously set ProgressTracker is replaced by this one. Specified by:
setProgressTracker
in interfaceTrackableSearch<T extends Copyable<T>>
 Parameters:
tracker
 The new ProgressTracker to set. The tracker must not be null. This method does nothing if tracker is null.

getProblem
Description copied from interface:TrackableSearch
Gets a reference to the problem that this search is solving. Specified by:
getProblem
in interfaceTrackableSearch<T extends Copyable<T>>
 Returns:
 a reference to the problem.

getTotalRunLength
public long getTotalRunLength()Gets the total run length in number of fitness evaluations. This is the total run length across all calls toMetaheuristic.optimize(int)
andReoptimizableMetaheuristic.reoptimize(int)
. This may differ from what may be expected based on run lengths. For example, the search terminates if it finds the theoretical best solution, and also immediately returns if a prior call found the theoretical best. In such cases, the total run length may be less than the requested run length. Specified by:
getTotalRunLength
in interfaceTrackableSearch<T extends Copyable<T>>
 Returns:
 The total number of generations completed across all calls to
Metaheuristic.optimize(int)
andReoptimizableMetaheuristic.reoptimize(int)
.
