HardSoftBigDecimalScore or a scaled HardSoftLongScore instead.@Deprecated public final class HardSoftDoubleScore extends AbstractScore<HardSoftDoubleScore> implements FeasibilityScore<HardSoftDoubleScore>
Score is based on 2 levels of double constraints: hard and soft.
Hard constraints have priority over soft constraints.
Hard constraints determine feasibility.
WARNING: NOT RECOMMENDED TO USE DUE TO ROUNDING ERRORS THAT CAUSE SCORE CORRUPTION.
For example, this prints false: System.out.println((0.01 + 0.05) == (0.01 + 0.02 + 0.03));
Use HardSoftBigDecimalScore instead.
This class is immutable.
Score,
Serialized Form| Modifier and Type | Field and Description |
|---|---|
static HardSoftDoubleScore |
ONE_HARD
Deprecated.
|
static HardSoftDoubleScore |
ONE_SOFT
Deprecated.
|
static HardSoftDoubleScore |
ZERO
Deprecated.
|
INIT_LABEL, initScore| Modifier and Type | Method and Description |
|---|---|
HardSoftDoubleScore |
add(HardSoftDoubleScore addend)
Deprecated.
Returns a Score whose value is (this + addend).
|
int |
compareTo(HardSoftDoubleScore other)
Deprecated.
|
HardSoftDoubleScore |
divide(double divisor)
Deprecated.
Returns a Score whose value is (this / divisor).
|
boolean |
equals(Object o)
Deprecated.
|
double |
getHardScore()
Deprecated.
The total of the broken negative hard constraints and fulfilled positive hard constraints.
|
double |
getSoftScore()
Deprecated.
The total of the broken negative soft constraints and fulfilled positive soft constraints.
|
int |
hashCode()
Deprecated.
|
boolean |
isCompatibleArithmeticArgument(Score otherScore)
Deprecated.
|
boolean |
isFeasible()
Deprecated.
A
PlanningSolution is feasible if it has no broken hard constraints
and Score.isSolutionInitialized() is true. |
HardSoftDoubleScore |
multiply(double multiplicand)
Deprecated.
Returns a Score whose value is (this * multiplicand).
|
HardSoftDoubleScore |
negate()
Deprecated.
Returns a Score whose value is (- this).
|
static HardSoftDoubleScore |
of(double hardScore,
double softScore)
Deprecated.
|
static HardSoftDoubleScore |
ofHard(double hardScore)
Deprecated.
|
static HardSoftDoubleScore |
ofSoft(double softScore)
Deprecated.
|
static HardSoftDoubleScore |
ofUninitialized(int initScore,
double hardScore,
double softScore)
Deprecated.
|
static HardSoftDoubleScore |
parseScore(String scoreString)
Deprecated.
|
HardSoftDoubleScore |
power(double exponent)
Deprecated.
Returns a Score whose value is (this ^ exponent).
|
HardSoftDoubleScore |
subtract(HardSoftDoubleScore subtrahend)
Deprecated.
Returns a Score whose value is (this - subtrahend).
|
Number[] |
toLevelNumbers()
Deprecated.
Returns an array of numbers representing the Score.
|
String |
toShortString()
Deprecated.
Like
Object.toString(), but trims score levels which have a zero weight. |
String |
toString()
Deprecated.
|
static HardSoftDoubleScore |
valueOf(double hardScore,
double softScore)
Deprecated.
in favor of
of(double, double) |
static HardSoftDoubleScore |
valueOfUninitialized(int initScore,
double hardScore,
double softScore)
Deprecated.
in favor of
ofUninitialized(int, double, double) |
HardSoftDoubleScore |
withInitScore(int newInitScore)
Deprecated.
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, isSolutionInitialized, toInitializedScorepublic static final HardSoftDoubleScore ZERO
public static final HardSoftDoubleScore ONE_HARD
public static final HardSoftDoubleScore ONE_SOFT
public static HardSoftDoubleScore parseScore(String scoreString)
public static HardSoftDoubleScore ofUninitialized(int initScore, double hardScore, double softScore)
@Deprecated public static HardSoftDoubleScore valueOfUninitialized(int initScore, double hardScore, double softScore)
ofUninitialized(int, double, double)public static HardSoftDoubleScore of(double hardScore, double softScore)
@Deprecated public static HardSoftDoubleScore valueOf(double hardScore, double softScore)
of(double, double)public static HardSoftDoubleScore ofHard(double hardScore)
public static HardSoftDoubleScore ofSoft(double softScore)
public double getHardScore()
public double getSoftScore()
In a normal score comparison, the soft score is irrelevant if the 2 scores don't have the same hard score.
public HardSoftDoubleScore withInitScore(int newInitScore)
Score0hard/-8soft with -7 returns -7init/0hard/-8soft.withInitScore in interface Score<HardSoftDoubleScore>newInitScore - always negative (except in statistical calculations), 0 if all planning variables are initializedScore.getInitScore() is set to newInitScorepublic boolean isFeasible()
FeasibilityScorePlanningSolution is feasible if it has no broken hard constraints
and Score.isSolutionInitialized() is true.isFeasible in interface FeasibilityScore<HardSoftDoubleScore>isFeasible in interface Score<HardSoftDoubleScore>Score.getInitScore() is 0.public HardSoftDoubleScore add(HardSoftDoubleScore addend)
Scoreadd in interface Score<HardSoftDoubleScore>addend - value to be added to this Scorepublic HardSoftDoubleScore subtract(HardSoftDoubleScore subtrahend)
Scoresubtract in interface Score<HardSoftDoubleScore>subtrahend - value to be subtracted from this Scorepublic HardSoftDoubleScore 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<HardSoftDoubleScore>multiplicand - value to be multiplied by this Score.public HardSoftDoubleScore 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<HardSoftDoubleScore>divisor - value by which this Score is to be dividedpublic HardSoftDoubleScore 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<HardSoftDoubleScore>exponent - value by which this Score is to be poweredpublic HardSoftDoubleScore negate()
Scorenegate in interface Score<HardSoftDoubleScore>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<HardSoftDoubleScore>ScoreDefinition.fromLevelNumbers(int, Number[])public int compareTo(HardSoftDoubleScore other)
compareTo in interface Comparable<HardSoftDoubleScore>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<HardSoftDoubleScore>public boolean isCompatibleArithmeticArgument(Score otherScore)
isCompatibleArithmeticArgument in interface Score<HardSoftDoubleScore>otherScore - never nullScore.add(Score), Score.subtract(Score)
and Comparable.compareTo(Object).Copyright © 2006–2021 JBoss by Red Hat. All rights reserved.