Class SolverScope<Solution_>
java.lang.Object
org.optaplanner.core.impl.solver.scope.SolverScope<Solution_>
- Type Parameters:
 Solution_- the solution type, the class with thePlanningSolutionannotation
- 
Field Summary
FieldsModifier 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 Summary
Constructors - 
Method Summary
Modifier 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
 - 
monitoringTags
protected io.micrometer.core.instrument.Tags monitoringTags - 
startingSolverCount
protected int startingSolverCount - 
workingRandom
 - 
scoreDirector
 - 
runnableThreadSemaphore
Used for capping CPU power usage in multithreaded scenarios. - 
startingSystemTimeMillis
 - 
endingSystemTimeMillis
 - 
childThreadsScoreCalculationCount
protected long childThreadsScoreCalculationCount - 
startingInitializedScore
 - 
bestSolution
 - 
bestScore
 - 
bestSolutionTimeMillis
 - 
stepScoreMap
Used for tracking step score 
 - 
 - 
Constructor Details
- 
SolverScope
public SolverScope() 
 - 
 - 
Method Details
- 
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() - 
getWorkingValueCount
public int getWorkingValueCount() - 
calculateScore
 - 
assertScoreFromScratch
 - 
getStartingInitializedScore
 - 
setStartingInitializedScore
 - 
addChildThreadsScoreCalculationCount
public void addChildThreadsScoreCalculationCount(long addition)  - 
getScoreCalculationCount
public long getScoreCalculationCount() - 
getBestSolution
 - 
setBestSolution
Thebest 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
 - 
startingNow
public void startingNow() - 
getBestSolutionTimeMillisSpent
 - 
endingNow
public void endingNow() - 
isBestSolutionInitialized
public boolean isBestSolutionInitialized() - 
calculateTimeMillisSpentUpToNow
public long calculateTimeMillisSpentUpToNow() - 
getTimeMillisSpent
public long getTimeMillisSpent() - 
getScoreCalculationSpeed
public long getScoreCalculationSpeed()- 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
Termination.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() 
 -