Genetic Algorithms

Genetic Algorithms are processes that mimick Darwinian evolution where a population is generated, the fitness of each memeber of the population is scored, unfit members are removed, and fit members are maintained, bred (merged) or mutated (changed) to create a new population.

This is a simplistic overview of the Genetic Algorithm (GA) classes in jMusic. We hope to get more details soon.

First, the GA only works for Phrases, not any of the other music types like Scores and Parts.

The central class to the GA framework is the PhrGeneticAlgorithm class. Once you've initialised the GA you can get the best phrase after a n iterations like this:

ga.iterate(n);
Phrase best = ga.getBestIndividual();

The PhrGeneticAlgorithm class has a single constructor, with most of the parameters being interfaces representing the distinct steps in the GA. These are:

  1. Initialise population (PopulationInitialiser interface)
  2. While termination criteria has not been met (TerminationCriteria)
    1. Evaluate fitness (FitnessEvaluator interface)
    2. Select parents (ParentSelector iterface)
    3. Breed next generation from parents (Recombiner iterface)
    4. Mutate next generation (Mutater iterface)
    5. Discard unfit children (SurvivorSelector interface)

So in order to create a GA you will first need to write concrete implementations of these 7 interfaces.

There are implementations of these available in the jm.music.tools.ga package, however these were specifically tailored for a particular task and will probably only be useful as a guide.


jMusic Tutorial Index