Package ec.vector

# Class FloatVectorSpecies

java.lang.Object
ec.Species
ec.vector.VectorSpecies
ec.vector.FloatVectorSpecies

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

Direct Known Subclasses:
  `AMALGAMSpecies`, `CMAESSpecies`

public class FloatVectorSpecies extends VectorSpecies
FloatVectorSpecies is a subclass of VectorSpecies with special constraints for floating-point vectors, namely FloatVectorIndividual and DoubleVectorIndividual.

FloatVectorSpecies can specify a number of parameters globally, per-segment, and per-gene. See VectorSpecies for information on how to this works.

FloatVectorSpecies defines a minimum and maximum gene value. These values are used during initialization and, depending on whether `mutation-bounded` is true, also during various mutation algorithms to guarantee that the gene value will not exceed these minimum and maximum bounds.

FloatVectorSpecies provides support for five ways of mutating a gene.

- reset Replacing the gene's value with a value uniformly drawn from the gene's range (the default behavior).
- gaussPerturbing the gene's value with gaussian noise; if the gene-by-gene range is used, than the standard deviation is scaled to reflect each gene's range. If the gaussian mutation's standard deviation is too large for the range, than there's a large probability the mutated value will land outside range. We will try again a number of times (100) before giving up and using the previous mutation method.
- polynomial Perturbing the gene's value with noise chosen from a polynomial distribution, similar to the gaussian distribution. The polynomial distribution was popularized by Kalyanmoy Deb and is found in many of his publications (see http://www.iitk.ac.in/kangal/deb.shtml). The polynomial distribution has two options. First, there is the index. This variable defines the shape of the distribution and is in some sense the equivalent of the standard deviation in the gaussian distribution. The index is an integer. If it is zero, the polynomial distribution is simply the uniform distribution from [1,-1]. If it is 1, the polynomial distribution is basically a triangular distribution from [1,-1] peaking at 0. If it is 2, the polynomial distribution follows a squared function, again peaking at 0. Larger values result in even more peaking and narrowness. The default values used in nearly all of the NSGA-II and Deb work is 20. Second, there is whether or not the value is intended for bounded genes. The default polynomial distribution is used when we assume the gene can take on literally any value, even beyond the min and max values. For genes which are restricted to be between min and max, there is an alternative version of the polynomial distribution, used by Deb's team but not discussed much in the literature, desiged for that situation. We assume boundedness by default, and have found it to be somewhat better for NSGA-II and SPEA2 problems. For a description of this alternative version, see "A Niched-Penalty Approach for Constraint Handling in Genetic Algorithms" by Kalyanmoy Deb and Samir Agrawal. Deb's default implementation bounds the result to min or max; instead ECJ's implementation of the polynomial distribution retries until it finds a legal value. This will be just fine for ranges like [0,1], but for smaller ranges you may be waiting a long time.
- integer-reset Replacing the gene's value with a value uniformly drawn from the gene's range but restricted to only integers.
- integer-random-walk Replacing the gene's value by performing a random walk starting at the gene value. The random walk either adds 1 or subtracts 1 (chosen at random), then does a coin-flip to see whether to continue the random walk. When the coin-flip finally comes up false, the gene value is set to the current random walk position.

FloatVectorSpecies provides support for two ways of initializing a gene. The initialization procedure is determined by the choice of mutation procedure as described above. If the mutation is floating-point (`reset, gauss, polynomial`), then initialization will be done by resetting the gene to uniformly chosen floating-point value between the minimum and maximum legal gene values, inclusive. If the mutation is integer (`integer-reset, integer-random-walk`), then initialization will be done by performing the same kind of reset, but restricting values to integers only.

Parameters

base.`min-gene` or
base.`segment`.segment-number.`min-gene` or
base.`min-gene`.gene-number 0.0 <= double <= 1.0 | (probability that a gene will get mutated over default mutation)
double (default=0.0) | (the minimum gene value)
base.`max-gene` or
base.`segment`.segment-number.`max-gene` or
base.`max-gene`.gene-number 0.0 <= double <= 1.0 | (probability that a gene will get mutated over default mutation)
double >= base.min-gene | (the maximum gene value)
base.`mutation-type` or
base.`segment`.segment-number.`mutation-type` or
base.`mutation-prob`.gene-number `reset`, `gauss`, `polynomial`, `integer-reset`, or `integer-random-walk` (default=`reset`) | (the mutation type)
base.`mutation-stdev` or
base.`segment`.segment-number.`mutation-stdev` or
base.`mutation-stdev`.gene-number double ≥ 0 | (the standard deviation or the gauss perturbation)
base.`distribution-index` or
base.`segment`.segment-number.`distribution-index` or
base.`distribution-index`.gene-number int ≥ 0 | (the mutation distribution index for the polynomial mutation distribution)
base.`alternative-polynomial-version` or
base.`segment`.segment-number.`alternative-polynomial-version` or
base.`alternative-polynomial-version`.gene-number boolean (default=true) | (whether to use the "bounded" variation of the polynomial mutation or the standard ("unbounded") version)
base.`random-walk-probability` or
base.`segment`.segment-number.`random-walk-probability` or
base.`random-walk-probability`.gene-number 0.0 <= double <= 1.0 | (the probability that a random walk will continue. Random walks go up or down by 1.0 until the coin flip comes up false.)
base.`mutation-bounded` or
base.`segment`.segment-number.`mutation-bounded` or
base.`mutation-bounded`.gene-number boolean (default=true) | (whether mutation is restricted to only being within the min/max gene values. Does not apply to SimulatedBinaryCrossover (which is always bounded))
| base.`out-of-bounds-retries` int ≥ 0 (default=100) | (number of times the gaussian mutation got the gene out of range before we give up and reset the gene's value; 0 means "never give up")

See Also:
  - Serialized Form

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final int`
  `C_GAUSS_MUTATION`
  `static final int`
  `C_INTEGER_RANDOM_WALK_MUTATION`
  `static final int`
  `C_INTEGER_RESET_MUTATION`
  `static final int`
  `C_POLYNOMIAL_MUTATION`
  `static final int`
  `C_RESET_MUTATION`
  `static final int`
  `DEFAULT_OUT_OF_BOUNDS_RETRIES`
  `protected double[]`
  `gaussMutationStdev`
  Standard deviation for Gaussian Mutation, per gene.
  `protected double[]`
  `maxGene`
  Max-gene value, per gene.
  `protected double[]`
  `minGene`
  Min-gene value, per gene.
  `protected int[]`
  `mutationDistributionIndex`
  The distribution index for Polynomial Mutation, per gene.
  `protected boolean[]`
  `mutationIsBounded`
  Whether mutation is bounded to the min- and max-gene values, per gene.
  `protected int[]`
  `mutationType`
  Mutation type, per gene.
  `int`
  `outOfBoundsRetries`
  The number of times Polynomial Mutation or Gaussian Mutation retry for valid numbers until they get one.
  `static final String`
  `P_MAXGENE`
  `static final String`
  `P_MINGENE`
  `static final String`
  `P_MUTATION_BOUNDED`
  `static final String`
  `P_MUTATION_DISTRIBUTION_INDEX`
  `static final String`
  `P_MUTATIONTYPE`
  `static final String`
  `P_OUTOFBOUNDS_RETRIES`
  `static final String`
  `P_POLYNOMIAL_ALTERNATIVE`
  `static final String`
  `P_RANDOM_WALK_PROBABILITY`
  `static final String`
  `P_STDEV`
  `protected boolean[]`
  `polynomialIsAlternative`
  Whether the Polynomial Mutation method is the "alternative" method, per gene.
  `protected double[]`
  `randomWalkProbability`
  The continuation probability for Integer Random Walk Mutation, per gene.
  `static final String`
  `V_GAUSS_MUTATION`
  `static final String`
  `V_INTEGER_RANDOM_WALK_MUTATION`
  `static final String`
  `V_INTEGER_RESET_MUTATION`
  `static final String`
  `V_POLYNOMIAL_MUTATION`
  `static final String`
  `V_RESET_MUTATION`

  ### Fields inherited from class ec.vector.VectorSpecies

  `C_ANY_POINT, C_GEOMETRIC, C_INTERMED_RECOMB, C_LINE_RECOMB, C_NONE, C_ONE_POINT, C_ONE_POINT_NO_NOP, C_SIMULATED_BINARY, C_TWO_POINT, C_TWO_POINT_NO_NOP, C_UNIFORM, chunksize, crossoverDistributionIndex, crossoverProbability, crossoverType, duplicateRetries, dynamicInitialSize, genomeIncreaseProbability, genomeResizeAlgorithm, genomeSize, lineDistance, maxInitialSize, minInitialSize, mutationProbability, P_CHUNKSIZE, P_CROSSOVER_DISTRIBUTION_INDEX, P_CROSSOVERPROB, P_CROSSOVERTYPE, P_DUPLICATE_RETRIES, P_GENOMESIZE, P_GEOMETRIC_PROBABILITY, P_LINEDISTANCE, P_MUTATIONPROB, P_NUM_SEGMENTS, P_SEGMENT, P_SEGMENT_END, P_SEGMENT_START, P_SEGMENT_TYPE, P_UNIFORM_MAX, P_UNIFORM_MIN, P_VECTORSPECIES, V_ANY_POINT, V_GEOMETRIC, V_INTERMED_RECOMB, V_LINE_RECOMB, V_ONE_POINT, V_ONE_POINT_NO_NOP, V_SIMULATED_BINARY, V_TWO_POINT, V_TWO_POINT_NO_NOP, V_UNIFORM`

  ### Fields inherited from class ec.Species

  `f_prototype, i_prototype, P_FITNESS, P_INDIVIDUAL, P_PIPE, pipe_prototype`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `FloatVectorSpecies()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `double`
  `gaussMutationStdev(int gene)`
  `boolean`
  `inNumericalTypeRange(double geneVal)`
  `protected void`
  `loadParametersForGene(EvolutionState state, int index, Parameter base, Parameter def, String postfix)`
  Called when VectorSpecies is setting up per-gene and per-segment parameters.
  `double`
  `maxGene(int gene)`
  `double`
  `minGene(int gene)`
  `int`
  `mutationDistributionIndex(int gene)`
  `boolean`
  `mutationIsBounded(int gene)`
  `int`
  `mutationType(int gene)`
  `void`
  `outOfRangeRetryLimitReached(EvolutionState state)`
  `boolean`
  `polynomialIsAlternative(int gene)`
  `double`
  `randomWalkProbability(int gene)`
  `void`
  `setup(EvolutionState state, Parameter base)`
  The default version of setup(...) loads requested pipelines and calls setup(...) on them and normalizes their probabilities.

  ### Methods inherited from class ec.vector.VectorSpecies

  `contains, contains, contains, contains, defaultBase, duplicateRetries, fill, fill, fill, fill, initializeGenomeSegmentsByEndIndices, initializeGenomeSegmentsByStartIndices, mutationProbability, newIndividual, setupGenome`

  ### Methods inherited from class ec.Species

  `buildMisc, clone, newIndividual, newIndividual, updateIndividual, updateSubpopulation`

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

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

- ## Field Details

  - ### P_MINGENE

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

  - ### P_MAXGENE

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

  - ### P_MUTATIONTYPE

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

  - ### P_STDEV

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

  - ### P_MUTATION_DISTRIBUTION_INDEX

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

  - ### P_POLYNOMIAL_ALTERNATIVE

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

  - ### V_RESET_MUTATION

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

  - ### V_GAUSS_MUTATION

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

  - ### V_POLYNOMIAL_MUTATION

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

  - ### V_INTEGER_RANDOM_WALK_MUTATION

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

  - ### V_INTEGER_RESET_MUTATION

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

  - ### P_RANDOM_WALK_PROBABILITY

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

  - ### P_OUTOFBOUNDS_RETRIES

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

  - ### P_MUTATION_BOUNDED

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

  - ### C_RESET_MUTATION

    public static final int C_RESET_MUTATION
    See Also:
      - Constant Field Values

  - ### C_GAUSS_MUTATION

    public static final int C_GAUSS_MUTATION
    See Also:
      - Constant Field Values

  - ### C_POLYNOMIAL_MUTATION

    public static final int C_POLYNOMIAL_MUTATION
    See Also:
      - Constant Field Values

  - ### C_INTEGER_RESET_MUTATION

    public static final int C_INTEGER_RESET_MUTATION
    See Also:
      - Constant Field Values

  - ### C_INTEGER_RANDOM_WALK_MUTATION

    public static final int C_INTEGER_RANDOM_WALK_MUTATION
    See Also:
      - Constant Field Values

  - ### minGene

    protected double[] minGene
    Min-gene value, per gene. This array is one longer than the standard genome length. The top element in the array represents the parameters for genes in genomes which have extended beyond the genome length.

  - ### maxGene

    protected double[] maxGene
    Max-gene value, per gene. This array is one longer than the standard genome length. The top element in the array represents the parameters for genes in genomes which have extended beyond the genome length.

  - ### mutationType

    protected int[] mutationType
    Mutation type, per gene. This array is one longer than the standard genome length. The top element in the array represents the parameters for genes in genomes which have extended beyond the genome length.

  - ### gaussMutationStdev

    protected double[] gaussMutationStdev
    Standard deviation for Gaussian Mutation, per gene. This array is one longer than the standard genome length. The top element in the array represents the parameters for genes in genomes which have extended beyond the genome length.

  - ### mutationIsBounded

    protected boolean[] mutationIsBounded
    Whether mutation is bounded to the min- and max-gene values, per gene. This array is one longer than the standard genome length. The top element in the array represents the parameters for genes in genomes which have extended beyond the genome length.

  - ### mutationDistributionIndex

    protected int[] mutationDistributionIndex
    The distribution index for Polynomial Mutation, per gene. This array is one longer than the standard genome length. The top element in the array represents the parameters for genes in genomes which have extended beyond the genome length.

  - ### polynomialIsAlternative

    protected boolean[] polynomialIsAlternative
    Whether the Polynomial Mutation method is the "alternative" method, per gene. This array is one longer than the standard genome length. The top element in the array represents the parameters for genes in genomes which have extended beyond the genome length.

  - ### randomWalkProbability

    protected double[] randomWalkProbability
    The continuation probability for Integer Random Walk Mutation, per gene. This array is one longer than the standard genome length. The top element in the array represents the parameters for genes in genomes which have extended beyond the genome length.

  - ### outOfBoundsRetries

    public int outOfBoundsRetries
    The number of times Polynomial Mutation or Gaussian Mutation retry for valid numbers until they get one.

  - ### DEFAULT_OUT_OF_BOUNDS_RETRIES

    public static final int DEFAULT_OUT_OF_BOUNDS_RETRIES
    See Also:
      - Constant Field Values

- ## Constructor Details

  - ### FloatVectorSpecies

    public FloatVectorSpecies()

- ## Method Details

  - ### outOfRangeRetryLimitReached

    public void outOfRangeRetryLimitReached(EvolutionState state)

  - ### maxGene

    public double maxGene(int gene)

  - ### minGene

    public double minGene(int gene)

  - ### mutationType

    public int mutationType(int gene)

  - ### gaussMutationStdev

    public double gaussMutationStdev(int gene)

  - ### mutationIsBounded

    public boolean mutationIsBounded(int gene)

  - ### mutationDistributionIndex

    public int mutationDistributionIndex(int gene)

  - ### polynomialIsAlternative

    public boolean polynomialIsAlternative(int gene)

  - ### randomWalkProbability

    public double randomWalkProbability(int gene)

  - ### inNumericalTypeRange

    public boolean inNumericalTypeRange(double geneVal)

  - ### setup

    public void setup(EvolutionState state, Parameter base)
    Description copied from class: `Species`
    The default version of setup(...) loads requested pipelines and calls setup(...) on them and normalizes their probabilities. If your individual prototype might need to know special things about the species (like parameters stored in it), then when you override this setup method, you'll need to set those parameters BEFORE you call super.setup(...), because the setup(...) code in Species sets up the prototype.
    Specified by:
      `setup` in interface `Prototype`
    Specified by:
      `setup` in interface `Setup`
    Overrides:
      `setup` in class `VectorSpecies`
    See Also:
      - `Prototype.setup(EvolutionState,Parameter)`

  - ### loadParametersForGene

    protected void loadParametersForGene(EvolutionState state, int index, Parameter base, Parameter def, String postfix)
    Description copied from class: `VectorSpecies`
    Called when VectorSpecies is setting up per-gene and per-segment parameters. The index is the current gene whose parameter is getting set up. The Parameters in question are the bases for the gene. The postfix should be appended to the end of any parameter looked up (it often contains a number indicating the gene in question), such as state.parameters.exists(base.push(P_PARAM).push(postfix), def.push(P_PARAM).push(postfix)

    If you override this method, be sure to call super(...) at some point, ideally first.

    Overrides:
      `loadParametersForGene` in class `VectorSpecies`