Class SolverScope<Solution_>
java.lang.Object
ai.timefold.solver.core.impl.solver.scope.SolverScope<Solution_>
- Type Parameters:
Solution_- the solution type, the class with thePlanningSolutionannotation
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddChildThreadsScoreCalculationCount(long addition) voidaddMoveEvaluationCount(long addition) voidaddMoveEvaluationCountPerType(String moveType, long count) voidassertScoreFromScratch(Solution_ solution) <Score_ extends Score<Score_>>
InnerScore<Score_>longvoidSimilar toThread.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.createChildThreadSolverScope(ChildThreadType childThreadType) voidvoid<Score_ extends Score<Score_>>
InnerScore<Score_>getClock()io.micrometer.core.instrument.Tagslonglonglonglong<Score_ extends Score<Score_>>
InnerScoreDirector<Solution_,Score_> <Score_ extends Score<Score_>>
Score_intMap<io.micrometer.core.instrument.Tags,ScoreLevels> longintvoidbooleanbooleanisMetricEnabled(SolverMetric solverMetric) <Score_ extends Score<Score_>>
voidsetBestScore(InnerScore<Score_> bestScore) voidsetBestSolution(Solution_ bestSolution) Thebest solutionmust never be the same instance as theworking solution, it should be a (un)changed clone.voidsetBestSolutionTimeMillis(Long bestSolutionTimeMillis) <Score_ extends Score<Score_>>
voidsetInitializedBestScore(Score_ bestScore) voidsetMonitoringTags(io.micrometer.core.instrument.Tags monitoringTags) voidsetProblemChangeDirector(DefaultProblemChangeDirector<Solution_> problemChangeDirector) voidsetProblemSizeStatistics(ProblemSizeStatistics problemSizeStatistics) voidsetRunnableThreadSemaphore(Semaphore runnableThreadSemaphore) voidsetScoreDirector(InnerScoreDirector<Solution_, ?> scoreDirector) voidsetSolver(AbstractSolver<Solution_> solver) voidsetSolverMetricSet(EnumSet<SolverMetric> solverMetricSet) voidsetStartingInitializedScore(Score<?> startingInitializedScore) voidsetStartingSolverCount(int startingSolverCount) voidsetWorkingRandom(Random workingRandom) voidvoid
-
Constructor Details
-
SolverScope
public SolverScope() -
SolverScope
-
-
Method Details
-
getClock
-
getSolver
-
setSolver
-
getProblemChangeDirector
-
setProblemChangeDirector
-
getMonitoringTags
public io.micrometer.core.instrument.Tags getMonitoringTags() -
setMonitoringTags
public void setMonitoringTags(io.micrometer.core.instrument.Tags monitoringTags) -
getStepScoreMap
-
getSolverMetricSet
-
setSolverMetricSet
-
getStartingSolverCount
public int getStartingSolverCount() -
setStartingSolverCount
public void setStartingSolverCount(int startingSolverCount) -
getWorkingRandom
-
setWorkingRandom
-
getScoreDirector
-
setScoreDirector
-
setRunnableThreadSemaphore
-
getStartingSystemTimeMillis
-
getEndingSystemTimeMillis
-
getSolutionDescriptor
-
getScoreDefinition
-
getWorkingSolution
-
getWorkingEntityCount
public int getWorkingEntityCount() -
calculateScore
-
assertScoreFromScratch
-
getStartingInitializedScore
-
setStartingInitializedScore
-
addChildThreadsScoreCalculationCount
public void addChildThreadsScoreCalculationCount(long addition) -
getScoreCalculationCount
public long getScoreCalculationCount() -
addMoveEvaluationCount
public void addMoveEvaluationCount(long addition) -
getMoveEvaluationCount
public long getMoveEvaluationCount() -
getBestSolution
-
setBestSolution
Thebest solutionmust never be the same instance as theworking solution, it should be a (un)changed clone.- Parameters:
bestSolution- never null
-
getBestScore
-
setInitializedBestScore
-
setBestScore
-
getBestSolutionTimeMillis
-
setBestSolutionTimeMillis
-
getMoveCountTypes
-
getMoveEvaluationCountPerType
-
isMetricEnabled
-
startingNow
public void startingNow() -
getBestSolutionTimeMillisSpent
-
endingNow
public void endingNow() -
isBestSolutionInitialized
public boolean isBestSolutionInitialized() -
calculateTimeMillisSpentUpToNow
public long calculateTimeMillisSpentUpToNow() -
getTimeMillisSpent
public long getTimeMillisSpent() -
getProblemSizeStatistics
-
setProblemSizeStatistics
-
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
-
initializeYielding
public void initializeYielding() -
checkYielding
public void checkYielding()Similar toThread.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 (soSolver.terminateEarly()reacts immediately). -
destroyYielding
public void destroyYielding() -
addMoveEvaluationCountPerType
-