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