public class TestGenDroolsScoreDirector<Solution_> extends DroolsScoreDirector<Solution_>
GLOBAL_SCORE_HOLDER_KEY, kieSession, scoreHolder
allChangesWillBeUndoneBeforeStepEnds, 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
VariableListener s 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()
Explains the
Score of ScoreDirector.calculateScore() by splitting it up per constraint type
(which is usually a score rule). |
Collection<ConstraintMatchTotal> |
getConstraintMatchTotals()
Explains the
Score of ScoreDirector.calculateScore() by splitting it up per constraint type
(which is usually a score rule). |
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, isConstraintMatchEnabled
afterEntityAdded, 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, triggerVariableListeners
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
dispose
public org.kie.api.runtime.KieSession createKieSession()
public void setWorkingSolution(Solution_ workingSolution)
ScoreDirector
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 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()
ScoreDirector
Score
and updates the working solution
accordingly.calculateScore
in interface ScoreDirector<Solution_>
calculateScore
in class DroolsScoreDirector<Solution_>
Score
of the working solution
public void assertShadowVariablesAreNotStale(Score expectedWorkingScore, Object completedAction)
InnerScoreDirector
VariableListener
s 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)
InnerScoreDirector
Score
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()
ScoreDirector
Score
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.
getConstraintMatchTotals
in interface ScoreDirector<Solution_>
getConstraintMatchTotals
in class DroolsScoreDirector<Solution_>
ScoreDirector.getConstraintMatchTotalMap()
,
ScoreDirector.getIndictmentMap()
public Map<String,ConstraintMatchTotal> getConstraintMatchTotalMap()
ScoreDirector
Score
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.
getConstraintMatchTotalMap
in interface ScoreDirector<Solution_>
getConstraintMatchTotalMap
in class DroolsScoreDirector<Solution_>
constraintId
(to create one, use ConstraintMatchTotal.composeConstraintId(String, String)
).ScoreDirector.getIndictmentMap()
public void close()
ScoreDirector
close
in interface AutoCloseable
close
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–2020 JBoss by Red Hat. All rights reserved.