coreEngine.Calibration

## Class GeneticAlgorithm

- java.lang.Object
- - coreEngine.Calibration.Algorithm
  - - coreEngine.Calibration.Metaheuristic
    - - coreEngine.Calibration.GeneticAlgorithm

- Direct Known Subclasses:
    SimpleGA

      public abstract class GeneticAlgorithm
      extends Metaheuristic

  Author:
    jltrask

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `AlgHelper` | `algHelper`
    `protected java.lang.String` | `algSubtype`
    `protected int` | `binStringLength`
    `protected CrossoverHelper` | `crossover` Crossover Strategy Field
    `static int` | `CROSSOVER_TYPE_BLOCK_UNIFORM`
    `static int` | `CROSSOVER_TYPE_ONEPOINT`
    `static int` | `CROSSOVER_TYPE_TWOPOINT`
    `static int` | `CROSSOVER_TYPE_UNIFORM`
    `static java.lang.String[]` | `CrossoverTypeList`
    `static int` | `DEFAULT_CROSSOVER_TYPE`
    `static int` | `DEFAULT_ELITISIM_TYPE`
    `static float` | `DEFAULT_ELITISM_PERCENT`
    `static int` | `DEFAULT_MUTATION_NUMBER`
    `static float` | `DEFAULT_MUTATION_PERCENT`
    `static int` | `DEFAULT_MUTATION_TYPE`
    `static int` | `DEFAULT_POP_SIZE`
    `static float` | `DEFAULT_PRESERVE_PERCENT`
    `static int` | `DEFAULT_PRESERVE_TYPE`
    `static int` | `DEFAULT_SELECTION_TYPE`
    `protected ElitismHelper` | `elitism` ElitismHelper Strategy Field
    `static int` | `ELITISM_TYPE_NONE`
    `static int` | `ELITISM_TYPE_PERCENTAGE`
    `static java.lang.String[]` | `ElitismTypeList`
    `protected int` | `genSinceImprovement`
    `float` | `lambda1`
    `float` | `lambda2`
    `float` | `MUTATION_PERCENT`
    `static int` | `MUTATION_TYPE_BOUNDARY`
    `static int` | `MUTATION_TYPE_GUASSIAN`
    `static int` | `MUTATION_TYPE_NONUNIFORM`
    `static int` | `MUTATION_TYPE_PG`
    `static int` | `MUTATION_TYPE_PU`
    `static int` | `MUTATION_TYPE_SG`
    `static int` | `MUTATION_TYPE_SMOOTH`
    `static int` | `MUTATION_TYPE_SU`
    `static int` | `MUTATION_TYPE_UNIFORM`
    `static java.lang.String[]` | `MutationTypeList`
    `protected Mutation` | `mutator` Mutation Strategy Field
    `protected static int` | `nameIndex`
    `int` | `objectiveType`
    `protected int` | `popSize` Integer size of the population
    `protected Population` | `population` Population instance of organisms for the algorithm
    `static int` | `PRESERVE_TYPE_NONE`
    `static int` | `PRESERVE_TYPE_PCT_RAND`
    `protected float` | `preservePct` Percent of each generation to be randomly preserved and moved to next generation
    `protected PreserveHelper` | `preserver` PreserveHelper Strategy Field
    `static java.lang.String[]` | `PreserveTypeList`
    `SearchSpace` | `searchSpace`
    `static int` | `SELECTION_TYPE_EP`
    `static int` | `SELECTION_TYPE_RANDOM`
    `static int` | `SELECTION_TYPE_ROULETTE`
    `static int` | `SELECTION_TYPE_TOURNAMENT`
    `static java.lang.String[]` | `SelectionTypeList`
    `protected SelectionHelper` | `selector` Selection Strategy Field
    `static java.lang.String` | `TYPE_SGA`
    `float` | `w1`
    `float` | `w2`
    `float` | `w3`

    - ### Fields inherited from class coreEngine.Calibration.Metaheuristic

      `MODEL_TYPES, numBestSolutionsSaved, rng, type, TYPE_CAPACITY, TYPE_CAPACITY_FULL, TYPE_DEMAND_HYBRID, TYPE_DEMAND_HYBRID_CDP, TYPE_NDIST_DEMAND, TYPE_NDIST_DEMAND_CDP, TYPE_PROFILE_BASED, TYPE_PROFILE_BASED_CDP`

    - ### Fields inherited from class coreEngine.Calibration.Algorithm

      `DEFAULT_AF_RANGE, DEFAULT_AF_STEP, DEFAULT_CDP_MIN, DEFAULT_CDP_RANGE, DEFAULT_CDP_STEP, DEFAULT_JD_MIN, DEFAULT_JD_RANGE, DEFAULT_JD_STEP, DEFAULT_MAX_ITERATIONS, DEFUALT_AF_MIN, isAdaptive, isMemetic, MAX_ITER, name, numIter, numParallelSeeds, optimalTol, stats, useParallel`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `GeneticAlgorithm()`
    `GeneticAlgorithm(int popSize)`
    `GeneticAlgorithm(java.lang.String name, int popSize)`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods
    Modifier and Type | Method and Description
    --- | ---
    `java.lang.String` | `convertToBinString(float newAF)`
    `float` | `getAF_MAX(int type, int seg, int per)`
    `float` | `getAF_MIN(int type, int seg, int per)`
    `int` | `getAF_RANGE(int type, int seg, int per)`
    `float` | `getAF_STEP(int type, int seg, int per)`
    `Organism` | `getBestOrganism()` Returns the best organism that has been found.
    `java.lang.String` | `getBinString(int intToConvert)`
    `static java.lang.String` | `getBinString(int intToConvert, int numDigits)`
    `int` | `getBinStringLength()`
    `CrossoverHelper` | `getCrossover()` Getter for the CrossoverHelper operator
    `ElitismHelper` | `getElitism()` Getter for the ElitismHelper operator.
    `int` | `getElitismNumberSelected()`
    `int` | `getGenSinceImprovement()`
    `int` | `getIterationCount()`
    `Mutation` | `getMutator()` Getter for the Mutation operator.
    `java.lang.String` | `getName()`
    `int` | `getNumBestSolutionsSaved()`
    `Population` | `getPopulation()`
    `Seed` | `getPopulationSeed(int seedIndex)`
    `int` | `getPreservationNumberSelected()`
    `float` | `getPreservePct()` Getter for the algorithm organism preservation percentage.
    `PreserveHelper` | `getPreserver()` Getter for the PreserveHelper operator.
    `java.util.Random` | `getRNG()`
    `SelectionHelper` | `getSelector()` Getter for the SelectionHelper operator.
    `int` | `getSize()`
    `Seed` | `getSolnSeed()` Returns the Seed file with the best found solution applied to it.
    `void` | `initialize(AlgHelper fh, Seed[] seed)` Initializes the algorithm
    `void` | `initialize(AlgHelper fh, Seed[] seed, boolean createNewSearchSpace)`
    `private void` | `initialize(Population population)`
    `void` | `initialize(Seed targetSeed, Seed[] seed)` Initializes the algorithm
    `void` | `initialize(Seed targetSeed, Seed[] seed, boolean createNewSearchSpace)`
    `void` | `setAlgSubtype(java.lang.String subtype)` Specifies the subtype of the of GA
    `void` | `setBGASearchSpace(int segment, FloatProfile prof)` Uses the profile and the binary string length to determine a search space genetic algorithm with a binary encoding.
    `void` | `setBinStringLength(int binStringLength)`
    `void` | `setCrossoverStrategy(CrossoverHelper crossover)` Direct Setter for the CrossoverHelper operator.
    `void` | `setCrossoverStrategy(int crossoverStrategy)` Setter for the crossover operator (use static fields).
    `void` | `setElitismStrategy(ElitismHelper elitism)` Setter for the Elitism operator.
    `void` | `setElitismStrategy(int elitismStrategy)` Setter for the Elitism operator with default values (use static fields).
    `void` | `setGenSinceImprovement(int newVal)`
    `void` | `setMutationStrategy(int mutationStrategy)` Setter for the mutator operator (use static fields).
    `void` | `setMutationStrategy(Mutation mutator)` Direct Setter for the CrossoverHelper operator.
    `void` | `setNumBestSolutionsSaved(int numBestSolutionsSaved)`
    `void` | `setPopulationSize(int popSize)` Deprecated.
    `void` | `setPreservationStrategy(int preserveStrategy)` Setter for the PreserveHelper operator with default values (use static fields).
    `void` | `setPreservePct(float preservePct)` Setter for the organism algorithm preservation percentage.
    `void` | `setPreserveStrategy(PreserveHelper preserver)` Setter for the Preserve operator.
    `void` | `setRNGSeed(int rngSeed)`
    `void` | `setRNGSeed(long rngSeed)`
    `void` | `setRVGASearchSpace(int segment, FloatProfile prof, float step)` Uses the profile and the specified step size to determine a search space genetic algorithm with a real valued encoding.
    `void` | `setSelectionStrategy(int selectionStrategy)` Setter for the SelectionHelper operator with default values (use static fields).
    `void` | `setSelectionStrategy(SelectionHelper selector)` Setter for the Selection operator.

    - ### Methods inherited from class coreEngine.Calibration.Metaheuristic

      `setType`

    - ### Methods inherited from class coreEngine.Calibration.Algorithm

      `getAF_MAX, getAF_MIN, getAF_RANGE, getAF_STEP, getCDP_MAX, getCDP_MIN, getCDP_RANGE, getCDP_STEP, getJD_MAX, getJD_MIN, getJD_RANGE, getJD_STEP, getMAX_ITER, getNumParallelSeeds, getOptimalTol, isAdaptive, isMemetic, isUseParallel, setAdaptive, setAF_MIN, setAF_RANGE, setAF_STEP, setCDP_MIN, setCDP_RANGE, setCDP_STEP, setJD_MIN, setJD_RANGE, setJD_STEP, setMAX_ITER, setMemetic, setName, setNumParallelSeeds, setOptimalTol, setUseParallel, solveInstance, solveInstance, toString`

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

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

- - ### Field Detail

    - #### popSize

          protected final int popSize

      Integer size of the population

    - #### population

          protected Population population

      Population instance of organisms for the algorithm

    - #### elitism

          protected ElitismHelper elitism

      ElitismHelper Strategy Field

    - #### preserver

          protected PreserveHelper preserver

      PreserveHelper Strategy Field

    - #### selector

          protected SelectionHelper selector

      Selection Strategy Field

    - #### crossover

          protected CrossoverHelper crossover

      Crossover Strategy Field

    - #### mutator

          protected Mutation mutator

      Mutation Strategy Field

    - #### searchSpace

          public SearchSpace searchSpace

    - #### algSubtype

          protected java.lang.String algSubtype

    - #### genSinceImprovement

          protected int genSinceImprovement

    - #### algHelper

          public AlgHelper algHelper

    - #### objectiveType

          public int objectiveType

    - #### w1

          public float w1

    - #### w2

          public float w2

    - #### w3

          public float w3

    - #### lambda1

          public float lambda1

    - #### lambda2

          public float lambda2

    - #### preservePct

          protected float preservePct

      Percent of each generation to be randomly preserved and moved to next generation

    - #### binStringLength

          protected int binStringLength

    - #### nameIndex

          protected static int nameIndex

    - #### ELITISM_TYPE_NONE

          public static final int ELITISM_TYPE_NONE

      See Also:
        Constant Field Values

    - #### ELITISM_TYPE_PERCENTAGE

          public static final int ELITISM_TYPE_PERCENTAGE

      See Also:
        Constant Field Values

    - #### ElitismTypeList

          public static final java.lang.String[] ElitismTypeList

    - #### PRESERVE_TYPE_NONE

          public static final int PRESERVE_TYPE_NONE

      See Also:
        Constant Field Values

    - #### PRESERVE_TYPE_PCT_RAND

          public static final int PRESERVE_TYPE_PCT_RAND

      See Also:
        Constant Field Values

    - #### PreserveTypeList

          public static final java.lang.String[] PreserveTypeList

    - #### SELECTION_TYPE_TOURNAMENT

          public static final int SELECTION_TYPE_TOURNAMENT

      See Also:
        Constant Field Values

    - #### SELECTION_TYPE_ROULETTE

          public static final int SELECTION_TYPE_ROULETTE

      See Also:
        Constant Field Values

    - #### SELECTION_TYPE_EP

          public static final int SELECTION_TYPE_EP

      See Also:
        Constant Field Values

    - #### SELECTION_TYPE_RANDOM

          public static final int SELECTION_TYPE_RANDOM

      See Also:
        Constant Field Values

    - #### SelectionTypeList

          public static final java.lang.String[] SelectionTypeList

    - #### CROSSOVER_TYPE_ONEPOINT

          public static final int CROSSOVER_TYPE_ONEPOINT

      See Also:
        Constant Field Values

    - #### CROSSOVER_TYPE_TWOPOINT

          public static final int CROSSOVER_TYPE_TWOPOINT

      See Also:
        Constant Field Values

    - #### CROSSOVER_TYPE_UNIFORM

          public static final int CROSSOVER_TYPE_UNIFORM

      See Also:
        Constant Field Values

    - #### CROSSOVER_TYPE_BLOCK_UNIFORM

          public static final int CROSSOVER_TYPE_BLOCK_UNIFORM

      See Also:
        Constant Field Values

    - #### CrossoverTypeList

          public static final java.lang.String[] CrossoverTypeList

    - #### MUTATION_TYPE_UNIFORM

          public static final int MUTATION_TYPE_UNIFORM

      See Also:
        Constant Field Values

    - #### MUTATION_TYPE_NONUNIFORM

          public static final int MUTATION_TYPE_NONUNIFORM

      See Also:
        Constant Field Values

    - #### MUTATION_TYPE_BOUNDARY

          public static final int MUTATION_TYPE_BOUNDARY

      See Also:
        Constant Field Values

    - #### MUTATION_TYPE_GUASSIAN

          public static final int MUTATION_TYPE_GUASSIAN

      See Also:
        Constant Field Values

    - #### MUTATION_TYPE_SMOOTH

          public static final int MUTATION_TYPE_SMOOTH

      See Also:
        Constant Field Values

    - #### MUTATION_TYPE_SG

          public static final int MUTATION_TYPE_SG

      See Also:
        Constant Field Values

    - #### MUTATION_TYPE_SU

          public static final int MUTATION_TYPE_SU

      See Also:
        Constant Field Values

    - #### MUTATION_TYPE_PG

          public static final int MUTATION_TYPE_PG

      See Also:
        Constant Field Values

    - #### MUTATION_TYPE_PU

          public static final int MUTATION_TYPE_PU

      See Also:
        Constant Field Values

    - #### MutationTypeList

          public static final java.lang.String[] MutationTypeList

    - #### DEFAULT_POP_SIZE

          public static final int DEFAULT_POP_SIZE

      See Also:
        Constant Field Values

    - #### DEFAULT_ELITISIM_TYPE

          public static final int DEFAULT_ELITISIM_TYPE

      See Also:
        Constant Field Values

    - #### DEFAULT_PRESERVE_TYPE

          public static final int DEFAULT_PRESERVE_TYPE

      See Also:
        Constant Field Values

    - #### DEFAULT_SELECTION_TYPE

          public static final int DEFAULT_SELECTION_TYPE

      See Also:
        Constant Field Values

    - #### DEFAULT_CROSSOVER_TYPE

          public static final int DEFAULT_CROSSOVER_TYPE

      See Also:
        Constant Field Values

    - #### DEFAULT_MUTATION_TYPE

          public static final int DEFAULT_MUTATION_TYPE

      See Also:
        Constant Field Values

    - #### DEFAULT_ELITISM_PERCENT

          public static final float DEFAULT_ELITISM_PERCENT

      See Also:
        Constant Field Values

    - #### DEFAULT_PRESERVE_PERCENT

          public static final float DEFAULT_PRESERVE_PERCENT

      See Also:
        Constant Field Values

    - #### DEFAULT_MUTATION_PERCENT

          public static final float DEFAULT_MUTATION_PERCENT

      See Also:
        Constant Field Values

    - #### MUTATION_PERCENT

          public float MUTATION_PERCENT

    - #### DEFAULT_MUTATION_NUMBER

          public static final int DEFAULT_MUTATION_NUMBER

      See Also:
        Constant Field Values

    - #### TYPE_SGA

          public static final java.lang.String TYPE_SGA

      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### GeneticAlgorithm

          public GeneticAlgorithm()

    - #### GeneticAlgorithm

          public GeneticAlgorithm(int popSize)

    - #### GeneticAlgorithm

          public GeneticAlgorithm(java.lang.String name,
                                  int popSize)

  - ### Method Detail

    - #### initialize

          private void initialize(Population population)

    - #### initialize

          public void initialize(Seed targetSeed,
                                 Seed[] seed)

      Description copied from class: `Algorithm`
      Initializes the algorithm
      Specified by:
        `initialize` in class `Algorithm`

    - #### initialize

          public void initialize(Seed targetSeed,
                                 Seed[] seed,
                                 boolean createNewSearchSpace)

    - #### initialize

          public void initialize(AlgHelper fh,
                                 Seed[] seed)

      Description copied from class: `Algorithm`
      Initializes the algorithm
      Specified by:
        `initialize` in class `Algorithm`

    - #### initialize

          public void initialize(AlgHelper fh,
                                 Seed[] seed,
                                 boolean createNewSearchSpace)

    - #### getBestOrganism

          public Organism getBestOrganism()

      Description copied from class: `Algorithm`
      Returns the best organism that has been found.
      Specified by:
        `getBestOrganism` in class `Algorithm`
      Returns:

    - #### getSolnSeed

          public Seed getSolnSeed()

      Description copied from class: `Algorithm`
      Returns the Seed file with the best found solution applied to it.
      Specified by:
        `getSolnSeed` in class `Algorithm`
      Returns:

    - #### getPopulation

          public Population getPopulation()

    - #### getGenSinceImprovement

          public int getGenSinceImprovement()

    - #### getIterationCount

          public int getIterationCount()

    - #### setGenSinceImprovement

          public void setGenSinceImprovement(int newVal)

    - #### setAlgSubtype

          public void setAlgSubtype(java.lang.String subtype)

      Specifies the subtype of the of GA
      Parameters:
        `subtype` -

    - #### getName

          public java.lang.String getName()

    - #### setRNGSeed

          public void setRNGSeed(int rngSeed)

    - #### setRNGSeed

          public void setRNGSeed(long rngSeed)

    - #### getRNG

          public java.util.Random getRNG()

    - #### getSize

          public int getSize()

    - #### getPopulationSeed

          public Seed getPopulationSeed(int seedIndex)

    - #### setPopulationSize

          public void setPopulationSize(int popSize)

      Deprecated.
      Sets the size of the solution population
      Parameters:
        `popSize` -

    - #### getNumBestSolutionsSaved

          public int getNumBestSolutionsSaved()

    - #### setNumBestSolutionsSaved

          public void setNumBestSolutionsSaved(int numBestSolutionsSaved)

    - #### getElitism

          public ElitismHelper getElitism()

      Getter for the ElitismHelper operator.
      Returns:

    - #### setElitismStrategy

          public void setElitismStrategy(int elitismStrategy)

      Setter for the Elitism operator with default values (use static fields).
      Parameters:
        `elitismStrategy` -

    - #### setElitismStrategy

          public void setElitismStrategy(ElitismHelper elitism)

      Setter for the Elitism operator.
      Parameters:
        `elitism` -

    - #### getPreserver

          public PreserveHelper getPreserver()

      Getter for the PreserveHelper operator.
      Returns:

    - #### setPreservationStrategy

          public void setPreservationStrategy(int preserveStrategy)

      Setter for the PreserveHelper operator with default values (use static fields).
      Parameters:
        `preserveStrategy` -

    - #### setPreserveStrategy

          public void setPreserveStrategy(PreserveHelper preserver)

      Setter for the Preserve operator.
      Parameters:
        `preserver` -

    - #### getSelector

          public SelectionHelper getSelector()

      Getter for the SelectionHelper operator.
      Returns:

    - #### setSelectionStrategy

          public void setSelectionStrategy(int selectionStrategy)

      Setter for the SelectionHelper operator with default values (use static fields).
      Parameters:
        `selectionStrategy` -

    - #### setSelectionStrategy

          public void setSelectionStrategy(SelectionHelper selector)

      Setter for the Selection operator.
      Parameters:
        `selector` -

    - #### getPreservePct

          public float getPreservePct()

      Getter for the algorithm organism preservation percentage.
      Returns:
        Preservation float value between 0 and 1

    - #### setPreservePct

          public void setPreservePct(float preservePct)

      Setter for the organism algorithm preservation percentage.
      Parameters:
        `preservePct` -

    - #### getCrossover

          public CrossoverHelper getCrossover()

      Getter for the CrossoverHelper operator
      Returns:

    - #### setCrossoverStrategy

          public void setCrossoverStrategy(int crossoverStrategy)

      Setter for the crossover operator (use static fields).
      Parameters:
        `crossoverStrategy` -

    - #### setCrossoverStrategy

          public void setCrossoverStrategy(CrossoverHelper crossover)

      Direct Setter for the CrossoverHelper operator.
      Parameters:
        `crossover` -

    - #### getMutator

          public Mutation getMutator()

      Getter for the Mutation operator.
      Returns:

    - #### setMutationStrategy

          public void setMutationStrategy(int mutationStrategy)

      Setter for the mutator operator (use static fields).
      Parameters:
        `mutationStrategy` -

    - #### setMutationStrategy

          public void setMutationStrategy(Mutation mutator)

      Direct Setter for the CrossoverHelper operator.
      Parameters:
        `mutator` -

    - #### getElitismNumberSelected

          public int getElitismNumberSelected()

    - #### getPreservationNumberSelected

          public int getPreservationNumberSelected()

    - #### setBGASearchSpace

          public void setBGASearchSpace(int segment,
                                        FloatProfile prof)

      Uses the profile and the binary string length to determine a search space genetic algorithm with a binary encoding.
      Parameters:
        `segment` -
        `prof` -

    - #### setRVGASearchSpace

          public void setRVGASearchSpace(int segment,
                                         FloatProfile prof,
                                         float step)

      Uses the profile and the specified step size to determine a search space genetic algorithm with a real valued encoding.
      Parameters:
        `segment` -
        `prof` -
        `step` -

    - #### getAF_MIN

          public float getAF_MIN(int type,
                                 int seg,
                                 int per)

    - #### getAF_MAX

          public float getAF_MAX(int type,
                                 int seg,
                                 int per)

    - #### getAF_RANGE

          public int getAF_RANGE(int type,
                                 int seg,
                                 int per)

    - #### getAF_STEP

          public float getAF_STEP(int type,
                                  int seg,
                                  int per)

    - #### getBinStringLength

          public int getBinStringLength()

    - #### setBinStringLength

          public void setBinStringLength(int binStringLength)

    - #### convertToBinString

          public java.lang.String convertToBinString(float newAF)

    - #### getBinString

          public java.lang.String getBinString(int intToConvert)

    - #### getBinString

          public static java.lang.String getBinString(int intToConvert,
                                                      int numDigits)