Package org.optaplanner.core.api.score
Interface ScoreManager<Solution_,Score_ extends Score<Score_>>
- Type Parameters:
Solution_
- the solution type, the class with thePlanningSolution
annotationScore_
- 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
Modifier and TypeMethodDescriptionstatic <Solution_,
Score_ extends Score<Score_>>
ScoreManager<Solution_,Score_> create
(SolverFactory<Solution_> solverFactory) Uses aSolverFactory
to build aScoreManager
.static <Solution_,
Score_ extends Score<Score_>, ProblemId_>
ScoreManager<Solution_,Score_> create
(SolverManager<Solution_, ProblemId_> solverManager) Uses aSolverManager
to build aScoreManager
.explainScore
(Solution_ solution) Calculates and retrievesConstraintMatchTotal
s andIndictment
s necessary for describing the quality of a particular solution.getSummary
(Solution_ solution) Returns a diagnostic text that explains the solution through theConstraintMatch
API to identify which constraints or planning entities cause that score quality.updateScore
(Solution_ solution)
-
Method Details
-
create
static <Solution_,Score_ extends Score<Score_>> ScoreManager<Solution_,Score_> create(SolverFactory<Solution_> solverFactory) Uses aSolverFactory
to build aScoreManager
.- Type Parameters:
Solution_
- the solution type, the class with thePlanningSolution
annotationScore_
- the actual score type- Parameters:
solverFactory
- never null- Returns:
- never null
-
create
static <Solution_,Score_ extends Score<Score_>, ScoreManager<Solution_,ProblemId_> Score_> create(SolverManager<Solution_, ProblemId_> solverManager) Uses aSolverManager
to build aScoreManager
.- Type Parameters:
Solution_
- the solution type, the class with thePlanningSolution
annotationScore_
- the actual score typeProblemId_
- the ID type of a submitted problem, such asLong
orUUID
- Parameters:
solverManager
- never null- Returns:
- never null
-
updateScore
- Parameters:
solution
- never null
-
getSummary
Returns a diagnostic text that explains the solution 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
explainScore(Object)
to retrieveScoreExplanation.getConstraintMatchTotalMap()
andScoreExplanation.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 asEasyScoreCalculator
.
-
explainScore
Calculates and retrievesConstraintMatchTotal
s andIndictment
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 asEasyScoreCalculator
.
-