Solution_
- the solution type, the class with the PlanningSolution
annotationpublic class DefaultSolverScope<Solution_> extends Object
Modifier and Type | Field and Description |
---|---|
protected Score |
bestScore |
protected Solution_ |
bestSolution |
protected Long |
bestSolutionTimeMillis |
protected Long |
endingSystemTimeMillis |
protected org.slf4j.Logger |
logger |
protected Semaphore |
runnableThreadSemaphore
Used for capping CPU power usage in multi-threaded scenario's
|
protected InnerScoreDirector<Solution_> |
scoreDirector |
protected Score |
startingInitializedScore |
protected int |
startingSolverCount |
protected Long |
startingSystemTimeMillis |
protected Random |
workingRandom |
Constructor and Description |
---|
DefaultSolverScope() |
protected final transient org.slf4j.Logger logger
protected int startingSolverCount
protected Random workingRandom
protected InnerScoreDirector<Solution_> scoreDirector
protected Semaphore runnableThreadSemaphore
protected Long startingSystemTimeMillis
protected Long endingSystemTimeMillis
protected Score startingInitializedScore
protected volatile Solution_ bestSolution
protected volatile Score bestScore
protected Long bestSolutionTimeMillis
public int getStartingSolverCount()
public void setStartingSolverCount(int startingSolverCount)
public Random getWorkingRandom()
public void setWorkingRandom(Random workingRandom)
public InnerScoreDirector<Solution_> getScoreDirector()
public void setScoreDirector(InnerScoreDirector<Solution_> scoreDirector)
public void setRunnableThreadSemaphore(Semaphore runnableThreadSemaphore)
public Long getStartingSystemTimeMillis()
public Long getEndingSystemTimeMillis()
public SolutionDescriptor<Solution_> getSolutionDescriptor()
public ScoreDefinition getScoreDefinition()
public Solution_ getWorkingSolution()
public int getWorkingEntityCount()
public int getWorkingValueCount()
public Score calculateScore()
public void assertExpectedWorkingScore(Score expectedWorkingScore, Object completedAction)
public void assertWorkingScoreFromScratch(Score workingScore, Object completedAction)
public void assertScoreFromScratch(Solution_ solution)
public void assertShadowVariablesAreNotStale(Score workingScore, Object completedAction)
public Score getStartingInitializedScore()
public void setStartingInitializedScore(Score startingInitializedScore)
public long getScoreCalculationCount()
public Solution_ getBestSolution()
public void setBestSolution(Solution_ bestSolution)
best solution
must never be the same instance
as the working solution
, it should be a (un)changed clone.bestSolution
- never nullpublic Score getBestScore()
public void setBestScore(Score bestScore)
public Long getBestSolutionTimeMillis()
public void setBestSolutionTimeMillis(Long bestSolutionTimeMillis)
public void startingNow()
public Long getBestSolutionTimeMillisSpent()
public void endingNow()
public boolean isBestSolutionInitialized()
public long calculateTimeMillisSpentUpToNow()
public long getTimeMillisSpent()
public long getScoreCalculationSpeed()
public void setWorkingSolutionFromBestSolution()
public DefaultSolverScope<Solution_> createChildThreadSolverScope(ChildThreadType childThreadType)
public void initializeYielding()
public void checkYielding()
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 CPU's 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
(so Solver.terminateEarly()
reacts immediately).
Furthermore, this method will
public void destroyYielding()
Copyright © 2006–2016 JBoss by Red Hat. All rights reserved.