Class GrammarMutation

java.lang.Object
org.moeaframework.core.operator.grammar.GrammarMutation
All Implemented Interfaces:
Configurable, Mutation, Variation

public class GrammarMutation extends Object implements Mutation
Uniform mutation for grammars. Each integer codon in the grammar representation is uniformly mutated with a specified probability.

This variation operator is type-safe.

  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructs a uniform mutation operators for grammars.
    GrammarMutation(double probability)
    Constructs a uniform mutation operator for grammars with the specified probability of mutating each integer codon in the grammar representation.
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns the name of this variation operator.
    double
    Returns the probability of mutating each integer codon in the grammar representation.
    mutate(Solution parent)
    Mutates the given parent to produce an offspring.
    static void
    mutate(Grammar grammar, double probability)
    Performs uniform mutation on the specified grammar.
    void
    setProbability(double probability)
    Sets the probability of mutating each integer codon in the grammar representation.

    Methods inherited from class java.lang.Object

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

    Methods inherited from interface org.moeaframework.core.configuration.Configurable

    applyConfiguration, getConfiguration

    Methods inherited from interface org.moeaframework.core.operator.Mutation

    evolve, getArity
  • Constructor Details

    • GrammarMutation

      public GrammarMutation()
      Constructs a uniform mutation operators for grammars.
    • GrammarMutation

      public GrammarMutation(double probability)
      Constructs a uniform mutation operator for grammars with the specified probability of mutating each integer codon in the grammar representation.
      Parameters:
      probability - the probability of mutating each integer codon in the grammar representation
  • Method Details

    • getName

      public String getName()
      Description copied from interface: Variation
      Returns the name of this variation operator. This name should also be used as the prefix for any parameters. As such, the name should only contain alphanumeric characters, avoid using whitespace and other symbols.
      Specified by:
      getName in interface Variation
      Returns:
      the name of this variation operator
    • getProbability

      public double getProbability()
      Returns the probability of mutating each integer codon in the grammar representation.
      Returns:
      the probability
    • setProbability

      public void setProbability(double probability)
      Sets the probability of mutating each integer codon in the grammar representation.
      Parameters:
      probability - the probability (0.0 - 1.0)
    • mutate

      public Solution mutate(Solution parent)
      Description copied from interface: Mutation
      Mutates the given parent to produce an offspring.
      Specified by:
      mutate in interface Mutation
      Parameters:
      parent - the parent solution
      Returns:
      the offspring
    • mutate

      public static void mutate(Grammar grammar, double probability)
      Performs uniform mutation on the specified grammar. Each integer codon in the grammar representation is uniformly mutated with the specified probability in the range [0, getMaximumValue()-1].
      Parameters:
      grammar - the grammar to mutate
      probability - the probability of mutating each integer codon in the grammar representation