Class SolverScope<Solution_>
java.lang.Object
org.optaplanner.core.impl.solver.scope.SolverScope<Solution_>
- Type Parameters:
- Solution_- the solution type, the class with the- PlanningSolutionannotation
- 
Field SummaryFieldsModifier and TypeFieldDescriptionprotected Scoreprotected Solution_protected Longprotected longprotected Longprotected io.micrometer.core.instrument.Tagsprotected SemaphoreUsed for capping CPU power usage in multithreaded scenarios.protected InnerScoreDirector<Solution_,?> protected Set<SolverMetric>protected Scoreprotected intprotected Longprotected final Map<io.micrometer.core.instrument.Tags,List<AtomicReference<Number>>> Used for tracking step scoreprotected Random
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionvoidaddChildThreadsScoreCalculationCount(long addition) voidassertScoreFromScratch(Solution_ solution) 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) voidvoidio.micrometer.core.instrument.Tagslonglong<Score_ extends Score<Score_>>
 InnerScoreDirector<Solution_,Score_> intMap<io.micrometer.core.instrument.Tags,List<AtomicReference<Number>>> longintintvoidbooleanbooleanisMetricEnabled(SolverMetric solverMetric) voidsetBestScore(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) voidsetMonitoringTags(io.micrometer.core.instrument.Tags monitoringTags) voidsetProblemChangeDirector(DefaultProblemChangeDirector<Solution_> problemChangeDirector) voidsetRunnableThreadSemaphore(Semaphore runnableThreadSemaphore) voidsetScoreDirector(InnerScoreDirector<Solution_, ?> scoreDirector) voidsetSolverMetricSet(EnumSet<SolverMetric> solverMetricSet) voidsetStartingInitializedScore(Score startingInitializedScore) voidsetStartingSolverCount(int startingSolverCount) voidsetWorkingRandom(Random workingRandom) voidvoid
- 
Field Details- 
solverMetricSet
- 
monitoringTagsprotected io.micrometer.core.instrument.Tags monitoringTags
- 
startingSolverCountprotected int startingSolverCount
- 
workingRandom
- 
scoreDirector
- 
runnableThreadSemaphoreUsed for capping CPU power usage in multithreaded scenarios.
- 
startingSystemTimeMillis
- 
endingSystemTimeMillis
- 
childThreadsScoreCalculationCountprotected long childThreadsScoreCalculationCount
- 
startingInitializedScore
- 
bestSolution
- 
bestScore
- 
bestSolutionTimeMillis
- 
stepScoreMapUsed for tracking step score
 
- 
- 
Constructor Details- 
SolverScopepublic SolverScope()
 
- 
- 
Method Details- 
getProblemChangeDirector
- 
setProblemChangeDirector
- 
getMonitoringTagspublic io.micrometer.core.instrument.Tags getMonitoringTags()
- 
setMonitoringTagspublic void setMonitoringTags(io.micrometer.core.instrument.Tags monitoringTags) 
- 
getStepScoreMap
- 
getSolverMetricSet
- 
setSolverMetricSet
- 
getStartingSolverCountpublic int getStartingSolverCount()
- 
setStartingSolverCountpublic void setStartingSolverCount(int startingSolverCount) 
- 
getWorkingRandom
- 
setWorkingRandom
- 
getScoreDirector
- 
setScoreDirector
- 
setRunnableThreadSemaphore
- 
getStartingSystemTimeMillis
- 
getEndingSystemTimeMillis
- 
getSolutionDescriptor
- 
getScoreDefinition
- 
getWorkingSolution
- 
getWorkingEntityCountpublic int getWorkingEntityCount()
- 
getWorkingValueCountpublic int getWorkingValueCount()
- 
calculateScore
- 
assertScoreFromScratch
- 
getStartingInitializedScore
- 
setStartingInitializedScore
- 
addChildThreadsScoreCalculationCountpublic void addChildThreadsScoreCalculationCount(long addition) 
- 
getScoreCalculationCountpublic long getScoreCalculationCount()
- 
getBestSolution
- 
setBestSolutionThebest solutionmust never be the same instance as theworking solution, it should be a (un)changed clone.- Parameters:
- bestSolution- never null
 
- 
getBestScore
- 
setBestScore
- 
getBestSolutionTimeMillis
- 
setBestSolutionTimeMillis
- 
isMetricEnabled
- 
startingNowpublic void startingNow()
- 
getBestSolutionTimeMillisSpent
- 
endingNowpublic void endingNow()
- 
isBestSolutionInitializedpublic boolean isBestSolutionInitialized()
- 
calculateTimeMillisSpentUpToNowpublic long calculateTimeMillisSpentUpToNow()
- 
getTimeMillisSpentpublic long getTimeMillisSpent()
- 
getScoreCalculationSpeedpublic long getScoreCalculationSpeed()- Returns:
- at least 0, per second
 
- 
setWorkingSolutionFromBestSolutionpublic void setWorkingSolutionFromBestSolution()
- 
createChildThreadSolverScope
- 
initializeYieldingpublic void initializeYielding()
- 
checkYieldingpublic 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 Termination.isPhaseTerminated(AbstractPhaseScope), so the decision to start a new iteration is after any yield waiting time has been consumed (soSolver.terminateEarly()reacts immediately).
- 
destroyYieldingpublic void destroyYielding()
 
-