Package org.optaplanner.core.api.score
Interface ScoreExplanation<Solution_,Score_ extends Score<Score_>>
-
- Type Parameters:
Solution_
- the solution type, the class with thePlanningSolution
annotationScore_
- the actual score type
- All Known Implementing Classes:
DefaultScoreExplanation
public interface ScoreExplanation<Solution_,Score_ extends Score<Score_>>
Build byScoreManager.explainScore(Object)
to holdConstraintMatchTotal
s andIndictment
s necessary to explain the quality of a particularScore
.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description Map<String,ConstraintMatchTotal<Score_>>
getConstraintMatchTotalMap()
Map<Object,Indictment<Score_>>
getIndictmentMap()
Explains the impact of each planning entity or problem fact on theScore
.List<ConstraintJustification>
getJustificationList()
Explains theScore
ofgetScore()
for all constraints.default <ConstraintJustification_ extends ConstraintJustification>
List<ConstraintJustification_>getJustificationList(Class<? extends ConstraintJustification_> constraintJustificationClass)
Explains theScore
ofgetScore()
for all constraints justified with a givenConstraintJustification
type.Score_
getScore()
Return theScore
being explained.Solution_
getSolution()
Retrieve thePlanningSolution
that the score being explained comes from.String
getSummary()
Returns a diagnostic text that explains theScore
through theConstraintMatch
API to identify which constraints or planning entities cause that score quality.
-
-
-
Method Detail
-
getSolution
Solution_ getSolution()
Retrieve thePlanningSolution
that the score being explained comes from.- Returns:
- never null
-
getScore
Score_ getScore()
Return theScore
being explained. If the specificScore
type used by thePlanningSolution
is required, callgetSolution()
and retrieve it from there.- Returns:
- never null
-
getSummary
String getSummary()
Returns a diagnostic text that explains theScore
through theConstraintMatch
API to identify which constraints or planning entities cause that score quality. In case of aninfeasible
solution, this can help diagnose the cause of that.Do not parse this string. Instead, to provide this information in a UI or a service, use
getConstraintMatchTotalMap()
andgetIndictmentMap()
and convert those into a domain specific API.- Returns:
- never null
-
getConstraintMatchTotalMap
Map<String,ConstraintMatchTotal<Score_>> getConstraintMatchTotalMap()
Explains theScore
ofgetScore()
by splitting it up perConstraint
.The sum of
ConstraintMatchTotal.getScore()
equalsgetScore()
.- Returns:
- never null, the key is the
constraintId
(to create one, useConstraintMatchTotal.composeConstraintId(String, String)
). - See Also:
getIndictmentMap()
-
getJustificationList
List<ConstraintJustification> getJustificationList()
Explains theScore
ofgetScore()
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, everyConstraintMatch
of 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
, everyConstraintMatch
will be associated with the justification class that the user created it with. -
With score DRL, every
ConstraintMatch
will be associated withDefaultConstraintJustification
.
- Returns:
- never null, all constraint matches
- See Also:
getIndictmentMap()
-
With Constraint Streams, the user has an option to provide a custom justification mapping,
implementing
-
getJustificationList
default <ConstraintJustification_ extends ConstraintJustification> List<ConstraintJustification_> getJustificationList(Class<? extends ConstraintJustification_> constraintJustificationClass)
Explains theScore
ofgetScore()
for all constraints justified with a givenConstraintJustification
type. Otherwise, as defined bygetJustificationList()
.- Parameters:
constraintJustificationClass
- never null- Returns:
- never null, all constraint matches associated with the given justification class
- See Also:
getIndictmentMap()
-
getIndictmentMap
Map<Object,Indictment<Score_>> getIndictmentMap()
Explains the impact of each planning entity or problem fact on theScore
. AnIndictment
is basically the inverse of aConstraintMatchTotal
: it is aScore
total for any of theindicted objects
.The sum of
ConstraintMatchTotal.getScore()
differs fromgetScore()
because eachConstraintMatch.getScore()
is counted for each of theindicted objects
.- Returns:
- never null, the key is a
problem fact
or aplanning entity
- See Also:
getConstraintMatchTotalMap()
-
-