Class GrammarCrossover

java.lang.Object
org.moeaframework.core.operator.TypeSafeCrossover<Grammar>
org.moeaframework.core.operator.grammar.GrammarCrossover
All Implemented Interfaces:
Configurable, Variation

public class GrammarCrossover extends TypeSafeCrossover<Grammar>
Single-point crossover for grammars. A crossover point is selected in both parents with the tail portions swapped.

This variation operator is type-safe.

  • Constructor Details

    • GrammarCrossover

      public GrammarCrossover()
      Constructs a new grammar crossover operator with 100% probability of being applied to each solution.
    • GrammarCrossover

      public GrammarCrossover(double probability)
      Constructs a single-point crossover operator for grammars with the specified probability of applying this operator to each grammar variable.
      Parameters:
      probability - the probability of applying this operator to each grammar variable
  • 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.
      Returns:
      the name of this variation operator
    • evolve

      public void evolve(Grammar g1, Grammar g2)
      Performs single-point crossover on the specified grammars. Crossover points are chosen for both parents and the tail sections swapped. The two grammars are modified as a result of this operation.
      Specified by:
      evolve in class TypeSafeCrossover<Grammar>
      Parameters:
      g1 - the first grammar
      g2 - the second grammar