Interface ScoreDefinition<S extends Score<S>>
-
- All Known Subinterfaces:
PlanningScore.NullScoreDefinition
- All Known Implementing Classes:
AbstractBendableScoreDefinition
,AbstractScoreDefinition
,BendableBigDecimalScoreDefinition
,BendableLongScoreDefinition
,BendableScoreDefinition
,HardMediumSoftBigDecimalScoreDefinition
,HardMediumSoftLongScoreDefinition
,HardMediumSoftScoreDefinition
,HardSoftBigDecimalScoreDefinition
,HardSoftDoubleScoreDefinition
,HardSoftLongScoreDefinition
,HardSoftScoreDefinition
,SimpleBigDecimalScoreDefinition
,SimpleDoubleScoreDefinition
,SimpleLongScoreDefinition
,SimpleScoreDefinition
public interface ScoreDefinition<S extends Score<S>>
- See Also:
AbstractScoreDefinition
,HardSoftScoreDefinition
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description S
buildOptimisticBound(InitializingScoreTrend initializingScoreTrend, S score)
S
buildPessimisticBound(InitializingScoreTrend initializingScoreTrend, S score)
ScoreHolder<S>
buildScoreHolder(boolean constraintMatchEnabled)
Used byDroolsScoreDirector
.ScoreInliner<S>
buildScoreInliner(boolean constraintMatchEnabled)
Used byBavetConstraintFactory
S
divideBySanitizedDivisor(S dividend, S divisor)
ReturnScore
whose every level is the result of dividing the matching levels in this and the divisor.String
formatScore(S score)
S
fromLevelNumbers(int initScore, Number[] levelNumbers)
The opposite ofScore.toLevelNumbers()
.int
getFeasibleLevelsSize()
Returns the number of levels ofScore.toLevelNumbers()
.String
getInitLabel()
Returns the label forScore.getInitScore()
.String[]
getLevelLabels()
Returns a label for each score level.int
getLevelsSize()
Returns the length ofScore.toLevelNumbers()
for everyScore
of this definition.S
getOneSoftestScore()
The score that represents the softest possible one.Class<S>
getScoreClass()
S
getZeroScore()
The score that represents zero.boolean
isCompatibleArithmeticArgument(Score score)
default boolean
isNegativeOrZero(S score)
default boolean
isPositiveOrZero(S score)
S
parseScore(String scoreString)
-
-
-
Method Detail
-
getInitLabel
String getInitLabel()
Returns the label forScore.getInitScore()
.- Returns:
- never null
- See Also:
getLevelLabels()
-
getLevelsSize
int getLevelsSize()
Returns the length ofScore.toLevelNumbers()
for everyScore
of this definition. For example: returns 2 onHardSoftScoreDefinition
.- Returns:
- at least 1
-
getFeasibleLevelsSize
int getFeasibleLevelsSize()
Returns the number of levels ofScore.toLevelNumbers()
. that are used to determineScore.isFeasible()
.- Returns:
- at least 0, at most
getLevelsSize()
-
getLevelLabels
String[] getLevelLabels()
Returns a label for each score level. Each label includes the suffix "score" and must start in lower case. For example: returns{"hard score", "soft score "}
onHardSoftScoreDefinition
.It does not include the
getInitLabel()
.- Returns:
- never null, array with length of
getLevelsSize()
, each element is never null
-
getScoreClass
Class<S> getScoreClass()
Returns theClass
of the actualScore
implementation. For example: returnsHardSoftScore.class
onHardSoftScoreDefinition
.- Returns:
- never null
-
getZeroScore
S getZeroScore()
The score that represents zero.- Returns:
- never null
-
getOneSoftestScore
S getOneSoftestScore()
The score that represents the softest possible one.- Returns:
- never null
-
isPositiveOrZero
default boolean isPositiveOrZero(S score)
- Parameters:
score
- never null- Returns:
- true if the score is higher or equal to
getZeroScore()
-
isNegativeOrZero
default boolean isNegativeOrZero(S score)
- Parameters:
score
- never null- Returns:
- true if the score is lower or equal to
getZeroScore()
-
formatScore
String formatScore(S score)
- Parameters:
score
- never null- Returns:
- never null
- See Also:
parseScore(String)
-
parseScore
S parseScore(String scoreString)
- Parameters:
scoreString
- never null- Returns:
- never null
- See Also:
formatScore(Score)
,ScoreUtils.parseScore(Class, String)
-
fromLevelNumbers
S fromLevelNumbers(int initScore, Number[] levelNumbers)
The opposite ofScore.toLevelNumbers()
.- Parameters:
initScore
-<= 0
, managed by OptaPlanner, needed as a parameter in theScore
's creation method, seeScore.getInitScore()
levelNumbers
- never null- Returns:
- never null
-
buildScoreInliner
ScoreInliner<S> buildScoreInliner(boolean constraintMatchEnabled)
Used byBavetConstraintFactory
- Parameters:
constraintMatchEnabled
- true ifScoreDirector.isConstraintMatchEnabled()
should be true- Returns:
- never null
-
buildScoreHolder
ScoreHolder<S> buildScoreHolder(boolean constraintMatchEnabled)
Used byDroolsScoreDirector
.- Parameters:
constraintMatchEnabled
- true ifScoreDirector.isConstraintMatchEnabled()
should be true- Returns:
- never null
-
buildOptimisticBound
S buildOptimisticBound(InitializingScoreTrend initializingScoreTrend, S score)
Builds aScore
which is equal or better than any otherScore
with more variables initialized (while the already variables don't change).- Parameters:
initializingScoreTrend
- never null, withInitializingScoreTrend.getLevelsSize()
equal togetLevelsSize()
.score
- never null, withScore.getInitScore()
0
.- Returns:
- never null
-
buildPessimisticBound
S buildPessimisticBound(InitializingScoreTrend initializingScoreTrend, S score)
Builds aScore
which is equal or worse than any otherScore
with more variables initialized (while the already variables don't change).- Parameters:
initializingScoreTrend
- never null, withInitializingScoreTrend.getLevelsSize()
equal togetLevelsSize()
.score
- never null, withScore.getInitScore()
0
- Returns:
- never null
-
divideBySanitizedDivisor
S divideBySanitizedDivisor(S dividend, S divisor)
ReturnScore
whose every level is the result of dividing the matching levels in this and the divisor. When rounding is needed, it is floored (as defined byMath.floor(double)
).If any of the levels in the divisor are equal to zero, the method behaves as if they were equal to one instead.
- Parameters:
divisor
- value by which this Score is to be divided- Returns:
- this / divisor
-
isCompatibleArithmeticArgument
boolean isCompatibleArithmeticArgument(Score score)
- Parameters:
score
- never null- Returns:
- true if the otherScore is accepted as a parameter of
Score.add(Score)
,Score.subtract(Score)
andComparable.compareTo(Object)
for scores of this score definition.
-
-