Class AbstractScoreDirector<Solution_,Score_ extends Score<Score_>,Factory_ extends AbstractScoreDirectorFactory<Solution_,Score_,Factory_>>
- All Implemented Interfaces:
ScoreDirector<Solution_>,InnerScoreDirector<Solution_,,Score_> VariableDescriptorAwareScoreDirector<Solution_>,AutoCloseable,Cloneable
- Direct Known Subclasses:
BavetConstraintStreamScoreDirector,EasyScoreDirector,IncrementalScoreDirector
ScoreDirector.
Implementation note: Extending classes should follow these guidelines:
InnerScoreDirector.setWorkingSolution(Object)should delegate tosetWorkingSolution(Object, Consumer)- before* method: last statement should be a call to the super method
- after* method: first statement should be a call to the super method
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classAbstractScoreDirector.AbstractScoreDirectorBuilder<Solution_,Score_ extends Score<Score_>, Factory_ extends AbstractScoreDirectorFactory<Solution_, Score_, Factory_>, Builder_ extends AbstractScoreDirector.AbstractScoreDirectorBuilder<Solution_, Score_, Factory_, Builder_>> An abstract builder for creating instances ofInnerScoreDirector. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final ConstraintMatchPolicyprotected final org.slf4j.Loggerprotected final Factory_protected final VariableListenerSupport<Solution_>protected Solution_ -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractScoreDirector(Factory_ scoreDirectorFactory, boolean lookUpEnabled, ConstraintMatchPolicy constraintMatchPolicy, boolean expectShadowVariablesInCorrectState) -
Method Summary
Modifier and TypeMethodDescriptionvoidafterEntityAdded(EntityDescriptor<Solution_> entityDescriptor, Object entity) voidafterEntityRemoved(EntityDescriptor<Solution_> entityDescriptor, Object entity) voidafterListVariableChanged(ListVariableDescriptor<Solution_> variableDescriptor, Object entity, int fromIndex, int toIndex) Notify the score director after a list variable changes.voidafterListVariableElementAssigned(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).voidafterListVariableElementUnassigned(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).voidafterProblemFactAdded(Object problemFact) voidafterProblemFactRemoved(Object problemFact) voidafterProblemPropertyChanged(Object problemFactOrEntity) voidafterVariableChanged(VariableDescriptor<Solution_> variableDescriptor, Object entity) voidassertExpectedUndoMoveScore(Move<Solution_> move, InnerScore<Score_> beforeMoveInnerScore, SolverLifecyclePoint executionPoint) Asserts that if theScoreis calculated for the currentworking solutionin the currentScoreDirector(with incremental calculation residue), it is equal to the parameterbeforeMoveScore.voidassertExpectedWorkingScore(InnerScore<Score_> expectedWorkingScore, Object completedAction) Asserts that if theScoreis calculated for the currentworking solutionin the currentScoreDirector(with possibly incremental calculation residue), it is equal to the parameterexpectedWorkingScore.voidassertPredictedScoreFromScratch(InnerScore<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 parameterpredictedScore.voidassertShadowVariablesAreNotStale(InnerScore<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(InnerScore<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.voidbeforeEntityAdded(EntityDescriptor<Solution_> entityDescriptor, Object entity) voidbeforeEntityRemoved(EntityDescriptor<Solution_> entityDescriptor, Object entity) voidbeforeListVariableChanged(ListVariableDescriptor<Solution_> variableDescriptor, Object entity, int fromIndex, int toIndex) Notify the score director before a list variable changes.voidbeforeListVariableElementAssigned(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).voidbeforeListVariableElementUnassigned(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).voidbeforeProblemFactAdded(Object problemFact) voidbeforeProblemFactRemoved(Object problemFact) voidbeforeProblemPropertyChanged(Object problemFactOrEntity) voidbeforeVariableChanged(VariableDescriptor<Solution_> variableDescriptor, Object entity) protected StringbuildScoreCorruptionAnalysis(InnerScoreDirector<Solution_, Score_> uncorruptedScoreDirector, boolean predicted) protected StringbuildShadowVariableAnalysis(boolean predicted) protected voidThis function clears all listener events that have been generated without triggering any of them.clone()Deprecated, for removal: This API element is subject to removal in a future version.Unused, but kept for backward compatibility.cloneSolution(Solution_ originalSolution) Returns a planning clone of the solution, which is not a shallow clone nor a deep clone nor a partition clone.voidclose()Needs to be called after use because some implementations need to clean up their resources.createChildThreadScoreDirector(ChildThreadType childThreadType) voidexecuteMove(Move<Solution_> move) executeTemporaryMove(Move<Solution_> move, boolean assertMoveScoreFromScratch) Executes a move, finds out its score, and immediately undoes it.booleanInverse shadow variables have a fail-fast for cases where the shadow variable doesn't actually point to its correct inverse.voidUnlikeScoreDirector.triggerVariableListeners()which only triggers notifications already in the queue, this triggers every variable listener on every genuine variable.longfinal ConstraintMatchPolicygetListVariableStateSupply(ListVariableDescriptor<Solution_> variableDescriptor) getSolutionCorruptionAfterUndo(Move<Solution_> move, InnerScore<Score_> undoInnerScore) longintint@NonNull Solution_ThePlanningSolutionthat is used to calculate theScore.voidprotected booleanisConstraintConfiguration(Object problemFactOrEntity) booleanisWorkingEntityListDirty(long expectedWorkingEntityListRevision) boolean<E> @Nullable ElookUpWorkingObject(@Nullable E externalObject) Translates an entity or fact instance (often from anotherThreador JVM) to thisScoreDirector's internal working instance.<E> @Nullable ElookUpWorkingObjectOrReturnNull(@Nullable E externalObject) As defined byScoreDirector.lookUpWorkingObject(Object), but doesn't fail fast if no workingObject was ever added for the externalObject.voidvoidsetAllChangesWillBeUndoneBeforeStepEnds(boolean allChangesWillBeUndoneBeforeStepEnds) Do not waste performance by propagating changes to step (or higher) mechanisms.protected voidsetCalculatedScore(Score_ score) voidsetMoveRepository(@Nullable MoveRepository<Solution_> moveRepository) Different phases may need different move repositories, as they may be based on different sets of moves.protected voidprotected voidsetWorkingSolution(Solution_ workingSolution, Consumer<Object> entityAndFactVisitor) Note: resetting the working solution does NOT substitute the calls to before/after methods of theProblemChangeDirectorduringproblem changes, as these calls are propagated tovariable listeners, which update shadow variables in theworking solutionto keep it consistent.toString()voidMethods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface ai.timefold.solver.core.impl.score.director.InnerScoreDirector
afterEntityAdded, afterEntityRemoved, beforeEntityAdded, beforeEntityRemoved, buildScoreAnalysis, calculateScore, cloneWorkingSolution, getConstraintMatchTotalMap, getIndictmentMap, isDerived, requiresFlushing, setWorkingSolutionMethods inherited from interface ai.timefold.solver.core.impl.score.director.VariableDescriptorAwareScoreDirector
afterListVariableChanged, afterListVariableElementAssigned, afterListVariableElementUnassigned, afterVariableChanged, beforeListVariableChanged, beforeListVariableElementAssigned, beforeListVariableElementUnassigned, beforeVariableChanged, changeVariableFacade
-
Field Details
-
logger
protected final org.slf4j.Logger logger -
constraintMatchPolicy
-
scoreDirectorFactory
protected final Factory_ extends AbstractScoreDirectorFactory<Solution_,Score_, scoreDirectorFactoryFactory_> -
variableListenerSupport
-
workingSolution
-
-
Constructor Details
-
AbstractScoreDirector
protected AbstractScoreDirector(Factory_ scoreDirectorFactory, boolean lookUpEnabled, ConstraintMatchPolicy constraintMatchPolicy, boolean expectShadowVariablesInCorrectState)
-
-
Method Details
-
getConstraintMatchPolicy
- Specified by:
getConstraintMatchPolicyin interfaceInnerScoreDirector<Solution_,Score_ extends Score<Score_>> - Returns:
ConstraintMatchPolicy.ENABLEDifInnerScoreDirector.getConstraintMatchTotalMap()andInnerScoreDirector.getIndictmentMap()can be called.ConstraintMatchPolicy.ENABLED_WITHOUT_JUSTIFICATIONSif only the former can be called.ConstraintMatchPolicy.DISABLEDif neither can be called.
-
getScoreDirectorFactory
- Specified by:
getScoreDirectorFactoryin interfaceInnerScoreDirector<Solution_,Score_ extends Score<Score_>> - Returns:
- never null
-
getSolutionDescriptor
- Specified by:
getSolutionDescriptorin interfaceInnerScoreDirector<Solution_,Score_ extends Score<Score_>> - Specified by:
getSolutionDescriptorin interfaceVariableDescriptorAwareScoreDirector<Solution_>- Returns:
- never null
-
getScoreDefinition
- Specified by:
getScoreDefinitionin interfaceInnerScoreDirector<Solution_,Score_ extends Score<Score_>> - Returns:
- never null
-
getVariableDescriptorCache
- Specified by:
getVariableDescriptorCachein interfaceVariableDescriptorAwareScoreDirector<Solution_>
-
getListVariableStateSupply
public ListVariableStateSupply<Solution_> getListVariableStateSupply(ListVariableDescriptor<Solution_> variableDescriptor) - Specified by:
getListVariableStateSupplyin interfaceInnerScoreDirector<Solution_,Score_ extends Score<Score_>>
-
expectShadowVariablesInCorrectState
public boolean expectShadowVariablesInCorrectState()Description copied from interface:InnerScoreDirectorInverse shadow variables have a fail-fast for cases where the shadow variable doesn't actually point to its correct inverse. This is very useful to pinpoint improperly initialized solutions.However,
SolutionManager.update(Object)exists precisely for the purpose of initializing solutions. And when this API is used, the fail-fast must not be triggered as it is guaranteed and expected that the inverse relationships will be wrong. In fact, they will be null.For this case and this case only, this method is allowed to return false. All other cases must return true, otherwise a very valuable fail-fast is lost.
- Specified by:
expectShadowVariablesInCorrectStatein interfaceInnerScoreDirector<Solution_,Score_ extends Score<Score_>> - Returns:
- false if the fail-fast on shadow variables should not be triggered
-
getWorkingSolution
Description copied from interface:ScoreDirectorThePlanningSolutionthat is used to calculate theScore.Because a
Scoreis best calculated incrementally (by deltas), theScoreDirectorneeds to be notified when itsworking solutionchanges.- Specified by:
getWorkingSolutionin interfaceScoreDirector<Solution_>
-
getWorkingInitScore
public int getWorkingInitScore()- Specified by:
getWorkingInitScorein interfaceInnerScoreDirector<Solution_,Score_ extends Score<Score_>>
-
getWorkingEntityListRevision
public long getWorkingEntityListRevision()- Specified by:
getWorkingEntityListRevisionin interfaceInnerScoreDirector<Solution_,Score_ extends Score<Score_>> - Returns:
- used to check
InnerScoreDirector.isWorkingEntityListDirty(long)later on
-
getWorkingGenuineEntityCount
public int getWorkingGenuineEntityCount()- Specified by:
getWorkingGenuineEntityCountin interfaceInnerScoreDirector<Solution_,Score_ extends Score<Score_>>
-
setAllChangesWillBeUndoneBeforeStepEnds
public void setAllChangesWillBeUndoneBeforeStepEnds(boolean allChangesWillBeUndoneBeforeStepEnds) Description copied from interface:InnerScoreDirectorDo not waste performance by propagating changes to step (or higher) mechanisms.- Specified by:
setAllChangesWillBeUndoneBeforeStepEndsin interfaceInnerScoreDirector<Solution_,Score_ extends Score<Score_>> - Parameters:
allChangesWillBeUndoneBeforeStepEnds- true if all changes will be undone
-
getCalculationCount
public long getCalculationCount()- Specified by:
getCalculationCountin interfaceInnerScoreDirector<Solution_,Score_ extends Score<Score_>> - Returns:
- at least 0L
-
resetCalculationCount
public void resetCalculationCount()- Specified by:
resetCalculationCountin interfaceInnerScoreDirector<Solution_,Score_ extends Score<Score_>>
-
incrementCalculationCount
public void incrementCalculationCount()- Specified by:
incrementCalculationCountin interfaceInnerScoreDirector<Solution_,Score_ extends Score<Score_>>
-
getSupplyManager
- Specified by:
getSupplyManagerin interfaceInnerScoreDirector<Solution_,Score_ extends Score<Score_>> - Returns:
- never null
-
getMoveDirector
- Specified by:
getMoveDirectorin interfaceInnerScoreDirector<Solution_,Score_ extends Score<Score_>>
-
setWorkingSolution
Note: resetting the working solution does NOT substitute the calls to before/after methods of theProblemChangeDirectorduringproblem changes, as these calls are propagated tovariable listeners, which update shadow variables in theworking solutionto keep it consistent.- Parameters:
workingSolution- the working solution to setentityAndFactVisitor- maybe null; a function to apply to all problem facts and problem entities
-
setMoveRepository
Description copied from interface:InnerScoreDirectorDifferent phases may need different move repositories, as they may be based on different sets of moves. Therefore move repository cannot be injected at score director construction time. A phase may not need a move repository at all, such as construction heuristics, which currently does not support Move Streams. Each phase is responsible for calling this method to set its repository, and also calling it again at the end to null it out.- Specified by:
setMoveRepositoryin interfaceInnerScoreDirector<Solution_,Score_ extends Score<Score_>>
-
executeMove
- Specified by:
executeMovein interfaceInnerScoreDirector<Solution_,Score_ extends Score<Score_>>
-
executeTemporaryMove
public InnerScore<Score_> executeTemporaryMove(Move<Solution_> move, boolean assertMoveScoreFromScratch) Description copied from interface:InnerScoreDirectorExecutes a move, finds out its score, and immediately undoes it.- Specified by:
executeTemporaryMovein interfaceInnerScoreDirector<Solution_,Score_ extends Score<Score_>> - Parameters:
move- never nullassertMoveScoreFromScratch- true will hurt performance- Returns:
- never null
-
isWorkingEntityListDirty
public boolean isWorkingEntityListDirty(long expectedWorkingEntityListRevision) - Specified by:
isWorkingEntityListDirtyin interfaceInnerScoreDirector<Solution_,Score_ extends Score<Score_>> - Parameters:
expectedWorkingEntityListRevision- an- Returns:
- true if the entityList might have a different set of instances now
-
isWorkingSolutionInitialized
public boolean isWorkingSolutionInitialized()- Specified by:
isWorkingSolutionInitializedin interfaceInnerScoreDirector<Solution_,Score_ extends Score<Score_>>
-
setWorkingEntityListDirty
protected void setWorkingEntityListDirty() -
cloneSolution
Description copied from interface:InnerScoreDirectorReturns a planning clone of the solution, which is not a shallow clone nor a deep clone nor a partition clone.- Specified by:
cloneSolutionin interfaceInnerScoreDirector<Solution_,Score_ extends Score<Score_>> - Parameters:
originalSolution- never null- Returns:
- never null, planning clone
-
triggerVariableListeners
public void triggerVariableListeners()- Specified by:
triggerVariableListenersin interfaceScoreDirector<Solution_>
-
clearVariableListenerEvents
protected void clearVariableListenerEvents()This function clears all listener events that have been generated without triggering any of them. Using this method requires caution because clearing the event queue can lead to inconsistent states. This occurs when the shadow variables are not updated, causing constraints reliant on these variables to be inaccurately evaluated. -
forceTriggerVariableListeners
public void forceTriggerVariableListeners()Description copied from interface:InnerScoreDirectorUnlikeScoreDirector.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:
forceTriggerVariableListenersin interfaceInnerScoreDirector<Solution_,Score_ extends Score<Score_>>
-
setCalculatedScore
-
clone
@Deprecated(forRemoval=true, since="1.14.0") public AbstractScoreDirector<Solution_,Score_, clone()Factory_> Deprecated, for removal: This API element is subject to removal in a future version.Unused, but kept for backward compatibility. -
createChildThreadScoreDirector
public InnerScoreDirector<Solution_,Score_> createChildThreadScoreDirector(ChildThreadType childThreadType) - Specified by:
createChildThreadScoreDirectorin interfaceInnerScoreDirector<Solution_,Score_ extends Score<Score_>>
-
close
public void close()Description copied from interface:InnerScoreDirectorNeeds to be called after use because some implementations need to clean up their resources.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceInnerScoreDirector<Solution_,Score_ extends Score<Score_>>
-
beforeEntityAdded
- Specified by:
beforeEntityAddedin interfaceInnerScoreDirector<Solution_,Score_ extends Score<Score_>>
-
afterEntityAdded
- Specified by:
afterEntityAddedin interfaceInnerScoreDirector<Solution_,Score_ extends Score<Score_>>
-
beforeVariableChanged
- Specified by:
beforeVariableChangedin interfaceVariableDescriptorAwareScoreDirector<Solution_>
-
afterVariableChanged
- Specified by:
afterVariableChangedin interfaceVariableDescriptorAwareScoreDirector<Solution_>
-
beforeListVariableElementAssigned
public void beforeListVariableElementAssigned(ListVariableDescriptor<Solution_> variableDescriptor, Object element) Description copied from interface:VariableDescriptorAwareScoreDirectorCall 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:
beforeListVariableElementAssignedin interfaceVariableDescriptorAwareScoreDirector<Solution_>- Parameters:
variableDescriptor- the list variable descriptorelement- the assigned element
-
afterListVariableElementAssigned
public void afterListVariableElementAssigned(ListVariableDescriptor<Solution_> variableDescriptor, Object element) Description copied from interface:VariableDescriptorAwareScoreDirectorCall 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:
afterListVariableElementAssignedin interfaceVariableDescriptorAwareScoreDirector<Solution_>- Parameters:
variableDescriptor- the list variable descriptorelement- the assigned element
-
beforeListVariableElementUnassigned
public void beforeListVariableElementUnassigned(ListVariableDescriptor<Solution_> variableDescriptor, Object element) Description copied from interface:VariableDescriptorAwareScoreDirectorCall 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:
beforeListVariableElementUnassignedin interfaceVariableDescriptorAwareScoreDirector<Solution_>- Parameters:
variableDescriptor- the list variable descriptorelement- the unassigned element
-
afterListVariableElementUnassigned
public void afterListVariableElementUnassigned(ListVariableDescriptor<Solution_> variableDescriptor, Object element) Description copied from interface:VariableDescriptorAwareScoreDirectorCall 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:
afterListVariableElementUnassignedin interfaceVariableDescriptorAwareScoreDirector<Solution_>- 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:VariableDescriptorAwareScoreDirectorNotify 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:
fromIndexmust be greater than or equal to 0;toIndexmust be less than or equal to the list variable size.toIndexmust 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 (
fromIndexequalstoIndex) if none of the existing list variable elements are going to be changed.
VariableDescriptorAwareScoreDirector.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:
beforeListVariableChangedin interfaceVariableDescriptorAwareScoreDirector<Solution_>- 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:VariableDescriptorAwareScoreDirectorNotify 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:
fromIndexmust be greater than or equal to 0;toIndexmust be less than or equal to the list variable size.toIndexmust 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 (
fromIndexequalstoIndex) if none of the existing list variable elements have changed.
VariableDescriptorAwareScoreDirector.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:
afterListVariableChangedin interfaceVariableDescriptorAwareScoreDirector<Solution_>- 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
- Specified by:
beforeEntityRemovedin interfaceInnerScoreDirector<Solution_,Score_ extends Score<Score_>>
-
afterEntityRemoved
- Specified by:
afterEntityRemovedin interfaceInnerScoreDirector<Solution_,Score_ extends Score<Score_>>
-
beforeProblemFactAdded
- Specified by:
beforeProblemFactAddedin interfaceInnerScoreDirector<Solution_,Score_ extends Score<Score_>> - Specified by:
beforeProblemFactAddedin interfaceScoreDirector<Solution_>
-
afterProblemFactAdded
- Specified by:
afterProblemFactAddedin interfaceInnerScoreDirector<Solution_,Score_ extends Score<Score_>> - Specified by:
afterProblemFactAddedin interfaceScoreDirector<Solution_>
-
beforeProblemPropertyChanged
- Specified by:
beforeProblemPropertyChangedin interfaceInnerScoreDirector<Solution_,Score_ extends Score<Score_>> - Specified by:
beforeProblemPropertyChangedin interfaceScoreDirector<Solution_>
-
afterProblemPropertyChanged
- Specified by:
afterProblemPropertyChangedin interfaceInnerScoreDirector<Solution_,Score_ extends Score<Score_>> - Specified by:
afterProblemPropertyChangedin interfaceScoreDirector<Solution_>
-
beforeProblemFactRemoved
- Specified by:
beforeProblemFactRemovedin interfaceInnerScoreDirector<Solution_,Score_ extends Score<Score_>> - Specified by:
beforeProblemFactRemovedin interfaceScoreDirector<Solution_>
-
afterProblemFactRemoved
- Specified by:
afterProblemFactRemovedin interfaceInnerScoreDirector<Solution_,Score_ extends Score<Score_>> - Specified by:
afterProblemFactRemovedin interfaceScoreDirector<Solution_>
-
lookUpWorkingObject
public <E> @Nullable E lookUpWorkingObject(@Nullable E externalObject) Description copied from interface:ScoreDirectorTranslates an entity or fact instance (often from anotherThreador JVM) to thisScoreDirector's internal working instance. Useful for move rebasing and in aProblemChange.Matching is determined by the
LookUpStrategyTypeonPlanningSolution. Matching uses aPlanningIdby default.- Specified by:
lookUpWorkingObjectin interfaceScoreDirector<Solution_>- Type Parameters:
E- the object type- Returns:
- null if externalObject is null
-
lookUpWorkingObjectOrReturnNull
public <E> @Nullable E lookUpWorkingObjectOrReturnNull(@Nullable E externalObject) Description copied from interface:ScoreDirectorAs 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:
lookUpWorkingObjectOrReturnNullin interfaceScoreDirector<Solution_>- Type Parameters:
E- the object type- Returns:
- null if externalObject is null or if there is no workingObject for externalObject
-
assertExpectedWorkingScore
public void assertExpectedWorkingScore(InnerScore<Score_> expectedWorkingScore, Object completedAction) Description copied from interface:InnerScoreDirectorAsserts that if theScoreis calculated for the currentworking solutionin 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:
assertExpectedWorkingScorein 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
public void assertShadowVariablesAreNotStale(InnerScore<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_,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: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_,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
public void assertPredictedScoreFromScratch(InnerScore<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 parameterpredictedScore.Furthermore, if the assert fails, a score corruption analysis might be included in the exception message.
- Specified by:
assertPredictedScoreFromScratchin 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
public void assertExpectedUndoMoveScore(Move<Solution_> move, InnerScore<Score_> beforeMoveInnerScore, SolverLifecyclePoint executionPoint) Description copied from interface:InnerScoreDirectorAsserts that if theScoreis calculated for the currentworking solutionin 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:
assertExpectedUndoMoveScorein interfaceInnerScoreDirector<Solution_,Score_ extends Score<Score_>> - Parameters:
move- never nullbeforeMoveInnerScore- never null
-
getSolutionCorruptionAfterUndo
public SolutionTracker.SolutionCorruptionResult getSolutionCorruptionAfterUndo(Move<Solution_> move, InnerScore<Score_> undoInnerScore) -
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
-