Package org.optaplanner.core.api.solver
Interface SolverFactory<Solution_>
-
- Type Parameters:
Solution_
- the solution type, the class with thePlanningSolution
annotation
- All Known Implementing Classes:
DefaultSolverFactory
public interface SolverFactory<Solution_>
CreatesSolver
instances. Most applications only need one SolverFactory.To create a SolverFactory, use
createFromXmlResource(String)
. To change the configuration programmatically, create aSolverConfig
first and then usecreate(SolverConfig)
.These methods are thread-safe unless explicitly stated otherwise.
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description Solver<Solution_>
buildSolver()
Creates a newSolver
instance.static <Solution_>
SolverFactory<Solution_>create(SolverConfig solverConfig)
Uses aSolverConfig
to build aSolverFactory
.static <Solution_>
SolverFactory<Solution_>createFromXmlFile(File solverConfigFile)
Reads an XML solver configuration from the file system and uses thatSolverConfig
to build aSolverFactory
.static <Solution_>
SolverFactory<Solution_>createFromXmlFile(File solverConfigFile, ClassLoader classLoader)
As defined bycreateFromXmlFile(File)
.static <Solution_>
SolverFactory<Solution_>createFromXmlResource(String solverConfigResource)
Reads an XML solver configuration from the classpath and uses thatSolverConfig
to build aSolverFactory
.static <Solution_>
SolverFactory<Solution_>createFromXmlResource(String solverConfigResource, ClassLoader classLoader)
As defined bycreateFromXmlResource(String)
.
-
-
-
Method Detail
-
createFromXmlResource
static <Solution_> SolverFactory<Solution_> createFromXmlResource(String solverConfigResource)
Reads an XML solver configuration from the classpath and uses thatSolverConfig
to build aSolverFactory
. The XML root element must be<solver>
.- Type Parameters:
Solution_
- the solution type, the class with thePlanningSolution
annotation- Parameters:
solverConfigResource
- never null, a classpath resource as defined byClassLoader.getResource(String)
- Returns:
- never null, subsequent changes to the config have no effect on the returned instance
-
createFromXmlResource
static <Solution_> SolverFactory<Solution_> createFromXmlResource(String solverConfigResource, ClassLoader classLoader)
As defined bycreateFromXmlResource(String)
.- Type Parameters:
Solution_
- the solution type, the class with thePlanningSolution
annotation- Parameters:
solverConfigResource
- never null, a classpath resource as defined byClassLoader.getResource(String)
classLoader
- sometimes null, theClassLoader
to use for loading all resources andClass
es, null to use the defaultClassLoader
- Returns:
- never null, subsequent changes to the config have no effect on the returned instance
-
createFromXmlFile
static <Solution_> SolverFactory<Solution_> createFromXmlFile(File solverConfigFile)
Reads an XML solver configuration from the file system and uses thatSolverConfig
to build aSolverFactory
.Warning: this leads to platform dependent code, it's recommend to use
createFromXmlResource(String)
instead.- Type Parameters:
Solution_
- the solution type, the class with thePlanningSolution
annotation- Parameters:
solverConfigFile
- never null- Returns:
- never null, subsequent changes to the config have no effect on the returned instance
-
createFromXmlFile
static <Solution_> SolverFactory<Solution_> createFromXmlFile(File solverConfigFile, ClassLoader classLoader)
As defined bycreateFromXmlFile(File)
.- Type Parameters:
Solution_
- the solution type, the class with thePlanningSolution
annotation- Parameters:
solverConfigFile
- never nullclassLoader
- sometimes null, theClassLoader
to use for loading all resources andClass
es, null to use the defaultClassLoader
- Returns:
- never null, subsequent changes to the config have no effect on the returned instance
-
create
static <Solution_> SolverFactory<Solution_> create(SolverConfig solverConfig)
Uses aSolverConfig
to build aSolverFactory
. If you don't need to manipulate theSolverConfig
programmatically, usecreateFromXmlResource(String)
instead.- Type Parameters:
Solution_
- the solution type, the class with thePlanningSolution
annotation- Parameters:
solverConfig
- never null- Returns:
- never null, subsequent changes to the config have no effect on the returned instance
-
-