SimpleBigDecimalScore
or a scaled SimpleLongScore
instead.@Deprecated public final class SimpleDoubleScore extends AbstractScore<SimpleDoubleScore>
Score
is based on 1 level of double constraints.
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 SimpleBigDecimalScore
instead.
This class is immutable.
Score
,
Serialized FormModifier and Type | Field and Description |
---|---|
static SimpleDoubleScore |
ONE
Deprecated.
|
static SimpleDoubleScore |
ZERO
Deprecated.
|
INIT_LABEL, initScore
Modifier and Type | Method and Description |
---|---|
SimpleDoubleScore |
add(SimpleDoubleScore addend)
Deprecated.
Returns a Score whose value is (this + addend).
|
int |
compareTo(SimpleDoubleScore other)
Deprecated.
|
SimpleDoubleScore |
divide(double divisor)
Deprecated.
Returns a Score whose value is (this / divisor).
|
boolean |
equals(Object o)
Deprecated.
|
double |
getScore()
Deprecated.
The total of the broken negative constraints and fulfilled positive 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. |
SimpleDoubleScore |
multiply(double multiplicand)
Deprecated.
Returns a Score whose value is (this * multiplicand).
|
SimpleDoubleScore |
negate()
Deprecated.
Returns a Score whose value is (- this).
|
static SimpleDoubleScore |
of(double score)
Deprecated.
|
static SimpleDoubleScore |
ofUninitialized(int initScore,
double score)
Deprecated.
|
static SimpleDoubleScore |
parseScore(String scoreString)
Deprecated.
|
SimpleDoubleScore |
power(double exponent)
Deprecated.
Returns a Score whose value is (this ^ exponent).
|
SimpleDoubleScore |
subtract(SimpleDoubleScore 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 SimpleDoubleScore |
valueOf(double score)
Deprecated.
in favor of
of(double) |
static SimpleDoubleScore |
valueOfUninitialized(int initScore,
double score)
Deprecated.
in favor of
ofUninitialized(int, double) |
SimpleDoubleScore |
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, parseScoreTokens
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
toInitializedScore
public static final SimpleDoubleScore ZERO
public static final SimpleDoubleScore ONE
public static SimpleDoubleScore parseScore(String scoreString)
public static SimpleDoubleScore ofUninitialized(int initScore, double score)
@Deprecated public static SimpleDoubleScore valueOfUninitialized(int initScore, double score)
ofUninitialized(int, double)
public static SimpleDoubleScore of(double score)
@Deprecated public static SimpleDoubleScore valueOf(double score)
of(double)
public double getScore()
public SimpleDoubleScore withInitScore(int newInitScore)
Score
0hard/-8soft
with -7
returns -7init/0hard/-8soft
.newInitScore
- always negative (except in statistical calculations), 0 if all planning variables are initializedScore.getInitScore()
is set to newInitScore
public SimpleDoubleScore add(SimpleDoubleScore addend)
Score
addend
- value to be added to this Scorepublic SimpleDoubleScore subtract(SimpleDoubleScore subtrahend)
Score
subtrahend
- value to be subtracted from this Scorepublic SimpleDoubleScore 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.
multiplicand
- value to be multiplied by this Score.public SimpleDoubleScore 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.
divisor
- value by which this Score is to be dividedpublic SimpleDoubleScore 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.
exponent
- value by which this Score is to be poweredpublic SimpleDoubleScore negate()
Score
public boolean isFeasible()
Score
PlanningSolution
is feasible if it has no broken hard constraints
and Score.isSolutionInitialized()
is true.
Simple scores (SimpleScore
, SimpleLongScore
, SimpleBigDecimalScore
) are always feasible,
if their Score.getInitScore()
is 0.Score.getInitScore()
is 0.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}
ScoreDefinition.fromLevelNumbers(int, Number[])
public int compareTo(SimpleDoubleScore other)
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.
public boolean isCompatibleArithmeticArgument(Score otherScore)
otherScore
- never nullScore.add(Score)
, Score.subtract(Score)
and Comparable.compareTo(Object)
.Copyright © 2006–2021 JBoss by Red Hat. All rights reserved.