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
 
 public class SolverScope<Solution_> extends Object 
- 
- 
Field SummaryFields Modifier and Type Field Description protected ScorebestScoreprotected Solution_bestSolutionprotected LongbestSolutionTimeMillisprotected longchildThreadsScoreCalculationCountprotected LongendingSystemTimeMillisprotected SemaphorerunnableThreadSemaphoreUsed for capping CPU power usage in multithreaded scenarios.protected InnerScoreDirector<Solution_,?>scoreDirectorprotected ScorestartingInitializedScoreprotected intstartingSolverCountprotected LongstartingSystemTimeMillisprotected RandomworkingRandom
 - 
Constructor SummaryConstructors Constructor Description SolverScope()
 - 
Method Summary
 
- 
- 
- 
Field Detail- 
startingSolverCountprotected int startingSolverCount 
 - 
workingRandomprotected Random workingRandom 
 - 
scoreDirectorprotected InnerScoreDirector<Solution_,?> scoreDirector 
 - 
runnableThreadSemaphoreprotected Semaphore runnableThreadSemaphore Used for capping CPU power usage in multithreaded scenarios.
 - 
startingSystemTimeMillisprotected volatile Long startingSystemTimeMillis 
 - 
endingSystemTimeMillisprotected volatile Long endingSystemTimeMillis 
 - 
childThreadsScoreCalculationCountprotected long childThreadsScoreCalculationCount 
 - 
startingInitializedScoreprotected Score startingInitializedScore 
 - 
bestSolutionprotected volatile Solution_ bestSolution 
 - 
bestScoreprotected volatile Score bestScore 
 - 
bestSolutionTimeMillisprotected Long bestSolutionTimeMillis 
 
- 
 - 
Method Detail- 
getStartingSolverCountpublic int getStartingSolverCount() 
 - 
setStartingSolverCountpublic void setStartingSolverCount(int startingSolverCount) 
 - 
getWorkingRandompublic Random getWorkingRandom() 
 - 
setWorkingRandompublic void setWorkingRandom(Random workingRandom) 
 - 
getScoreDirectorpublic InnerScoreDirector<Solution_,?> getScoreDirector() 
 - 
setScoreDirectorpublic void setScoreDirector(InnerScoreDirector<Solution_,?> scoreDirector) 
 - 
setRunnableThreadSemaphorepublic void setRunnableThreadSemaphore(Semaphore runnableThreadSemaphore) 
 - 
getStartingSystemTimeMillispublic Long getStartingSystemTimeMillis() 
 - 
getEndingSystemTimeMillispublic Long getEndingSystemTimeMillis() 
 - 
getSolutionDescriptorpublic SolutionDescriptor<Solution_> getSolutionDescriptor() 
 - 
getScoreDefinitionpublic ScoreDefinition getScoreDefinition() 
 - 
getWorkingSolutionpublic Solution_ getWorkingSolution() 
 - 
getWorkingEntityCountpublic int getWorkingEntityCount() 
 - 
getWorkingValueCountpublic int getWorkingValueCount() 
 - 
calculateScorepublic Score calculateScore() 
 - 
assertScoreFromScratchpublic void assertScoreFromScratch(Solution_ solution) 
 - 
getStartingInitializedScorepublic Score getStartingInitializedScore() 
 - 
setStartingInitializedScorepublic void setStartingInitializedScore(Score startingInitializedScore) 
 - 
addChildThreadsScoreCalculationCountpublic void addChildThreadsScoreCalculationCount(long addition) 
 - 
getScoreCalculationCountpublic long getScoreCalculationCount() 
 - 
getBestSolutionpublic Solution_ getBestSolution() 
 - 
setBestSolutionpublic void setBestSolution(Solution_ bestSolution) Thebest solutionmust never be the same instance as theworking solution, it should be a (un)changed clone.- Parameters:
- bestSolution- never null
 
 - 
getBestScorepublic Score getBestScore() 
 - 
setBestScorepublic void setBestScore(Score bestScore) 
 - 
getBestSolutionTimeMillispublic Long getBestSolutionTimeMillis() 
 - 
setBestSolutionTimeMillispublic void setBestSolutionTimeMillis(Long bestSolutionTimeMillis) 
 - 
startingNowpublic void startingNow() 
 - 
getBestSolutionTimeMillisSpentpublic Long 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() 
 - 
createChildThreadSolverScopepublic SolverScope<Solution_> createChildThreadSolverScope(ChildThreadType childThreadType) 
 - 
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() 
 
- 
 
-