Class AbstractScoreDirector<Solution_,Score_ extends Score<Score_>,Factory_ extends AbstractScoreDirectorFactory<Solution_,Score_>>
- All Implemented Interfaces:
AutoCloseable
,Cloneable
,ScoreDirector<Solution_>
,InnerScoreDirector<Solution_,
Score_>
- Direct Known Subclasses:
DrlScoreDirector
,EasyScoreDirector
,IncrementalScoreDirector
ScoreDirector
.
Implementation note: Extending classes should follow these guidelines:
- before* method: last statement should be a call to the super method
- after* method: first statement should be a call to the super method
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionprotected boolean
protected long
protected boolean
protected final org.slf4j.Logger
protected final boolean
protected final LookUpManager
protected final Factory_
protected final VariableListenerSupport<Solution_>
protected long
protected Integer
protected Solution_
-
Constructor Summary
ModifierConstructorDescriptionprotected
AbstractScoreDirector
(Factory_ scoreDirectorFactory, boolean lookUpEnabled, boolean constraintMatchEnabledPreference) -
Method Summary
Modifier and TypeMethodDescriptionfinal void
afterEntityAdded
(Object entity) void
afterEntityAdded
(EntityDescriptor<Solution_> entityDescriptor, Object entity) final void
afterEntityRemoved
(Object entity) void
afterEntityRemoved
(EntityDescriptor<Solution_> entityDescriptor, Object entity) void
afterListVariableChanged
(Object entity, String variableName, int fromIndex, int toIndex) void
afterListVariableChanged
(ListVariableDescriptor<Solution_> variableDescriptor, Object entity, int fromIndex, int toIndex) Notify the score director after a list variable changes.void
afterListVariableElementAssigned
(Object entity, String variableName, Object element) void
afterListVariableElementAssigned
(ListVariableDescriptor<Solution_> variableDescriptor, Object element) Call this for each element that was assigned (added to a list variable of one entity without being removed from a list variable of another entity).void
afterListVariableElementUnassigned
(Object entity, String variableName, Object element) void
afterListVariableElementUnassigned
(ListVariableDescriptor<Solution_> variableDescriptor, Object element) Call this for each element that was unassigned (removed from a list variable of one entity without being added to a list variable of another entity).void
afterProblemFactAdded
(Object problemFact) void
afterProblemFactRemoved
(Object problemFact) void
afterProblemPropertyChanged
(Object problemFactOrEntity) final void
afterVariableChanged
(Object entity, String variableName) void
afterVariableChanged
(VariableDescriptor<Solution_> variableDescriptor, Object entity) void
assertExpectedUndoMoveScore
(Move<Solution_> move, Score_ beforeMoveScore) Asserts that if theScore
is calculated for the currentworking solution
in the currentScoreDirector
(with incremental calculation residue), it is equal to the parameterbeforeMoveScore
.void
assertExpectedWorkingScore
(Score_ expectedWorkingScore, Object completedAction) Asserts that if theScore
is calculated for the currentworking solution
in the currentScoreDirector
(with possibly incremental calculation residue), it is equal to the parameterexpectedWorkingScore
.void
Asserts that none of the planning facts fromScoreDirector.getWorkingSolution()
havePlanningId
s with a null value.void
assertPredictedScoreFromScratch
(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 parameterpredictedScore
.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
.final void
beforeEntityAdded
(Object entity) void
beforeEntityAdded
(EntityDescriptor<Solution_> entityDescriptor, Object entity) final void
beforeEntityRemoved
(Object entity) void
beforeEntityRemoved
(EntityDescriptor<Solution_> entityDescriptor, Object entity) void
beforeListVariableChanged
(Object entity, String variableName, int fromIndex, int toIndex) void
beforeListVariableChanged
(ListVariableDescriptor<Solution_> variableDescriptor, Object entity, int fromIndex, int toIndex) Notify the score director before a list variable changes.void
beforeListVariableElementAssigned
(Object entity, String variableName, Object element) void
beforeListVariableElementAssigned
(ListVariableDescriptor<Solution_> variableDescriptor, Object element) Call this for each element that will be assigned (added to a list variable of one entity without being removed from a list variable of another entity).void
beforeListVariableElementUnassigned
(Object entity, String variableName, Object element) void
beforeListVariableElementUnassigned
(ListVariableDescriptor<Solution_> variableDescriptor, Object element) Call this for each element that will be unassigned (removed from a list variable of one entity without being added to a list variable of another entity).void
beforeProblemFactAdded
(Object problemFact) void
beforeProblemFactRemoved
(Object problemFact) void
beforeProblemPropertyChanged
(Object problemFactOrEntity) final void
beforeVariableChanged
(Object entity, String variableName) void
beforeVariableChanged
(VariableDescriptor<Solution_> variableDescriptor, Object entity) protected String
buildScoreCorruptionAnalysis
(InnerScoreDirector<Solution_, Score_> uncorruptedScoreDirector, boolean predicted) protected String
buildShadowVariableAnalysis
(boolean predicted) void
changeVariableFacade
(VariableDescriptor<Solution_> variableDescriptor, Object entity, Object newValue) clone()
Clones thisScoreDirector
and itsworking solution
.cloneSolution
(Solution_ originalSolution) Returns a planning clone of the solution, which is not a shallow clone nor a deep clone nor a partition clone.Returns a planning clone of the solution, which is not a shallow clone nor a deep clone nor a partition clone.void
close()
Needs to be called after use because some implementations need to clean up their resources.createChildThreadScoreDirector
(ChildThreadType childThreadType) doAndProcessMove
(Move<Solution_> move, boolean assertMoveScoreFromScratch) void
doAndProcessMove
(Move<Solution_> move, boolean assertMoveScoreFromScratch, Consumer<Score_> moveProcessor) void
UnlikeScoreDirector.triggerVariableListeners()
which only triggers notifications already in the queue, this triggers every variable listener on every genuine variable.long
long
ThePlanningSolution
that is used to calculate theScore
.void
protected boolean
isConstraintConfiguration
(Object problemFactOrEntity) boolean
isWorkingEntityListDirty
(long expectedWorkingEntityListRevision) <E> E
lookUpWorkingObject
(E externalObject) Translates an entity or fact instance (often from anotherThread
or JVM) to thisScoreDirector
's internal working instance.<E> E
lookUpWorkingObjectOrReturnNull
(E externalObject) As defined byScoreDirector.lookUpWorkingObject(Object)
, but doesn't fail fast if no workingObject was ever added for the externalObject.void
overwriteConstraintMatchEnabledPreference
(boolean constraintMatchEnabledPreference) void
void
setAllChangesWillBeUndoneBeforeStepEnds
(boolean allChangesWillBeUndoneBeforeStepEnds) Do not waste performance by propagating changes to step (or higher) mechanisms.protected void
setCalculatedScore
(Score_ score) protected void
void
setWorkingSolution
(Solution_ workingSolution) Note: resetting the working solution does NOT substitute the calls to before/after methods of theProblemChangeDirector
duringproblem changes
, as these calls are propagated tovariable listeners
, which update shadow variables in theworking solution
to keep it consistent.toString()
void
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.InnerScoreDirector
calculateScore, getConstraintMatchTotalMap, getIndictmentMap, isConstraintMatchEnabled, requiresFlushing
-
Field Details
-
logger
protected final transient org.slf4j.Logger logger -
scoreDirectorFactory
protected final Factory_ extends AbstractScoreDirectorFactory<Solution_,Score_> scoreDirectorFactory -
lookUpEnabled
protected final boolean lookUpEnabled -
lookUpManager
-
constraintMatchEnabledPreference
protected boolean constraintMatchEnabledPreference -
variableListenerSupport
-
workingSolution
-
workingEntityListRevision
protected long workingEntityListRevision -
workingInitScore
-
allChangesWillBeUndoneBeforeStepEnds
protected boolean allChangesWillBeUndoneBeforeStepEnds -
calculationCount
protected long calculationCount
-
-
Constructor Details
-
AbstractScoreDirector
protected AbstractScoreDirector(Factory_ scoreDirectorFactory, boolean lookUpEnabled, boolean constraintMatchEnabledPreference)
-
-
Method Details
-
getScoreDirectorFactory
- Specified by:
getScoreDirectorFactory
in interfaceInnerScoreDirector<Solution_,
Score_ extends Score<Score_>> - Returns:
- never null
-
getSolutionDescriptor
- Specified by:
getSolutionDescriptor
in interfaceInnerScoreDirector<Solution_,
Score_ extends Score<Score_>> - Returns:
- never null
-
getScoreDefinition
- Specified by:
getScoreDefinition
in interfaceInnerScoreDirector<Solution_,
Score_ extends Score<Score_>> - Returns:
- never null
-
overwriteConstraintMatchEnabledPreference
public void overwriteConstraintMatchEnabledPreference(boolean constraintMatchEnabledPreference) - Specified by:
overwriteConstraintMatchEnabledPreference
in interfaceInnerScoreDirector<Solution_,
Score_ extends Score<Score_>> - Parameters:
constraintMatchEnabledPreference
- false if aScoreDirector
implementation should not doConstraintMatch
tracking even if it supports it.
-
getWorkingSolution
Description copied from interface:ScoreDirector
ThePlanningSolution
that is used to calculate theScore
.Because a
Score
is best calculated incrementally (by deltas), theScoreDirector
needs to be notified when itsworking solution
changes.- Specified by:
getWorkingSolution
in interfaceScoreDirector<Solution_>
- Returns:
- never null
-
getWorkingEntityListRevision
public long getWorkingEntityListRevision()- Specified by:
getWorkingEntityListRevision
in interfaceInnerScoreDirector<Solution_,
Score_ extends Score<Score_>> - Returns:
- used to check
InnerScoreDirector.isWorkingEntityListDirty(long)
later on
-
setAllChangesWillBeUndoneBeforeStepEnds
public void setAllChangesWillBeUndoneBeforeStepEnds(boolean allChangesWillBeUndoneBeforeStepEnds) Description copied from interface:InnerScoreDirector
Do not waste performance by propagating changes to step (or higher) mechanisms.- Specified by:
setAllChangesWillBeUndoneBeforeStepEnds
in interfaceInnerScoreDirector<Solution_,
Score_ extends Score<Score_>> - Parameters:
allChangesWillBeUndoneBeforeStepEnds
- true if all changes will be undone
-
getCalculationCount
public long getCalculationCount()- Specified by:
getCalculationCount
in interfaceInnerScoreDirector<Solution_,
Score_ extends Score<Score_>> - Returns:
- at least 0L
-
resetCalculationCount
public void resetCalculationCount()- Specified by:
resetCalculationCount
in interfaceInnerScoreDirector<Solution_,
Score_ extends Score<Score_>>
-
incrementCalculationCount
public void incrementCalculationCount()- Specified by:
incrementCalculationCount
in interfaceInnerScoreDirector<Solution_,
Score_ extends Score<Score_>>
-
getSupplyManager
- Specified by:
getSupplyManager
in interfaceInnerScoreDirector<Solution_,
Score_ extends Score<Score_>> - Returns:
- never null
-
setWorkingSolution
Note: resetting the working solution does NOT substitute the calls to before/after methods of theProblemChangeDirector
duringproblem changes
, as these calls are propagated tovariable listeners
, which update shadow variables in theworking solution
to keep it consistent.- Specified by:
setWorkingSolution
in interfaceInnerScoreDirector<Solution_,
Score_ extends Score<Score_>> - Parameters:
workingSolution
- never null
-
assertNonNullPlanningIds
public void assertNonNullPlanningIds()Description copied from interface:InnerScoreDirector
Asserts that none of the planning facts fromScoreDirector.getWorkingSolution()
havePlanningId
s with a null value.- Specified by:
assertNonNullPlanningIds
in interfaceInnerScoreDirector<Solution_,
Score_ extends Score<Score_>>
-
doAndProcessMove
- Specified by:
doAndProcessMove
in interfaceInnerScoreDirector<Solution_,
Score_ extends Score<Score_>> - Parameters:
move
- never nullassertMoveScoreFromScratch
- true will hurt performance- Returns:
- never null
-
doAndProcessMove
public void doAndProcessMove(Move<Solution_> move, boolean assertMoveScoreFromScratch, Consumer<Score_> moveProcessor) - Specified by:
doAndProcessMove
in interfaceInnerScoreDirector<Solution_,
Score_ extends Score<Score_>> - Parameters:
move
- never nullassertMoveScoreFromScratch
- true will hurt performancemoveProcessor
- never null, use this to store the score as well as call the acceptor and forager
-
isWorkingEntityListDirty
public boolean isWorkingEntityListDirty(long expectedWorkingEntityListRevision) - Specified by:
isWorkingEntityListDirty
in interfaceInnerScoreDirector<Solution_,
Score_ extends Score<Score_>> - Parameters:
expectedWorkingEntityListRevision
- an- Returns:
- true if the entityList might have a different set of instances now
-
setWorkingEntityListDirty
protected void setWorkingEntityListDirty() -
cloneWorkingSolution
Description copied from interface:InnerScoreDirector
Returns a planning clone of the solution, which is not a shallow clone nor a deep clone nor a partition clone.- Specified by:
cloneWorkingSolution
in interfaceInnerScoreDirector<Solution_,
Score_ extends Score<Score_>> - Returns:
- never null, planning clone
-
cloneSolution
Description copied from interface:InnerScoreDirector
Returns a planning clone of the solution, which is not a shallow clone nor a deep clone nor a partition clone.- Specified by:
cloneSolution
in interfaceInnerScoreDirector<Solution_,
Score_ extends Score<Score_>> - Parameters:
originalSolution
- never null- Returns:
- never null, planning clone
-
triggerVariableListeners
public void triggerVariableListeners()- Specified by:
triggerVariableListeners
in interfaceScoreDirector<Solution_>
-
forceTriggerVariableListeners
public void forceTriggerVariableListeners()Description copied from interface:InnerScoreDirector
UnlikeScoreDirector.triggerVariableListeners()
which only triggers notifications already in the queue, this triggers every variable listener on every genuine variable. This is useful inSolutionManager.update(Object)
to fill in shadow variable values.- Specified by:
forceTriggerVariableListeners
in interfaceInnerScoreDirector<Solution_,
Score_ extends Score<Score_>>
-
setCalculatedScore
-
clone
Description copied from interface:InnerScoreDirector
Clones thisScoreDirector
and itsworking solution
. UseScoreDirector.getWorkingSolution()
to retrieve theworking solution
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.
-
createChildThreadScoreDirector
public InnerScoreDirector<Solution_,Score_> createChildThreadScoreDirector(ChildThreadType childThreadType) - Specified by:
createChildThreadScoreDirector
in interfaceInnerScoreDirector<Solution_,
Score_ extends Score<Score_>>
-
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_>>
-
beforeEntityAdded
- Specified by:
beforeEntityAdded
in interfaceScoreDirector<Solution_>
-
afterEntityAdded
- Specified by:
afterEntityAdded
in interfaceScoreDirector<Solution_>
-
beforeVariableChanged
- Specified by:
beforeVariableChanged
in interfaceScoreDirector<Solution_>
-
afterVariableChanged
- Specified by:
afterVariableChanged
in interfaceScoreDirector<Solution_>
-
beforeListVariableElementAssigned
- Specified by:
beforeListVariableElementAssigned
in interfaceScoreDirector<Solution_>
-
afterListVariableElementAssigned
- Specified by:
afterListVariableElementAssigned
in interfaceScoreDirector<Solution_>
-
beforeListVariableElementUnassigned
- Specified by:
beforeListVariableElementUnassigned
in interfaceScoreDirector<Solution_>
-
afterListVariableElementUnassigned
- Specified by:
afterListVariableElementUnassigned
in interfaceScoreDirector<Solution_>
-
beforeListVariableChanged
public void beforeListVariableChanged(Object entity, String variableName, int fromIndex, int toIndex) - Specified by:
beforeListVariableChanged
in interfaceScoreDirector<Solution_>
-
afterListVariableChanged
public void afterListVariableChanged(Object entity, String variableName, int fromIndex, int toIndex) - Specified by:
afterListVariableChanged
in interfaceScoreDirector<Solution_>
-
beforeEntityRemoved
- Specified by:
beforeEntityRemoved
in interfaceScoreDirector<Solution_>
-
afterEntityRemoved
- Specified by:
afterEntityRemoved
in interfaceScoreDirector<Solution_>
-
beforeEntityAdded
-
afterEntityAdded
-
beforeVariableChanged
- Specified by:
beforeVariableChanged
in interfaceInnerScoreDirector<Solution_,
Score_ extends Score<Score_>>
-
afterVariableChanged
- Specified by:
afterVariableChanged
in interfaceInnerScoreDirector<Solution_,
Score_ extends Score<Score_>>
-
changeVariableFacade
public void changeVariableFacade(VariableDescriptor<Solution_> variableDescriptor, Object entity, Object newValue) - Specified by:
changeVariableFacade
in interfaceInnerScoreDirector<Solution_,
Score_ extends Score<Score_>>
-
beforeListVariableElementAssigned
public void beforeListVariableElementAssigned(ListVariableDescriptor<Solution_> variableDescriptor, Object element) Description copied from interface:InnerScoreDirector
Call this for each element that will be assigned (added to a list variable of one entity without being removed from a list variable of another entity).- Specified by:
beforeListVariableElementAssigned
in interfaceInnerScoreDirector<Solution_,
Score_ extends Score<Score_>> - Parameters:
variableDescriptor
- the list variable descriptorelement
- the assigned element
-
afterListVariableElementAssigned
public void afterListVariableElementAssigned(ListVariableDescriptor<Solution_> variableDescriptor, Object element) Description copied from interface:InnerScoreDirector
Call this for each element that was assigned (added to a list variable of one entity without being removed from a list variable of another entity).- Specified by:
afterListVariableElementAssigned
in interfaceInnerScoreDirector<Solution_,
Score_ extends Score<Score_>> - Parameters:
variableDescriptor
- the list variable descriptorelement
- the assigned element
-
beforeListVariableElementUnassigned
public void beforeListVariableElementUnassigned(ListVariableDescriptor<Solution_> variableDescriptor, Object element) Description copied from interface:InnerScoreDirector
Call this for each element that will be unassigned (removed from a list variable of one entity without being added to a list variable of another entity).- Specified by:
beforeListVariableElementUnassigned
in interfaceInnerScoreDirector<Solution_,
Score_ extends Score<Score_>> - Parameters:
variableDescriptor
- the list variable descriptorelement
- the unassigned element
-
afterListVariableElementUnassigned
public void afterListVariableElementUnassigned(ListVariableDescriptor<Solution_> variableDescriptor, Object element) Description copied from interface:InnerScoreDirector
Call this for each element that was unassigned (removed from a list variable of one entity without being added to a list variable of another entity).- Specified by:
afterListVariableElementUnassigned
in interfaceInnerScoreDirector<Solution_,
Score_ extends Score<Score_>> - Parameters:
variableDescriptor
- the list variable descriptorelement
- the unassigned element
-
beforeListVariableChanged
public void beforeListVariableChanged(ListVariableDescriptor<Solution_> variableDescriptor, Object entity, int fromIndex, int toIndex) Description copied from interface:InnerScoreDirector
Notify the score director before a list variable changes.The list variable change includes:
- Changing position (index) of one or more elements.
- Removing one or more elements from the list variable.
- Adding one or more elements to the list variable.
- Any mix of the above.
fromIndex
(inclusive) and ends attoIndex
(exclusive).The range has to comply with the following contract:
fromIndex
must be greater than or equal to 0;toIndex
must be less than or equal to the list variable size.toIndex
must be greater than or equal tofromIndex
.- The range must contain all elements that are going to be changed.
- The range is allowed to contain elements that are not going to be changed.
- The range may be empty (
fromIndex
equalstoIndex
) if none of the existing list variable elements are going to be changed.
InnerScoreDirector.beforeListVariableElementUnassigned(ListVariableDescriptor, Object)
must be called for each element that will be unassigned (removed from a list variable of one entity without being added to a list variable of another entity).- Specified by:
beforeListVariableChanged
in interfaceInnerScoreDirector<Solution_,
Score_ extends Score<Score_>> - Parameters:
variableDescriptor
- descriptor of the list variable being changedentity
- the entity owning the list variable being changedfromIndex
- low endpoint (inclusive) of the changed rangetoIndex
- high endpoint (exclusive) of the changed range
-
afterListVariableChanged
public void afterListVariableChanged(ListVariableDescriptor<Solution_> variableDescriptor, Object entity, int fromIndex, int toIndex) Description copied from interface:InnerScoreDirector
Notify the score director after a list variable changes.The list variable change includes:
- Changing position (index) of one or more elements.
- Removing one or more elements from the list variable.
- Adding one or more elements to the list variable.
- Any mix of the above.
fromIndex
(inclusive) and ends attoIndex
(exclusive).The range has to comply with the following contract:
fromIndex
must be greater than or equal to 0;toIndex
must be less than or equal to the list variable size.toIndex
must be greater than or equal tofromIndex
.- The range must contain all elements that have changed.
- The range is allowed to contain elements that have not changed.
- The range may be empty (
fromIndex
equalstoIndex
) if none of the existing list variable elements have changed.
InnerScoreDirector.afterListVariableElementUnassigned(ListVariableDescriptor, Object)
must be called for each element that was unassigned (removed from a list variable of one entity without being added to a list variable of another entity).- Specified by:
afterListVariableChanged
in interfaceInnerScoreDirector<Solution_,
Score_ extends Score<Score_>> - Parameters:
variableDescriptor
- descriptor of the list variable being changedentity
- the entity owning the list variable being changedfromIndex
- low endpoint (inclusive) of the changed rangetoIndex
- high endpoint (exclusive) of the changed range
-
beforeEntityRemoved
-
afterEntityRemoved
-
beforeProblemFactAdded
- Specified by:
beforeProblemFactAdded
in interfaceScoreDirector<Solution_>
-
afterProblemFactAdded
- Specified by:
afterProblemFactAdded
in interfaceScoreDirector<Solution_>
-
beforeProblemPropertyChanged
- Specified by:
beforeProblemPropertyChanged
in interfaceScoreDirector<Solution_>
-
afterProblemPropertyChanged
- Specified by:
afterProblemPropertyChanged
in interfaceScoreDirector<Solution_>
-
beforeProblemFactRemoved
- Specified by:
beforeProblemFactRemoved
in interfaceScoreDirector<Solution_>
-
afterProblemFactRemoved
- Specified by:
afterProblemFactRemoved
in interfaceScoreDirector<Solution_>
-
lookUpWorkingObject
public <E> E lookUpWorkingObject(E externalObject) Description copied from interface:ScoreDirector
Translates an entity or fact instance (often from anotherThread
or JVM) to thisScoreDirector
's internal working instance. Useful for move rebasing and in aProblemChange
.Matching is determined by the
LookUpStrategyType
onPlanningSolution
. Matching uses aPlanningId
by default.- Specified by:
lookUpWorkingObject
in interfaceScoreDirector<Solution_>
- Type Parameters:
E
- the object type- Parameters:
externalObject
- sometimes null- Returns:
- null if externalObject is null
-
lookUpWorkingObjectOrReturnNull
public <E> E lookUpWorkingObjectOrReturnNull(E externalObject) Description copied from interface:ScoreDirector
As defined byScoreDirector.lookUpWorkingObject(Object)
, but doesn't fail fast if no workingObject was ever added for the externalObject. It's recommended to useScoreDirector.lookUpWorkingObject(Object)
instead, especially in move rebasing code.- Specified by:
lookUpWorkingObjectOrReturnNull
in interfaceScoreDirector<Solution_>
- Type Parameters:
E
- the object type- Parameters:
externalObject
- sometimes null- Returns:
- null if externalObject is null or if there is no workingObject for externalObject
-
assertExpectedWorkingScore
Description copied from interface:InnerScoreDirector
Asserts that if theScore
is calculated for the currentworking solution
in the currentScoreDirector
(with possibly incremental calculation residue), it is equal to the parameterexpectedWorkingScore
.Used to assert that skipping
InnerScoreDirector.calculateScore()
(when the score is otherwise determined) is correct.- Specified by:
assertExpectedWorkingScore
in interfaceInnerScoreDirector<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
-
assertShadowVariablesAreNotStale
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_>> - Parameters:
expectedWorkingScore
- never nullcompletedAction
- sometimes null, when assertion fails then the completedAction'sObject.toString()
is included in the exception message
-
buildShadowVariableAnalysis
- Parameters:
predicted
- true if the score was predicted and might have been calculated on another thread- Returns:
- never null
-
assertWorkingScoreFromScratch
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_>> - Parameters:
workingScore
- never nullcompletedAction
- sometimes null, when assertion fails then the completedAction'sObject.toString()
is included in the exception message- See Also:
-
assertPredictedScoreFromScratch
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 parameterpredictedScore
.Furthermore, if the assert fails, a score corruption analysis might be included in the exception message.
- Specified by:
assertPredictedScoreFromScratch
in interfaceInnerScoreDirector<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:
-
assertExpectedUndoMoveScore
Description copied from interface:InnerScoreDirector
Asserts that if theScore
is calculated for the currentworking solution
in the currentScoreDirector
(with incremental calculation residue), it is equal to the parameterbeforeMoveScore
.Furthermore, if the assert fails, a score corruption analysis might be included in the exception message.
- Specified by:
assertExpectedUndoMoveScore
in interfaceInnerScoreDirector<Solution_,
Score_ extends Score<Score_>> - Parameters:
move
- never nullbeforeMoveScore
- never null
-
buildScoreCorruptionAnalysis
protected String buildScoreCorruptionAnalysis(InnerScoreDirector<Solution_, Score_> uncorruptedScoreDirector, boolean predicted) - Parameters:
uncorruptedScoreDirector
- never nullpredicted
- true if the score was predicted and might have been calculated on another thread- Returns:
- never null
-
isConstraintConfiguration
-
toString
-