org.optaplanner.core.api.score

## Interface ScoreManager<Solution_>

- Type Parameters:
    `Solution_` - the solution type, the class with the `PlanningSolution` annotation
  All Known Implementing Classes:
    DefaultScoreManager

      public interface ScoreManager<Solution_>

  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 Default Methods
    Modifier and Type | Method and Description
    --- | ---
    `static <Solution_> ScoreManager<Solution_>` | `create(SolverFactory<Solution_> solverFactory)` Uses a `SolverFactory` to build a `ScoreManager`.
    `String` | `explainScore(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_> ScoreManager<Solution_> create(SolverFactory<Solution_> solverFactory)

      Uses a `SolverFactory` to build a `ScoreManager`.
      Type Parameters:
        `Solution_` - the solution type, the class with the `PlanningSolution` annotation
      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

    - #### explainScore

          String explainScore(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 `SolverFactory.getScoreDirectorFactory()` to retrieve `ScoreDirector.getConstraintMatchTotalMap()` and `ScoreDirector.getIndictmentMap()` and convert those into a domain specific API.

      This method is thread-safe.

      Returns:
        null if `updateScore(Object)` returns null with the same solution
      See Also:
        `ScoreDirector.explainScore()`

Copyright © 2006–2021 JBoss by Red Hat. All rights reserved.