Class SolverConfig
java.lang.Object
org.optaplanner.core.config.AbstractConfig<SolverConfig>
org.optaplanner.core.config.solver.SolverConfig
To read it from XML, use
createFromXmlResource(String)
.
To build a SolverFactory
with it, use SolverFactory.create(SolverConfig)
.-
Field Summary
Modifier and TypeFieldDescriptionprotected Boolean
protected DomainAccessType
protected EnvironmentMode
protected Map<String,
MemberAccessor> protected Map<String,
SolutionCloner> protected MonitoringConfig
static final String
static final String
protected Integer
protected String
protected List<PhaseConfig>
protected Class<? extends RandomFactory>
protected Long
protected RandomType
protected ScoreDirectorFactoryConfig
protected Class<?>
protected Class<? extends ThreadFactory>
static final String
static final String
static final String
-
Constructor Summary
ConstructorDescriptionCreate an empty solver config.SolverConfig
(ClassLoader classLoader) SolverConfig
(SolverConfig inheritedConfig) Allows you to programmatically change theSolverConfig
per concurrent request, based on a template solver config, by building a separateSolverFactory
withSolverFactory.create(SolverConfig)
and a separateSolver
per request to avoid race conditions. -
Method Summary
Modifier and TypeMethodDescriptionTypically implemented by constructing a new instance and callingAbstractConfig.inherit(AbstractConfig)
on it.static SolverConfig
createFromXmlFile
(File solverConfigFile) Reads an XML solver configuration from the file system.static SolverConfig
createFromXmlFile
(File solverConfigFile, ClassLoader classLoader) As defined bycreateFromXmlFile(File)
.static SolverConfig
static SolverConfig
createFromXmlInputStream
(InputStream in, ClassLoader classLoader) As defined bycreateFromXmlInputStream(InputStream)
.static SolverConfig
createFromXmlReader
(Reader reader) static SolverConfig
createFromXmlReader
(Reader reader, ClassLoader classLoader) As defined bycreateFromXmlReader(Reader)
.static SolverConfig
createFromXmlResource
(String solverConfigResource) Reads an XML solver configuration from the classpath.static SolverConfig
createFromXmlResource
(String solverConfigResource, ClassLoader classLoader) As defined bycreateFromXmlResource(String)
.Class<? extends RandomFactory>
Class<?>
Class<? extends ThreadFactory>
inherit
(SolverConfig inheritedConfig) Do not use this method, it is an internal method.void
offerRandomSeedFromSubSingleIndex
(long subSingleIndex) void
setClassLoader
(ClassLoader classLoader) void
void
setDomainAccessType
(DomainAccessType domainAccessType) void
setEntityClassList
(List<Class<?>> entityClassList) void
setEnvironmentMode
(EnvironmentMode environmentMode) void
setGizmoMemberAccessorMap
(Map<String, MemberAccessor> gizmoMemberAccessorMap) void
setGizmoSolutionClonerMap
(Map<String, SolutionCloner> gizmoSolutionClonerMap) void
setMonitoringConfig
(MonitoringConfig monitoringConfig) void
setMoveThreadBufferSize
(Integer moveThreadBufferSize) void
setMoveThreadCount
(String moveThreadCount) void
setPhaseConfigList
(List<PhaseConfig> phaseConfigList) void
setRandomFactoryClass
(Class<? extends RandomFactory> randomFactoryClass) void
setRandomSeed
(Long randomSeed) void
setRandomType
(RandomType randomType) void
setScoreDirectorFactoryConfig
(ScoreDirectorFactoryConfig scoreDirectorFactoryConfig) void
setSolutionClass
(Class<?> solutionClass) void
setTerminationConfig
(TerminationConfig terminationConfig) void
setThreadFactoryClass
(Class<? extends ThreadFactory> threadFactoryClass) void
visitReferencedClasses
(Consumer<Class<?>> classVisitor) Call the class visitor on each (possibly null) Class instance provided to this config by the user (including those provided in child configs).withConstraintProviderClass
(Class<? extends ConstraintProvider> constraintProviderClass) As defined byScoreDirectorFactoryConfig.withConstraintProviderClass(Class)
, but returns this.withConstraintStreamImplType
(ConstraintStreamImplType constraintStreamImplType) withDaemon
(Boolean daemon) withDomainAccessType
(DomainAccessType domainAccessType) withEasyScoreCalculatorClass
(Class<? extends EasyScoreCalculator> easyScoreCalculatorClass) As defined byScoreDirectorFactoryConfig.withEasyScoreCalculatorClass(Class)
, but returns this.withEntityClasses
(Class<?>... entityClasses) withEntityClassList
(List<Class<?>> entityClassList) withEnvironmentMode
(EnvironmentMode environmentMode) withGizmoMemberAccessorMap
(Map<String, MemberAccessor> memberAccessorMap) withGizmoSolutionClonerMap
(Map<String, SolutionCloner> solutionClonerMap) withMonitoringConfig
(MonitoringConfig monitoringConfig) withMoveThreadBufferSize
(Integer moveThreadBufferSize) withMoveThreadCount
(String moveThreadCount) withPhaseList
(List<PhaseConfig> phaseConfigList) withPhases
(PhaseConfig... phaseConfigs) withRandomFactoryClass
(Class<? extends RandomFactory> randomFactoryClass) withRandomSeed
(Long randomSeed) withRandomType
(RandomType randomType) withScoreDirectorFactory
(ScoreDirectorFactoryConfig scoreDirectorFactoryConfig) withSolutionClass
(Class<?> solutionClass) withTerminationConfig
(TerminationConfig terminationConfig) withTerminationSpentLimit
(Duration spentLimit) As defined byTerminationConfig.withSpentLimit(Duration)
, but returns this.withThreadFactoryClass
(Class<? extends ThreadFactory> threadFactoryClass) Methods inherited from class org.optaplanner.core.config.AbstractConfig
toString
-
Field Details
-
XML_ELEMENT_NAME
- See Also:
-
XML_NAMESPACE
- See Also:
-
XML_TYPE_NAME
- See Also:
-
MOVE_THREAD_COUNT_NONE
- See Also:
-
MOVE_THREAD_COUNT_AUTO
- See Also:
-
environmentMode
-
daemon
-
randomType
-
randomSeed
-
randomFactoryClass
-
moveThreadCount
-
moveThreadBufferSize
-
threadFactoryClass
-
solutionClass
-
entityClassList
-
domainAccessType
-
gizmoMemberAccessorMap
-
gizmoSolutionClonerMap
-
scoreDirectorFactoryConfig
-
phaseConfigList
-
monitoringConfig
-
-
Constructor Details
-
SolverConfig
public SolverConfig()Create an empty solver config. -
SolverConfig
- Parameters:
classLoader
- sometimes null
-
SolverConfig
Allows you to programmatically change theSolverConfig
per concurrent request, based on a template solver config, by building a separateSolverFactory
withSolverFactory.create(SolverConfig)
and a separateSolver
per request to avoid race conditions.- Parameters:
inheritedConfig
- never null
-
-
Method Details
-
createFromXmlResource
Reads an XML solver configuration from the classpath.- Parameters:
solverConfigResource
- never null, a classpath resource as defined byClassLoader.getResource(String)
- Returns:
- never null
-
createFromXmlResource
public static SolverConfig createFromXmlResource(String solverConfigResource, ClassLoader classLoader) As defined bycreateFromXmlResource(String)
.- 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
-
createFromXmlFile
Reads an XML solver configuration from the file system.Warning: this leads to platform dependent code, it's recommend to use
createFromXmlResource(String)
instead.- Parameters:
solverConfigFile
- never null- Returns:
- never null
-
createFromXmlFile
As defined bycreateFromXmlFile(File)
.- Parameters:
solverConfigFile
- never nullclassLoader
- sometimes null, theClassLoader
to use for loading all resources andClass
es, null to use the defaultClassLoader
- Returns:
- never null
-
createFromXmlInputStream
- Parameters:
in
- never null, gets closed- Returns:
- never null
-
createFromXmlInputStream
As defined bycreateFromXmlInputStream(InputStream)
.- Parameters:
in
- never null, gets closedclassLoader
- sometimes null, theClassLoader
to use for loading all resources andClass
es, null to use the defaultClassLoader
- Returns:
- never null
-
createFromXmlReader
- Parameters:
reader
- never null, gets closed- Returns:
- never null
-
createFromXmlReader
As defined bycreateFromXmlReader(Reader)
.- Parameters:
reader
- never null, gets closedclassLoader
- sometimes null, theClassLoader
to use for loading all resources andClass
es, null to use the defaultClassLoader
- Returns:
- never null
-
getClassLoader
-
setClassLoader
-
getEnvironmentMode
-
setEnvironmentMode
-
getDaemon
-
setDaemon
-
getRandomType
-
setRandomType
-
getRandomSeed
-
setRandomSeed
-
getRandomFactoryClass
-
setRandomFactoryClass
-
getMoveThreadCount
-
setMoveThreadCount
-
getMoveThreadBufferSize
-
setMoveThreadBufferSize
-
getThreadFactoryClass
-
setThreadFactoryClass
-
getSolutionClass
-
setSolutionClass
-
getEntityClassList
-
setEntityClassList
-
getDomainAccessType
-
setDomainAccessType
-
getGizmoMemberAccessorMap
-
setGizmoMemberAccessorMap
-
getGizmoSolutionClonerMap
-
setGizmoSolutionClonerMap
-
getScoreDirectorFactoryConfig
-
setScoreDirectorFactoryConfig
-
getTerminationConfig
-
setTerminationConfig
-
getPhaseConfigList
-
setPhaseConfigList
-
getMonitoringConfig
-
setMonitoringConfig
-
withEnvironmentMode
-
withDaemon
-
withRandomType
-
withRandomSeed
-
withRandomFactoryClass
-
withMoveThreadCount
-
withMoveThreadBufferSize
-
withThreadFactoryClass
-
withSolutionClass
-
withEntityClassList
-
withEntityClasses
-
withDomainAccessType
-
withGizmoMemberAccessorMap
-
withGizmoSolutionClonerMap
-
withScoreDirectorFactory
-
withEasyScoreCalculatorClass
public SolverConfig withEasyScoreCalculatorClass(Class<? extends EasyScoreCalculator> easyScoreCalculatorClass) As defined byScoreDirectorFactoryConfig.withEasyScoreCalculatorClass(Class)
, but returns this.- Parameters:
easyScoreCalculatorClass
- sometimes null- Returns:
- this, never null
-
withConstraintProviderClass
public SolverConfig withConstraintProviderClass(Class<? extends ConstraintProvider> constraintProviderClass) As defined byScoreDirectorFactoryConfig.withConstraintProviderClass(Class)
, but returns this.- Parameters:
constraintProviderClass
- sometimes null- Returns:
- this, never null
-
withConstraintStreamImplType
-
withTerminationConfig
-
withTerminationSpentLimit
As defined byTerminationConfig.withSpentLimit(Duration)
, but returns this.- Parameters:
spentLimit
- sometimes null- Returns:
- this, never null
-
withPhaseList
-
withPhases
-
withMonitoringConfig
-
determineEnvironmentMode
-
determineDomainAccessType
-
determineMetricConfig
-
offerRandomSeedFromSubSingleIndex
public void offerRandomSeedFromSubSingleIndex(long subSingleIndex) -
inherit
Do not use this method, it is an internal method. UseSolverConfig(SolverConfig)
instead.- Specified by:
inherit
in classAbstractConfig<SolverConfig>
- Parameters:
inheritedConfig
- never null- Returns:
- this
-
copyConfig
Description copied from class:AbstractConfig
Typically implemented by constructing a new instance and callingAbstractConfig.inherit(AbstractConfig)
on it.- Specified by:
copyConfig
in classAbstractConfig<SolverConfig>
- Returns:
- new instance
-
visitReferencedClasses
Description copied from class:AbstractConfig
Call the class visitor on each (possibly null) Class instance provided to this config by the user (including those provided in child configs). Required to create the bean factory in Quarkus.- Specified by:
visitReferencedClasses
in classAbstractConfig<SolverConfig>
- Parameters:
classVisitor
- The visitor of classes, never null. Can accept null instances of Class.
-