Package org.moeaframework.core.operator
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
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:
- If the previous operator produced
K
offspring and the current operator requiresK
parents, the current operator is applied normally. The current operator may produce any number of offspring. - If the previous operator produced
K
offspring and the current operator requires1
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. - Otherwise, an exception is thrown.
-
Field Summary
-
Constructor Summary
ConstructorDescriptionConstructs a compound variation operator with no variation operators. -
Method Summary
Modifier and TypeMethodDescriptionvoid
applyConfiguration
(TypedProperties properties) Applies the properties to this instance.boolean
Returnstrue
if one or more of the operators are the given type.Solution[]
Evolves one or more parent solutions (specified bygetArity
) and produces one or more child solutions.int
getArity()
Returns the number of solutions that must be supplied to theevolve
method.Gets the current configuration of this instance.getName()
Returns the name of this variation operator.Returns an unmodifiable list of the operations included in this compound variation instance.void
Sets the name of this variation operator.
-
Field Details
-
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
Returnstrue
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
Returns the name of this variation operator. If no name has been assigned throughsetName(String)
, a name is generated which identifies the underlying operators. -
setName
Sets the name of this variation operator.- Parameters:
name
- the name of this variation operator
-
evolve
Description copied from interface:Variation
Evolves one or more parent solutions (specified bygetArity
) 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. -
getArity
public int getArity()Description copied from interface:Variation
Returns the number of solutions that must be supplied to theevolve
method. -
getOperators
Returns an unmodifiable list of the operations included in this compound variation instance.- Returns:
- the operators
-
applyConfiguration
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 callTypedProperties.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 anyConfigurable
objects inside this object, they should be updated before callingsuper.applyConfiguration(properties)
.- Specified by:
applyConfiguration
in interfaceConfigurable
- Parameters:
properties
- the user-defined properties
-
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 interfaceConfigurable
- Returns:
- the properties defining this instance
-