public class TestGenDroolsScoreDirector<Solution_> extends DroolsScoreDirector<Solution_>
GLOBAL_SCORE_HOLDER_KEY, kieSession, scoreHolderallChangesWillBeUndoneBeforeStepEnds, calculationCount, constraintMatchEnabledPreference, logger, lookUpEnabled, lookUpManager, scoreDirectorFactory, variableListenerSupport, workingEntityListRevision, workingInitScore, workingSolution| Constructor and Description |
|---|
TestGenDroolsScoreDirector(DroolsScoreDirectorFactory<Solution_> scoreDirectorFactory,
boolean lookUpEnabled,
boolean constraintMatchEnabledPreference,
List<String> scoreDrlList,
List<File> scoreDrlFileList) |
| 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 |
afterVariableChanged(VariableDescriptor variableDescriptor,
Object entity) |
void |
assertShadowVariablesAreNotStale(Score expectedWorkingScore,
Object completedAction)
Asserts that if all
VariableListeners are forcibly triggered,
and therefore all shadow variables are updated if needed,
that none of the shadow variables of the working solution change,
Then also asserts that the Score calculated for the working solution afterwards
is equal to the parameter expectedWorkingScore. |
void |
assertWorkingScoreFromScratch(Score workingScore,
Object completedAction)
Asserts that if the
Score is calculated for the current working solution
in a fresh ScoreDirector (with no incremental calculation residue),
it is equal to the parameter workingScore. |
void |
beforeVariableChanged(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.
|
org.kie.api.runtime.KieSession |
createKieSession() |
Map<String,ConstraintMatchTotal> |
getConstraintMatchTotalMap()
|
Collection<ConstraintMatchTotal> |
getConstraintMatchTotals()
|
void |
setWorkingSolution(Solution_ workingSolution)
The
working solution must never be the same instance as the
best solution, it should be a (un)changed clone. |
afterProblemPropertyChanged, getIndictmentMap, getKieSession, getWorkingFacts, isConstraintMatchEnabledafterEntityAdded, afterEntityRemoved, afterVariableChanged, assertExpectedUndoMoveScore, assertExpectedWorkingScore, assertPredictedScoreFromScratch, beforeEntityAdded, beforeEntityAdded, beforeEntityRemoved, beforeEntityRemoved, beforeProblemFactAdded, beforeProblemFactRemoved, beforeProblemPropertyChanged, 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 org.kie.api.runtime.KieSession createKieSession()
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 SolverFactory.getScoreDirectorFactory(),
not on the one used inside the Solver itself.
setWorkingSolution in interface ScoreDirector<Solution_>setWorkingSolution in class DroolsScoreDirector<Solution_>workingSolution - never nullpublic Score calculateScore()
ScoreDirectorScore and updates the working solution accordingly.calculateScore in interface ScoreDirector<Solution_>calculateScore in class DroolsScoreDirector<Solution_>Score of the working solutionpublic void assertShadowVariablesAreNotStale(Score expectedWorkingScore, Object completedAction)
InnerScoreDirectorVariableListeners are forcibly triggered,
and therefore all shadow variables are updated if needed,
that none of the shadow variables of the working solution change,
Then also asserts that the Score calculated for the working solution afterwards
is equal to the parameter expectedWorkingScore.
Used to assert that the shadow variables' state is consistent with the genuine variables' state.
assertShadowVariablesAreNotStale in interface InnerScoreDirector<Solution_>assertShadowVariablesAreNotStale in class AbstractScoreDirector<Solution_,DroolsScoreDirectorFactory<Solution_>>expectedWorkingScore - never nullcompletedAction - sometimes null, when assertion fails then the completedAction's Object.toString()
is included in the exception messagepublic void assertWorkingScoreFromScratch(Score workingScore, Object completedAction)
InnerScoreDirectorScore is calculated for the current working solution
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.
assertWorkingScoreFromScratch in interface InnerScoreDirector<Solution_>assertWorkingScoreFromScratch in class AbstractScoreDirector<Solution_,DroolsScoreDirectorFactory<Solution_>>workingScore - never nullcompletedAction - sometimes null, when assertion fails then the completedAction's Object.toString()
is included in the exception messageInnerScoreDirectorFactory.assertScoreFromScratch(Solution_)public Collection<ConstraintMatchTotal> getConstraintMatchTotals()
ScoreDirectorScore of ScoreDirector.calculateScore() by splitting it up per Constraint.
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.
getConstraintMatchTotals in interface ScoreDirector<Solution_>getConstraintMatchTotals in class DroolsScoreDirector<Solution_>ScoreDirector.getConstraintMatchTotalMap(),
ScoreDirector.getIndictmentMap()public Map<String,ConstraintMatchTotal> getConstraintMatchTotalMap()
ScoreDirectorScore of ScoreDirector.calculateScore() by splitting it up per Constraint.
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.
getConstraintMatchTotalMap in interface ScoreDirector<Solution_>getConstraintMatchTotalMap in class DroolsScoreDirector<Solution_>constraintId
(to create one, use ConstraintMatchTotal.composeConstraintId(String, String)).ScoreDirector.getIndictmentMap()public void close()
ScoreDirectorclose in interface AutoCloseableclose in interface ScoreDirector<Solution_>close in class DroolsScoreDirector<Solution_>public void afterEntityAdded(EntityDescriptor<Solution_> entityDescriptor, Object entity)
afterEntityAdded in class DroolsScoreDirector<Solution_>public void beforeVariableChanged(VariableDescriptor variableDescriptor, Object entity)
beforeVariableChanged in interface ScoreDirector<Solution_>beforeVariableChanged in class AbstractScoreDirector<Solution_,DroolsScoreDirectorFactory<Solution_>>public void afterVariableChanged(VariableDescriptor variableDescriptor, Object entity)
afterVariableChanged in interface ScoreDirector<Solution_>afterVariableChanged in class DroolsScoreDirector<Solution_>public void afterEntityRemoved(EntityDescriptor<Solution_> entityDescriptor, Object entity)
afterEntityRemoved in class DroolsScoreDirector<Solution_>public void afterProblemFactAdded(Object problemFact)
afterProblemFactAdded in interface ScoreDirector<Solution_>afterProblemFactAdded in class DroolsScoreDirector<Solution_>public void afterProblemFactRemoved(Object problemFact)
afterProblemFactRemoved in interface ScoreDirector<Solution_>afterProblemFactRemoved in class DroolsScoreDirector<Solution_>Copyright © 2006–2021 JBoss by Red Hat. All rights reserved.