Package org.optaplanner.core.api.score

## Interface ScoreExplanation<Solution_,​Score_ extends Score<Score_>>

- Type Parameters:
    `Solution_` - the solution type, the class with the `PlanningSolution` annotation
    `Score_` - the actual score type
  All Known Implementing Classes:
    `DefaultScoreExplanation`

      public interface ScoreExplanation<Solution_,​Score_ extends Score<Score_>>

  Build by `ScoreManager.explainScore(Object)` to hold `ConstraintMatchTotal`s and `Indictment`s necessary to explain the quality of a particular `Score`.

- - ### Method Summary

    All Methods Instance Methods Abstract Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `Map<String,​ConstraintMatchTotal<Score_>>` | `getConstraintMatchTotalMap()` | Explains the `Score` of `getScore()` ()} by splitting it up per `Constraint`.
    `Map<Object,​Indictment<Score_>>` | `getIndictmentMap()` | Explains the impact of each planning entity or problem fact on the `Score`.
    `Score_` | `getScore()` | Return the `Score` being explained.
    `Solution_` | `getSolution()` | Retrieve the `PlanningSolution` that the score being explained comes from.
    `String` | `getSummary()` | Returns a diagnostic text that explains the `Score` through the `ConstraintMatch` API to identify which constraints or planning entities cause that score quality.

- - ### Method Detail

    - #### getSolution

          Solution_ getSolution()

      Retrieve the `PlanningSolution` that the score being explained comes from.
      Returns:
        never null

    - #### getScore

          Score_ getScore()

      Return the `Score` being explained. If the specific `Score` type used by the `PlanningSolution` is required, call `getSolution()` and retrieve it from there.
      Returns:
        never null

    - #### getSummary

          String getSummary()

      Returns a diagnostic text that explains the `Score` through the `ConstraintMatch` API to identify which constraints or planning entities cause that score quality. In case of an `infeasible` 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()` and `getIndictmentMap()` and convert those into a domain specific API.

      Returns:
        never null

    - #### getConstraintMatchTotalMap

          Map<String,​ConstraintMatchTotal<Score_>> getConstraintMatchTotalMap()

      Explains the `Score` of `getScore()` ()} by splitting it up per `Constraint`.

      The sum of `ConstraintMatchTotal.getScore()` equals `getScore()` ()}.

      Returns:
        never null, the key is the `constraintId` (to create one, use `ConstraintMatchTotal.composeConstraintId(String, String)`).
      See Also:
        `getIndictmentMap()`

    - #### getIndictmentMap

          Map<Object,​Indictment<Score_>> getIndictmentMap()

      Explains the impact of each planning entity or problem fact on the `Score`. An `Indictment` is basically the inverse of a `ConstraintMatchTotal`: it is a `Score` total for each justification `Object` in `ConstraintMatch.getJustificationList()`.

      The sum of `ConstraintMatchTotal.getScore()` differs from `getScore()` ()} because each `ConstraintMatch.getScore()` is counted for each justification in `ConstraintMatch.getJustificationList()`.

      Returns:
        never null, the key is a `problem fact` or a `planning entity`
      See Also:
        `getConstraintMatchTotalMap()`