public final class HardMediumSoftScore extends AbstractScore<HardMediumSoftScore> implements FeasibilityScore<HardMediumSoftScore>
Score
is based on 3 levels of int 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 HardMediumSoftScore |
ONE_HARD |
static HardMediumSoftScore |
ONE_MEDIUM |
static HardMediumSoftScore |
ONE_SOFT |
static HardMediumSoftScore |
ZERO |
INIT_LABEL, initScore
Modifier and Type | Method and Description |
---|---|
HardMediumSoftScore |
add(HardMediumSoftScore addend)
Returns a Score whose value is (this + addend).
|
int |
compareTo(HardMediumSoftScore other) |
HardMediumSoftScore |
divide(double divisor)
Returns a Score whose value is (this / divisor).
|
boolean |
equals(Object o) |
int |
getHardScore()
The total of the broken negative hard constraints and fulfilled positive hard constraints.
|
int |
getMediumScore()
The total of the broken negative medium constraints and fulfilled positive medium constraints.
|
int |
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. |
HardMediumSoftScore |
multiply(double multiplicand)
Returns a Score whose value is (this * multiplicand).
|
HardMediumSoftScore |
negate()
Returns a Score whose value is (- this).
|
static HardMediumSoftScore |
of(int hardScore,
int mediumScore,
int softScore) |
static HardMediumSoftScore |
ofHard(int hardScore) |
static HardMediumSoftScore |
ofMedium(int mediumScore) |
static HardMediumSoftScore |
ofSoft(int softScore) |
static HardMediumSoftScore |
ofUninitialized(int initScore,
int hardScore,
int mediumScore,
int softScore) |
static HardMediumSoftScore |
parseScore(String scoreString) |
HardMediumSoftScore |
power(double exponent)
Returns a Score whose value is (this ^ exponent).
|
HardMediumSoftScore |
subtract(HardMediumSoftScore subtrahend)
Returns a Score whose value is (this - subtrahend).
|
HardMediumSoftScore |
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 HardMediumSoftScore |
valueOf(int hardScore,
int mediumScore,
int softScore)
Deprecated.
in favor of
of(int, int, int) |
static HardMediumSoftScore |
valueOfUninitialized(int initScore,
int hardScore,
int mediumScore,
int softScore)
Deprecated.
in favor of
ofUninitialized(int, int, int, int) |
HardMediumSoftScore |
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 HardMediumSoftScore ZERO
public static final HardMediumSoftScore ONE_HARD
public static final HardMediumSoftScore ONE_MEDIUM
public static final HardMediumSoftScore ONE_SOFT
public static HardMediumSoftScore parseScore(String scoreString)
public static HardMediumSoftScore ofUninitialized(int initScore, int hardScore, int mediumScore, int softScore)
@Deprecated public static HardMediumSoftScore valueOfUninitialized(int initScore, int hardScore, int mediumScore, int softScore)
ofUninitialized(int, int, int, int)
public static HardMediumSoftScore of(int hardScore, int mediumScore, int softScore)
@Deprecated public static HardMediumSoftScore valueOf(int hardScore, int mediumScore, int softScore)
of(int, int, int)
public static HardMediumSoftScore ofHard(int hardScore)
public static HardMediumSoftScore ofMedium(int mediumScore)
public static HardMediumSoftScore ofSoft(int softScore)
public int getHardScore()
public int getMediumScore()
In a normal score comparison, the medium score is irrelevant if the 2 scores don't have the same hard score.
public int 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 HardMediumSoftScore toInitializedScore()
Score
-7init/0hard/-8soft
returns 0hard/-8soft
.toInitializedScore
in interface Score<HardMediumSoftScore>
Score.getInitScore()
is 0
.public HardMediumSoftScore withInitScore(int newInitScore)
Score
0hard/-8soft
with -7
returns -7init/0hard/-8soft
.withInitScore
in interface Score<HardMediumSoftScore>
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<HardMediumSoftScore>
getHardScore()
is 0 or higherpublic HardMediumSoftScore add(HardMediumSoftScore addend)
Score
add
in interface Score<HardMediumSoftScore>
addend
- value to be added to this Scorepublic HardMediumSoftScore subtract(HardMediumSoftScore subtrahend)
Score
subtract
in interface Score<HardMediumSoftScore>
subtrahend
- value to be subtracted from this Scorepublic HardMediumSoftScore 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<HardMediumSoftScore>
multiplicand
- value to be multiplied by this Score.public HardMediumSoftScore 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<HardMediumSoftScore>
divisor
- value by which this Score is to be dividedpublic HardMediumSoftScore 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<HardMediumSoftScore>
exponent
- value by which this Score is to be poweredpublic HardMediumSoftScore negate()
Score
negate
in interface Score<HardMediumSoftScore>
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<HardMediumSoftScore>
ScoreDefinition.fromLevelNumbers(int, Number[])
public int compareTo(HardMediumSoftScore other)
compareTo
in interface Comparable<HardMediumSoftScore>
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<HardMediumSoftScore>
public boolean isCompatibleArithmeticArgument(Score otherScore)
isCompatibleArithmeticArgument
in interface Score<HardMediumSoftScore>
otherScore
- never nullScore.add(Score)
, Score.subtract(Score)
and Comparable.compareTo(Object)
.Copyright © 2006–2020 JBoss by Red Hat. All rights reserved.