SPEAII - Configuring and Running

From jecoliwiki
Jump to: navigation, search

The Stregth Pareto Evolutionary Algorithm 2



The main steps involved in the configuration are:

  • the evaluation function to use
  • the solution factory to create new solutions
  • the population size
  • the maximum size for the archive
  • the termination criteria of the algorithm (e.g. the number of iterations)
  • the selection operator
  • the environmental selection operator (for now only EnvironmentalSelection (by Zitzer) is implemented)
  • the reproduction operators (at least one crossover and one mutation)

An Example configuration (for the Fonseca problem)

* Creating the configuration object
SPEA2Configuration<ILinearRepresentation<Double>,RealValueRepresentationFactory> configuration = 
     new SPEA2Configuration<ILinearRepresentation<Double>,RealValueRepresentationFactory>();

/** Defining the statistics configuration - for automatic statistics handling */
configuration.setStatisticsConfiguration(new StatisticsConfiguration());
IRandomNumberGenerator randomNumberGenerator = new DefaultRandomNumberGenerator();
* The Evaluation Function - notice that true or false must be supplied
* as an argument for maximization or minimization respectively
IEvaluationFunction<ILinearRepresentation<Double>> evaluationFunction = 
      new FonsecaEvaluationFunction<ILinearRepresentation<Double>>(false); //minimization

* The size of the solutions to generate and the definition of the solution factory
int solutionSize = 3;
ISolutionFactory solutionFactory = new RealValueRepresentationFactory(solutionSize,-4.0,4.0,2); //notice the real values representation factory here

* Setting the population and maximum archive sizes
int populationSize = 500;
int maximumArchiveSize = 500;

* Defining the termination criteria - in this example, the number of iterations
int numberGenerations = 300;
ITerminationCriteria terminationCriteria = new IterationTerminationCriteria(numberGenerations);
* Setting the recombination parameters
* RecombinationParameters(num survivors, offspring size, elitism value, multiple offspring) 
RecombinationParameters recombinationParameters = new RecombinationParameters(0,populationSize,0,true);
* The selection operator
configuration.setSelectionOperator(new TournamentSelection(1,2));

* The environmental Selection operator - specific for the SPEA2 algorithm
configuration.setEnvironmentalSelectionOperator(new EnvironmentalSelection<ILinearRepresentation<Double>>());

* The reproduction operators - note that the probabilities for the operators in a container must sum 1
ReproductionOperatorContainer reproductionOperatorContainer = new ReproductionOperatorContainer();

/** the traditional uniform crossover - will always be used, since SPEA2 uses serial recombination (crossover+mutation)
reproductionOperatorContainer.addOperator(0.5,new UniformCrossover<Double>());

/** a random mutation - this is parameterised with the Representation used (Real values, in this case)
reproductionOperatorContainer.addOperator(0.5,new LinearGenomeRandomMutation<Double>(1));


Running the Algorithm

To run the algorithm it suffices to instantiate the algorithm with the correct configuration object as a parameter and then invoke the method run().

See the example bellow (relative to the above configuration example)

/** instantiation of the algorithm */
IAlgorithm<ILinearRepresentation<Double>> algorithm = 
    new SPEA2<ILinearRepresentation<Double>,RealValueRepresentationFactory>(configuration);

/** running the algorithm and getting the results */
IAlgorithmResult<ILinearRepresentation<Double>> result =  algorithm.run();
Personal tools