Class SubtreeCrossover

java.lang.Object
org.moeaframework.core.operator.TypeSafeCrossover<Program>
org.moeaframework.core.operator.program.SubtreeCrossover
All Implemented Interfaces:
Configurable, Variation

public class SubtreeCrossover extends TypeSafeCrossover<Program>
Exchanges a randomly-selected subtree from one program with a compatible, randomly-selected subtree from another program.

This operator is type-safe.

  • Constructor Details

    • SubtreeCrossover

      public SubtreeCrossover()
      Constructs a new subtree crossover instance with a 90% chance of being applied to each solution.
    • SubtreeCrossover

      public SubtreeCrossover(double probability)
      Constructs a new subtree crossover instance.
      Parameters:
      probability - the probability that subtree crossover is applied to a program
  • 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 Solution[] evolve(Solution[] parents)
      Description copied from interface: Variation
      Evolves one or more parent solutions (specified by getArity) and produces one or more child solutions. By contract, the parents must not be modified. The copy constructor should be used to create copies of the parents with these copies subsequently modified.
      Specified by:
      evolve in interface Variation
      Overrides:
      evolve in class TypeSafeCrossover<Program>
      Parameters:
      parents - the array of parent solutions
      Returns:
      an array of child solutions
    • evolve

      public void evolve(Program program1, Program program2)
      Applies subtree crossover to the programs.
      Specified by:
      evolve in class TypeSafeCrossover<Program>
      Parameters:
      program1 - the first program, which is the parent program
      program2 - the second program, which provides the replacement subtree