org.optaplanner.core.impl.score.director.drools
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 |
calculateCount, constraintMatchEnabledPreference, logger, scoreDirectorFactory, trailingEntityMapSupport, variableListenerSupport, workingSolution
Constructor and Description |
---|
DroolsScoreDirector(DroolsScoreDirectorFactory scoreDirectorFactory) |
Modifier and Type | Method and Description |
---|---|
void |
afterEntityAdded(PlanningEntityDescriptor entityDescriptor,
Object entity) |
void |
afterEntityRemoved(PlanningEntityDescriptor entityDescriptor,
Object entity) |
void |
afterProblemFactAdded(Object problemFact) |
void |
afterProblemFactChanged(Object problemFact) |
void |
afterProblemFactRemoved(Object problemFact) |
void |
afterShadowVariableChanged(Object entity,
String variableName) |
void |
afterVariableChanged(PlanningVariableDescriptor variableDescriptor,
Object entity) |
protected void |
appendLegacyConstraintOccurrences(StringBuilder analysis,
ScoreDirector corruptedScoreDirector,
ScoreDirector uncorruptedScoreDirector)
Deprecated.
|
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() |
protected org.kie.api.KieBase |
getKieBase() |
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, assertWorkingScoreFromScratch, beforeEntityAdded, beforeEntityAdded, beforeEntityRemoved, beforeEntityRemoved, beforeProblemFactAdded, beforeProblemFactChanged, beforeProblemFactRemoved, beforeShadowVariableChanged, beforeVariableChanged, beforeVariableChanged, buildScoreCorruptionAnalysis, cloneWorkingSolution, countWorkingSolutionUninitializedVariables, getCalculateCount, getScoreDefinition, getScoreDirectorFactory, getSolutionDescriptor, getTrailingEntity, getWorkingEntityCount, getWorkingEntityList, getWorkingSolution, getWorkingValueCount, isWorkingSolutionInitialized, setCalculatedScore, toString
public static final String GLOBAL_SCORE_HOLDER_KEY
protected org.kie.api.runtime.KieSession kieSession
protected ScoreHolder workingScoreHolder
public DroolsScoreDirector(DroolsScoreDirectorFactory scoreDirectorFactory)
protected org.kie.api.KieBase getKieBase()
public org.kie.api.runtime.KieSession getKieSession()
public void setWorkingSolution(Solution workingSolution)
ScoreDirector
workingSolution
must never be the same instance as the bestSolution
,
it should be a (un)changed clone.setWorkingSolution
in interface ScoreDirector
setWorkingSolution
in class AbstractScoreDirector<DroolsScoreDirectorFactory>
workingSolution
- never nullpublic Collection<Object> getWorkingFacts()
public Score calculateScore()
ScoreDirector
Score
and updates the workingSolution
accordingly.Score
of the workingSolution
public boolean isConstraintMatchEnabled()
isConstraintMatchEnabled
in interface ScoreDirector
isConstraintMatchEnabled
in class AbstractScoreDirector<DroolsScoreDirectorFactory>
ScoreDirector.getConstraintMatchTotals()
can be calledpublic Collection<ConstraintMatchTotal> getConstraintMatchTotals()
getConstraintMatchTotals
in interface ScoreDirector
getConstraintMatchTotals
in class AbstractScoreDirector<DroolsScoreDirectorFactory>
public DroolsScoreDirector clone()
ScoreDirector
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 ScoreDirector
clone
in class AbstractScoreDirector<DroolsScoreDirectorFactory>
public void dispose()
ScoreDirector
dispose
in interface ScoreDirector
dispose
in class AbstractScoreDirector<DroolsScoreDirectorFactory>
public void afterEntityAdded(PlanningEntityDescriptor entityDescriptor, Object entity)
afterEntityAdded
in class AbstractScoreDirector<DroolsScoreDirectorFactory>
public void afterVariableChanged(PlanningVariableDescriptor variableDescriptor, Object entity)
afterVariableChanged
in class AbstractScoreDirector<DroolsScoreDirectorFactory>
public void afterShadowVariableChanged(Object entity, String variableName)
afterShadowVariableChanged
in class AbstractScoreDirector<DroolsScoreDirectorFactory>
public void afterEntityRemoved(PlanningEntityDescriptor entityDescriptor, Object entity)
afterEntityRemoved
in class AbstractScoreDirector<DroolsScoreDirectorFactory>
public void afterProblemFactAdded(Object problemFact)
afterProblemFactAdded
in interface ScoreDirector
afterProblemFactAdded
in class AbstractScoreDirector<DroolsScoreDirectorFactory>
public void afterProblemFactChanged(Object problemFact)
afterProblemFactChanged
in interface ScoreDirector
afterProblemFactChanged
in class AbstractScoreDirector<DroolsScoreDirectorFactory>
public void afterProblemFactRemoved(Object problemFact)
afterProblemFactRemoved
in interface ScoreDirector
afterProblemFactRemoved
in class AbstractScoreDirector<DroolsScoreDirectorFactory>
@Deprecated protected void appendLegacyConstraintOccurrences(StringBuilder analysis, ScoreDirector corruptedScoreDirector, ScoreDirector uncorruptedScoreDirector)
appendLegacyConstraintOccurrences
in class AbstractScoreDirector<DroolsScoreDirectorFactory>
Copyright © 2006-2013 JBoss by Red Hat. All Rights Reserved.