Class SolverConfig
- java.lang.Object
-
- org.optaplanner.core.config.AbstractConfig<SolverConfig>
-
- org.optaplanner.core.config.solver.SolverConfig
-
public class SolverConfig extends AbstractConfig<SolverConfig>
To read it from XML, usecreateFromXmlResource(String)
. To build aSolverFactory
with it, useSolverFactory.create(SolverConfig)
.
-
-
Field Summary
Fields Modifier and Type Field Description protected Boolean
daemon
protected DomainAccessType
domainAccessType
protected List<Class<?>>
entityClassList
protected EnvironmentMode
environmentMode
protected Map<String,MemberAccessor>
gizmoMemberAccessorMap
protected Map<String,SolutionCloner>
gizmoSolutionClonerMap
protected MonitoringConfig
monitoringConfig
static String
MOVE_THREAD_COUNT_AUTO
static String
MOVE_THREAD_COUNT_NONE
protected Integer
moveThreadBufferSize
protected String
moveThreadCount
protected List<PhaseConfig>
phaseConfigList
protected Class<? extends RandomFactory>
randomFactoryClass
protected Long
randomSeed
protected RandomType
randomType
protected ScoreDirectorFactoryConfig
scoreDirectorFactoryConfig
protected Class<?>
solutionClass
protected Class<? extends ThreadFactory>
threadFactoryClass
static String
XML_ELEMENT_NAME
static String
XML_NAMESPACE
static String
XML_TYPE_NAME
-
Constructor Summary
Constructors Constructor Description SolverConfig()
Create 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
-
Methods inherited from class org.optaplanner.core.config.AbstractConfig
toString
-
-
-
-
Field Detail
-
XML_ELEMENT_NAME
public static final String XML_ELEMENT_NAME
- See Also:
- Constant Field Values
-
XML_NAMESPACE
public static final String XML_NAMESPACE
- See Also:
- Constant Field Values
-
XML_TYPE_NAME
public static final String XML_TYPE_NAME
- See Also:
- Constant Field Values
-
MOVE_THREAD_COUNT_NONE
public static final String MOVE_THREAD_COUNT_NONE
- See Also:
- Constant Field Values
-
MOVE_THREAD_COUNT_AUTO
public static final String MOVE_THREAD_COUNT_AUTO
- See Also:
- Constant Field Values
-
environmentMode
protected EnvironmentMode environmentMode
-
daemon
protected Boolean daemon
-
randomType
protected RandomType randomType
-
randomSeed
protected Long randomSeed
-
randomFactoryClass
protected Class<? extends RandomFactory> randomFactoryClass
-
moveThreadCount
protected String moveThreadCount
-
moveThreadBufferSize
protected Integer moveThreadBufferSize
-
threadFactoryClass
protected Class<? extends ThreadFactory> threadFactoryClass
-
solutionClass
protected Class<?> solutionClass
-
domainAccessType
protected DomainAccessType domainAccessType
-
gizmoMemberAccessorMap
protected Map<String,MemberAccessor> gizmoMemberAccessorMap
-
gizmoSolutionClonerMap
protected Map<String,SolutionCloner> gizmoSolutionClonerMap
-
scoreDirectorFactoryConfig
protected ScoreDirectorFactoryConfig scoreDirectorFactoryConfig
-
phaseConfigList
protected List<PhaseConfig> phaseConfigList
-
monitoringConfig
protected MonitoringConfig monitoringConfig
-
-
Constructor Detail
-
SolverConfig
public SolverConfig()
Create an empty solver config.
-
SolverConfig
public SolverConfig(ClassLoader classLoader)
- Parameters:
classLoader
- sometimes null
-
SolverConfig
public 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.- Parameters:
inheritedConfig
- never null
-
-
Method Detail
-
createFromXmlResource
public static SolverConfig createFromXmlResource(String solverConfigResource)
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
public static SolverConfig createFromXmlFile(File solverConfigFile)
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
public static SolverConfig createFromXmlFile(File solverConfigFile, ClassLoader classLoader)
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
public static SolverConfig createFromXmlInputStream(InputStream in)
- Parameters:
in
- never null, gets closed- Returns:
- never null
-
createFromXmlInputStream
public static SolverConfig createFromXmlInputStream(InputStream in, ClassLoader classLoader)
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
public static SolverConfig createFromXmlReader(Reader reader)
- Parameters:
reader
- never null, gets closed- Returns:
- never null
-
createFromXmlReader
public static SolverConfig createFromXmlReader(Reader reader, ClassLoader classLoader)
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
public ClassLoader getClassLoader()
-
setClassLoader
public void setClassLoader(ClassLoader classLoader)
-
getEnvironmentMode
public EnvironmentMode getEnvironmentMode()
-
setEnvironmentMode
public void setEnvironmentMode(EnvironmentMode environmentMode)
-
getDaemon
public Boolean getDaemon()
-
setDaemon
public void setDaemon(Boolean daemon)
-
getRandomType
public RandomType getRandomType()
-
setRandomType
public void setRandomType(RandomType randomType)
-
getRandomSeed
public Long getRandomSeed()
-
setRandomSeed
public void setRandomSeed(Long randomSeed)
-
getRandomFactoryClass
public Class<? extends RandomFactory> getRandomFactoryClass()
-
setRandomFactoryClass
public void setRandomFactoryClass(Class<? extends RandomFactory> randomFactoryClass)
-
getMoveThreadCount
public String getMoveThreadCount()
-
setMoveThreadCount
public void setMoveThreadCount(String moveThreadCount)
-
getMoveThreadBufferSize
public Integer getMoveThreadBufferSize()
-
setMoveThreadBufferSize
public void setMoveThreadBufferSize(Integer moveThreadBufferSize)
-
getThreadFactoryClass
public Class<? extends ThreadFactory> getThreadFactoryClass()
-
setThreadFactoryClass
public void setThreadFactoryClass(Class<? extends ThreadFactory> threadFactoryClass)
-
getSolutionClass
public Class<?> getSolutionClass()
-
setSolutionClass
public void setSolutionClass(Class<?> solutionClass)
-
getDomainAccessType
public DomainAccessType getDomainAccessType()
-
setDomainAccessType
public void setDomainAccessType(DomainAccessType domainAccessType)
-
getGizmoMemberAccessorMap
public Map<String,MemberAccessor> getGizmoMemberAccessorMap()
-
setGizmoMemberAccessorMap
public void setGizmoMemberAccessorMap(Map<String,MemberAccessor> gizmoMemberAccessorMap)
-
getGizmoSolutionClonerMap
public Map<String,SolutionCloner> getGizmoSolutionClonerMap()
-
setGizmoSolutionClonerMap
public void setGizmoSolutionClonerMap(Map<String,SolutionCloner> gizmoSolutionClonerMap)
-
getScoreDirectorFactoryConfig
public ScoreDirectorFactoryConfig getScoreDirectorFactoryConfig()
-
setScoreDirectorFactoryConfig
public void setScoreDirectorFactoryConfig(ScoreDirectorFactoryConfig scoreDirectorFactoryConfig)
-
getTerminationConfig
public TerminationConfig getTerminationConfig()
-
setTerminationConfig
public void setTerminationConfig(TerminationConfig terminationConfig)
-
getPhaseConfigList
public List<PhaseConfig> getPhaseConfigList()
-
setPhaseConfigList
public void setPhaseConfigList(List<PhaseConfig> phaseConfigList)
-
getMonitoringConfig
public MonitoringConfig getMonitoringConfig()
-
setMonitoringConfig
public void setMonitoringConfig(MonitoringConfig monitoringConfig)
-
withEnvironmentMode
public SolverConfig withEnvironmentMode(EnvironmentMode environmentMode)
-
withDaemon
public SolverConfig withDaemon(Boolean daemon)
-
withRandomType
public SolverConfig withRandomType(RandomType randomType)
-
withRandomSeed
public SolverConfig withRandomSeed(Long randomSeed)
-
withRandomFactoryClass
public SolverConfig withRandomFactoryClass(Class<? extends RandomFactory> randomFactoryClass)
-
withMoveThreadCount
public SolverConfig withMoveThreadCount(String moveThreadCount)
-
withMoveThreadBufferSize
public SolverConfig withMoveThreadBufferSize(Integer moveThreadBufferSize)
-
withThreadFactoryClass
public SolverConfig withThreadFactoryClass(Class<? extends ThreadFactory> threadFactoryClass)
-
withSolutionClass
public SolverConfig withSolutionClass(Class<?> solutionClass)
-
withEntityClassList
public SolverConfig withEntityClassList(List<Class<?>> entityClassList)
-
withEntityClasses
public SolverConfig withEntityClasses(Class<?>... entityClasses)
-
withDomainAccessType
public SolverConfig withDomainAccessType(DomainAccessType domainAccessType)
-
withGizmoMemberAccessorMap
public SolverConfig withGizmoMemberAccessorMap(Map<String,MemberAccessor> memberAccessorMap)
-
withGizmoSolutionClonerMap
public SolverConfig withGizmoSolutionClonerMap(Map<String,SolutionCloner> solutionClonerMap)
-
withScoreDirectorFactory
public SolverConfig withScoreDirectorFactory(ScoreDirectorFactoryConfig scoreDirectorFactoryConfig)
-
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
public SolverConfig withConstraintStreamImplType(ConstraintStreamImplType constraintStreamImplType)
-
withTerminationConfig
public SolverConfig withTerminationConfig(TerminationConfig terminationConfig)
-
withTerminationSpentLimit
public SolverConfig withTerminationSpentLimit(Duration spentLimit)
As defined byTerminationConfig.withSpentLimit(Duration)
, but returns this.- Parameters:
spentLimit
- sometimes null- Returns:
- this, never null
-
withPhaseList
public SolverConfig withPhaseList(List<PhaseConfig> phaseConfigList)
-
withPhases
public SolverConfig withPhases(PhaseConfig... phaseConfigs)
-
withMonitoringConfig
public SolverConfig withMonitoringConfig(MonitoringConfig monitoringConfig)
-
determineEnvironmentMode
public EnvironmentMode determineEnvironmentMode()
-
determineDomainAccessType
public DomainAccessType determineDomainAccessType()
-
determineMetricConfig
public MonitoringConfig determineMetricConfig()
-
offerRandomSeedFromSubSingleIndex
public void offerRandomSeedFromSubSingleIndex(long subSingleIndex)
-
inherit
public SolverConfig inherit(SolverConfig inheritedConfig)
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
public SolverConfig 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
public void visitReferencedClasses(Consumer<Class<?>> classVisitor)
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.
-
-