Package org.moeaframework.core.spi
Class RegisteredAlgorithmProvider
java.lang.Object
org.moeaframework.core.spi.AlgorithmProvider
org.moeaframework.core.spi.RegisteredAlgorithmProvider
- Direct Known Subclasses:
DefaultAlgorithms
Algorithm provider that lets callers register algorithms by name. Names are case-insensitive.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetAlgorithm
(String name, TypedProperties properties, Problem problem) Returns the algorithm with the specified name, ornull
if this provider does not support the algorithm.Returns the algorithms names to appear in the diagnostic tool.Returns all algorithms that have been registered with this provider.protected final void
register
(BiFunction<TypedProperties, Problem, Algorithm> constructor, String name, String... aliases) Registers a new algorithm with this provider.protected final void
Registers the given algorithm to appear in the diagnostic tool.protected final void
Registers all of the given algorithms to appear in the diagnostic tool.
-
Constructor Details
-
RegisteredAlgorithmProvider
public RegisteredAlgorithmProvider()Creates a new, empty problem provider.
-
-
Method Details
-
getRegisteredAlgorithms
Returns all algorithms that have been registered with this provider. Note that this does not necessarily include all algorithms that can be instantiated by the provider, only those that have been explicitly registered. This also does not include aliases.- Returns:
- the algorithm names
-
getDiagnosticToolAlgorithms
Description copied from class:AlgorithmProvider
Returns the algorithms names to appear in the diagnostic tool. If there are multiple aliases for the same algorithm, provide only the canonical name.- Overrides:
getDiagnosticToolAlgorithms
in classAlgorithmProvider
- Returns:
- the algorithm names
-
registerDiagnosticToolAlgorithm
Registers the given algorithm to appear in the diagnostic tool.- Parameters:
name
- the algorithm name
-
registerDiagnosticToolAlgorithms
Registers all of the given algorithms to appear in the diagnostic tool.- Parameters:
names
- the algorithm names
-
register
protected final void register(BiFunction<TypedProperties, Problem, Algorithm> constructor, String name, String... aliases) Registers a new algorithm with this provider. The official name of the algorithm should be the first string argument, with any alternative spellings or aliases following.- Parameters:
constructor
- the function that creates a new instance of the algorithmname
- the registered name for this algorithmaliases
- optional aliases for this algorithm
-
getAlgorithm
Description copied from class:AlgorithmProvider
Returns the algorithm with the specified name, ornull
if this provider does not support the algorithm. An optional set of properties may be provided to further define the algorithm; however, the provider is expected to supply default properties if none are provided.- Specified by:
getAlgorithm
in classAlgorithmProvider
- Parameters:
name
- the algorithm nameproperties
- optional properties for the algorithmproblem
- the problem- Returns:
- the algorithm instance or
null
-