|
OptaPlanner distribution 6.2.0.CR1 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.optaplanner.core.impl.score.director.AbstractScoreDirector<F>
public abstract class AbstractScoreDirector<F extends AbstractScoreDirectorFactory>
Abstract superclass for ScoreDirector.
ScoreDirector| Field Summary | |
|---|---|
protected boolean |
allChangesWillBeUndoneBeforeStepEnds
|
protected long |
calculateCount
|
protected boolean |
constraintMatchEnabledPreference
|
protected org.slf4j.Logger |
logger
|
protected F |
scoreDirectorFactory
|
protected TrailingEntityMapSupport |
trailingEntityMapSupport
|
protected VariableListenerSupport |
variableListenerSupport
|
protected long |
workingEntityListRevision
|
protected Solution |
workingSolution
|
| Constructor Summary | |
|---|---|
protected |
AbstractScoreDirector(F scoreDirectorFactory,
boolean constraintMatchEnabledPreference)
|
| Method Summary | |
|---|---|
void |
afterEntityAdded(EntityDescriptor entityDescriptor,
Object entity)
|
void |
afterEntityAdded(Object entity)
|
void |
afterEntityRemoved(EntityDescriptor entityDescriptor,
Object entity)
|
void |
afterEntityRemoved(Object entity)
|
void |
afterProblemFactAdded(Object problemFact)
|
void |
afterProblemFactChanged(Object problemFact)
|
void |
afterProblemFactRemoved(Object problemFact)
|
void |
afterVariableChanged(Object entity,
String variableName)
|
void |
afterVariableChanged(VariableDescriptor variableDescriptor,
Object entity)
|
void |
assertExpectedWorkingScore(Score expectedWorkingScore,
Object completedAction)
Asserts that if the Score is calculated for the current workingSolution
in the current ScoreDirector (with possibly incremental calculation residue),
it is equal to the parameter expectedWorkingScore. |
void |
assertWorkingScoreFromScratch(Score workingScore,
Object completedAction)
Asserts that if the Score is calculated for the current workingSolution
in a fresh ScoreDirector (with no incremental calculation residue),
it is equal to the parameter workingScore. |
void |
beforeEntityAdded(EntityDescriptor entityDescriptor,
Object entity)
|
void |
beforeEntityAdded(Object entity)
|
void |
beforeEntityRemoved(EntityDescriptor entityDescriptor,
Object entity)
|
void |
beforeEntityRemoved(Object entity)
|
void |
beforeProblemFactAdded(Object problemFact)
|
void |
beforeProblemFactChanged(Object problemFact)
|
void |
beforeProblemFactRemoved(Object problemFact)
|
void |
beforeVariableChanged(Object entity,
String variableName)
|
void |
beforeVariableChanged(VariableDescriptor variableDescriptor,
Object entity)
|
protected String |
buildScoreCorruptionAnalysis(ScoreDirector uncorruptedScoreDirector)
|
AbstractScoreDirector |
clone()
Clones this ScoreDirector and its workingSolution. |
Solution |
cloneWorkingSolution()
|
int |
countWorkingSolutionUninitializedVariables()
|
void |
dispose()
Needs to be called after use because some implementations needs to clean up their resources. |
long |
getCalculateCount()
|
ScoreDefinition |
getScoreDefinition()
|
F |
getScoreDirectorFactory()
|
SolutionDescriptor |
getSolutionDescriptor()
|
Object |
getTrailingEntity(GenuineVariableDescriptor chainedVariableDescriptor,
Object planningValue)
|
int |
getWorkingEntityCount()
|
List<Object> |
getWorkingEntityList()
|
long |
getWorkingEntityListRevision()
|
Solution |
getWorkingSolution()
The Solution that is used to calculate the Score. |
int |
getWorkingValueCount()
|
boolean |
isAllChangesWillBeUndoneBeforeStepEnds()
|
boolean |
isWorkingEntityListDirty(long expectedWorkingEntityListRevision)
|
boolean |
isWorkingSolutionInitialized()
|
void |
setAllChangesWillBeUndoneBeforeStepEnds(boolean allChangesWillBeUndoneBeforeStepEnds)
Do not waste performance by propagating changes to step (or higher) mechanisms. |
protected void |
setCalculatedScore(Score score)
|
protected void |
setWorkingEntityListDirty()
|
void |
setWorkingSolution(Solution workingSolution)
The workingSolution must never be the same instance as the bestSolution,
it should be a (un)changed clone. |
String |
toString()
|
| Methods inherited from class java.lang.Object |
|---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface org.optaplanner.core.impl.score.director.ScoreDirector |
|---|
calculateScore, getConstraintMatchTotals, isConstraintMatchEnabled |
| Field Detail |
|---|
protected final transient org.slf4j.Logger logger
protected final F extends AbstractScoreDirectorFactory scoreDirectorFactory
protected final boolean constraintMatchEnabledPreference
protected TrailingEntityMapSupport trailingEntityMapSupport
protected VariableListenerSupport variableListenerSupport
protected Solution workingSolution
protected long workingEntityListRevision
protected boolean allChangesWillBeUndoneBeforeStepEnds
protected long calculateCount
| Constructor Detail |
|---|
protected AbstractScoreDirector(F scoreDirectorFactory,
boolean constraintMatchEnabledPreference)
| Method Detail |
|---|
public F getScoreDirectorFactory()
getScoreDirectorFactory in interface InnerScoreDirectorpublic SolutionDescriptor getSolutionDescriptor()
getSolutionDescriptor in interface InnerScoreDirectorpublic ScoreDefinition getScoreDefinition()
getScoreDefinition in interface InnerScoreDirectorpublic Solution getWorkingSolution()
ScoreDirectorSolution that is used to calculate the Score.
Because a Score is best calculated incrementally (by delta's),
the ScoreDirector needs to be notified when it's workingSolution changes.
If the Solution has been changed since ScoreDirector.calculateScore() has been called,
the Solution.getScore() of this Solution won't be correct.
getWorkingSolution in interface ScoreDirectorpublic long getWorkingEntityListRevision()
getWorkingEntityListRevision in interface InnerScoreDirectorInnerScoreDirector.isWorkingEntityListDirty(long) later onpublic boolean isAllChangesWillBeUndoneBeforeStepEnds()
public void setAllChangesWillBeUndoneBeforeStepEnds(boolean allChangesWillBeUndoneBeforeStepEnds)
InnerScoreDirector
setAllChangesWillBeUndoneBeforeStepEnds in interface InnerScoreDirectorallChangesWillBeUndoneBeforeStepEnds - true if all changes will be undonepublic long getCalculateCount()
getCalculateCount in interface InnerScoreDirectorpublic void setWorkingSolution(Solution workingSolution)
ScoreDirectorworkingSolution must never be the same instance as the bestSolution,
it should be a (un)changed clone.
Only call this method on a separate ScoreDirector instance,
build by Solver.getScoreDirectorFactory(),
not on the one used inside the Solver itself.
setWorkingSolution in interface ScoreDirectorworkingSolution - never nullpublic boolean isWorkingEntityListDirty(long expectedWorkingEntityListRevision)
isWorkingEntityListDirty in interface InnerScoreDirectorexpectedWorkingEntityListRevision - an
protected void setWorkingEntityListDirty()
public Solution cloneWorkingSolution()
cloneWorkingSolution in interface InnerScoreDirectorpublic int getWorkingEntityCount()
getWorkingEntityCount in interface InnerScoreDirectorpublic List<Object> getWorkingEntityList()
getWorkingEntityList in interface InnerScoreDirectorpublic int getWorkingValueCount()
getWorkingValueCount in interface InnerScoreDirectorpublic int countWorkingSolutionUninitializedVariables()
countWorkingSolutionUninitializedVariables in interface InnerScoreDirectorpublic boolean isWorkingSolutionInitialized()
isWorkingSolutionInitialized in interface InnerScoreDirectorprotected void setCalculatedScore(Score score)
public AbstractScoreDirector clone()
InnerScoreDirectorScoreDirector and its workingSolution.
Use ScoreDirector.getWorkingSolution() to retrieve the workingSolution of that clone.
This is heavy method, because it usually breaks incremental score calculation. Use it sparingly.
Therefore it's best to clone lazily by delaying the clone call as long as possible.
clone in interface InnerScoreDirectorclone in class Objectpublic void dispose()
ScoreDirector
dispose in interface ScoreDirector
public Object getTrailingEntity(GenuineVariableDescriptor chainedVariableDescriptor,
Object planningValue)
getTrailingEntity in interface InnerScoreDirectorchainedVariableDescriptor - never null, must be GenuineVariableDescriptor.isChained() true
and known to the SolutionDescriptorplanningValue - sometimes null
public final void beforeEntityAdded(Object entity)
beforeEntityAdded in interface ScoreDirectorpublic final void afterEntityAdded(Object entity)
afterEntityAdded in interface ScoreDirector
public final void beforeVariableChanged(Object entity,
String variableName)
beforeVariableChanged in interface ScoreDirector
public final void afterVariableChanged(Object entity,
String variableName)
afterVariableChanged in interface ScoreDirectorpublic final void beforeEntityRemoved(Object entity)
beforeEntityRemoved in interface ScoreDirectorpublic final void afterEntityRemoved(Object entity)
afterEntityRemoved in interface ScoreDirector
public void beforeEntityAdded(EntityDescriptor entityDescriptor,
Object entity)
public void afterEntityAdded(EntityDescriptor entityDescriptor,
Object entity)
public void beforeVariableChanged(VariableDescriptor variableDescriptor,
Object entity)
beforeVariableChanged in interface ScoreDirector
public void afterVariableChanged(VariableDescriptor variableDescriptor,
Object entity)
afterVariableChanged in interface ScoreDirector
public void beforeEntityRemoved(EntityDescriptor entityDescriptor,
Object entity)
public void afterEntityRemoved(EntityDescriptor entityDescriptor,
Object entity)
public void beforeProblemFactAdded(Object problemFact)
beforeProblemFactAdded in interface ScoreDirectorpublic void afterProblemFactAdded(Object problemFact)
afterProblemFactAdded in interface ScoreDirectorpublic void beforeProblemFactChanged(Object problemFact)
beforeProblemFactChanged in interface ScoreDirectorpublic void afterProblemFactChanged(Object problemFact)
afterProblemFactChanged in interface ScoreDirectorpublic void beforeProblemFactRemoved(Object problemFact)
beforeProblemFactRemoved in interface ScoreDirectorpublic void afterProblemFactRemoved(Object problemFact)
afterProblemFactRemoved in interface ScoreDirector
public void assertExpectedWorkingScore(Score expectedWorkingScore,
Object completedAction)
InnerScoreDirectorScore is calculated for the current workingSolution
in the current ScoreDirector (with possibly incremental calculation residue),
it is equal to the parameter expectedWorkingScore.
Used to assert that skipping ScoreDirector.calculateScore() (when the score is otherwise determined) is correct,
assertExpectedWorkingScore in interface InnerScoreDirectorexpectedWorkingScore - never nullcompletedAction - sometimes null, when assertion fails then the completedAction's Object.toString()
is included in the exception message
public void assertWorkingScoreFromScratch(Score workingScore,
Object completedAction)
InnerScoreDirectorScore is calculated for the current workingSolution
in a fresh ScoreDirector (with no incremental calculation residue),
it is equal to the parameter workingScore.
Furthermore, if the assert fails, a score corruption analysis might be included in the exception message.
assertWorkingScoreFromScratch in interface InnerScoreDirectorworkingScore - never nullcompletedAction - sometimes null, when assertion fails then the completedAction's Object.toString()
is included* in the exception messageInnerScoreDirectorFactory.assertScoreFromScratch(Solution)protected String buildScoreCorruptionAnalysis(ScoreDirector uncorruptedScoreDirector)
uncorruptedScoreDirector - never null
public String toString()
toString in class Object
|
OptaPlanner distribution 6.2.0.CR1 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||