Interface ScoreExplanation<Solution_,Score_ extends Score<Score_>>
- Type Parameters:
Solution_- the solution type, the class with thePlanningSolutionannotationScore_- the actual score type
- All Known Implementing Classes:
DefaultScoreExplanation
public interface ScoreExplanation<Solution_,Score_ extends Score<Score_>>
Build by
SolutionManager.explain(Object) to hold ConstraintMatchTotals and Indictments
necessary to explain the quality of a particular Score.
For a simplified, faster and JSON-friendly alternative, see ScoreAnalysis.
-
Method Summary
Modifier and TypeMethodDescription@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 theScoreofgetScore()for all constraints.default <ConstraintJustification_ extends ConstraintJustification>
@NonNull List<ConstraintJustification_>getJustificationList(@NonNull Class<? extends ConstraintJustification_> constraintJustificationClass) Explains theScoreofgetScore()for all constraints justified with a givenConstraintJustificationtype.@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.booleanWhethergetSolution()is initialized or not.
-
Method Details
-
getSolution
@NonNull Solution_ getSolution()Retrieve thePlanningSolutionthat the score being explained comes from. -
getScore
@NonNull Score_ getScore()Return theScorebeing explained. If the specificScoretype used by thePlanningSolutionis required, callgetSolution()and retrieve it from there. -
isInitialized
boolean isInitialized()WhethergetSolution()is initialized or not.- Returns:
- true if initialized
-
getSummary
@NonNull String getSummary()Returns 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
getConstraintMatchTotalMap()andgetIndictmentMap()and convert those into a domain-specific API. -
getConstraintMatchTotalMap
@NonNull Map<String,ConstraintMatchTotal<Score_>> getConstraintMatchTotalMap()Explains theScoreofgetScore()by splitting it up perConstraint.The sum of
ConstraintMatchTotal.getScore()equalsgetScore().- Returns:
- the key is the constraintId
(to create one, use
ConstraintRef.composeConstraintId(String, String)). - See Also:
-
getJustificationList
@NonNull List<ConstraintJustification> getJustificationList()Explains theScoreofgetScore()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.
- Returns:
- all constraint matches
- See Also:
-
With Constraint Streams, the user has an option to provide a custom justification mapping,
implementing
-
getJustificationList
default <ConstraintJustification_ extends ConstraintJustification> @NonNull List<ConstraintJustification_> getJustificationList(@NonNull Class<? extends ConstraintJustification_> constraintJustificationClass) Explains theScoreofgetScore()for all constraints justified with a givenConstraintJustificationtype. Otherwise, as defined bygetJustificationList(). May be empty, if the score explanation ran with justification support disabled.- Returns:
- all constraint matches associated with the given justification class
- See Also:
-
getIndictmentMap
@NonNull Map<Object,Indictment<Score_>> getIndictmentMap()Explains 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 fromgetScore()because eachConstraintMatch.getScore()is counted for each of theindicted objects.- Returns:
- the key is a
problem factor aplanning entity - See Also:
-