|
OptaPlanner core 6.2.0.CR2 | |||||||||
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 InnerScoreDirector
public SolutionDescriptor getSolutionDescriptor()
getSolutionDescriptor
in interface InnerScoreDirector
public ScoreDefinition getScoreDefinition()
getScoreDefinition
in interface InnerScoreDirector
public Solution getWorkingSolution()
ScoreDirector
Solution
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 ScoreDirector
public long getWorkingEntityListRevision()
getWorkingEntityListRevision
in interface InnerScoreDirector
InnerScoreDirector.isWorkingEntityListDirty(long)
later onpublic boolean isAllChangesWillBeUndoneBeforeStepEnds()
public void setAllChangesWillBeUndoneBeforeStepEnds(boolean allChangesWillBeUndoneBeforeStepEnds)
InnerScoreDirector
setAllChangesWillBeUndoneBeforeStepEnds
in interface InnerScoreDirector
allChangesWillBeUndoneBeforeStepEnds
- true if all changes will be undonepublic long getCalculateCount()
getCalculateCount
in interface InnerScoreDirector
public void setWorkingSolution(Solution workingSolution)
ScoreDirector
workingSolution
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 ScoreDirector
workingSolution
- never nullpublic boolean isWorkingEntityListDirty(long expectedWorkingEntityListRevision)
isWorkingEntityListDirty
in interface InnerScoreDirector
expectedWorkingEntityListRevision
- an
protected void setWorkingEntityListDirty()
public Solution cloneWorkingSolution()
cloneWorkingSolution
in interface InnerScoreDirector
public int getWorkingEntityCount()
getWorkingEntityCount
in interface InnerScoreDirector
public List<Object> getWorkingEntityList()
getWorkingEntityList
in interface InnerScoreDirector
public int getWorkingValueCount()
getWorkingValueCount
in interface InnerScoreDirector
public int countWorkingSolutionUninitializedVariables()
countWorkingSolutionUninitializedVariables
in interface InnerScoreDirector
public boolean isWorkingSolutionInitialized()
isWorkingSolutionInitialized
in interface InnerScoreDirector
protected void setCalculatedScore(Score score)
public AbstractScoreDirector clone()
InnerScoreDirector
ScoreDirector
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 InnerScoreDirector
clone
in class Object
public void dispose()
ScoreDirector
dispose
in interface ScoreDirector
public Object getTrailingEntity(GenuineVariableDescriptor chainedVariableDescriptor, Object planningValue)
getTrailingEntity
in interface InnerScoreDirector
chainedVariableDescriptor
- never null, must be GenuineVariableDescriptor.isChained()
true
and known to the SolutionDescriptor
planningValue
- sometimes null
public final void beforeEntityAdded(Object entity)
beforeEntityAdded
in interface ScoreDirector
public 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 ScoreDirector
public final void beforeEntityRemoved(Object entity)
beforeEntityRemoved
in interface ScoreDirector
public 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 ScoreDirector
public void afterProblemFactAdded(Object problemFact)
afterProblemFactAdded
in interface ScoreDirector
public void beforeProblemFactChanged(Object problemFact)
beforeProblemFactChanged
in interface ScoreDirector
public void afterProblemFactChanged(Object problemFact)
afterProblemFactChanged
in interface ScoreDirector
public void beforeProblemFactRemoved(Object problemFact)
beforeProblemFactRemoved
in interface ScoreDirector
public void afterProblemFactRemoved(Object problemFact)
afterProblemFactRemoved
in interface ScoreDirector
public void assertExpectedWorkingScore(Score expectedWorkingScore, Object completedAction)
InnerScoreDirector
Score
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 InnerScoreDirector
expectedWorkingScore
- never nullcompletedAction
- sometimes null, when assertion fails then the completedAction's Object.toString()
is included in the exception messagepublic void assertWorkingScoreFromScratch(Score workingScore, Object completedAction)
InnerScoreDirector
Score
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 InnerScoreDirector
workingScore
- 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 core 6.2.0.CR2 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |