Score_
- the actual score type to allow addition, subtraction and other arithmeticpublic interface Score<Score_ extends Score> extends Comparable<Score_>
Implementations must be immutable.
Implementations are allowed to optionally implement Pareto comparison
and therefore slightly violate the transitive requirement of Comparable.compareTo(Object)
.
An implementation must extend AbstractScore
to ensure backwards compatibility in future versions.
AbstractScore
,
HardSoftScore
Modifier and Type | Method and Description |
---|---|
Score_ |
add(Score_ augment)
Returns a Score whose value is (this + augment).
|
Score_ |
divide(double divisor)
Returns a Score whose value is (this / divisor).
|
int |
getInitScore()
The init score is the negative of the number of uninitialized genuine planning variables.
|
boolean |
isCompatibleArithmeticArgument(Score otherScore) |
boolean |
isSolutionInitialized()
Checks if the
PlanningSolution of this score was fully initialized when it was calculated. |
Score_ |
multiply(double multiplicand)
Returns a Score whose value is (this * multiplicand).
|
Score_ |
negate()
Returns a Score whose value is (- this).
|
Score_ |
power(double exponent)
Returns a Score whose value is (this ^ exponent).
|
Score_ |
subtract(Score_ subtrahend)
Returns a Score whose value is (this - subtrahend).
|
Score_ |
toInitializedScore()
For example
-7init/0hard/-8soft returns 0hard/-8soft . |
Number[] |
toLevelNumbers()
Returns an array of numbers representing the Score.
|
String |
toShortString()
Like
Object.toString() , but trims score levels which have a zero weight. |
Score_ |
withInitScore(int newInitScore)
For example
0hard/-8soft with -7 returns -7init/0hard/-8soft . |
compareTo
int getInitScore()
PlanningSolution
is fully initialized
and the score's Object.toString()
does not mention it.
During Comparable.compareTo(Object)
, it's even more important than the hard score:
if you don't want this behaviour, read about overconstrained planning in the reference manual.
boolean isSolutionInitialized()
PlanningSolution
of this score was fully initialized when it was calculated.getInitScore()
is 0Score_ toInitializedScore()
-7init/0hard/-8soft
returns 0hard/-8soft
.getInitScore()
is 0
.Score_ withInitScore(int newInitScore)
0hard/-8soft
with -7
returns -7init/0hard/-8soft
.newInitScore
- always negative (except in statistical calculations), 0 if all planning variables are initializedgetInitScore()
is set to newInitScore
IllegalStateException
- if the original getInitScore()
is not 0Score_ add(Score_ augment)
augment
- value to be added to this ScoreScore_ subtract(Score_ subtrahend)
subtrahend
- value to be subtracted from this ScoreScore_ multiply(double multiplicand)
Math.floor(double)
).
If the implementation has a scale/precision, then the unspecified scale/precision of the double multiplicand should have no impact on the returned scale/precision.
multiplicand
- value to be multiplied by this Score.Score_ divide(double divisor)
Math.floor(double)
).
If the implementation has a scale/precision, then the unspecified scale/precision of the double divisor should have no impact on the returned scale/precision.
divisor
- value by which this Score is to be dividedScore_ power(double exponent)
Math.floor(double)
).
If the implementation has a scale/precision, then the unspecified scale/precision of the double exponent should have no impact on the returned scale/precision.
exponent
- value by which this Score is to be poweredScore_ negate()
Number[] toLevelNumbers()
When rounding is needed, each rounding should be floored (as defined by Math.floor(double)
).
The length of the returned array must be stable for a specific Score
implementation.
For example: -0hard/-7soft
returns new int{-0, -7}
The level numbers do not contain the getInitScore()
.
For example: -3init/-0hard/-7soft
also returns new int{-0, -7}
ScoreDefinition.fromLevelNumbers(int, Number[])
boolean isCompatibleArithmeticArgument(Score otherScore)
otherScore
- never nulladd(Score)
, subtract(Score)
and Comparable.compareTo(Object)
.String toShortString()
Object.toString()
, but trims score levels which have a zero weight.
For example 0hard/-258soft returns -258soft.
Do not use this format to persist information as text, use Object.toString()
instead,
so it can be parsed reliably.
Copyright © 2006–2019 JBoss by Red Hat. All rights reserved.