Package org.moeaframework.core.operator
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
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 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
-