Package ec

# Class Evaluator

java.lang.Object
ec.Evaluator

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

Direct Known Subclasses:
  `CompetitiveEvaluator`, `MultiPopCoevolutionaryEvaluator`, `SimpleEvaluator`

public abstract class Evaluator extends Object implements Singleton
An Evaluator is a singleton object which is responsible for the evaluation process during the course of an evolutionary run. Only one Evaluator is created in a run, and is stored in the EvolutionState object.

Evaluators typically do their work by applying an instance of some subclass of Problem to individuals in the population. Evaluators come with a Problem prototype which they may clone as necessary to create new Problem spaces to evaluate individuals in (Problems may be reused to prevent constant cloning).

Evaluators may be multithreaded, with one Problem instance per thread usually. The number of threads they may spawn (excepting a parent "gathering" thread) is governed by the EvolutionState's evalthreads value.

Be careful about spawning threads -- this system has no few synchronized methods for efficiency's sake, so you must either divvy up evaluation in a thread-safe fashion, or otherwise you must obtain the appropriate locks on individuals in the population and other objects as necessary.

Parameters

base`.problem` classname, inherits and != ec.Problem | (the class for the Problem prototype p_problem)
base`.masterproblem` classname, inherits | (the class for the MasterProblem prototype masterproblem)

See Also:
  - Serialized Form

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `MasterProblem`
  `masterproblem`
  `static final String`
  `P_IAMSLAVE`
  `static final String`
  `P_MASTERPROBLEM`
  `Problem`
  `p_problem`
  `static final String`
  `P_PROBLEM`
  `String`
  `runComplete`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `Evaluator()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `closeContacts(EvolutionState state, int result)`
  Called to shut down remote evaluation network contacts when the run is completed.
  `abstract void`
  `evaluatePopulation(EvolutionState state)`
  Evaluates the fitness of an entire population.
  `void`
  `initializeContacts(EvolutionState state)`
  Called to set up remote evaluation network contacts when the run is started.
  `void`
  `postEvaluationGlobalUpdate(EvolutionState state)`
  Called to update some state by considering the current population.
  `void`
  `postEvaluationLocalUpdate(EvolutionState state, Individual ind, int subpop)`
  Called to update some state by considering a single Individual.
  `void`
  `reinitializeContacts(EvolutionState state)`
  Called to reinitialize remote evaluation network contacts when the run is restarted from checkpoint.
  `abstract 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`
  `setRunComplete(String message)`
  Requests that the Evaluator quit soon for a user-defined reason provided in the message.
  `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 java.lang.Object

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

- ## Field Details

  - ### P_PROBLEM

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

  - ### p_problem

    public Problem p_problem

  - ### masterproblem

    public MasterProblem masterproblem

  - ### P_MASTERPROBLEM

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

  - ### P_IAMSLAVE

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

  - ### runComplete

    public String runComplete

- ## Constructor Details

  - ### Evaluator

    public Evaluator()

- ## Method Details

  - ### evaluatePopulation

    public abstract void evaluatePopulation(EvolutionState state)
    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.

  - ### runComplete

    public abstract 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. Typically a message is stored in the String for the user to know why the system shut down.

  - ### setRunComplete

    public void setRunComplete(String message)
    Requests that the Evaluator quit soon for a user-defined reason provided in the message.

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

  - ### initializeContacts

    public void initializeContacts(EvolutionState state)
    Called to set up remote evaluation network contacts when the run is started. Mostly used for client/server evaluation (see MasterProblem). By default calls p_problem.initializeContacts(state)

  - ### reinitializeContacts

    public void reinitializeContacts(EvolutionState state)
    Called to reinitialize remote evaluation network contacts when the run is restarted from checkpoint. Mostly used for client/server evaluation (see MasterProblem). By default calls p_problem.reinitializeContacts(state)

  - ### closeContacts

    public void closeContacts(EvolutionState state, int result)
    Called to shut down remote evaluation network contacts when the run is completed. Mostly used for client/server evaluation (see MasterProblem). By default calls p_problem.closeContacts(state,result)

  - ### postEvaluationGlobalUpdate

    public void postEvaluationGlobalUpdate(EvolutionState state)
    Called to update some state by considering the current population. This is used by some algorithms to update additional state (stored the population's Species) beyond fitness values (ex. ACO's pheromone distributions). This method will typically just call a similar hook on a Species, where the actually state update occurs.

  - ### postEvaluationLocalUpdate

    public void postEvaluationLocalUpdate(EvolutionState state, Individual ind, int subpop)
    Called to update some state by considering a single Individual. This is used by some algorithms to update additional state (stored the population's Species) beyond fitness values (ex. ACO's pheromone distributions). This method will typically just call a similar hook on a Species, where the actually state update occurs.