Package ec.eval

# Class Slave

java.lang.Object
ec.eval.Slave

public class Slave extends Object
Slave.java

Slave is the main entry point for a slave evaluation process. The slave works with a master process, receiving individuals from the master, evaluating them, and reporting the results back to the master, thus enabling distributed evolution.

Slave replicates most of the functionality of the ec.Evolve class, for example in terms of parameters and checkpointing. This is mostly because it needs to bootstrap and set up the EvolutionState in much the same way that ec.Evolve does. Additionally, depending on settings below, the Slave may act like a mini-evolver on the individuals it receives from the master.

Like ec.Evolve, Slave is run with like this:

`java ec.eval.Slave -file` parameter_file [`-p` parameter=value]*

This starts a new slave, using the parameter file parameter_file. The user can provide optional overriding parameters on the command-line with the `-p` option.

Slaves need to know some things in order to run: the master's IP address and socket port number, whether to do compression, and whether or not to return individuals or just fitnesses. Unfortunately, Sun's CompressedInputStream/CompressedOutputStream is broken (it doesn't allow partial flushes, which is critical for doing compressed network streams). In order to do compression, you need to download the JZLIB library from the ECJ website or from http://www.jcraft.com/jzlib/ . ECJ will detect and use it automatically.

Slaves presently always run in single-threaded mode and receive their random number generator seed from the master. Thus they ignore any seed parameters given to them.

Slaves run in one of three modes:

- "Regular" mode, which does a loop where it receives N individuals, evaluates them, and returns either the individuals or their new fitnesses.

- "Regular Coevolutionary" mode, which does a loop where it receives N individuals to assess together in a single coevolutionary evaluation, evaluates them, and returns either the individuals or their new fitnesses (or only some fitnesses if only some are requested).

- "Evolve" mode, which does a loop where it receives N individuals, evaluates them, and if there's some more time left, does a little evolution on those individuals as if they were a population, then when the time is up, the current individuals in the population are returned in lieu of the original individuals. In this second form, individuals MUST be returned, not fitnesses. This mode is not available if you're doing coevolution.

Parameters

`eval.slave-name` String | (the slave's name, only for debugging purposes. If not specified, the slave makes one up.)
`eval.master.host` String | (the IP Address of the master.)
`eval.master.port` integer >= 1024 | (the socket port number of the master.)
`eval.compression` bool = `true` or `false` (default) | (should we use compressed streams in communicating with the master?)
`eval.run-evolve` bool = `true` or `false` (default) | (should we immediately evaluate the individuals and return them (or their fitnesses), or if we have extra time (defined by eval.runtime), should we do a little evolution on our individuals first?)
`eval.runtime` integer > 0 | (if eval.run-evolve is true, how long (in milliseconds wall-clock time) should we allow the individuals to evolve?)
`eval.return-inds` bool = `true` or `false` (default) | (should we return whole individuals or (if false) just the fitnesses of the individuals? This must be TRUE if eval.run-evolve is true.)
`eval.one-shot` bool = `true` (default) or `false` | (Should the slave quit when the master quits, or loop continuously in the background processing new masters?)

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final String`
  `A_AT`
  The argument indicating the class where the resource is relative to.
  `static final String`
  `A_FILE`
  The argument indicating that we're starting fresh from a new parameter file.
  `static final String`
  `A_FROM`
  The argument indicating that we're starting fresh from a parameter file stored in a jar file or as some resource.
  `static boolean`
  `oneShot`
  `static final String`
  `P_EVALCOMPRESSION`
  `static final String`
  `P_EVALMASTERHOST`
  `static final String`
  `P_EVALMASTERPORT`
  `static final String`
  `P_EVALNODELAY`
  `static final String`
  `P_EVALRECVBUFFER`
  `static final String`
  `P_EVALSENDBUFER`
  `static final String`
  `P_EVALSLAVENAME`
  `static final String`
  `P_MUZZLE`
  `static final String`
  `P_ONESHOT`
  Should slave go into an infinite loop looking for new masters after the master has quit, or not?
  `static final String`
  `P_RETURNINDIVIDUALS`
  `static final String`
  `P_RUNEVOLVE`
  Should slave run its own evolutionary process?
  `static final String`
  `P_RUNTIME`
  Time to run evolution on the slaves in seconds
  `static final String`
  `P_SILENT`
  `static final ThreadPool`
  `pool`
  `static boolean`
  `runEvolve`
  `static int`
  `runTime`
  `static int`
  `slaveNum`
  My unique slave number.
  `static final int`
  `SLEEP_TIME`
  How long we sleep in between attempts to connect to the master (in milliseconds).
  `static final byte`
  `V_EVALUATEGROUPED`
  `static final byte`
  `V_EVALUATESIMPLE`
  `static final byte`
  `V_FITNESS`
  `static final byte`
  `V_INDIVIDUAL`
  `static final byte`
  `V_NOTHING`
  `static final byte`
  `V_SHUTDOWN`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `Slave()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static void`
  `evaluateGroupedProblemForm(EvolutionState state, boolean returnIndividuals, DataInputStream dataIn, DataOutputStream dataOut)`
  `static void`
  `evaluateSimpleProblemForm(EvolutionState state, boolean returnIndividuals, DataInputStream dataIn, DataOutputStream dataOut, String[] args)`
  `static void`
  `main(String[] args)`

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

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

- ## Field Details

  - ### P_EVALNODELAY

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

  - ### P_EVALSENDBUFER

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

  - ### P_EVALRECVBUFFER

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

  - ### P_EVALSLAVENAME

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

  - ### P_EVALMASTERHOST

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

  - ### P_EVALMASTERPORT

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

  - ### P_EVALCOMPRESSION

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

  - ### P_RETURNINDIVIDUALS

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

  - ### P_SILENT

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

  - ### P_MUZZLE

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

  - ### V_NOTHING

    public static final byte V_NOTHING
    See Also:
      - Constant Field Values

  - ### V_INDIVIDUAL

    public static final byte V_INDIVIDUAL
    See Also:
      - Constant Field Values

  - ### V_FITNESS

    public static final byte V_FITNESS
    See Also:
      - Constant Field Values

  - ### V_SHUTDOWN

    public static final byte V_SHUTDOWN
    See Also:
      - Constant Field Values

  - ### V_EVALUATESIMPLE

    public static final byte V_EVALUATESIMPLE
    See Also:
      - Constant Field Values

  - ### V_EVALUATEGROUPED

    public static final byte V_EVALUATEGROUPED
    See Also:
      - Constant Field Values

  - ### A_FROM

    public static final String A_FROM
    The argument indicating that we're starting fresh from a parameter file stored in a jar file or as some resource.
    See Also:
      - Constant Field Values

  - ### A_AT

    public static final String A_AT
    The argument indicating the class where the resource is relative to.
    See Also:
      - Constant Field Values

  - ### A_FILE

    public static final String A_FILE
    The argument indicating that we're starting fresh from a new parameter file.
    See Also:
      - Constant Field Values

  - ### P_RUNTIME

    public static final String P_RUNTIME
    Time to run evolution on the slaves in seconds
    See Also:
      - Constant Field Values

  - ### runTime

    public static int runTime

  - ### P_RUNEVOLVE

    public static final String P_RUNEVOLVE
    Should slave run its own evolutionary process?
    See Also:
      - Constant Field Values

  - ### runEvolve

    public static boolean runEvolve

  - ### P_ONESHOT

    public static final String P_ONESHOT
    Should slave go into an infinite loop looking for new masters after the master has quit, or not?
    See Also:
      - Constant Field Values

  - ### oneShot

    public static boolean oneShot

  - ### SLEEP_TIME

    public static final int SLEEP_TIME
    How long we sleep in between attempts to connect to the master (in milliseconds).
    See Also:
      - Constant Field Values

  - ### pool

    public static final ThreadPool pool

  - ### slaveNum

    public static int slaveNum
    My unique slave number. At present this is just used to define a unique name.

- ## Constructor Details

  - ### Slave

    public Slave()

- ## Method Details

  - ### main

    public static void main(String[] args)

  - ### evaluateSimpleProblemForm

    public static void evaluateSimpleProblemForm(EvolutionState state, boolean returnIndividuals, DataInputStream dataIn, DataOutputStream dataOut, String[] args)

  - ### evaluateGroupedProblemForm

    public static void evaluateGroupedProblemForm(EvolutionState state, boolean returnIndividuals, DataInputStream dataIn, DataOutputStream dataOut)