Package org.moeaframework.core.spi
Class RegisteredOperatorProvider
java.lang.Object
org.moeaframework.core.spi.OperatorProvider
org.moeaframework.core.spi.RegisteredOperatorProvider
- Direct Known Subclasses:
DefaultOperators
Operator provider that lets callers register operators by name.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptiongetMutationHint
(Problem problem) Returns the name of the suggested mutation operator for the given problem, ornull
if no hint is available.Returns the names of all operators registered with this provider.getVariation
(String name, TypedProperties properties, Problem problem) Returns an instance of the variation operator with the specified name.getVariationHint
(Problem problem) Returns the name of the suggested variation operator for the given problem, ornull
if no hint is available.protected final void
register
(String name, BiFunction<TypedProperties, Problem, Variation> constructor) Registers a new operator with this provider.protected final void
setCrossoverHint
(Class<? extends Variable> type, String operator) Sets the crossover hint for the given decision variable type, overwriting any existing hint.protected final void
setMutationHint
(Class<? extends Variable> type, String operator) Sets the mutation hint for the given decision variable type, overwriting any existing hint.
-
Constructor Details
-
RegisteredOperatorProvider
public RegisteredOperatorProvider()Constructs a new, empty operator provider.
-
-
Method Details
-
setMutationHint
Sets the mutation hint for the given decision variable type, overwriting any existing hint. By convention, all mutation operators should accept a single parent and produce a single offspring.- Parameters:
type
- the decision variable typeoperator
- the suggested operator
-
setCrossoverHint
Sets the crossover hint for the given decision variable type, overwriting any existing hint. While not strictly required, we recommend only configuring crossover operators that accept two parents and produce two offspring. This convention guarantees the crossover operators can be combined safely.- Parameters:
type
- the decision variable typeoperator
- the suggested operator
-
register
protected final void register(String name, BiFunction<TypedProperties, Problem, Variation> constructor) Registers a new operator with this provider.- Parameters:
name
- the operator nameconstructor
- the function that creates a new instance of the operator
-
getRegisteredOperators
Returns the names of all operators registered with this provider.- Returns:
- the names of all registered operators
-
getMutationHint
Description copied from class:OperatorProvider
Returns the name of the suggested mutation operator for the given problem, ornull
if no hint is available.- Specified by:
getMutationHint
in classOperatorProvider
- Parameters:
problem
- the problem- Returns:
- the name of the suggested mutation operator for the given problem
-
getVariationHint
Description copied from class:OperatorProvider
Returns the name of the suggested variation operator for the given problem, ornull
if no hint is available.- Specified by:
getVariationHint
in classOperatorProvider
- Parameters:
problem
- the problem- Returns:
- the name of the suggested variation operator for the given problem
-
getVariation
Description copied from class:OperatorProvider
Returns an instance of the variation operator with the specified name. This method must returnnull
if no suitable operator is found.- Specified by:
getVariation
in classOperatorProvider
- Parameters:
name
- the name identifying the variation operatorproperties
- the implementation-specific propertiesproblem
- the problem to be solved- Returns:
- an instance of the variation operator with the specified name
-