Interface InnerScoreDirector<Solution_>
-
- Type Parameters:
Solution_
- the solution type, the class with thePlanningSolution
annotation
- All Superinterfaces:
AutoCloseable
,ScoreDirector<Solution_>
- All Known Implementing Classes:
AbstractScoreDirector
,ConstraintStreamScoreDirector
,DroolsScoreDirector
,EasyScoreDirector
,IncrementalScoreDirector
,TestGenDroolsScoreDirector
public interface InnerScoreDirector<Solution_> extends ScoreDirector<Solution_>
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
assertExpectedUndoMoveScore(Move 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
assertPredictedScoreFromScratch(Score predictedScore, 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
.ScoreDirector<Solution_>
clone()
Clones thisScoreDirector
and itsworking solution
.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.Solution_
cloneWorkingSolution()
Returns a planning clone of the solution, which is not a shallow clone nor a deep clone nor a partition clone.InnerScoreDirector<Solution_>
createChildThreadScoreDirector(ChildThreadType childThreadType)
Score
doAndProcessMove(Move<Solution_> move, boolean assertMoveScoreFromScratch)
void
doAndProcessMove(Move<Solution_> move, boolean assertMoveScoreFromScratch, Consumer<Score> moveProcessor)
long
getCalculationCount()
ScoreDefinition
getScoreDefinition()
InnerScoreDirectorFactory<Solution_>
getScoreDirectorFactory()
SolutionDescriptor<Solution_>
getSolutionDescriptor()
SupplyManager
getSupplyManager()
int
getWorkingEntityCount()
List<Object>
getWorkingEntityList()
long
getWorkingEntityListRevision()
int
getWorkingValueCount()
boolean
isWorkingEntityListDirty(long expectedWorkingEntityListRevision)
void
overwriteConstraintMatchEnabledPreference(boolean constraintMatchEnabledPreference)
void
resetCalculationCount()
void
setAllChangesWillBeUndoneBeforeStepEnds(boolean allChangesWillBeUndoneBeforeStepEnds)
Do not waste performance by propagating changes to step (or higher) mechanisms.-
Methods inherited from interface org.optaplanner.core.impl.score.director.ScoreDirector
afterEntityAdded, afterEntityRemoved, afterProblemFactAdded, afterProblemFactRemoved, afterProblemPropertyChanged, afterVariableChanged, afterVariableChanged, beforeEntityAdded, beforeEntityRemoved, beforeProblemFactAdded, beforeProblemFactRemoved, beforeProblemPropertyChanged, beforeVariableChanged, beforeVariableChanged, calculateScore, changeVariableFacade, close, dispose, explainScore, getConstraintMatchTotalMap, getConstraintMatchTotals, getIndictmentMap, getWorkingSolution, isConstraintMatchEnabled, lookUpWorkingObject, lookUpWorkingObjectOrReturnNull, setWorkingSolution, triggerVariableListeners
-
-
-
-
Method Detail
-
overwriteConstraintMatchEnabledPreference
void overwriteConstraintMatchEnabledPreference(boolean constraintMatchEnabledPreference)
- Parameters:
constraintMatchEnabledPreference
- false if aScoreDirector
implementation should not doConstraintMatch
tracking even if it supports it.
-
getWorkingEntityListRevision
long getWorkingEntityListRevision()
- Returns:
- used to check
isWorkingEntityListDirty(long)
later on
-
doAndProcessMove
Score doAndProcessMove(Move<Solution_> move, boolean assertMoveScoreFromScratch)
- Parameters:
move
- never nullassertMoveScoreFromScratch
- true will hurt performance- Returns:
- never null
-
doAndProcessMove
void doAndProcessMove(Move<Solution_> move, boolean assertMoveScoreFromScratch, Consumer<Score> moveProcessor)
- 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
boolean isWorkingEntityListDirty(long expectedWorkingEntityListRevision)
- Parameters:
expectedWorkingEntityListRevision
- an- Returns:
- true if the entityList might have a different set of instances now
-
getScoreDirectorFactory
InnerScoreDirectorFactory<Solution_> getScoreDirectorFactory()
- Returns:
- never null
-
getSolutionDescriptor
SolutionDescriptor<Solution_> getSolutionDescriptor()
- Returns:
- never null
-
getScoreDefinition
ScoreDefinition getScoreDefinition()
- Returns:
- never null
-
cloneWorkingSolution
Solution_ cloneWorkingSolution()
Returns a planning clone of the solution, which is not a shallow clone nor a deep clone nor a partition clone.- Returns:
- never null, planning clone
-
cloneSolution
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.- Parameters:
originalSolution
- never null- Returns:
- never null, planning clone
-
getWorkingEntityCount
int getWorkingEntityCount()
- Returns:
>= 0
-
getWorkingEntityList
List<Object> getWorkingEntityList()
- Returns:
- never null: an empty list if there are none
-
getWorkingValueCount
int getWorkingValueCount()
- Returns:
>= 0
-
getCalculationCount
long getCalculationCount()
- Returns:
- at least 0L
-
resetCalculationCount
void resetCalculationCount()
-
getSupplyManager
SupplyManager getSupplyManager()
- Returns:
- never null
-
clone
ScoreDirector<Solution_> clone()
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.
- Returns:
- never null
-
createChildThreadScoreDirector
InnerScoreDirector<Solution_> createChildThreadScoreDirector(ChildThreadType childThreadType)
-
setAllChangesWillBeUndoneBeforeStepEnds
void setAllChangesWillBeUndoneBeforeStepEnds(boolean allChangesWillBeUndoneBeforeStepEnds)
Do not waste performance by propagating changes to step (or higher) mechanisms.- Parameters:
allChangesWillBeUndoneBeforeStepEnds
- true if all changes will be undone
-
assertExpectedWorkingScore
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
.Used to assert that skipping
ScoreDirector.calculateScore()
(when the score is otherwise determined) is correct.- Parameters:
expectedWorkingScore
- never nullcompletedAction
- sometimes null, when assertion fails then the completedAction'sObject.toString()
is included in the exception message
-
assertShadowVariablesAreNotStale
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
.Used to assert that the shadow variables' state is consistent with the genuine variables' state.
- Parameters:
expectedWorkingScore
- never nullcompletedAction
- sometimes null, when assertion fails then the completedAction'sObject.toString()
is included in the exception message
-
assertWorkingScoreFromScratch
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
.Furthermore, if the assert fails, a score corruption analysis might be included in the exception message.
- 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_)
-
assertPredictedScoreFromScratch
void assertPredictedScoreFromScratch(Score predictedScore, 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
.Furthermore, if the assert fails, a score corruption analysis might be included in the exception message.
- Parameters:
predictedScore
- never nullcompletedAction
- sometimes null, when assertion fails then the completedAction'sObject.toString()
is included in the exception message- See Also:
InnerScoreDirectorFactory.assertScoreFromScratch(Solution_)
-
assertExpectedUndoMoveScore
void assertExpectedUndoMoveScore(Move 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
.Furthermore, if the assert fails, a score corruption analysis might be included in the exception message.
- Parameters:
move
- never nullbeforeMoveScore
- never null
-
-