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 and Description
    --- | ---
    `protected Boolean` | `daemon`
    `protected static long` | `DEFAULT_RANDOM_SEED`
    `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 ScanAnnotatedClassesConfig` | `scanAnnotatedClassesConfig`
    `protected ScoreDirectorFactoryConfig` | `scoreDirectorFactoryConfig`
    `protected Class<?>` | `solutionClass`
    `protected Class<? extends ThreadFactory>` | `threadFactoryClass`

  - ### Constructor Summary

    Constructors
    Constructor and 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 and Description
    --- | ---
    `protected <Solution_> List<Phase<Solution_>>` | `buildPhaseList(HeuristicConfigPolicy configPolicy, BestSolutionRecaller bestSolutionRecaller, Termination termination)`
    `protected RandomFactory` | `buildRandomFactory(EnvironmentMode environmentMode_)`
    `<Solution_> InnerScoreDirectorFactory<Solution_>` | `buildScoreDirectorFactory(SolverConfigContext configContext, EnvironmentMode environmentMode)` Do not use this method, it is an internal method.
    `<Solution_> SolutionDescriptor<Solution_>` | `buildSolutionDescriptor(SolverConfigContext configContext)` Do not use this method, it is an internal method.
    `<Solution_> Solver<Solution_>` | `buildSolver(SolverConfigContext configContext)` Do not use this method, it is an internal method.
    `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()`
    `protected int` | `getAvailableProcessors()`
    `ClassLoader` | `getClassLoader()`
    `Boolean` | `getDaemon()`
    `List<Class<?>>` | `getEntityClassList()`
    `EnvironmentMode` | `getEnvironmentMode()`
    `Integer` | `getMoveThreadBufferSize()`
    `String` | `getMoveThreadCount()`
    `List<PhaseConfig>` | `getPhaseConfigList()`
    `Class<? extends RandomFactory>` | `getRandomFactoryClass()`
    `Long` | `getRandomSeed()`
    `RandomType` | `getRandomType()`
    `ScanAnnotatedClassesConfig` | `getScanAnnotatedClassesConfig()`
    `ScoreDirectorFactoryConfig` | `getScoreDirectorFactoryConfig()`
    `Class<?>` | `getSolutionClass()`
    `TerminationConfig` | `getTerminationConfig()`
    `Class<? extends ThreadFactory>` | `getThreadFactoryClass()`
    `void` | `inherit(SolverConfig inheritedConfig)` Do not use this method, it is an internal method.
    `void` | `offerRandomSeedFromSubSingleIndex(long subSingleIndex)`
    `protected Integer` | `resolveMoveThreadCount()`
    `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` | `setScanAnnotatedClassesConfig(ScanAnnotatedClassesConfig scanAnnotatedClassesConfig)`
    `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

      `copyConfig, deduceEntityDescriptor, deduceVariableDescriptor, deduceVariableDescriptorList, newInstance, toString`

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

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

- - ### Field Detail

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

    - #### DEFAULT_RANDOM_SEED

          protected static final long DEFAULT_RANDOM_SEED

      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

    - #### scanAnnotatedClassesConfig

          protected ScanAnnotatedClassesConfig scanAnnotatedClassesConfig

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

    - #### getScanAnnotatedClassesConfig

          public ScanAnnotatedClassesConfig getScanAnnotatedClassesConfig()

    - #### setScanAnnotatedClassesConfig

          public void setScanAnnotatedClassesConfig(ScanAnnotatedClassesConfig scanAnnotatedClassesConfig)

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

    - #### buildSolver

          public <Solution_> Solver<Solution_> buildSolver(SolverConfigContext configContext)

      Do not use this method, it is an internal method. Use `SolverFactory.buildSolver()` instead.

      Will be removed in 8.0 (by putting it in an InnerSolverConfig).

      Type Parameters:
        `Solution_` - the solution type, the class with the `PlanningSolution` annotation
      Parameters:
        `configContext` - never null
      Returns:
        never null

    - #### buildRandomFactory

          protected RandomFactory buildRandomFactory(EnvironmentMode environmentMode_)

    - #### getAvailableProcessors

          protected int getAvailableProcessors()

    - #### resolveMoveThreadCount

          protected Integer resolveMoveThreadCount()

    - #### buildScoreDirectorFactory

          public <Solution_> InnerScoreDirectorFactory<Solution_> buildScoreDirectorFactory(SolverConfigContext configContext,
                                                                                            EnvironmentMode environmentMode)

      Do not use this method, it is an internal method. Use `SolverFactory.getScoreDirectorFactory()` instead.

      Will be removed in 8.0 (by putting it in an InnerSolverConfig).

      Type Parameters:
        `Solution_` - the solution type, the class with the `PlanningSolution` annotation
      Parameters:
        `configContext` - never null
        `environmentMode` - never null
      Returns:
        never null

    - #### buildSolutionDescriptor

          public <Solution_> SolutionDescriptor<Solution_> buildSolutionDescriptor(SolverConfigContext configContext)

      Do not use this method, it is an internal method.

      Will be removed in 8.0 (by putting it in an InnerSolverConfig).

      Type Parameters:
        `Solution_` - the solution type, the class with the `PlanningSolution` annotation
      Returns:
        never null

    - #### buildPhaseList

          protected <Solution_> List<Phase<Solution_>> buildPhaseList(HeuristicConfigPolicy configPolicy,
                                                                      BestSolutionRecaller bestSolutionRecaller,
                                                                      Termination termination)

    - #### inherit

          public void 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

Copyright © 2006–2020 JBoss by Red Hat. All rights reserved.