Class TestGenDrlScoreDirector<Solution_,Score_ extends Score<Score_>>
- java.lang.Object
-
- org.optaplanner.core.impl.score.director.AbstractScoreDirector<Solution_,Score_,DrlScoreDirectorFactory<Solution_,Score_>>
-
- org.optaplanner.core.impl.score.director.drl.DrlScoreDirector<Solution_,Score_>
-
- org.optaplanner.core.impl.score.director.drl.testgen.TestGenDrlScoreDirector<Solution_,Score_>
-
- All Implemented Interfaces:
AutoCloseable
,Cloneable
,ScoreDirector<Solution_>
,InnerScoreDirector<Solution_,Score_>
public class TestGenDrlScoreDirector<Solution_,Score_ extends Score<Score_>> extends DrlScoreDirector<Solution_,Score_>
-
-
Field Summary
-
Fields inherited from class org.optaplanner.core.impl.score.director.drl.DrlScoreDirector
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 TestGenDrlScoreDirector(DrlScoreDirectorFactory<Solution_,Score_> scoreDirectorFactory, boolean lookUpEnabled, boolean constraintMatchEnabledPreference, List<String> scoreDrlList, List<File> scoreDrlFileList)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method 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 allVariableListener
s are forcibly triggered, and therefore all shadow variables are updated if needed, that none of the shadow variables of theworking solution
change, Then also asserts that theScore
calculated for theworking solution
afterwards is equal to the parameterexpectedWorkingScore
.void
assertWorkingScoreFromScratch(Score_ workingScore, Object completedAction)
Asserts that if theScore
is calculated for the currentworking solution
in a freshScoreDirector
(with no incremental calculation residue), it is equal to the parameterworkingScore
.void
beforeVariableChanged(VariableDescriptor variableDescriptor, Object entity)
Score_
calculateScore()
Calculates theScore
and updates theworking 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<Score_>>
getConstraintMatchTotalMap()
void
setWorkingSolution(Solution_ workingSolution)
Theworking solution
must 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.drl.DrlScoreDirector
afterProblemPropertyChanged, getIndictmentMap, getKieSession, isConstraintMatchEnabled, requiresFlushing
-
Methods inherited from class org.optaplanner.core.impl.score.director.AbstractScoreDirector
afterEntityAdded, afterEntityRemoved, afterVariableChanged, assertExpectedUndoMoveScore, assertExpectedWorkingScore, assertNonNullPlanningIds, assertPredictedScoreFromScratch, beforeEntityAdded, beforeEntityAdded, beforeEntityRemoved, beforeEntityRemoved, beforeProblemFactAdded, beforeProblemFactRemoved, beforeProblemPropertyChanged, beforeVariableChanged, buildScoreCorruptionAnalysis, buildShadowVariableAnalysis, changeVariableFacade, clone, cloneSolution, cloneWorkingSolution, createChildThreadScoreDirector, createShadowVariablesViolationMessage, doAndProcessMove, doAndProcessMove, getCalculationCount, getScoreDefinition, getScoreDirectorFactory, getSolutionDescriptor, getSupplyManager, getWorkingEntityListRevision, getWorkingSolution, isAllChangesWillBeUndoneBeforeStepEnds, isConstraintConfiguration, isConstraintMatchEnabledPreference, isLookUpEnabled, isWorkingEntityListDirty, lookUpWorkingObject, lookUpWorkingObjectOrReturnNull, overwriteConstraintMatchEnabledPreference, resetCalculationCount, setAllChangesWillBeUndoneBeforeStepEnds, setCalculatedScore, setWorkingEntityListDirty, toString, triggerVariableListeners
-
-
-
-
Method Detail
-
createKieSession
public org.kie.api.runtime.KieSession createKieSession()
-
setWorkingSolution
public void setWorkingSolution(Solution_ workingSolution)
Description copied from interface:InnerScoreDirector
Theworking solution
must never be the same instance as thebest solution
, it should be a (un)changed clone.- Specified by:
setWorkingSolution
in interfaceInnerScoreDirector<Solution_,Score_ extends Score<Score_>>
- Overrides:
setWorkingSolution
in classDrlScoreDirector<Solution_,Score_ extends Score<Score_>>
- Parameters:
workingSolution
- never null
-
calculateScore
public Score_ calculateScore()
Description copied from interface:InnerScoreDirector
Calculates theScore
and updates theworking solution
accordingly.- Specified by:
calculateScore
in interfaceInnerScoreDirector<Solution_,Score_ extends Score<Score_>>
- Overrides:
calculateScore
in classDrlScoreDirector<Solution_,Score_ extends Score<Score_>>
- Returns:
- never null, the
Score
of theworking solution
-
assertShadowVariablesAreNotStale
public void assertShadowVariablesAreNotStale(Score_ expectedWorkingScore, Object completedAction)
Description copied from interface:InnerScoreDirector
Asserts that if allVariableListener
s are forcibly triggered, and therefore all shadow variables are updated if needed, that none of the shadow variables of theworking solution
change, Then also asserts that theScore
calculated for theworking solution
afterwards is equal to the parameterexpectedWorkingScore
.Used to assert that the shadow variables' state is consistent with the genuine variables' state.
- Specified by:
assertShadowVariablesAreNotStale
in interfaceInnerScoreDirector<Solution_,Score_ extends Score<Score_>>
- Overrides:
assertShadowVariablesAreNotStale
in classAbstractScoreDirector<Solution_,Score_ extends Score<Score_>,DrlScoreDirectorFactory<Solution_,Score_ extends Score<Score_>>>
- 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:InnerScoreDirector
Asserts that if theScore
is calculated for the currentworking solution
in 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:
assertWorkingScoreFromScratch
in interfaceInnerScoreDirector<Solution_,Score_ extends Score<Score_>>
- Overrides:
assertWorkingScoreFromScratch
in classAbstractScoreDirector<Solution_,Score_ extends Score<Score_>,DrlScoreDirectorFactory<Solution_,Score_ extends Score<Score_>>>
- 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_)
-
getConstraintMatchTotalMap
public Map<String,ConstraintMatchTotal<Score_>> getConstraintMatchTotalMap()
Description copied from interface:InnerScoreDirector
Explains theScore
ofInnerScoreDirector.calculateScore()
by splitting it up perConstraint
.The sum of
ConstraintMatchTotal.getScore()
equalsInnerScoreDirector.calculateScore()
.Call
InnerScoreDirector.calculateScore()
before calling this method, unless that method has already been called since the lastPlanningVariable
changes.- Specified by:
getConstraintMatchTotalMap
in interfaceInnerScoreDirector<Solution_,Score_ extends Score<Score_>>
- Overrides:
getConstraintMatchTotalMap
in classDrlScoreDirector<Solution_,Score_ extends Score<Score_>>
- Returns:
- never null, the key is the
constraintId
(to create one, useConstraintMatchTotal.composeConstraintId(String, String)
). - See Also:
InnerScoreDirector.getIndictmentMap()
-
close
public void close()
Description copied from interface:InnerScoreDirector
Needs to be called after use because some implementations need to clean up their resources.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceInnerScoreDirector<Solution_,Score_ extends Score<Score_>>
- Overrides:
close
in classDrlScoreDirector<Solution_,Score_ extends Score<Score_>>
-
afterEntityAdded
public void afterEntityAdded(EntityDescriptor<Solution_> entityDescriptor, Object entity)
- Overrides:
afterEntityAdded
in classDrlScoreDirector<Solution_,Score_ extends Score<Score_>>
-
beforeVariableChanged
public void beforeVariableChanged(VariableDescriptor variableDescriptor, Object entity)
- Specified by:
beforeVariableChanged
in interfaceInnerScoreDirector<Solution_,Score_ extends Score<Score_>>
- Overrides:
beforeVariableChanged
in classAbstractScoreDirector<Solution_,Score_ extends Score<Score_>,DrlScoreDirectorFactory<Solution_,Score_ extends Score<Score_>>>
-
afterVariableChanged
public void afterVariableChanged(VariableDescriptor variableDescriptor, Object entity)
- Specified by:
afterVariableChanged
in interfaceInnerScoreDirector<Solution_,Score_ extends Score<Score_>>
- Overrides:
afterVariableChanged
in classDrlScoreDirector<Solution_,Score_ extends Score<Score_>>
-
afterEntityRemoved
public void afterEntityRemoved(EntityDescriptor<Solution_> entityDescriptor, Object entity)
- Overrides:
afterEntityRemoved
in classDrlScoreDirector<Solution_,Score_ extends Score<Score_>>
-
afterProblemFactAdded
public void afterProblemFactAdded(Object problemFact)
- Specified by:
afterProblemFactAdded
in interfaceScoreDirector<Solution_>
- Overrides:
afterProblemFactAdded
in classDrlScoreDirector<Solution_,Score_ extends Score<Score_>>
-
afterProblemFactRemoved
public void afterProblemFactRemoved(Object problemFact)
- Specified by:
afterProblemFactRemoved
in interfaceScoreDirector<Solution_>
- Overrides:
afterProblemFactRemoved
in classDrlScoreDirector<Solution_,Score_ extends Score<Score_>>
-
-