ec.multiobjective.spea2
Class SPEA2Breeder

java.lang.Object
  extended by ec.Breeder
      extended by ec.simple.SimpleBreeder
          extended by ec.multiobjective.spea2.SPEA2Breeder
All Implemented Interfaces:
Setup, Singleton, java.io.Serializable

public class SPEA2Breeder
extends SimpleBreeder

Breeds each subpopulation separately, with no inter-population exchange, and using the SPEA2 approach. A SPEA2Breeder may have multiple threads; it divvys up a subpopulation into chunks and hands one chunk to each thread to populate. One array of BreedingPipelines is obtained from a population's Species for each operating breeding thread. Prior to breeding a subpopulation, a SPEA2Breeder will first fill part of the new subpopulation (the archive) with the individuals with an SPEA2 fitness of less than 1.0 from the old subpopulation. If there are less individuals with this cutoff than can fit in the archive the free slots are filled with the lowest scoring SPEA2fitness individuals. If there are more individuals with an SPEA2Fitness less than 1 than can fit in the archive then a density metric is used to truncate the archive and remove individuals which are close to others. The archive filling step is performed by a single thread.

This is actually a re-write of SPEA2Breeder.java by Robert Hubley, to make it more modular so it's easier for me to extend it. Namely:

  1. I isolated the following functionality: "Out of N individuals, give me a front of size M < N." I need this at the last generation, when one createad a bunch of individuals, evaluated them, but not give them a chance to enter the archive, as the breeder is not called on the last generation!
  2. Additonally, I made double[][] distances and int[][] sortedIndex static and then reused them to reduce GC!!! For more advanced cases where the the number of individuals is not fixed and/or known in advance I chose to have these arrays extended when needed.
  3. Lastly, I do fewer iterations in the loop that compacts surviving individuals and copies them in the new population (i.e. previous version was visiting a bunch of nulls at the end of the array).

See Also:
Serialized Form

Field Summary
 
Fields inherited from class ec.simple.SimpleBreeder
elite, P_ELITE
 
Constructor Summary
SPEA2Breeder()
           
 
Method Summary
 int computeSubpopulationLength(EvolutionState state, int subpopulation)
          Elites are often stored in the top part of the subpopulation; this function returns what part of the subpopulation contains individuals to replace with newly-bred ones (up to but not including the elites).
static void loadElites(EvolutionState state, Individual[] oldInds, Individual[] newInds, int archiveSize)
           
 void loadElites(EvolutionState state, Population newpop)
          A private helper function for breedPopulation which loads elites into a subpopulation.
 void setup(EvolutionState state, Parameter base)
          Sets up the object by reading it from the parameters stored in state, built off of the parameter base base.
 
Methods inherited from class ec.simple.SimpleBreeder
breedPopChunk, breedPopulation
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SPEA2Breeder

public SPEA2Breeder()
Method Detail

setup

public void setup(EvolutionState state,
                  Parameter base)
Description copied from interface: Setup
Sets up the object by reading it from the parameters stored in state, built off of the parameter base base. If an ancestor implements this method, be sure to call super.setup(state,base); before you do anything else.

Specified by:
setup in interface Setup
Overrides:
setup in class SimpleBreeder

computeSubpopulationLength

public int computeSubpopulationLength(EvolutionState state,
                                      int subpopulation)
Description copied from class: SimpleBreeder
Elites are often stored in the top part of the subpopulation; this function returns what part of the subpopulation contains individuals to replace with newly-bred ones (up to but not including the elites).

Overrides:
computeSubpopulationLength in class SimpleBreeder

loadElites

public void loadElites(EvolutionState state,
                       Population newpop)
Description copied from class: SimpleBreeder
A private helper function for breedPopulation which loads elites into a subpopulation.

Overrides:
loadElites in class SimpleBreeder

loadElites

public static void loadElites(EvolutionState state,
                              Individual[] oldInds,
                              Individual[] newInds,
                              int archiveSize)