S
- the actual score typepublic interface Score<S extends Score> extends Comparable<S>
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 |
---|---|
S |
add(S augment)
Returns a Score whose value is (this + augment).
|
S |
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. |
S |
multiply(double multiplicand)
Returns a Score whose value is (this * multiplicand).
|
S |
negate()
Returns a Score whose value is (- this).
|
S |
power(double exponent)
Returns a Score whose value is (this ^ exponent).
|
S |
subtract(S subtrahend)
Returns a Score whose value is (this - subtrahend).
|
S |
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. |
S |
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 0S toInitializedScore()
-7init/0hard/-8soft
returns 0hard/-8soft
.getInitScore()
is 0
.S 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 0S add(S augment)
augment
- value to be added to this ScoreS subtract(S subtrahend)
subtrahend
- value to be subtracted from this ScoreS 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.S 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 dividedS 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 poweredS 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–2018 JBoss by Red Hat. All rights reserved.