Class TestGenDroolsScoreDirector<Solution_>
- java.lang.Object
-
- org.optaplanner.core.impl.score.director.AbstractScoreDirector<Solution_,DroolsScoreDirectorFactory<Solution_>>
-
- org.optaplanner.core.impl.score.director.drools.DroolsScoreDirector<Solution_>
-
- org.optaplanner.core.impl.score.director.drools.testgen.TestGenDroolsScoreDirector<Solution_>
-
- All Implemented Interfaces:
AutoCloseable,Cloneable,InnerScoreDirector<Solution_>,ScoreDirector<Solution_>
public class TestGenDroolsScoreDirector<Solution_> extends DroolsScoreDirector<Solution_>
-
-
Field Summary
-
Fields inherited from class org.optaplanner.core.impl.score.director.drools.DroolsScoreDirector
GLOBAL_SCORE_HOLDER_KEY, kieSession, scoreHolder
-
Fields inherited from class org.optaplanner.core.impl.score.director.AbstractScoreDirector
allChangesWillBeUndoneBeforeStepEnds, calculationCount, constraintMatchEnabledPreference, logger, lookUpEnabled, lookUpManager, scoreDirectorFactory, variableListenerSupport, workingEntityListRevision, workingInitScore, workingSolution
-
-
Constructor Summary
Constructors Constructor Description TestGenDroolsScoreDirector(DroolsScoreDirectorFactory<Solution_> scoreDirectorFactory, boolean lookUpEnabled, boolean constraintMatchEnabledPreference, List<String> scoreDrlList, List<File> scoreDrlFileList)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidafterEntityAdded(EntityDescriptor<Solution_> entityDescriptor, Object entity)voidafterEntityRemoved(EntityDescriptor<Solution_> entityDescriptor, Object entity)voidafterProblemFactAdded(Object problemFact)voidafterProblemFactRemoved(Object problemFact)voidafterVariableChanged(VariableDescriptor variableDescriptor, Object entity)voidassertShadowVariablesAreNotStale(Score expectedWorkingScore, Object completedAction)Asserts that if allVariableListeners are forcibly triggered, and therefore all shadow variables are updated if needed, that none of the shadow variables of theworking solutionchange, Then also asserts that theScorecalculated for theworking solutionafterwards is equal to the parameterexpectedWorkingScore.voidassertWorkingScoreFromScratch(Score workingScore, Object completedAction)Asserts that if theScoreis calculated for the currentworking solutionin a freshScoreDirector(with no incremental calculation residue), it is equal to the parameterworkingScore.voidbeforeVariableChanged(VariableDescriptor variableDescriptor, Object entity)ScorecalculateScore()Calculates theScoreand updates theworking solutionaccordingly.voidclose()Needs to be called after use because some implementations need to clean up their resources.org.kie.api.runtime.KieSessioncreateKieSession()Map<String,ConstraintMatchTotal>getConstraintMatchTotalMap()Collection<ConstraintMatchTotal>getConstraintMatchTotals()voidsetWorkingSolution(Solution_ workingSolution)Theworking solutionmust never be the same instance as thebest solution, it should be a (un)changed clone.-
Methods inherited from class org.optaplanner.core.impl.score.director.drools.DroolsScoreDirector
afterProblemPropertyChanged, getIndictmentMap, getKieSession, getWorkingFacts, isConstraintMatchEnabled
-
Methods inherited from class org.optaplanner.core.impl.score.director.AbstractScoreDirector
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
-
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.optaplanner.core.impl.score.director.ScoreDirector
dispose
-
-
-
-
Method Detail
-
createKieSession
public org.kie.api.runtime.KieSession createKieSession()
-
setWorkingSolution
public void setWorkingSolution(Solution_ workingSolution)
Description copied from interface:ScoreDirectorTheworking solutionmust never be the same instance as thebest solution, it should be a (un)changed clone.Only call this method on a separate
ScoreDirectorinstance, built bySolverFactory.getScoreDirectorFactory(), not on the one used inside theSolveritself.- Specified by:
setWorkingSolutionin interfaceScoreDirector<Solution_>- Overrides:
setWorkingSolutionin classDroolsScoreDirector<Solution_>- Parameters:
workingSolution- never null
-
calculateScore
public Score calculateScore()
Description copied from interface:ScoreDirectorCalculates theScoreand updates theworking solutionaccordingly.- Specified by:
calculateScorein interfaceScoreDirector<Solution_>- Overrides:
calculateScorein classDroolsScoreDirector<Solution_>- Returns:
- never null, the
Scoreof theworking solution
-
assertShadowVariablesAreNotStale
public void assertShadowVariablesAreNotStale(Score expectedWorkingScore, Object completedAction)
Description copied from interface:InnerScoreDirectorAsserts that if allVariableListeners are forcibly triggered, and therefore all shadow variables are updated if needed, that none of the shadow variables of theworking solutionchange, Then also asserts that theScorecalculated for theworking solutionafterwards is equal to the parameterexpectedWorkingScore.Used to assert that the shadow variables' state is consistent with the genuine variables' state.
- Specified by:
assertShadowVariablesAreNotStalein interfaceInnerScoreDirector<Solution_>- Overrides:
assertShadowVariablesAreNotStalein classAbstractScoreDirector<Solution_,DroolsScoreDirectorFactory<Solution_>>- Parameters:
expectedWorkingScore- never nullcompletedAction- sometimes null, when assertion fails then the completedAction'sObject.toString()is included in the exception message
-
assertWorkingScoreFromScratch
public void assertWorkingScoreFromScratch(Score workingScore, Object completedAction)
Description copied from interface:InnerScoreDirectorAsserts that if theScoreis calculated for the currentworking solutionin a freshScoreDirector(with no incremental calculation residue), it is equal to the parameterworkingScore.Furthermore, if the assert fails, a score corruption analysis might be included in the exception message.
- Specified by:
assertWorkingScoreFromScratchin interfaceInnerScoreDirector<Solution_>- Overrides:
assertWorkingScoreFromScratchin classAbstractScoreDirector<Solution_,DroolsScoreDirectorFactory<Solution_>>- Parameters:
workingScore- never nullcompletedAction- sometimes null, when assertion fails then the completedAction'sObject.toString()is included in the exception message- See Also:
InnerScoreDirectorFactory.assertScoreFromScratch(Solution_)
-
getConstraintMatchTotals
public Collection<ConstraintMatchTotal> getConstraintMatchTotals()
Description copied from interface:ScoreDirectorExplains theScoreofScoreDirector.calculateScore()by splitting it up perConstraint.The sum of
ConstraintMatchTotal.getScore()equalsScoreDirector.calculateScore().Call
ScoreDirector.calculateScore()before calling this method, unless that method has already been called since the lastPlanningVariablechanges.- Specified by:
getConstraintMatchTotalsin interfaceScoreDirector<Solution_>- Overrides:
getConstraintMatchTotalsin classDroolsScoreDirector<Solution_>- Returns:
- never null
- See Also:
ScoreDirector.getConstraintMatchTotalMap(),ScoreDirector.getIndictmentMap()
-
getConstraintMatchTotalMap
public Map<String,ConstraintMatchTotal> getConstraintMatchTotalMap()
Description copied from interface:ScoreDirectorExplains theScoreofScoreDirector.calculateScore()by splitting it up perConstraint.The sum of
ConstraintMatchTotal.getScore()equalsScoreDirector.calculateScore().Call
ScoreDirector.calculateScore()before calling this method, unless that method has already been called since the lastPlanningVariablechanges.- Specified by:
getConstraintMatchTotalMapin interfaceScoreDirector<Solution_>- Overrides:
getConstraintMatchTotalMapin classDroolsScoreDirector<Solution_>- Returns:
- never null, the key is the
constraintId(to create one, useConstraintMatchTotal.composeConstraintId(String, String)). - See Also:
ScoreDirector.getIndictmentMap()
-
close
public void close()
Description copied from interface:ScoreDirectorNeeds to be called after use because some implementations need to clean up their resources.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceScoreDirector<Solution_>- Overrides:
closein classDroolsScoreDirector<Solution_>
-
afterEntityAdded
public void afterEntityAdded(EntityDescriptor<Solution_> entityDescriptor, Object entity)
- Overrides:
afterEntityAddedin classDroolsScoreDirector<Solution_>
-
beforeVariableChanged
public void beforeVariableChanged(VariableDescriptor variableDescriptor, Object entity)
- Specified by:
beforeVariableChangedin interfaceScoreDirector<Solution_>- Overrides:
beforeVariableChangedin classAbstractScoreDirector<Solution_,DroolsScoreDirectorFactory<Solution_>>
-
afterVariableChanged
public void afterVariableChanged(VariableDescriptor variableDescriptor, Object entity)
- Specified by:
afterVariableChangedin interfaceScoreDirector<Solution_>- Overrides:
afterVariableChangedin classDroolsScoreDirector<Solution_>
-
afterEntityRemoved
public void afterEntityRemoved(EntityDescriptor<Solution_> entityDescriptor, Object entity)
- Overrides:
afterEntityRemovedin classDroolsScoreDirector<Solution_>
-
afterProblemFactAdded
public void afterProblemFactAdded(Object problemFact)
- Specified by:
afterProblemFactAddedin interfaceScoreDirector<Solution_>- Overrides:
afterProblemFactAddedin classDroolsScoreDirector<Solution_>
-
afterProblemFactRemoved
public void afterProblemFactRemoved(Object problemFact)
- Specified by:
afterProblemFactRemovedin interfaceScoreDirector<Solution_>- Overrides:
afterProblemFactRemovedin classDroolsScoreDirector<Solution_>
-
-