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. Names are case-insensitive.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetMutationHint(Problem problem) Returns the name of the suggested mutation operator for the given problem, ornullif 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, ornullif no hint is available.protected final voidregister(String name, BiFunction<TypedProperties, Problem, Variation> constructor) Registers a new operator with this provider.protected final voidsetCrossoverHint(Class<? extends Variable> type, String operator) Sets the crossover hint for the given decision variable type, overwriting any existing hint.protected final voidsetMutationHint(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:OperatorProviderReturns the name of the suggested mutation operator for the given problem, ornullif no hint is available.- Specified by:
getMutationHintin classOperatorProvider- Parameters:
problem- the problem- Returns:
- the name of the suggested mutation operator for the given problem
-
getVariationHint
Description copied from class:OperatorProviderReturns the name of the suggested variation operator for the given problem, ornullif no hint is available.- Specified by:
getVariationHintin classOperatorProvider- Parameters:
problem- the problem- Returns:
- the name of the suggested variation operator for the given problem
-
getVariation
Description copied from class:OperatorProviderReturns an instance of the variation operator with the specified name. This method must returnnullif the named operator is not supported, or no suitable operator could be identified using hints.- Specified by:
getVariationin classOperatorProvider- Parameters:
name- the name identifying the variation operator, ornullto select a default operator based on the hintsproperties- the implementation-specific propertiesproblem- the problem to be solved- Returns:
- an instance of the variation operator or
null
-