Application interface

This article briefly describes the application interface of nage's evolutionary algorithms library.
The core module contains the main classes and interfaces for writing evolutionary algorithms, along with many abstract high-level implementations.

Note about parameterized strategies

Most strategies in solution packages are parameterized by some TSol suptype of ISolution.
This is usually the type of solution they are able to perform some operations on
(e.g. factories, mutations, etc.). Instances of these strategies need to provide
an actual type parameter. That way, we can be type-safely put together multiple genetic
operators which can inter-operate together, while being sure that any of them won't
get solutions of a type it does not support.




ISolution is the most general interface for describing potential solutions in an evolutionary algorithm. It consists of a representation, which can be associated with some evaluation in the context of a given population.


ISolutionFactory<TSol> is a factory and strategy interface for creating and copying solutions. To keep solutions as simple as possible, the responsibility of creating new instances is given to this dedicated strategy.
Factories can create empty solutions, solutions initialized with respect to some problem or copy existing ones. They also decide of representations actual implementation.
ISolutionFactory<TSol> is a parameterized type - its type parameter TSol reflects the type of solutions being created by some given factory.


ISolutionEvaluator<TSol> is a strategy interface for evaluating solutions. It is parameterized by the type of solutions it supports.
When given a solution, evaluators should return a double value. This value is the fitness of the solution in the context of the problem being solved.

Generally, evolutionary algorithms aim to maximize the fitness function. If you are given with a cost function you need to minimize instead, you will need to transform it somehow into a fitness function. It may be usually done by negating the cost function.

Evaluators may or may not be idempotent - they may return the same value when asked about an identical solution (with regard to representation), or they may return a different value on each consecutive evaluation.




IPopulation<TSol> is a general interface for describing populations, that is collections of solutions, along with their evaluations.
It is a parameterized type - its type parameter TSol reflects the type of solutions being held in the population.

Populations associate solutions' representation with some evaluation. This evaluation reflects the quality of the representation in the context of the problem being solved.

IPopulation represents a mapping between solutions and their evaluations. A solution can then have multiple evaluations during its lifecycle - each is defined in the context of some population.


IPopulationFactory<TSol> is a factory and strategy interface for creating populations. It is parameterized just like the populations it creates.

Implementations should rely on ISolutionFactory<TSol> instances to create the actual solutions. However, different strategies may be implemented in order to assemble populations out of such solutions, effectively defining initial conditions of the evolutionary algorithm.




IPopulationMutation<TSol> defines a strategy for mutating a population.


IPopulationRecombination<TSol> defines a strategy for recombining a population.


ISolutionMutation<TSol> is the strategy that actually performs the mutation of a given solution.


ISolutionRecombination<TSol> is the strategy that actually performs the recombination of two given solutions.


IEvolution<TSol> is the basic interface for transforming populations.




IStopCondition defines when the generation should stop.


FixedStepsStopCondition is a basic implementation of IStopCondition interface. It stops the workplaces after a given number of steps, specified to the constructor.




IGeneticAlgorithm<TSol> defines an abstraction layer of genetic algorithm putting togeter all of the components like evolution operators or stop condition etc.


GeneticAlgorithm<TSol> provides a basic skeleton implementation of genetic algorithm


IGAWrapper provides a solution-type unaware wrapper interface for IGeneticAlgorithm


GAWrapper<TSol> provides a basic implementation of GA wrapper that prints every generation to standard output while proceeding.

Last edited Jan 8, 2013 at 4:21 PM by marochm, version 6


No comments yet.