Class AbstractCompoundVariation<T extends Variation>

java.lang.Object
org.moeaframework.core.operator.AbstractCompoundVariation<T>
All Implemented Interfaces:
Configurable, Variation
Direct Known Subclasses:
AdaptiveMultimethodVariation, CompoundMutation, CompoundVariation

public class AbstractCompoundVariation<T extends Variation> extends Object implements Variation
Construct a variation operator applying one or more variations sequentially. This construct is used to support mixed-type decision variables; however, this requires that the variation operators are type safe. Type safe variation operates only on supported types and ignores unsupported types.

CompoundVariation provides the following behavior:

  1. If the previous operator produced K offspring and the current operator requires K parents, the current operator is applied normally. The current operator may produce any number of offspring.
  2. If the previous operator produced K offspring and the current operator requires 1 parent, the current operator is applied to each offspring individually. The current operator may produce any number of offspring, but only the first offspring will be retained.
  3. Otherwise, an exception is 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