Package org.moeaframework.core.spi
Class OperatorFactory
java.lang.Object
org.moeaframework.core.spi.AbstractFactory<OperatorProvider>
org.moeaframework.core.spi.OperatorFactory
- All Implemented Interfaces:
Iterable<OperatorProvider>
Factory for creating and variation (e.g., crossover and mutation) operator instances.
Operators can be combined by joining the two operator names with the plus sign, such as "sbx+pm"
. Not all
operators can be joined this way. See CompoundVariation
for the restrictions.
This class is thread safe.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic OperatorFactory
Returns the default operator factory.getMutation
(String name, TypedProperties properties, Problem problem) Returns the suggested mutation operator for the given problem.getMutation
(Problem problem) Returns the suggested mutation operator for the given problem.getVariation
(String name, Problem problem) Returns the named variation operator using default settings.getVariation
(String name, TypedProperties properties, Problem problem) Returns an instance of the variation operator with the specified name.getVariation
(Problem problem) Returns the suggested variation operator for the given problem.static void
setInstance
(OperatorFactory instance) Sets the default operator factory.Methods inherited from class org.moeaframework.core.spi.AbstractFactory
addProvider, hasProvider, iterator
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
OperatorFactory
public OperatorFactory()Constructs a new operator factory.
-
-
Method Details
-
getInstance
Returns the default operator factory.- Returns:
- the default operator factory
-
setInstance
Sets the default operator factory.- Parameters:
instance
- the default operator factory
-
getMutation
Returns the suggested mutation operator for the given problem.- Parameters:
problem
- the problem- Returns:
- an instance of the mutation operator
-
getMutation
Returns the suggested mutation operator for the given problem. Ifname
isnull
, this will attempt to return a mutation operator appropriate for the problem.- Parameters:
name
- the name of the mutation operatorproperties
- the implementation-specific propertiesproblem
- the problem- Returns:
- an instance of the mutation operator
-
getVariation
Returns the suggested variation operator for the given problem.- Parameters:
problem
- the problem to be solved- Returns:
- an instance of the variation operator
-
getVariation
Returns the named variation operator using default settings.- Parameters:
name
- the name identifying the variation operatorproblem
- the problem to be solved- Returns:
- an instance of the variation operator
-
getVariation
Returns an instance of the variation operator with the specified name. This method must throw aProviderNotFoundException
if no suitable operator is found. Ifname
is null, the factory should return a default variation operator appropriate for the problem.- Parameters:
name
- the name of the variation operatorproperties
- the implementation-specific propertiesproblem
- the problem to be solved- Returns:
- an instance of the variation operator
- Throws:
ProviderNotFoundException
- if no provider for the algorithm is available
-