Package org.moeaframework.core.spi
Class AlgorithmProvider
java.lang.Object
org.moeaframework.core.spi.AlgorithmProvider
- Direct Known Subclasses:
RegisteredAlgorithmProvider
Defines a SPI for algorithms.
To create a custom AlgorithmProvider
:
- Extend this class and implement the abstract methods.
- Create the file
META-INF/services/org.moeaframework.core.spi.AlgorithmProvider
with a line identifying the fully-qualified class name of the custom provider. - Compile and bundle the
.class
file(s) along with theMETA-INF
folder into a JAR. - Include this JAR on the classpath.
AlgorithmFactory
.
As algorithm names are often used in file names, it is best to avoid characters which are not compatible with the
file system. It is suggested that names match the following regular expression: ^[a-zA-Z0-9()\-,]+$
.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract Algorithm
getAlgorithm
(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.
-
Constructor Details
-
AlgorithmProvider
public AlgorithmProvider()Constructs an algorithm provider.
-
-
Method Details
-
getDiagnosticToolAlgorithms
Returns the algorithms names to appear in the diagnostic tool. If there are multiple aliases for the same algorithm, provide only the canonical name.- Returns:
- the algorithm names
-
getAlgorithm
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.- Parameters:
name
- the algorithm nameproperties
- optional properties for the algorithmproblem
- the problem- Returns:
- the algorithm instance or
null
- Throws:
ProviderException
- if the creation of the algorithm failed for any reason
-