jm.music.tools.ga

## Class PhrGeneticAlgorithm

- java.lang.Object
- - jm.music.tools.ga.PhrGeneticAlgorithm

-     public class PhrGeneticAlgorithm
      extends java.lang.Object

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected int` | `beatsPerBar`
    `protected boolean` | `finished`
    `protected double[]` | `fitness`
    `protected FitnessEvaluater` | `fitnessEvaluater`
    `protected double` | `initialLength`
    `protected int` | `initialSize`
    `protected long` | `iteration`
    `protected Mutater` | `mutater`
    `protected int` | `originalSize`
    `protected ParentSelector` | `parentSelector`
    `protected Phrase[]` | `population`
    `protected PopulationInitialiser` | `populationInitialiser`
    `protected Recombiner` | `recombiner`
    `protected SurvivorSelector` | `survivorSelector`
    `protected TerminationCriteria` | `terminationCriteria`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `PhrGeneticAlgorithm(Phrase phrase, int beatsPerBar, PopulationInitialiser populationInitialiser, FitnessEvaluater fitnessEvaluater, TerminationCriteria terminationCriteria, ParentSelector parentSelector, Recombiner recombiner, Mutater mutater, SurvivorSelector survivorSelector)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `double` | `getAverageFitness()`
    `double` | `getBestFitness()`
    `Phrase` | `getBestIndividual()`
    `double[]` | `getFitness()`
    `long` | `getIteration()`
    `Mutater` | `getMutater()`
    `Phrase[]` | `getOrderedPopulation()` Returns the population ordered by fitness with better fitness' first.
    `Phrase[]` | `getPopulation()`
    `double` | `getStandardDeviation()`
    `boolean` | `iterate()` Evolve the population through one generation.
    `long` | `iterate(long iterations)` Evolve the population through the specified number of generations.
    `void` | `restoreInitialSize()`
    `void` | `setBeatsPerBar(int beats)`
    `void` | `setUpNewPopulation(Phrase phrase)`
    `void` | `zeroInitialSize()`

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

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

- - ### Field Detail

    - #### population

          protected Phrase[] population

    - #### fitness

          protected double[] fitness

    - #### populationInitialiser

          protected PopulationInitialiser populationInitialiser

    - #### fitnessEvaluater

          protected FitnessEvaluater fitnessEvaluater

    - #### terminationCriteria

          protected TerminationCriteria terminationCriteria

    - #### parentSelector

          protected ParentSelector parentSelector

    - #### recombiner

          protected Recombiner recombiner

    - #### mutater

          protected Mutater mutater

    - #### survivorSelector

          protected SurvivorSelector survivorSelector

    - #### beatsPerBar

          protected int beatsPerBar

    - #### iteration

          protected long iteration

    - #### initialLength

          protected double initialLength

    - #### initialSize

          protected int initialSize

    - #### originalSize

          protected int originalSize

    - #### finished

          protected boolean finished

  - ### Constructor Detail

    - #### PhrGeneticAlgorithm

          public PhrGeneticAlgorithm(Phrase phrase,
                             int beatsPerBar,
                             PopulationInitialiser populationInitialiser,
                             FitnessEvaluater fitnessEvaluater,
                             TerminationCriteria terminationCriteria,
                             ParentSelector parentSelector,
                             Recombiner recombiner,
                             Mutater mutater,
                             SurvivorSelector survivorSelector)

  - ### Method Detail

    - #### setUpNewPopulation

          public void setUpNewPopulation(Phrase phrase)

    - #### setBeatsPerBar

          public void setBeatsPerBar(int beats)

    - #### zeroInitialSize

          public void zeroInitialSize()

    - #### restoreInitialSize

          public void restoreInitialSize()

    - #### getIteration

          public long getIteration()

    - #### iterate

          public boolean iterate()

      Evolve the population through one generation.

    - #### iterate

          public long iterate(long iterations)

      Evolve the population through the specified number of generations.

    - #### getFitness

          public double[] getFitness()

    - #### getPopulation

          public Phrase[] getPopulation()

    - #### getOrderedPopulation

          public Phrase[] getOrderedPopulation()

      Returns the population ordered by fitness with better fitness' first.

    - #### getBestFitness

          public double getBestFitness()

    - #### getAverageFitness

          public double getAverageFitness()

    - #### getStandardDeviation

          public double getStandardDeviation()

    - #### getBestIndividual

          public Phrase getBestIndividual()

    - #### getMutater

          public Mutater getMutater()