Package ec.spatial

# Class Spatial1DSubpopulation

java.lang.Object
ec.Subpopulation
ec.spatial.Spatial1DSubpopulation

All Implemented Interfaces:
  `Setup`, `Space`, `Serializable`, `Cloneable`

public class Spatial1DSubpopulation extends Subpopulation implements Space
A Spatial1DSubpopulation is an EC subpopulation that is additionally embedded into a one-dimmensional space. In a spatially-embedded EA, the subpopulations of individuals are assumed to be spatially distributed in some sort of space, be it one-dimmensional, two- dimmensional, or whatever else. The space may or may not be toroidal (although it usually is). Each location in the space has a set of neighboring locations. Thus, each individual has an index in the subpopulation, and also a location in the space.

This public interface provides a method to obtain the indexes of the neighbors of a location.

This Subpopulation does not include toroidalness in writing out to streams.

Parameters

`toroidal` true (default) or false | (Is this space toroidal?)

See Also:
  - Serialized Form

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final String`
  `P_TOROIDAL`
  This parameter stipulates whether the world is toroidal or not.
  `boolean`
  `toroidal`

  ### Fields inherited from class ec.Subpopulation

  `extraBehavior, file, FILL, INDIVIDUAL_INDEX_PREAMBLE, individuals, initialSize, loadInds, NUM_INDIVIDUALS_PREAMBLE, numDuplicateRetries, P_EXTRA_BEHAVIOR, P_FILE, P_RETRIES, P_SPECIES, P_SUBPOPSIZE, P_SUBPOPULATION, species, TRUNCATE, V_FILL, V_TRUNCATE, V_WRAP, WRAP`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `Spatial1DSubpopulation()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `int`
  `getIndex(int threadnum)`
  Functionality: retrieve the index for a specific threanum.
  `int`
  `getIndexRandomNeighbor(EvolutionState state, int threadnum, int distance)`
  Returns a the index of a random neighbor.
  `void`
  `setIndex(int threadnum, int index)`
  Input: a threadnumber (either for evaluation or for breeding), and an index in a subpopulation (the index in the subpopulation is, of course, associated with a location in the space) Functionality: stores the index and the threadnumber for further accesses to the getIndexRandomNeighbor method.
  `void`
  `setup(EvolutionState state, Parameter base)`
  Read additional parameters for the spatially-embedded subpopulation.

  ### Methods inherited from class ec.Subpopulation

  `clear, defaultBase, emptyClone, populate, printSubpopulation, printSubpopulation, printSubpopulation, printSubpopulationForHumans, printSubpopulationForHumans, readSubpopulation, readSubpopulation, truncate, writeSubpopulation`

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

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

- ## Field Details

  - ### P_TOROIDAL

    public static final String P_TOROIDAL
    This parameter stipulates whether the world is toroidal or not. If missing, its default value is true.
    See Also:
      - Constant Field Values

  - ### toroidal

    public boolean toroidal

- ## Constructor Details

  - ### Spatial1DSubpopulation

    public Spatial1DSubpopulation()

- ## Method Details

  - ### setup

    public void setup(EvolutionState state, Parameter base)
    Read additional parameters for the spatially-embedded subpopulation.
    Specified by:
      `setup` in interface `Setup`
    Overrides:
      `setup` in class `Subpopulation`

  - ### setIndex

    public void setIndex(int threadnum, int index)
    Description copied from interface: `Space`
    Input: a threadnumber (either for evaluation or for breeding), and an index in a subpopulation (the index in the subpopulation is, of course, associated with a location in the space) Functionality: stores the index and the threadnumber for further accesses to the getIndexRandomNeighbor method. All such accesses from the specific thread will use the exact same index, until this function is called again to change the index.
    Specified by:
      `setIndex` in interface `Space`

  - ### getIndex

    public int getIndex(int threadnum)
    Description copied from interface: `Space`
    Functionality: retrieve the index for a specific threanum. Returns -1 if any error is encountered.
    Specified by:
      `getIndex` in interface `Space`

  - ### getIndexRandomNeighbor

    public int getIndexRandomNeighbor(EvolutionState state, int threadnum, int distance)
    Returns a the index of a random neighbor.
    Specified by:
      `getIndexRandomNeighbor` in interface `Space`