Package org.optaplanner.core.api.score

## Interface ScoreManager<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:
    `DefaultScoreManager`

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

  A stateless service to help calculate `Score`, `ConstraintMatchTotal`, `Indictment`, etc.

  To create a ScoreManager, use `create(SolverFactory)`.

  These methods are thread-safe unless explicitly stated otherwise.

- - ### Method Summary

    All Methods Static Methods Instance Methods Abstract Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `static <Solution_,​Score_ extends Score<Score_>> ScoreManager<Solution_,​Score_>` | `create​(SolverFactory<Solution_> solverFactory)` | Uses a `SolverFactory` to build a `ScoreManager`.
    `ScoreExplanation<Solution_,​Score_>` | `explainScore​(Solution_ solution)` | Calculates and retrieves `ConstraintMatchTotal`s and `Indictment`s necessary for describing the quality of a particular solution.
    `String` | `getSummary​(Solution_ solution)` | Returns a diagnostic text that explains the solution through the `ConstraintMatch` API to identify which constraints or planning entities cause that score quality.
    `Score_` | `updateScore​(Solution_ solution)` | Calculates the `Score` of a `PlanningSolution` and updates its `PlanningScore` member.

- - ### Method Detail

    - #### create

          static <Solution_,​Score_ extends Score<Score_>> ScoreManager<Solution_,​Score_> create​(SolverFactory<Solution_> solverFactory)

      Uses a `SolverFactory` to build a `ScoreManager`.
      Type Parameters:
        `Solution_` - the solution type, the class with the `PlanningSolution` annotation
        `Score_` - the actual score type
      Parameters:
        `solverFactory` - never null
      Returns:
        never null

    - #### updateScore

          Score_ updateScore​(Solution_ solution)

      Calculates the `Score` of a `PlanningSolution` and updates its `PlanningScore` member.
      Parameters:
        `solution` - never null

    - #### getSummary

          String getSummary​(Solution_ solution)

      Returns a diagnostic text that explains the solution 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 `explainScore(Object)` to retrieve `ScoreExplanation.getConstraintMatchTotalMap()` and `ScoreExplanation.getIndictmentMap()` and convert those into a domain specific API.

      Parameters:
        `solution` - never null
      Returns:
        null if `updateScore(Object)` returns null with the same solution
      Throws:
        `IllegalStateException` - when constraint matching is disabled or not supported by the underlying score calculator, such as `EasyScoreCalculator`.

    - #### explainScore

          ScoreExplanation<Solution_,​Score_> explainScore​(Solution_ solution)

      Calculates and retrieves `ConstraintMatchTotal`s and `Indictment`s necessary for describing the quality of a particular solution.
      Parameters:
        `solution` - never null
      Returns:
        never null
      Throws:
        `IllegalStateException` - when constraint matching is disabled or not supported by the underlying score calculator, such as `EasyScoreCalculator`.