Class TypeSafeCrossover<T extends Variable>

java.lang.Object
org.moeaframework.core.operator.TypeSafeCrossover<T>
Type Parameters:
T - the type of decision variable this operator supports
All Implemented Interfaces:
Configurable, Variation
Direct Known Subclasses:
GrammarCrossover, HUX, PMX, SSX, SubtreeCrossover

public abstract class TypeSafeCrossover<T extends Variable> extends Object implements Variation
An abstract variation class that validates the types of each variable before applying the crossover operation with a given probability.
  • Constructor Summary

    Constructors
    Constructor
    Description
    TypeSafeCrossover(Class<T> type, double probability)
    Constructs a new variation operator for the given type.
  • Method Summary

    Modifier and Type
    Method
    Description
    evolve(Solution[] parents)
    Evolves one or more parent solutions (specified by getArity) and produces one or more child solutions.
    abstract void
    evolve(T variable1, T variable2)
    Performs the crossover operation on two decision variables.
    int
    Returns the number of solutions that must be supplied to the evolve method.
    double
    Returns the probability of applying this operator to each decision variable
    void
    setProbability(double probability)
    Sets the probability of applying this operator to each decision variable.

    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.Variation

    getName
  • Constructor Details

    • TypeSafeCrossover

      public TypeSafeCrossover(Class<T> type, double probability)
      Constructs a new variation operator for the given type.
      Parameters:
      type - the type of decision variable this operator supports
      probability - the probability of applying this operator to each decision variable
  • Method Details

    • getProbability

      public double getProbability()
      Returns the probability of applying this operator to each decision variable
      Returns:
      the probability between 0.0 and 1.0, inclusive
    • setProbability

      public void setProbability(double probability)
      Sets the probability of applying this operator to each decision variable.
      Parameters:
      probability - the probability between 0.0 and 1.0, inclusive
    • 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
      Parameters:
      parents - the array of parent solutions
      Returns:
      an array of child solutions
    • getArity

      public int getArity()
      Description copied from interface: Variation
      Returns the number of solutions that must be supplied to the evolve method.
      Specified by:
      getArity in interface Variation
      Returns:
      the number of solutions that must be supplied to the evolve method
    • evolve

      public abstract void evolve(T variable1, T variable2)
      Performs the crossover operation on two decision variables.
      Parameters:
      variable1 - the first variable
      variable2 - the second variable