Class SimpleScoreDefinition
- java.lang.Object
-
- org.optaplanner.core.impl.score.definition.AbstractScoreDefinition<SimpleScore>
-
- org.optaplanner.core.impl.score.buildin.SimpleScoreDefinition
-
- All Implemented Interfaces:
ScoreDefinition<SimpleScore>
public class SimpleScoreDefinition extends AbstractScoreDefinition<SimpleScore>
-
-
Constructor Summary
Constructors Constructor Description SimpleScoreDefinition()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description SimpleScore
buildOptimisticBound(InitializingScoreTrend initializingScoreTrend, SimpleScore score)
SimpleScore
buildPessimisticBound(InitializingScoreTrend initializingScoreTrend, SimpleScore score)
SimpleScore
divideBySanitizedDivisor(SimpleScore dividend, SimpleScore divisor)
ReturnScore
whose every level is the result of dividing the matching levels in this and the divisor.SimpleScore
fromLevelNumbers(int initScore, Number[] levelNumbers)
The opposite ofScore.toLevelNumbers()
.int
getFeasibleLevelsSize()
Returns the number of levels ofScore.toLevelNumbers()
.int
getLevelsSize()
Returns the length ofScore.toLevelNumbers()
for everyScore
of this definition.SimpleScore
getOneSoftestScore()
The score that represents the softest possible one.Class<SimpleScore>
getScoreClass()
SimpleScore
getZeroScore()
The score that represents zero.SimpleScore
parseScore(String scoreString)
-
Methods inherited from class org.optaplanner.core.impl.score.definition.AbstractScoreDefinition
divide, divide, divide, divide, formatScore, getInitLabel, getLevelLabels, isCompatibleArithmeticArgument, sanitize, sanitize, sanitize, toString
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.optaplanner.core.impl.score.definition.ScoreDefinition
isNegativeOrZero, isPositiveOrZero
-
-
-
-
Method Detail
-
getLevelsSize
public int getLevelsSize()
Description copied from interface:ScoreDefinition
Returns the length ofScore.toLevelNumbers()
for everyScore
of this definition. For example: returns 2 onHardSoftScoreDefinition
.- Specified by:
getLevelsSize
in interfaceScoreDefinition<SimpleScore>
- Overrides:
getLevelsSize
in classAbstractScoreDefinition<SimpleScore>
- Returns:
- at least 1
-
getFeasibleLevelsSize
public int getFeasibleLevelsSize()
Description copied from interface:ScoreDefinition
Returns the number of levels ofScore.toLevelNumbers()
. that are used to determineScore.isFeasible()
.- Returns:
- at least 0, at most
ScoreDefinition.getLevelsSize()
-
getScoreClass
public Class<SimpleScore> getScoreClass()
Description copied from interface:ScoreDefinition
Returns theClass
of the actualScore
implementation. For example: returnsHardSoftScore.class
onHardSoftScoreDefinition
.- Returns:
- never null
-
getZeroScore
public SimpleScore getZeroScore()
Description copied from interface:ScoreDefinition
The score that represents zero.- Returns:
- never null
-
getOneSoftestScore
public SimpleScore getOneSoftestScore()
Description copied from interface:ScoreDefinition
The score that represents the softest possible one.- Returns:
- never null
-
parseScore
public SimpleScore parseScore(String scoreString)
Description copied from interface:ScoreDefinition
- Parameters:
scoreString
- never null- Returns:
- never null
- See Also:
ScoreDefinition.formatScore(Score)
,ScoreUtils.parseScore(Class, String)
-
fromLevelNumbers
public SimpleScore fromLevelNumbers(int initScore, Number[] levelNumbers)
Description copied from interface:ScoreDefinition
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
-
buildOptimisticBound
public SimpleScore buildOptimisticBound(InitializingScoreTrend initializingScoreTrend, SimpleScore score)
Description copied from interface:ScoreDefinition
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 toScoreDefinition.getLevelsSize()
.score
- never null, withScore.getInitScore()
0
.- Returns:
- never null
-
buildPessimisticBound
public SimpleScore buildPessimisticBound(InitializingScoreTrend initializingScoreTrend, SimpleScore score)
Description copied from interface:ScoreDefinition
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 toScoreDefinition.getLevelsSize()
.score
- never null, withScore.getInitScore()
0
- Returns:
- never null
-
divideBySanitizedDivisor
public SimpleScore divideBySanitizedDivisor(SimpleScore dividend, SimpleScore divisor)
Description copied from interface:ScoreDefinition
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.
divisor
- value by which this Score is to be divided- Returns:
- this / divisor
-
-