Class AbstractCompoundVariation<T extends Variation>

java.lang.Object
org.moeaframework.core.operator.AbstractCompoundVariation<T>
Type Parameters:
T - the type of variation operators
All Implemented Interfaces:
Configurable, Variation
Direct Known Subclasses:
AdaptiveMultimethodVariation, CompoundMutation, CompoundVariation

public class AbstractCompoundVariation<T extends Variation> extends Object implements Variation
Constructs a variation operator applying two or more variations sequentially. This is often used for mixed-type decision variables by supplying a type-safe operator for each type.

The number of parents (arity) of an operator must equal or evenly divide the number of offspring produced by the previous operator. When equal, the offspring are passed directly into the next operator. When divisible, the offspring are partitioned and multiple calls made to the next operator. Therefore, we typically want to put all crossover operators first followed by any mutation operators.

Consequently, not all combinations of operators are valid and may result in a runtime exception being thrown.

  • Field Details

    • operators

      protected final List<T extends Variation> operators
      The variation operators in the order they are applied.
  • Constructor Details

    • AbstractCompoundVariation

      public AbstractCompoundVariation()
      Constructs a compound variation operator with no variation operators.
  • Method Details

    • contains

      public boolean contains(Class<? extends Variation> type)
      Returns true if one or more of the operators are the given type.
      Parameters:
      type - the variation type
      Returns:
      true if any operators are the given type
    • getName

      public String getName()
      Returns the name of this variation operator. If no name has been assigned through setName(String), a name is generated which identifies the underlying operators.
      Specified by:
      getName in interface Variation
      Returns:
      the name of this variation operator
    • setName

      public void setName(String name)
      Sets the name of this variation operator.
      Parameters:
      name - 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
      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
    • getOperators

      public List<T> getOperators()
      Returns an unmodifiable list of the operations included in this compound variation instance.
      Returns:
      the operators
    • applyConfiguration

      public void applyConfiguration(TypedProperties properties)
      Description copied from interface: Configurable
      Applies the properties to this instance. It is strongly recommended to apply a configuration immediately after creating the instance, as some properties can not be changed after the class is used. Exceptions may be thrown if attempting to set such properties. After calling this method, we encourage users to call TypedProperties.warnIfUnaccessedProperties() to verify all properties were processed. This can identify simple mistakes like typos. If overriding this method, properties should only be updated if a new value is provided. Additionally, if updating any Configurable objects inside this object, they should be updated before calling super.applyConfiguration(properties).
      Specified by:
      applyConfiguration in interface Configurable
      Parameters:
      properties - the user-defined properties
    • getConfiguration

      public TypedProperties getConfiguration()
      Description copied from interface: Configurable
      Gets the current configuration of this instance. In theory, these properties should be able to create a duplicate instance. Note however, they are unlikely to behave identically due to random numbers and other transient fields.
      Specified by:
      getConfiguration in interface Configurable
      Returns:
      the properties defining this instance