public final class HardSoftLongScore extends AbstractScore<HardSoftLongScore> implements FeasibilityScore<HardSoftLongScore>
Score
is based on 2 levels of long constraints: hard and soft.
Hard constraints have priority over soft constraints.
This class is immutable.
Score
,
Serialized FormINIT_LABEL, initScore
Modifier and Type | Method and Description |
---|---|
HardSoftLongScore |
add(HardSoftLongScore augment)
Returns a Score whose value is (this + augment).
|
int |
compareTo(HardSoftLongScore other) |
HardSoftLongScore |
divide(double divisor)
Returns a Score whose value is (this / divisor).
|
boolean |
equals(Object o) |
long |
getHardScore()
The total of the broken negative hard constraints and fulfilled positive hard constraints.
|
long |
getSoftScore()
The total of the broken negative soft constraints and fulfilled positive soft constraints.
|
int |
hashCode() |
boolean |
isCompatibleArithmeticArgument(Score otherScore) |
boolean |
isFeasible()
A
PlanningSolution is feasible if it has no broken hard constraints
and Score.isSolutionInitialized() is true. |
HardSoftLongScore |
multiply(double multiplicand)
Returns a Score whose value is (this * multiplicand).
|
HardSoftLongScore |
negate()
Returns a Score whose value is (- this).
|
static HardSoftLongScore |
parseScore(String scoreString) |
HardSoftLongScore |
power(double exponent)
Returns a Score whose value is (this ^ exponent).
|
HardSoftLongScore |
subtract(HardSoftLongScore subtrahend)
Returns a Score whose value is (this - subtrahend).
|
HardSoftLongScore |
toInitializedScore()
For example
-7init/0hard/-8soft returns 0hard/-8soft . |
Number[] |
toLevelNumbers()
Returns an array of numbers representing the Score.
|
String |
toString() |
static HardSoftLongScore |
valueOf(int initScore,
long hardScore,
long softScore) |
static HardSoftLongScore |
valueOfInitialized(long hardScore,
long softScore) |
buildScorePattern, getInitPrefix, getInitScore, isSolutionInitialized, parseInitScore, parseLevelAsBigDecimal, parseLevelAsDouble, parseLevelAsInt, parseLevelAsLong, parseScoreTokens
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
getInitScore, isSolutionInitialized
public static HardSoftLongScore parseScore(String scoreString)
public static HardSoftLongScore valueOf(int initScore, long hardScore, long softScore)
public static HardSoftLongScore valueOfInitialized(long hardScore, long softScore)
public long getHardScore()
public long getSoftScore()
In a normal score comparison, the soft score is irrelevant if the 2 scores don't have the same hard score.
public HardSoftLongScore toInitializedScore()
Score
-7init/0hard/-8soft
returns 0hard/-8soft
.toInitializedScore
in interface Score<HardSoftLongScore>
Score.getInitScore()
is 0
.public boolean isFeasible()
FeasibilityScore
PlanningSolution
is feasible if it has no broken hard constraints
and Score.isSolutionInitialized()
is true.isFeasible
in interface FeasibilityScore<HardSoftLongScore>
Score.getInitScore()
is 0.public HardSoftLongScore add(HardSoftLongScore augment)
Score
add
in interface Score<HardSoftLongScore>
augment
- value to be added to this Scorepublic HardSoftLongScore subtract(HardSoftLongScore subtrahend)
Score
subtract
in interface Score<HardSoftLongScore>
subtrahend
- value to be subtracted from this Scorepublic HardSoftLongScore multiply(double multiplicand)
Score
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.
multiply
in interface Score<HardSoftLongScore>
multiplicand
- value to be multiplied by this Score.public HardSoftLongScore divide(double divisor)
Score
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.
divide
in interface Score<HardSoftLongScore>
divisor
- value by which this Score is to be dividedpublic HardSoftLongScore power(double exponent)
Score
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.
power
in interface Score<HardSoftLongScore>
exponent
- value by which this Score is to be poweredpublic HardSoftLongScore negate()
Score
negate
in interface Score<HardSoftLongScore>
public Number[] toLevelNumbers()
Score
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 Score.getInitScore()
.
For example: -3init/-0hard/-7soft
also returns new int{-0, -7}
toLevelNumbers
in interface Score<HardSoftLongScore>
ScoreDefinition.fromLevelNumbers(int, Number[])
public int compareTo(HardSoftLongScore other)
compareTo
in interface Comparable<HardSoftLongScore>
public boolean isCompatibleArithmeticArgument(Score otherScore)
isCompatibleArithmeticArgument
in interface Score<HardSoftLongScore>
otherScore
- never nullScore.add(Score)
, Score.subtract(Score)
and Comparable.compareTo(Object)
.Copyright © 2006–2016 JBoss by Red Hat. All rights reserved.