Class DefaultScoreExplanation<Solution_,Score_ extends Score<Score_>>
java.lang.Object
ai.timefold.solver.core.impl.score.DefaultScoreExplanation<Solution_,Score_>
- All Implemented Interfaces:
ScoreExplanation<Solution_,Score_>
public final class DefaultScoreExplanation<Solution_,Score_ extends Score<Score_>>
extends Object
implements ScoreExplanation<Solution_,Score_>
-
Constructor Summary
ConstructorsConstructorDescriptionDefaultScoreExplanation(InnerScoreDirector<Solution_, Score_> scoreDirector) DefaultScoreExplanation(Solution_ solution, InnerScore<Score_> innerScore, Map<String, ConstraintMatchTotal<Score_>> constraintMatchTotalMap, Map<Object, Indictment<Score_>> indictmentMap) -
Method Summary
Modifier and TypeMethodDescriptionexplainScore(InnerScore<Score_> workingScore, Collection<ConstraintMatchTotal<Score_>> constraintMatchTotalCollection, Collection<Indictment<Score_>> indictmentCollection) explainScore(InnerScore<Score_> workingScore, Collection<ConstraintMatchTotal<Score_>> constraintMatchTotalCollection, Collection<Indictment<Score_>> indictmentCollection, int indictmentLimit, int constraintMatchLimit) @NonNull Map<String,ConstraintMatchTotal<Score_>> @NonNull Map<Object,Indictment<Score_>> Explains the impact of each planning entity or problem fact on theScore.@NonNull List<ConstraintJustification>Explains theScoreofScoreExplanation.getScore()for all constraints.@NonNull Score_getScore()Return theScorebeing explained.@NonNull Solution_Retrieve thePlanningSolutionthat the score being explained comes from.@NonNull StringReturns a diagnostic text that explains the solution through theConstraintMatchAPI to identify which constraints or planning entities cause that score quality.booleanWhetherScoreExplanation.getSolution()is initialized or not.toString()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface ai.timefold.solver.core.api.score.ScoreExplanation
getJustificationList
-
Constructor Details
-
DefaultScoreExplanation
-
DefaultScoreExplanation
public DefaultScoreExplanation(Solution_ solution, InnerScore<Score_> innerScore, Map<String, ConstraintMatchTotal<Score_>> constraintMatchTotalMap, Map<Object, Indictment<Score_>> indictmentMap)
-
-
Method Details
-
explainScore
public static <Score_ extends Score<Score_>> String explainScore(InnerScore<Score_> workingScore, Collection<ConstraintMatchTotal<Score_>> constraintMatchTotalCollection, Collection<Indictment<Score_>> indictmentCollection) -
explainScore
public static <Score_ extends Score<Score_>> String explainScore(InnerScore<Score_> workingScore, Collection<ConstraintMatchTotal<Score_>> constraintMatchTotalCollection, Collection<Indictment<Score_>> indictmentCollection, int indictmentLimit, int constraintMatchLimit) -
getSolution
Description copied from interface:ScoreExplanationRetrieve thePlanningSolutionthat the score being explained comes from.- Specified by:
getSolutionin interfaceScoreExplanation<Solution_,Score_ extends Score<Score_>>
-
getScore
Description copied from interface:ScoreExplanationReturn theScorebeing explained. If the specificScoretype used by thePlanningSolutionis required, callScoreExplanation.getSolution()and retrieve it from there. -
isInitialized
public boolean isInitialized()Description copied from interface:ScoreExplanationWhetherScoreExplanation.getSolution()is initialized or not.- Specified by:
isInitializedin interfaceScoreExplanation<Solution_,Score_ extends Score<Score_>> - Returns:
- true if initialized
-
getConstraintMatchTotalMap
Description copied from interface:ScoreExplanationExplains theScoreofScoreExplanation.getScore()by splitting it up perConstraint.The sum of
ConstraintMatchTotal.getScore()equalsScoreExplanation.getScore().- Specified by:
getConstraintMatchTotalMapin interfaceScoreExplanation<Solution_,Score_ extends Score<Score_>> - Returns:
- the key is the constraintId
(to create one, use
ConstraintRef.composeConstraintId(String, String)). - See Also:
-
getJustificationList
Description copied from interface:ScoreExplanationExplains theScoreofScoreExplanation.getScore()for all constraints. The return value of this method is determined by several factors:-
With Constraint Streams, the user has an option to provide a custom justification mapping,
implementing
ConstraintJustification. If provided, everyConstraintMatchof such constraint will be associated with this custom justification class. Every constraint not associated with a custom justification class will be associated withDefaultConstraintJustification. -
With
ConstraintMatchAwareIncrementalScoreCalculator, everyConstraintMatchwill be associated with the justification class that the user created it with.
- Specified by:
getJustificationListin interfaceScoreExplanation<Solution_,Score_ extends Score<Score_>> - Returns:
- all constraint matches
- See Also:
-
With Constraint Streams, the user has an option to provide a custom justification mapping,
implementing
-
getIndictmentMap
Description copied from interface:ScoreExplanationExplains the impact of each planning entity or problem fact on theScore. AnIndictmentis basically the inverse of aConstraintMatchTotal: it is aScoretotal for any of theindicted objects.The sum of
ConstraintMatchTotal.getScore()differs fromScoreExplanation.getScore()because eachConstraintMatch.getScore()is counted for each of theindicted objects.- Specified by:
getIndictmentMapin interfaceScoreExplanation<Solution_,Score_ extends Score<Score_>> - Returns:
- the key is a
problem factor aplanning entity - See Also:
-
getSummary
Description copied from interface:ScoreExplanationReturns a diagnostic text that explains the solution through theConstraintMatchAPI to identify which constraints or planning entities cause that score quality.In case of an
infeasiblesolution, this can help diagnose the cause of that.Do not parse the return value, its format may change without warning. Instead, to provide this information in a UI or a service, use
ScoreExplanation.getConstraintMatchTotalMap()andScoreExplanation.getIndictmentMap()and convert those into a domain-specific API.- Specified by:
getSummaryin interfaceScoreExplanation<Solution_,Score_ extends Score<Score_>>
-
toString
-