Class SolverScope<Solution_>

java.lang.Object
ai.timefold.solver.core.impl.solver.scope.SolverScope<Solution_>
Type Parameters:
Solution_ - the solution type, the class with the PlanningSolution annotation

public class SolverScope<Solution_> extends Object
  • Constructor Details

    • SolverScope

      public SolverScope()
    • SolverScope

      public SolverScope(Clock clock)
  • Method Details

    • getClock

      public Clock getClock()
    • getSolver

      public AbstractSolver<Solution_> getSolver()
    • setSolver

      public void setSolver(AbstractSolver<Solution_> solver)
    • getProblemChangeDirector

      public DefaultProblemChangeDirector<Solution_> getProblemChangeDirector()
    • setProblemChangeDirector

      public void setProblemChangeDirector(DefaultProblemChangeDirector<Solution_> problemChangeDirector)
    • getMonitoringTags

      public io.micrometer.core.instrument.Tags getMonitoringTags()
    • setMonitoringTags

      public void setMonitoringTags(io.micrometer.core.instrument.Tags monitoringTags)
    • getStepScoreMap

      public Map<io.micrometer.core.instrument.Tags,ScoreLevels> getStepScoreMap()
    • getSolverMetricSet

      public Set<SolverMetric> getSolverMetricSet()
    • setSolverMetricSet

      public void setSolverMetricSet(EnumSet<SolverMetric> solverMetricSet)
    • getStartingSolverCount

      public int getStartingSolverCount()
    • setStartingSolverCount

      public void setStartingSolverCount(int startingSolverCount)
    • getWorkingRandom

      public Random getWorkingRandom()
    • setWorkingRandom

      public void setWorkingRandom(Random workingRandom)
    • getScoreDirector

      public <Score_ extends Score<Score_>> InnerScoreDirector<Solution_,Score_> getScoreDirector()
    • setScoreDirector

      public void setScoreDirector(InnerScoreDirector<Solution_,?> scoreDirector)
    • setRunnableThreadSemaphore

      public void setRunnableThreadSemaphore(Semaphore runnableThreadSemaphore)
    • getStartingSystemTimeMillis

      public Long getStartingSystemTimeMillis()
    • getEndingSystemTimeMillis

      public Long getEndingSystemTimeMillis()
    • getSolutionDescriptor

      public SolutionDescriptor<Solution_> getSolutionDescriptor()
    • getScoreDefinition

      public ScoreDefinition getScoreDefinition()
    • getWorkingSolution

      public Solution_ getWorkingSolution()
    • getWorkingEntityCount

      public int getWorkingEntityCount()
    • calculateScore

      public <Score_ extends Score<Score_>> InnerScore<Score_> calculateScore()
    • assertScoreFromScratch

      public void assertScoreFromScratch(Solution_ solution)
    • getStartingInitializedScore

      public <Score_ extends Score<Score_>> Score_ getStartingInitializedScore()
    • setStartingInitializedScore

      public void setStartingInitializedScore(Score<?> startingInitializedScore)
    • addChildThreadsScoreCalculationCount

      public void addChildThreadsScoreCalculationCount(long addition)
    • getScoreCalculationCount

      public long getScoreCalculationCount()
    • addMoveEvaluationCount

      public void addMoveEvaluationCount(long addition)
    • getMoveEvaluationCount

      public long getMoveEvaluationCount()
    • getBestSolution

      public Solution_ getBestSolution()
    • setBestSolution

      public void setBestSolution(Solution_ bestSolution)
      The best solution must never be the same instance as the working solution, it should be a (un)changed clone.
      Parameters:
      bestSolution - never null
    • getBestScore

      public <Score_ extends Score<Score_>> InnerScore<Score_> getBestScore()
    • setInitializedBestScore

      public <Score_ extends Score<Score_>> void setInitializedBestScore(Score_ bestScore)
    • setBestScore

      public <Score_ extends Score<Score_>> void setBestScore(InnerScore<Score_> bestScore)
    • getBestSolutionTimeMillis

      public Long getBestSolutionTimeMillis()
    • setBestSolutionTimeMillis

      public void setBestSolutionTimeMillis(Long bestSolutionTimeMillis)
    • getMoveCountTypes

      public Set<String> getMoveCountTypes()
    • getMoveEvaluationCountPerType

      public Map<String,Long> getMoveEvaluationCountPerType()
    • isMetricEnabled

      public boolean isMetricEnabled(SolverMetric solverMetric)
    • startingNow

      public void startingNow()
    • getBestSolutionTimeMillisSpent

      public Long getBestSolutionTimeMillisSpent()
    • endingNow

      public void endingNow()
    • isBestSolutionInitialized

      public boolean isBestSolutionInitialized()
    • calculateTimeMillisSpentUpToNow

      public long calculateTimeMillisSpentUpToNow()
    • getTimeMillisSpent

      public long getTimeMillisSpent()
    • getProblemSizeStatistics

      public ProblemSizeStatistics getProblemSizeStatistics()
    • setProblemSizeStatistics

      public void setProblemSizeStatistics(ProblemSizeStatistics problemSizeStatistics)
    • getScoreCalculationSpeed

      public long getScoreCalculationSpeed()
      Returns:
      at least 0, per second
    • getMoveEvaluationSpeed

      public long getMoveEvaluationSpeed()
      Returns:
      at least 0, per second
    • setWorkingSolutionFromBestSolution

      public void setWorkingSolutionFromBestSolution()
    • createChildThreadSolverScope

      public SolverScope<Solution_> createChildThreadSolverScope(ChildThreadType childThreadType)
    • initializeYielding

      public void initializeYielding()
    • checkYielding

      public void checkYielding()
      Similar to Thread.yield(), but allows capping the number of active solver threads at less than the CPU processor count, so other threads (for example servlet threads that handle REST calls) and other processes (such as SSH) have access to uncontested CPUs and don't suffer any latency.

      Needs to be called before PhaseTermination.isPhaseTerminated(AbstractPhaseScope), so the decision to start a new iteration is after any yield waiting time has been consumed (so Solver.terminateEarly() reacts immediately).

    • destroyYielding

      public void destroyYielding()
    • addMoveEvaluationCountPerType

      public void addMoveEvaluationCountPerType(String moveType, long count)