public final class HardMediumSoftLongScore extends AbstractScore<HardMediumSoftLongScore> implements FeasibilityScore<HardMediumSoftLongScore>
Score
is based on 3 levels of long constraints: hard, medium and soft.
Hard constraints have priority over medium constraints.
Medium constraints have priority over soft constraints.
Hard constraints determine feasibility.
This class is immutable.
Score
,
Serialized FormModifier and Type | Field and Description |
---|---|
static HardMediumSoftLongScore |
ONE_HARD |
static HardMediumSoftLongScore |
ONE_MEDIUM |
static HardMediumSoftLongScore |
ONE_SOFT |
static HardMediumSoftLongScore |
ZERO |
INIT_LABEL, initScore
Modifier and Type | Method and Description |
---|---|
HardMediumSoftLongScore |
add(HardMediumSoftLongScore addend)
Returns a Score whose value is (this + addend).
|
int |
compareTo(HardMediumSoftLongScore other) |
HardMediumSoftLongScore |
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 |
getMediumScore()
The total of the broken negative medium constraints and fulfilled positive medium 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. |
HardMediumSoftLongScore |
multiply(double multiplicand)
Returns a Score whose value is (this * multiplicand).
|
HardMediumSoftLongScore |
negate()
Returns a Score whose value is (- this).
|
static HardMediumSoftLongScore |
of(long hardScore,
long mediumScore,
long softScore) |
static HardMediumSoftLongScore |
ofHard(long hardScore) |
static HardMediumSoftLongScore |
ofMedium(long mediumScore) |
static HardMediumSoftLongScore |
ofSoft(long softScore) |
static HardMediumSoftLongScore |
ofUninitialized(int initScore,
long hardScore,
long mediumScore,
long softScore) |
static HardMediumSoftLongScore |
parseScore(String scoreString) |
HardMediumSoftLongScore |
power(double exponent)
Returns a Score whose value is (this ^ exponent).
|
HardMediumSoftLongScore |
subtract(HardMediumSoftLongScore subtrahend)
Returns a Score whose value is (this - subtrahend).
|
HardMediumSoftLongScore |
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. |
String |
toString() |
static HardMediumSoftLongScore |
valueOf(long hardScore,
long mediumScore,
long softScore)
Deprecated.
in favor of
of(long, long, long) |
static HardMediumSoftLongScore |
valueOfUninitialized(int initScore,
long hardScore,
long mediumScore,
long softScore)
Deprecated.
in favor of
ofUninitialized(int, long, long, long) |
HardMediumSoftLongScore |
withInitScore(int newInitScore)
For example
0hard/-8soft with -7 returns -7init/0hard/-8soft . |
assertNoInitScore, buildScorePattern, buildShortString, getInitPrefix, getInitScore, isSolutionInitialized, parseInitScore, parseLevelAsBigDecimal, parseLevelAsDouble, parseLevelAsInt, parseLevelAsLong, parseScoreTokens
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
getInitScore, isSolutionInitialized
public static final HardMediumSoftLongScore ZERO
public static final HardMediumSoftLongScore ONE_HARD
public static final HardMediumSoftLongScore ONE_MEDIUM
public static final HardMediumSoftLongScore ONE_SOFT
public static HardMediumSoftLongScore parseScore(String scoreString)
public static HardMediumSoftLongScore ofUninitialized(int initScore, long hardScore, long mediumScore, long softScore)
@Deprecated public static HardMediumSoftLongScore valueOfUninitialized(int initScore, long hardScore, long mediumScore, long softScore)
ofUninitialized(int, long, long, long)
public static HardMediumSoftLongScore of(long hardScore, long mediumScore, long softScore)
@Deprecated public static HardMediumSoftLongScore valueOf(long hardScore, long mediumScore, long softScore)
of(long, long, long)
public static HardMediumSoftLongScore ofHard(long hardScore)
public static HardMediumSoftLongScore ofMedium(long mediumScore)
public static HardMediumSoftLongScore ofSoft(long softScore)
public long getHardScore()
public long getMediumScore()
In a normal score comparison, the medium score is irrelevant if the 2 scores don't have the same hard score.
public long getSoftScore()
In a normal score comparison, the soft score is irrelevant if the 2 scores don't have the same hard and medium score.
public HardMediumSoftLongScore toInitializedScore()
Score
-7init/0hard/-8soft
returns 0hard/-8soft
.toInitializedScore
in interface Score<HardMediumSoftLongScore>
Score.getInitScore()
is 0
.public HardMediumSoftLongScore withInitScore(int newInitScore)
Score
0hard/-8soft
with -7
returns -7init/0hard/-8soft
.withInitScore
in interface Score<HardMediumSoftLongScore>
newInitScore
- always negative (except in statistical calculations), 0 if all planning variables are initializedScore.getInitScore()
is set to newInitScore
public boolean isFeasible()
PlanningSolution
is feasible if it has no broken hard constraints.isFeasible
in interface FeasibilityScore<HardMediumSoftLongScore>
getHardScore()
is 0 or higherpublic HardMediumSoftLongScore add(HardMediumSoftLongScore addend)
Score
add
in interface Score<HardMediumSoftLongScore>
addend
- value to be added to this Scorepublic HardMediumSoftLongScore subtract(HardMediumSoftLongScore subtrahend)
Score
subtract
in interface Score<HardMediumSoftLongScore>
subtrahend
- value to be subtracted from this Scorepublic HardMediumSoftLongScore 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<HardMediumSoftLongScore>
multiplicand
- value to be multiplied by this Score.public HardMediumSoftLongScore 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<HardMediumSoftLongScore>
divisor
- value by which this Score is to be dividedpublic HardMediumSoftLongScore 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<HardMediumSoftLongScore>
exponent
- value by which this Score is to be poweredpublic HardMediumSoftLongScore negate()
Score
negate
in interface Score<HardMediumSoftLongScore>
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<HardMediumSoftLongScore>
ScoreDefinition.fromLevelNumbers(int, Number[])
public int compareTo(HardMediumSoftLongScore other)
compareTo
in interface Comparable<HardMediumSoftLongScore>
public String toShortString()
Score
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.
toShortString
in interface Score<HardMediumSoftLongScore>
public boolean isCompatibleArithmeticArgument(Score otherScore)
isCompatibleArithmeticArgument
in interface Score<HardMediumSoftLongScore>
otherScore
- never nullScore.add(Score)
, Score.subtract(Score)
and Comparable.compareTo(Object)
.Copyright © 2006–2020 JBoss by Red Hat. All rights reserved.