Package ec.coevolve

# Class MultiPopCoevolutionaryEvaluator

java.lang.Object
ec.Evaluator
ec.coevolve.MultiPopCoevolutionaryEvaluator

All Implemented Interfaces:
  `Setup`, `Singleton`, `Serializable`

Direct Known Subclasses:
  `SpatialMultiPopCoevolutionaryEvaluator`

public class MultiPopCoevolutionaryEvaluator extends Evaluator
MultiPopCoevolutionaryEvaluator.java

MultiPopCoevolutionaryEvaluator is an Evaluator which performs competitive or cooperative multi-population coevolution. Competitive coevolution is where individuals' fitness is determined by testing them against individuals from other subpopulation. Cooperative coevolution is where individuals form teams together with members of other subpopulations, and the individuals' fitness is computed based on the performance of such teams. This evaluator assumes that the problem can only evaluate groups of individuals containing one individual from each subpopulation. Individuals are evaluated regardless of whether or not they've been evaluated in the past.

Your Problem is responsible for updating up the fitness appropriately with values usually obtained from teaming up the individual with different partners from the other subpopulations. MultiPopCoevolutionaryEvaluator expects to use Problems which adhere to the GroupedProblemForm interface, which defines a new evaluate(...) function, plus a preprocess(...) and postprocess(...) function.

This coevolutionary evaluator is single-threaded -- maybe we'll hack in multithreading later. It allows any number of subpopulations (implicitly, any number of individuals being evaluated together). The order of individuals in the subpopulation may be changed during the evaluation process.

Ordinarily MultiPopCoevolutionaryEvaluator does "parallel" coevolution: all subpopulations are evaluated simultaneously, then bred simultaneously. But if you set the "sequential" parameter in the class ec.simple.SimpleBreeder, then MultiPopCoevolutionary behaves in a sequential fashion common in the "classic" version of cooperative coevolution: only one subpopulation is evaluated and bred per generation. The subpopulation index to breed is determined by taking the generation number, modulo the total number of subpopulations.

Parameters

breed.sequential boolean (default = false) | (should we evaluate and breed a single subpopulation each generation? Note that this is a SimpleBreeder parameter. )
base.`subpop.num-current` int >= 0 | (the number of random individuals from any given subpopulation fropm the current population to be selected as collaborators)
base.`subpop.num-gurus` int >= 0 | (the number of guru individuals from any given subpopulation from the previous population to be selected as collaborators. For generation 0, random individuals from the current population will be used. )
base.`subpop.num-prev` int >= 0 | (the number of random individuals from any given subpopulation from the previous population to be selected as collaborators. For generation 0, random individuals from the current population will be used)
base.`subpop.X.select-prev` instance of ec.SelectionMethod | (the SelectionMethod used to select partners from the individuals in subpopulation X at the previous generation)
base.`subpop.X.select-current` instance of ec.SelectionMethod | (the SelectionMethod used to select partners from the individuals in subpopulation X at the current generation. WARNING. This SelectionMethod must not select based on fitness, since fitness hasn't been set yet. RandomSelection is a good choice. )
base.`shuffling` boolean (default = false) | (instead of selecting individuals from )

See Also:
  - Serialized Form

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `protected int`
  `numCurrent`
  `protected int`
  `numGuru`
  `protected int`
  `numPrev`
  `protected int`
  `numShuffled`
  `static final String`
  `P_NUM_GURU`
  `static final String`
  `P_NUM_IND`
  `static final String`
  `P_NUM_RAND_IND`
  `static final String`
  `P_NUM_SHUFFLED`
  `static final String`
  `P_SELECTION_METHOD_CURRENT`
  `static final String`
  `P_SELECTION_METHOD_PREV`
  `static final String`
  `P_SUBPOP`

  ### Fields inherited from class ec.Evaluator

  `masterproblem, P_IAMSLAVE, P_MASTERPROBLEM, p_problem, P_PROBLEM, runComplete`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `MultiPopCoevolutionaryEvaluator()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `protected void`
  `afterCoevolutionaryEvaluation(EvolutionState state, GroupedProblemForm prob)`
  `protected void`
  `beforeCoevolutionaryEvaluation(EvolutionState state, Population population, GroupedProblemForm prob)`
  `void`
  `evaluatePopulation(EvolutionState state)`
  Evaluates the fitness of an entire population.
  `void`
  `performCoevolutionaryEvaluation(EvolutionState state, Population population, GroupedProblemForm prob)`
  `protected Individual`
  `produceCurrent(int subpopulation, EvolutionState state, int thread)`
  Selects one individual from the given subpopulation.
  `protected Individual`
  `producePrevious(int subpopulation, EvolutionState state, int thread)`
  Selects one individual from the previous subpopulation.
  `String`
  `runComplete(EvolutionState state)`
  Returns non-NULL if the Evaluator believes that the run is finished: perhaps an ideal individual has been found or some other run result has shortcircuited the run so that it should end prematurely right now.
  `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.
  `boolean`
  `shouldEvaluateSubpop(EvolutionState state, int subpop, int threadnum)`
  Returns true if the subpopulation should be evaluated.
  `protected void`
  `shuffle(EvolutionState state, int[] a)`

  ### Methods inherited from class ec.Evaluator

  `closeContacts, initializeContacts, postEvaluationGlobalUpdate, postEvaluationLocalUpdate, reinitializeContacts, setRunComplete`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Field Details

  - ### P_SUBPOP

    public static final String P_SUBPOP
    See Also:
      - Constant Field Values

  - ### P_NUM_RAND_IND

    public static final String P_NUM_RAND_IND
    See Also:
      - Constant Field Values

  - ### numCurrent

    protected int numCurrent

  - ### P_NUM_SHUFFLED

    public static final String P_NUM_SHUFFLED
    See Also:
      - Constant Field Values

  - ### numShuffled

    protected int numShuffled

  - ### P_NUM_GURU

    public static final String P_NUM_GURU
    See Also:
      - Constant Field Values

  - ### numGuru

    protected int numGuru

  - ### P_NUM_IND

    public static final String P_NUM_IND
    See Also:
      - Constant Field Values

  - ### numPrev

    protected int numPrev

  - ### P_SELECTION_METHOD_PREV

    public static final String P_SELECTION_METHOD_PREV
    See Also:
      - Constant Field Values

  - ### P_SELECTION_METHOD_CURRENT

    public static final String P_SELECTION_METHOD_CURRENT
    See Also:
      - Constant Field Values

- ## Constructor Details

  - ### MultiPopCoevolutionaryEvaluator

    public MultiPopCoevolutionaryEvaluator()

- ## Method Details

  - ### 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 `Evaluator`

  - ### runComplete

    public String runComplete(EvolutionState state)
    Description copied from class: `Evaluator`
    Returns non-NULL if the Evaluator believes that the run is finished: perhaps an ideal individual has been found or some other run result has shortcircuited the run so that it should end prematurely right now. Typically a message is stored in the String for the user to know why the system shut down.
    Specified by:
      `runComplete` in class `Evaluator`

  - ### shouldEvaluateSubpop

    public boolean shouldEvaluateSubpop(EvolutionState state, int subpop, int threadnum)
    Returns true if the subpopulation should be evaluated. This will happen if the Breeder believes that the subpopulation should be breed afterwards.

  - ### evaluatePopulation

    public void evaluatePopulation(EvolutionState state)
    Description copied from class: `Evaluator`
    Evaluates the fitness of an entire population. You will have to determine how to handle multiple threads on your own, as this is a very domain-specific thing.
    Specified by:
      `evaluatePopulation` in class `Evaluator`

  - ### beforeCoevolutionaryEvaluation

    protected void beforeCoevolutionaryEvaluation(EvolutionState state, Population population, GroupedProblemForm prob)

  - ### shuffle

    protected void shuffle(EvolutionState state, int[] a)

  - ### performCoevolutionaryEvaluation

    public void performCoevolutionaryEvaluation(EvolutionState state, Population population, GroupedProblemForm prob)

  - ### producePrevious

    protected Individual producePrevious(int subpopulation, EvolutionState state, int thread)
    Selects one individual from the previous subpopulation. If there is no previous population, because we're at generation 0, then an individual from the current population is selected at random.

  - ### produceCurrent

    protected Individual produceCurrent(int subpopulation, EvolutionState state, int thread)
    Selects one individual from the given subpopulation.

  - ### afterCoevolutionaryEvaluation

    protected void afterCoevolutionaryEvaluation(EvolutionState state, GroupedProblemForm prob)