Class OnePointCrossover

java.lang.Object
org.moeaframework.core.operator.OnePointCrossover
All Implemented Interfaces:
Configurable, Variation

public class OnePointCrossover extends Object implements Variation
One-point or single-point crossover. A crossover point is selected and all decision variables to the left/right are swapped between the two parents. The two children resulting from this swapping are returned.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructs a one-point crossover operator with a 100% probability.
    OnePointCrossover(double probability)
    Constructs a one-point crossover operator with the specified probability of applying this operator to solutions.
  • 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.
    int
    Returns the number of solutions that must be supplied to the evolve method.
    Returns the name of this variation operator.
    double
    Returns the probability of applying this operator to solutions.
    void
    setProbability(double probability)
    Sets the probability of applying this operator to solutions.

    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
  • Constructor Details

    • OnePointCrossover

      public OnePointCrossover()
      Constructs a one-point crossover operator with a 100% probability.
    • OnePointCrossover

      public OnePointCrossover(double probability)
      Constructs a one-point crossover operator with the specified probability of applying this operator to solutions.
      Parameters:
      probability - the probability of applying this operator to solutions
  • 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 applying this operator to solutions.
      Returns:
      the probability
    • setProbability

      public void setProbability(double probability)
      Sets the probability of applying this operator to solutions.
      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