Solution_
- the solution type, the class with the PlanningSolution
annotationpublic interface ScoreDirector<Solution_>
working solution
and calculates the Score
for it.Modifier and Type | Method and Description |
---|---|
void |
afterEntityAdded(Object entity) |
void |
afterEntityRemoved(Object entity) |
void |
afterProblemFactAdded(Object problemFact) |
void |
afterProblemFactRemoved(Object problemFact) |
void |
afterProblemPropertyChanged(Object problemFactOrEntity) |
void |
afterVariableChanged(Object entity,
String variableName) |
void |
afterVariableChanged(VariableDescriptor variableDescriptor,
Object entity) |
void |
beforeEntityAdded(Object entity) |
void |
beforeEntityRemoved(Object entity) |
void |
beforeProblemFactAdded(Object problemFact) |
void |
beforeProblemFactRemoved(Object problemFact) |
void |
beforeProblemPropertyChanged(Object problemFactOrEntity) |
void |
beforeVariableChanged(Object entity,
String variableName) |
void |
beforeVariableChanged(VariableDescriptor variableDescriptor,
Object entity) |
Score |
calculateScore()
Calculates the
Score and updates the working solution accordingly. |
void |
changeVariableFacade(VariableDescriptor variableDescriptor,
Object entity,
Object newValue) |
void |
dispose()
Needs to be called after use because some implementations needs to clean up their resources.
|
Collection<ConstraintMatchTotal> |
getConstraintMatchTotals()
Explains the
Score of calculateScore() by splitting it up per constraint type
(which is usually a score rule). |
Map<Object,Indictment> |
getIndictmentMap()
Explains the impact of each planning entity or problem fact on the
Score . |
Solution_ |
getWorkingSolution()
The
PlanningSolution that is used to calculate the Score . |
boolean |
isConstraintMatchEnabled() |
<E> E |
lookUpWorkingObject(E externalObject)
Translates an entity or fact instance (often from another
Thread or JVM)
to this ScoreDirector 's internal working instance. |
void |
setWorkingSolution(Solution_ workingSolution)
The
working solution must never be the same instance as the
best solution , it should be a (un)changed clone. |
void |
triggerVariableListeners() |
Solution_ getWorkingSolution()
PlanningSolution
that is used to calculate the Score
.
Because a Score
is best calculated incrementally (by deltas),
the ScoreDirector
needs to be notified when its working solution
changes.
If the working solution
has been changed since calculateScore()
was called,
its Score
won't be correct.
void setWorkingSolution(Solution_ workingSolution)
working solution
must never be the same instance as the
best solution
, it should be a (un)changed clone.
Only call this method on a separate ScoreDirector
instance,
built by Solver.getScoreDirectorFactory()
,
not on the one used inside the Solver
itself.
workingSolution
- never nullScore calculateScore()
Score
and updates the working solution
accordingly.Score
of the working solution
boolean isConstraintMatchEnabled()
getConstraintMatchTotals()
can be calledCollection<ConstraintMatchTotal> getConstraintMatchTotals()
Score
of calculateScore()
by splitting it up per constraint type
(which is usually a score rule).
The sum of ConstraintMatchTotal.getScoreTotal()
equals calculateScore()
.
IllegalStateException
- if isConstraintMatchEnabled()
returns falseMap<Object,Indictment> getIndictmentMap()
Score
.
An indictment is basically the inverse of getConstraintMatchTotals()
:
it is a Score
total for each justification Object
in ConstraintMatch.getJustificationList()
.
Warning: In practice, it often doesn't include the full impact on the Score
,
for example in DRL score rules with accumulate, the accumulate elements won't be indicted.
The sum of ConstraintMatchTotal.getScoreTotal()
differs from calculateScore()
because each ConstraintMatch.getScore()
is counted
for each justification in ConstraintMatch.getJustificationList()
.
IllegalStateException
- if isConstraintMatchEnabled()
returns falsevoid beforeEntityAdded(Object entity)
void afterEntityAdded(Object entity)
void beforeVariableChanged(VariableDescriptor variableDescriptor, Object entity)
void afterVariableChanged(VariableDescriptor variableDescriptor, Object entity)
void changeVariableFacade(VariableDescriptor variableDescriptor, Object entity, Object newValue)
void triggerVariableListeners()
void beforeEntityRemoved(Object entity)
void afterEntityRemoved(Object entity)
void beforeProblemFactAdded(Object problemFact)
void afterProblemFactAdded(Object problemFact)
void beforeProblemPropertyChanged(Object problemFactOrEntity)
void afterProblemPropertyChanged(Object problemFactOrEntity)
void beforeProblemFactRemoved(Object problemFact)
void afterProblemFactRemoved(Object problemFact)
<E> E lookUpWorkingObject(E externalObject)
Thread
or JVM)
to this ScoreDirector
's internal working instance.
Useful during Move
rebasing and in a ProblemFactChange
.
Matching is determined by the LookUpStrategyType
on PlanningSolution
.
Matching uses a PlanningId
by default.
E
- the object typeexternalObject
- sometimes nullIllegalArgumentException
- if it cannot be located or if the externalObject's class is not supportedIllegalStateException
- if it cannot be locatedvoid dispose()
Copyright © 2006–2017 JBoss by Red Hat. All rights reserved.