|
OptaPlanner core 6.1.0.Beta2 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface ScoreDirector
The ScoreDirector holds the workingSolution
and calculates the Score
for that Solution
.
Method Summary | |
---|---|
void |
afterEntityAdded(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 |
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(Object entity)
|
void |
beforeEntityRemoved(Object entity)
|
void |
beforeProblemFactAdded(Object problemFact)
|
void |
beforeProblemFactChanged(Object problemFact)
|
void |
beforeProblemFactRemoved(Object problemFact)
|
void |
beforeVariableChanged(Object entity,
String variableName)
|
Score |
calculateScore()
Calculates the Score and updates the workingSolution accordingly. |
ScoreDirector |
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()
|
Collection<ConstraintMatchTotal> |
getConstraintMatchTotals()
|
ScoreDefinition |
getScoreDefinition()
|
ScoreDirectorFactory |
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 |
isConstraintMatchEnabled()
|
boolean |
isWorkingEntityListDirty(long expectedWorkingEntityListRevision)
|
boolean |
isWorkingSolutionInitialized()
|
void |
setAllChangesWillBeUndoneBeforeStepEnds(boolean allChangesWillBeUndoneBeforeStepEnds)
Do not waste performance by propagating changes to step (or higher) mechanisms. |
void |
setWorkingSolution(Solution workingSolution)
The workingSolution must never be the same instance as the bestSolution ,
it should be a (un)changed clone. |
Method Detail |
---|
Solution getWorkingSolution()
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 calculateScore()
has been called,
the Solution.getScore()
of this Solution
won't be correct.
Score calculateScore()
Score
and updates the workingSolution
accordingly.
Score
of the workingSolution
boolean isConstraintMatchEnabled()
getConstraintMatchTotals()
can be calledCollection<ConstraintMatchTotal> getConstraintMatchTotals()
IllegalStateException
- if isConstraintMatchEnabled()
returns falsevoid beforeEntityAdded(Object entity)
void afterEntityAdded(Object entity)
void beforeVariableChanged(Object entity, String variableName)
void afterVariableChanged(Object entity, String variableName)
void beforeEntityRemoved(Object entity)
void afterEntityRemoved(Object entity)
void beforeProblemFactAdded(Object problemFact)
void afterProblemFactAdded(Object problemFact)
void beforeProblemFactChanged(Object problemFact)
void afterProblemFactChanged(Object problemFact)
void beforeProblemFactRemoved(Object problemFact)
void afterProblemFactRemoved(Object problemFact)
void dispose()
long getWorkingEntityListRevision()
isWorkingEntityListDirty(long)
later onboolean isWorkingEntityListDirty(long expectedWorkingEntityListRevision)
expectedWorkingEntityListRevision
- an
ScoreDirectorFactory getScoreDirectorFactory()
SolutionDescriptor getSolutionDescriptor()
ScoreDefinition getScoreDefinition()
void setWorkingSolution(Solution workingSolution)
workingSolution
must never be the same instance as the bestSolution
,
it should be a (un)changed clone.
workingSolution
- never nullSolution cloneWorkingSolution()
int getWorkingEntityCount()
List<Object> getWorkingEntityList()
int getWorkingValueCount()
int countWorkingSolutionUninitializedVariables()
boolean isWorkingSolutionInitialized()
workingSolution
is initializedlong getCalculateCount()
ScoreDirector clone()
ScoreDirector
and its workingSolution
.
Use 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.
Object getTrailingEntity(GenuineVariableDescriptor chainedVariableDescriptor, Object planningValue)
chainedVariableDescriptor
- never null, must be GenuineVariableDescriptor.isChained()
true
and known to the SolutionDescriptor
planningValue
- sometimes null
void setAllChangesWillBeUndoneBeforeStepEnds(boolean allChangesWillBeUndoneBeforeStepEnds)
allChangesWillBeUndoneBeforeStepEnds
- true if all changes will be undonevoid assertExpectedWorkingScore(Score expectedWorkingScore, Object completedAction)
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 calculateScore()
(when the score is otherwise determined) is correct,
expectedWorkingScore
- never nullcompletedAction
- sometimes null, when assertion fails then the completedAction's Object.toString()
is included in the exception messagevoid assertWorkingScoreFromScratch(Score workingScore, Object completedAction)
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.
workingScore
- never nullcompletedAction
- sometimes null, when assertion fails then the completedAction's Object.toString()
is included* in the exception messageScoreDirectorFactory.assertScoreFromScratch(Solution)
|
OptaPlanner core 6.1.0.Beta2 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |