Package org.optaplanner.core.impl.score
Class DefaultScoreExplanation<Solution_,Score_ extends Score<Score_>>
- java.lang.Object
-
- org.optaplanner.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_>
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static <Score_ extends Score<Score_>>
StringexplainScore(Score_ workingScore, Collection<ConstraintMatchTotal<Score_>> constraintMatchTotalCollection, Collection<Indictment<Score_>> indictmentCollection)
static <Score_ extends Score<Score_>>
StringexplainScore(Score_ workingScore, Collection<ConstraintMatchTotal<Score_>> constraintMatchTotalCollection, Collection<Indictment<Score_>> indictmentCollection, int indictmentLimit, int constraintMatchLimit)
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
ofScoreExplanation.getScore()
for all constraints.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.String
toString()
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.optaplanner.core.api.score.ScoreExplanation
getJustificationList
-
-
-
-
Method Detail
-
explainScore
public static <Score_ extends Score<Score_>> String explainScore(Score_ workingScore, Collection<ConstraintMatchTotal<Score_>> constraintMatchTotalCollection, Collection<Indictment<Score_>> indictmentCollection)
-
explainScore
public static <Score_ extends Score<Score_>> String explainScore(Score_ workingScore, Collection<ConstraintMatchTotal<Score_>> constraintMatchTotalCollection, Collection<Indictment<Score_>> indictmentCollection, int indictmentLimit, int constraintMatchLimit)
-
getSolution
public Solution_ getSolution()
Description copied from interface:ScoreExplanation
Retrieve thePlanningSolution
that the score being explained comes from.- Specified by:
getSolution
in interfaceScoreExplanation<Solution_,Score_ extends Score<Score_>>
- Returns:
- never null
-
getScore
public Score_ getScore()
Description copied from interface:ScoreExplanation
Return theScore
being explained. If the specificScore
type used by thePlanningSolution
is required, callScoreExplanation.getSolution()
and retrieve it from there.
-
getConstraintMatchTotalMap
public Map<String,ConstraintMatchTotal<Score_>> getConstraintMatchTotalMap()
Description copied from interface:ScoreExplanation
Explains theScore
ofScoreExplanation.getScore()
by splitting it up perConstraint
.The sum of
ConstraintMatchTotal.getScore()
equalsScoreExplanation.getScore()
.- Specified by:
getConstraintMatchTotalMap
in interfaceScoreExplanation<Solution_,Score_ extends Score<Score_>>
- Returns:
- never null, the key is the
constraintId
(to create one, useConstraintMatchTotal.composeConstraintId(String, String)
). - See Also:
ScoreExplanation.getIndictmentMap()
-
getJustificationList
public List<ConstraintJustification> getJustificationList()
Description copied from interface:ScoreExplanation
Explains theScore
ofScoreExplanation.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, 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
.
- Specified by:
getJustificationList
in interfaceScoreExplanation<Solution_,Score_ extends Score<Score_>>
- Returns:
- never null, all constraint matches
- See Also:
ScoreExplanation.getIndictmentMap()
-
With Constraint Streams, the user has an option to provide a custom justification mapping,
implementing
-
getIndictmentMap
public Map<Object,Indictment<Score_>> getIndictmentMap()
Description copied from interface:ScoreExplanation
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 fromScoreExplanation.getScore()
because eachConstraintMatch.getScore()
is counted for each of theindicted objects
.- Specified by:
getIndictmentMap
in interfaceScoreExplanation<Solution_,Score_ extends Score<Score_>>
- Returns:
- never null, the key is a
problem fact
or aplanning entity
- See Also:
ScoreExplanation.getConstraintMatchTotalMap()
-
getSummary
public String getSummary()
Description copied from interface:ScoreExplanation
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
ScoreExplanation.getConstraintMatchTotalMap()
andScoreExplanation.getIndictmentMap()
and convert those into a domain specific API.- Specified by:
getSummary
in interfaceScoreExplanation<Solution_,Score_ extends Score<Score_>>
- Returns:
- never null
-
-