Package org.optaplanner.core.config.solver

## 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, use `createFromXmlResource(String)`. To build a `SolverFactory` with it, use `SolverFactory.create(SolverConfig)`.

- - ### Field Summary

    Fields
    Modifier and Type | Field | Description
    --- | --- | ---
    `protected Boolean` | `daemon` |
    `protected List<Class<?>>` | `entityClassList` |
    `protected EnvironmentMode` | `environmentMode` |
    `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 the `SolverConfig` per concurrent request, based on a template solver config, by building a separate `SolverFactory` with `SolverFactory.create(SolverConfig)` and a separate `Solver` per request to avoid race conditions.

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `SolverConfig` | `copyConfig()` | Typically implemented by constructing a new instance and calling `AbstractConfig.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 by `createFromXmlFile(File)`.
    `static SolverConfig` | `createFromXmlInputStream​(InputStream in)` |
    `static SolverConfig` | `createFromXmlInputStream​(InputStream in, ClassLoader classLoader)` | As defined by `createFromXmlInputStream(InputStream)`.
    `static SolverConfig` | `createFromXmlReader​(Reader reader)` |
    `static SolverConfig` | `createFromXmlReader​(Reader reader, ClassLoader classLoader)` | As defined by `createFromXmlReader(Reader)`.
    `static SolverConfig` | `createFromXmlResource​(String solverConfigResource)` | Reads an XML solver configuration from the classpath.
    `static SolverConfig` | `createFromXmlResource​(String solverConfigResource, ClassLoader classLoader)` | As defined by `createFromXmlResource(String)`.
    `EnvironmentMode` | `determineEnvironmentMode()` |
    `ClassLoader` | `getClassLoader()` |
    `Boolean` | `getDaemon()` |
    `List<Class<?>>` | `getEntityClassList()` |
    `EnvironmentMode` | `getEnvironmentMode()` |
    `Integer` | `getMoveThreadBufferSize()` |
    `String` | `getMoveThreadCount()` |
    `List<PhaseConfig>` | `getPhaseConfigList()` |
    `Class<? extends RandomFactory>` | `getRandomFactoryClass()` |
    `Long` | `getRandomSeed()` |
    `RandomType` | `getRandomType()` |
    `ScoreDirectorFactoryConfig` | `getScoreDirectorFactoryConfig()` |
    `Class<?>` | `getSolutionClass()` |
    `TerminationConfig` | `getTerminationConfig()` |
    `Class<? extends ThreadFactory>` | `getThreadFactoryClass()` |
    `SolverConfig` | `inherit​(SolverConfig inheritedConfig)` | Do not use this method, it is an internal method.
    `void` | `offerRandomSeedFromSubSingleIndex​(long subSingleIndex)` |
    `void` | `setClassLoader​(ClassLoader classLoader)` |
    `void` | `setDaemon​(Boolean daemon)` |
    `void` | `setEntityClassList​(List<Class<?>> entityClassList)` |
    `void` | `setEnvironmentMode​(EnvironmentMode environmentMode)` |
    `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)` |
    `SolverConfig` | `withDaemon​(Boolean daemon)` |
    `SolverConfig` | `withEntityClasses​(Class<?>... entityClasses)` |
    `SolverConfig` | `withEntityClassList​(List<Class<?>> entityClassList)` |
    `SolverConfig` | `withEnvironmentMode​(EnvironmentMode environmentMode)` |
    `SolverConfig` | `withMoveThreadBufferSize​(Integer moveThreadBufferSize)` |
    `SolverConfig` | `withMoveThreadCount​(String moveThreadCount)` |
    `SolverConfig` | `withPhaseList​(List<PhaseConfig> phaseConfigList)` |
    `SolverConfig` | `withPhases​(PhaseConfig... phaseConfigs)` |
    `SolverConfig` | `withRandomFactoryClass​(Class<? extends RandomFactory> randomFactoryClass)` |
    `SolverConfig` | `withRandomSeed​(Long randomSeed)` |
    `SolverConfig` | `withRandomType​(RandomType randomType)` |
    `SolverConfig` | `withScoreDirectorFactory​(ScoreDirectorFactoryConfig scoreDirectorFactoryConfig)` |
    `SolverConfig` | `withSolutionClass​(Class<?> solutionClass)` |
    `SolverConfig` | `withTerminationConfig​(TerminationConfig terminationConfig)` |
    `SolverConfig` | `withThreadFactoryClass​(Class<? extends ThreadFactory> threadFactoryClass)` |

    - ### Methods inherited from class org.optaplanner.core.config.AbstractConfig

      `toString`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### 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

    - #### entityClassList

          protected List<Class<?>> entityClassList

    - #### scoreDirectorFactoryConfig

          protected ScoreDirectorFactoryConfig scoreDirectorFactoryConfig

    - #### phaseConfigList

          protected List<PhaseConfig> phaseConfigList

  - ### 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 the `SolverConfig` per concurrent request, based on a template solver config, by building a separate `SolverFactory` with `SolverFactory.create(SolverConfig)` and a separate `Solver` 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 by `ClassLoader.getResource(String)`
      Returns:
        never null

    - #### createFromXmlResource

          public static SolverConfig createFromXmlResource​(String solverConfigResource,
                                                           ClassLoader classLoader)

      As defined by `createFromXmlResource(String)`.
      Parameters:
        `solverConfigResource` - never null, a classpath resource as defined by `ClassLoader.getResource(String)`
        `classLoader` - sometimes null, the `ClassLoader` to use for loading all resources and `Class`es, null to use the default `ClassLoader`
      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 by `createFromXmlFile(File)`.
      Parameters:
        `solverConfigFile` - never null
        `classLoader` - sometimes null, the `ClassLoader` to use for loading all resources and `Class`es, null to use the default `ClassLoader`
      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 by `createFromXmlInputStream(InputStream)`.
      Parameters:
        `in` - never null, gets closed
        `classLoader` - sometimes null, the `ClassLoader` to use for loading all resources and `Class`es, null to use the default `ClassLoader`
      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 by `createFromXmlReader(Reader)`.
      Parameters:
        `reader` - never null, gets closed
        `classLoader` - sometimes null, the `ClassLoader` to use for loading all resources and `Class`es, null to use the default `ClassLoader`
      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)

    - #### getEntityClassList

          public List<Class<?>> getEntityClassList()

    - #### setEntityClassList

          public void setEntityClassList​(List<Class<?>> entityClassList)

    - #### 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)

    - #### 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)

    - #### withScoreDirectorFactory

          public SolverConfig withScoreDirectorFactory​(ScoreDirectorFactoryConfig scoreDirectorFactoryConfig)

    - #### withTerminationConfig

          public SolverConfig withTerminationConfig​(TerminationConfig terminationConfig)

    - #### withPhaseList

          public SolverConfig withPhaseList​(List<PhaseConfig> phaseConfigList)

    - #### withPhases

          public SolverConfig withPhases​(PhaseConfig... phaseConfigs)

    - #### determineEnvironmentMode

          public EnvironmentMode determineEnvironmentMode()

    - #### offerRandomSeedFromSubSingleIndex

          public void offerRandomSeedFromSubSingleIndex​(long subSingleIndex)

    - #### inherit

          public SolverConfig inherit​(SolverConfig inheritedConfig)

      Do not use this method, it is an internal method. Use `SolverConfig(SolverConfig)` instead.
      Specified by:
        `inherit` in class `AbstractConfig<SolverConfig>`
      Parameters:
        `inheritedConfig` - never null
      Returns:
        this

    - #### copyConfig

          public SolverConfig copyConfig()

      Description copied from class: `AbstractConfig`
      Typically implemented by constructing a new instance and calling `AbstractConfig.inherit(AbstractConfig)` on it
      Specified by:
        `copyConfig` in class `AbstractConfig<SolverConfig>`
      Returns:
        new instance