Class UniformCrossover

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

public class UniformCrossover extends Object implements Variation
Crossover operator where each index is randomly swapped between the parents with a 50% chance.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructs a uniform crossover operator with a 100% probability of mutating the parents.
    UniformCrossover(double probability)
    Constructs a uniform 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

    • UniformCrossover

      public UniformCrossover()
      Constructs a uniform crossover operator with a 100% probability of mutating the parents.
    • UniformCrossover

      public UniformCrossover(double probability)
      Constructs a uniform 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