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_>

- - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `DefaultScoreExplanation​(Solution_ solution, Score_ score, Map<String,​ConstraintMatchTotal<Score_>> constraintMatchTotalMap, Map<Object,​Indictment<Score_>> indictmentMap)` |

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `static <Score_ extends Score<Score_>> String` | `explainScore​(Score_ workingScore, Collection<ConstraintMatchTotal<Score_>> constraintMatchTotalCollection, Collection<Indictment<Score_>> indictmentCollection)` |
    `static <Score_ extends Score<Score_>> String` | `explainScore​(Score_ workingScore, Collection<ConstraintMatchTotal<Score_>> constraintMatchTotalCollection, Collection<Indictment<Score_>> indictmentCollection, int indictmentLimit, int constraintMatchLimit)` |
    `Map<String,​ConstraintMatchTotal<Score_>>` | `getConstraintMatchTotalMap()` | Explains the `Score` of `ScoreExplanation.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.
    `String` | `toString()` |

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### DefaultScoreExplanation

          public DefaultScoreExplanation​(Solution_ solution,
                                         Score_ score,
                                         Map<String,​ConstraintMatchTotal<Score_>> constraintMatchTotalMap,
                                         Map<Object,​Indictment<Score_>> indictmentMap)

  - ### 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 the `PlanningSolution` that the score being explained comes from.
      Specified by:
        `getSolution` in interface `ScoreExplanation<Solution_,​Score_ extends Score<Score_>>`
      Returns:
        never null

    - #### getScore

          public Score_ getScore()

      Description copied from interface: `ScoreExplanation`
      Return the `Score` being explained. If the specific `Score` type used by the `PlanningSolution` is required, call `ScoreExplanation.getSolution()` and retrieve it from there.
      Specified by:
        `getScore` in interface `ScoreExplanation<Solution_,​Score_ extends Score<Score_>>`
      Returns:
        never null

    - #### getConstraintMatchTotalMap

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

      Description copied from interface: `ScoreExplanation`
      Explains the `Score` of `ScoreExplanation.getScore()` ()} by splitting it up per `Constraint`.

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

      Specified by:
        `getConstraintMatchTotalMap` in interface `ScoreExplanation<Solution_,​Score_ extends Score<Score_>>`
      Returns:
        never null, the key is the `constraintId` (to create one, use `ConstraintMatchTotal.composeConstraintId(String, String)`).
      See Also:
        `ScoreExplanation.getIndictmentMap()`

    - #### getIndictmentMap

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

      Description copied from interface: `ScoreExplanation`
      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 `ScoreExplanation.getScore()` ()} because each `ConstraintMatch.getScore()` is counted for each justification in `ConstraintMatch.getJustificationList()`.

      Specified by:
        `getIndictmentMap` in interface `ScoreExplanation<Solution_,​Score_ extends Score<Score_>>`
      Returns:
        never null, the key is a `problem fact` or a `planning entity`
      See Also:
        `ScoreExplanation.getConstraintMatchTotalMap()`

    - #### getSummary

          public String getSummary()

      Description copied from interface: `ScoreExplanation`
      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 `ScoreExplanation.getConstraintMatchTotalMap()` and `ScoreExplanation.getIndictmentMap()` and convert those into a domain specific API.

      Specified by:
        `getSummary` in interface `ScoreExplanation<Solution_,​Score_ extends Score<Score_>>`
      Returns:
        never null

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`