Solution_ - the solution type, the class with the PlanningSolution annotationpublic class DroolsScoreDirector<Solution_> extends AbstractScoreDirector<Solution_,DroolsScoreDirectorFactory<Solution_>>
ScoreDirector, which directs the Rule Engine to calculate the Score
of the working solution.ScoreDirector| Modifier and Type | Field and Description |
|---|---|
static String |
GLOBAL_SCORE_HOLDER_KEY |
protected org.kie.api.runtime.KieSession |
kieSession |
protected ScoreHolder |
workingScoreHolder |
allChangesWillBeUndoneBeforeStepEnds, calculationCount, constraintMatchEnabledPreference, logger, lookUpEnabled, lookUpManager, scoreDirectorFactory, variableListenerSupport, workingEntityListRevision, workingInitScore, workingSolution| Constructor and Description |
|---|
DroolsScoreDirector(DroolsScoreDirectorFactory<Solution_> scoreDirectorFactory,
boolean lookUpEnabled,
boolean constraintMatchEnabledPreference) |
| Modifier and Type | Method and Description |
|---|---|
void |
afterEntityAdded(EntityDescriptor<Solution_> entityDescriptor,
Object entity) |
void |
afterEntityRemoved(EntityDescriptor<Solution_> entityDescriptor,
Object entity) |
void |
afterProblemFactAdded(Object problemFact) |
void |
afterProblemFactRemoved(Object problemFact) |
void |
afterProblemPropertyChanged(Object problemFactOrEntity) |
void |
afterVariableChanged(VariableDescriptor variableDescriptor,
Object entity) |
Score |
calculateScore()
Calculates the
Score and updates the working solution accordingly. |
void |
close()
Needs to be called after use because some implementations need to clean up their resources.
|
Collection<ConstraintMatchTotal> |
getConstraintMatchTotals()
Explains the
Score of ScoreDirector.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. |
org.kie.api.runtime.KieSession |
getKieSession() |
Collection<Object> |
getWorkingFacts() |
boolean |
isConstraintMatchEnabled() |
void |
setWorkingSolution(Solution_ workingSolution)
The
working solution must never be the same instance as the
best solution, it should be a (un)changed clone. |
afterEntityAdded, afterEntityRemoved, afterVariableChanged, assertExpectedUndoMoveScore, assertExpectedWorkingScore, assertPredictedScoreFromScratch, assertShadowVariablesAreNotStale, assertWorkingScoreFromScratch, beforeEntityAdded, beforeEntityAdded, beforeEntityRemoved, beforeEntityRemoved, beforeProblemFactAdded, beforeProblemFactRemoved, beforeProblemPropertyChanged, beforeVariableChanged, beforeVariableChanged, buildScoreCorruptionAnalysis, buildShadowVariableAnalysis, changeVariableFacade, clone, cloneSolution, cloneWorkingSolution, createChildThreadScoreDirector, createShadowVariablesViolationMessage, doAndProcessMove, doAndProcessMove, explainScore, getCalculationCount, getScoreDefinition, getScoreDirectorFactory, getSolutionDescriptor, getSupplyManager, getWorkingEntityCount, getWorkingEntityList, getWorkingEntityListRevision, getWorkingSolution, getWorkingValueCount, isAllChangesWillBeUndoneBeforeStepEnds, isConstraintMatchEnabledPreference, isLookUpEnabled, isWorkingEntityListDirty, lookUpWorkingObject, lookUpWorkingObjectOrReturnNull, overwriteConstraintMatchEnabledPreference, resetCalculationCount, setAllChangesWillBeUndoneBeforeStepEnds, setCalculatedScore, setWorkingEntityListDirty, toString, triggerVariableListenersequals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitdisposepublic static final String GLOBAL_SCORE_HOLDER_KEY
protected org.kie.api.runtime.KieSession kieSession
protected ScoreHolder workingScoreHolder
public DroolsScoreDirector(DroolsScoreDirectorFactory<Solution_> scoreDirectorFactory, boolean lookUpEnabled, boolean constraintMatchEnabledPreference)
public org.kie.api.runtime.KieSession getKieSession()
public void setWorkingSolution(Solution_ workingSolution)
ScoreDirectorworking 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.
setWorkingSolution in interface ScoreDirector<Solution_>setWorkingSolution in class AbstractScoreDirector<Solution_,DroolsScoreDirectorFactory<Solution_>>workingSolution - never nullpublic Collection<Object> getWorkingFacts()
public Score calculateScore()
ScoreDirectorScore and updates the working solution accordingly.Score of the working solutionpublic boolean isConstraintMatchEnabled()
ScoreDirector.getConstraintMatchTotals() can be calledpublic Collection<ConstraintMatchTotal> getConstraintMatchTotals()
ScoreDirectorScore of ScoreDirector.calculateScore() by splitting it up per constraint type
(which is usually a score rule).
The sum of ConstraintMatchTotal.getScore() equals ScoreDirector.calculateScore().
Call ScoreDirector.calculateScore() before calling this method,
unless that method has already been called since the last PlanningVariable changes.
public Map<Object,Indictment> getIndictmentMap()
ScoreDirectorScore.
An indictment is basically the inverse of ScoreDirector.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.getScore() differs from ScoreDirector.calculateScore()
because each ConstraintMatch.getScore() is counted
for each justification in ConstraintMatch.getJustificationList().
Call ScoreDirector.calculateScore() before calling this method,
unless that method has already been called since the last PlanningVariable changes.
public void close()
ScoreDirectorclose in interface AutoCloseableclose in interface ScoreDirector<Solution_>close in class AbstractScoreDirector<Solution_,DroolsScoreDirectorFactory<Solution_>>public void afterEntityAdded(EntityDescriptor<Solution_> entityDescriptor, Object entity)
afterEntityAdded in class AbstractScoreDirector<Solution_,DroolsScoreDirectorFactory<Solution_>>public void afterVariableChanged(VariableDescriptor variableDescriptor, Object entity)
afterVariableChanged in interface ScoreDirector<Solution_>afterVariableChanged in class AbstractScoreDirector<Solution_,DroolsScoreDirectorFactory<Solution_>>public void afterEntityRemoved(EntityDescriptor<Solution_> entityDescriptor, Object entity)
afterEntityRemoved in class AbstractScoreDirector<Solution_,DroolsScoreDirectorFactory<Solution_>>public void afterProblemFactAdded(Object problemFact)
afterProblemFactAdded in interface ScoreDirector<Solution_>afterProblemFactAdded in class AbstractScoreDirector<Solution_,DroolsScoreDirectorFactory<Solution_>>public void afterProblemPropertyChanged(Object problemFactOrEntity)
afterProblemPropertyChanged in interface ScoreDirector<Solution_>afterProblemPropertyChanged in class AbstractScoreDirector<Solution_,DroolsScoreDirectorFactory<Solution_>>public void afterProblemFactRemoved(Object problemFact)
afterProblemFactRemoved in interface ScoreDirector<Solution_>afterProblemFactRemoved in class AbstractScoreDirector<Solution_,DroolsScoreDirectorFactory<Solution_>>Copyright © 2006–2019 JBoss by Red Hat. All rights reserved.