public class DroolsScoreDirector extends AbstractScoreDirector<DroolsScoreDirectorFactory>
ScoreDirector, which directs the Rule Engine to calculate the Score
of the Solution workingSolution.ScoreDirector| Modifier and Type | Field and Description |
|---|---|
static String |
GLOBAL_SCORE_HOLDER_KEY |
protected org.kie.api.runtime.KieSession |
kieSession |
protected ScoreHolder |
workingScoreHolder |
allChangesWillBeUndoneBeforeStepEnds, calculateCount, constraintMatchEnabledPreference, logger, scoreDirectorFactory, variableListenerSupport, workingEntityListRevision, workingSolution| Constructor and Description |
|---|
DroolsScoreDirector(DroolsScoreDirectorFactory scoreDirectorFactory,
boolean constraintMatchEnabledPreference) |
| Modifier and Type | Method and Description |
|---|---|
void |
afterEntityAdded(EntityDescriptor entityDescriptor,
Object entity) |
void |
afterEntityRemoved(EntityDescriptor entityDescriptor,
Object entity) |
void |
afterProblemFactAdded(Object problemFact) |
void |
afterProblemFactChanged(Object problemFact) |
void |
afterProblemFactRemoved(Object problemFact) |
void |
afterVariableChanged(VariableDescriptor variableDescriptor,
Object entity) |
Score |
calculateScore()
Calculates the
Score and updates the workingSolution accordingly. |
DroolsScoreDirector |
clone()
Clones this
ScoreDirector and its workingSolution. |
void |
dispose()
Needs to be called after use because some implementations needs to clean up their resources.
|
Collection<ConstraintMatchTotal> |
getConstraintMatchTotals() |
org.kie.api.runtime.KieSession |
getKieSession() |
Collection<Object> |
getWorkingFacts() |
boolean |
isConstraintMatchEnabled() |
void |
setWorkingSolution(Solution workingSolution)
The
workingSolution must never be the same instance as the bestSolution,
it should be a (un)changed clone. |
afterEntityAdded, afterEntityRemoved, afterVariableChanged, assertExpectedWorkingScore, assertShadowVariablesAreNotStale, assertWorkingScoreFromScratch, beforeEntityAdded, beforeEntityAdded, beforeEntityRemoved, beforeEntityRemoved, beforeProblemFactAdded, beforeProblemFactChanged, beforeProblemFactRemoved, beforeVariableChanged, beforeVariableChanged, buildScoreCorruptionAnalysis, changeVariableFacade, cloneSolution, cloneWorkingSolution, countWorkingSolutionUninitializedVariables, getCalculateCount, getScoreDefinition, getScoreDirectorFactory, getSolutionDescriptor, getSupplyManager, getWorkingEntityCount, getWorkingEntityList, getWorkingEntityListRevision, getWorkingSolution, getWorkingValueCount, isAllChangesWillBeUndoneBeforeStepEnds, isWorkingEntityListDirty, resetCalculateCount, setAllChangesWillBeUndoneBeforeStepEnds, setCalculatedScore, setWorkingEntityListDirty, toString, triggerVariableListenerspublic static final String GLOBAL_SCORE_HOLDER_KEY
protected org.kie.api.runtime.KieSession kieSession
protected ScoreHolder workingScoreHolder
public DroolsScoreDirector(DroolsScoreDirectorFactory scoreDirectorFactory, boolean constraintMatchEnabledPreference)
public org.kie.api.runtime.KieSession getKieSession()
public 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 ScoreDirectorsetWorkingSolution in class AbstractScoreDirector<DroolsScoreDirectorFactory>workingSolution - never nullpublic Collection<Object> getWorkingFacts()
public Score calculateScore()
ScoreDirectorScore and updates the workingSolution accordingly.Score of the workingSolutionpublic boolean isConstraintMatchEnabled()
ScoreDirector.getConstraintMatchTotals() can be calledpublic Collection<ConstraintMatchTotal> getConstraintMatchTotals()
public DroolsScoreDirector 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 AbstractScoreDirector<DroolsScoreDirectorFactory>public void dispose()
ScoreDirectordispose in interface ScoreDirectordispose in class AbstractScoreDirector<DroolsScoreDirectorFactory>public void afterEntityAdded(EntityDescriptor entityDescriptor, Object entity)
afterEntityAdded in class AbstractScoreDirector<DroolsScoreDirectorFactory>public void afterVariableChanged(VariableDescriptor variableDescriptor, Object entity)
afterVariableChanged in interface ScoreDirectorafterVariableChanged in class AbstractScoreDirector<DroolsScoreDirectorFactory>public void afterEntityRemoved(EntityDescriptor entityDescriptor, Object entity)
afterEntityRemoved in class AbstractScoreDirector<DroolsScoreDirectorFactory>public void afterProblemFactAdded(Object problemFact)
afterProblemFactAdded in interface ScoreDirectorafterProblemFactAdded in class AbstractScoreDirector<DroolsScoreDirectorFactory>public void afterProblemFactChanged(Object problemFact)
afterProblemFactChanged in interface ScoreDirectorafterProblemFactChanged in class AbstractScoreDirector<DroolsScoreDirectorFactory>public void afterProblemFactRemoved(Object problemFact)
afterProblemFactRemoved in interface ScoreDirectorafterProblemFactRemoved in class AbstractScoreDirector<DroolsScoreDirectorFactory>Copyright © 2006–2016 JBoss by Red Hat. All rights reserved.