public final class BendableLongScore extends AbstractBendableScore<BendableLongScore> implements FeasibilityScore<BendableLongScore>
Score
is based on n levels of long constraints.
The number of levels is bendable at configuration time.
This class is immutable.
The getHardLevelsSize()
and getSoftLevelsSize()
must be the same as in the
BendableLongScoreDefinition
used.
Score
,
Serialized FormHARD_LABEL, LEVEL_SUFFIXES, SOFT_LABEL
INIT_LABEL, initScore
Modifier | Constructor and Description |
---|---|
protected |
BendableLongScore(int initScore,
long[] hardScores,
long[] softScores) |
Modifier and Type | Method and Description |
---|---|
BendableLongScore |
add(BendableLongScore addend)
Returns a Score whose value is (this + addend).
|
int |
compareTo(BendableLongScore other) |
BendableLongScore |
divide(double divisor)
Returns a Score whose value is (this / divisor).
|
boolean |
equals(Object o) |
int |
getHardLevelsSize()
The sum of this and
AbstractBendableScore.getSoftLevelsSize() equals AbstractBendableScore.getLevelsSize() . |
long |
getHardOrSoftScore(int index) |
long |
getHardScore(int index) |
long[] |
getHardScores() |
int |
getLevelsSize() |
int |
getSoftLevelsSize()
The sum of
AbstractBendableScore.getHardLevelsSize() and this equals AbstractBendableScore.getLevelsSize() . |
long |
getSoftScore(int index) |
long[] |
getSoftScores() |
int |
hashCode() |
boolean |
isCompatibleArithmeticArgument(Score otherScore) |
boolean |
isFeasible()
A
PlanningSolution is feasible if it has no broken hard constraints
and Score.isSolutionInitialized() is true. |
BendableLongScore |
multiply(double multiplicand)
Returns a Score whose value is (this * multiplicand).
|
BendableLongScore |
negate()
Returns a Score whose value is (- this).
|
static BendableLongScore |
of(long[] hardScores,
long[] softScores)
Creates a new
BendableLongScore . |
static BendableLongScore |
ofHard(int hardLevelsSize,
int softLevelsSize,
int hardLevel,
long hardScore)
Creates a new
BendableLongScore . |
static BendableLongScore |
ofSoft(int hardLevelsSize,
int softLevelsSize,
int softLevel,
long softScore)
Creates a new
BendableLongScore . |
static BendableLongScore |
ofUninitialized(int initScore,
long[] hardScores,
long[] softScores)
Creates a new
BendableLongScore . |
static BendableLongScore |
parseScore(String scoreString) |
BendableLongScore |
power(double exponent)
Returns a Score whose value is (this ^ exponent).
|
BendableLongScore |
subtract(BendableLongScore subtrahend)
Returns a Score whose value is (this - subtrahend).
|
BendableLongScore |
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() |
void |
validateCompatible(BendableLongScore other) |
static BendableLongScore |
valueOf(long[] hardScores,
long[] softScores)
Deprecated.
in favor of
of(long[], long[]) |
static BendableLongScore |
valueOfUninitialized(int initScore,
long[] hardScores,
long[] softScores)
Deprecated.
in favor of
ofUninitialized(int, long[], long[]) |
BendableLongScore |
withInitScore(int newInitScore)
For example
0hard/-8soft with -7 returns -7init/0hard/-8soft . |
static BendableLongScore |
zero(int hardLevelsSize,
int softLevelsSize)
Creates a new
BendableLongScore . |
buildBendableShortString, parseBendableScoreTokens
assertNoInitScore, buildScorePattern, buildShortString, getInitPrefix, getInitScore, isSolutionInitialized, parseInitScore, parseLevelAsBigDecimal, parseLevelAsDouble, parseLevelAsInt, parseLevelAsLong, parseScoreTokens
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
getInitScore, isSolutionInitialized
protected BendableLongScore(int initScore, long[] hardScores, long[] softScores)
initScore
- see Score.getInitScore()
hardScores
- never nullsoftScores
- never nullpublic static BendableLongScore parseScore(String scoreString)
scoreString
- never nullpublic static BendableLongScore ofUninitialized(int initScore, long[] hardScores, long[] softScores)
BendableLongScore
.initScore
- see Score.getInitScore()
hardScores
- never null, never change that array afterwards: it must be immutablesoftScores
- never null, never change that array afterwards: it must be immutable@Deprecated public static BendableLongScore valueOfUninitialized(int initScore, long[] hardScores, long[] softScores)
ofUninitialized(int, long[], long[])
public static BendableLongScore of(long[] hardScores, long[] softScores)
BendableLongScore
.hardScores
- never null, never change that array afterwards: it must be immutablesoftScores
- never null, never change that array afterwards: it must be immutable@Deprecated public static BendableLongScore valueOf(long[] hardScores, long[] softScores)
of(long[], long[])
public static BendableLongScore zero(int hardLevelsSize, int softLevelsSize)
BendableLongScore
.hardLevelsSize
- at least 0softLevelsSize
- at least 0public static BendableLongScore ofHard(int hardLevelsSize, int softLevelsSize, int hardLevel, long hardScore)
BendableLongScore
.hardLevelsSize
- at least 0softLevelsSize
- at least 0hardLevel
- at least 0, less than hardLevelsSizehardScore
- anypublic static BendableLongScore ofSoft(int hardLevelsSize, int softLevelsSize, int softLevel, long softScore)
BendableLongScore
.hardLevelsSize
- at least 0softLevelsSize
- at least 0softLevel
- at least 0, less than softLevelsSizesoftScore
- anypublic long[] getHardScores()
public long[] getSoftScores()
public int getHardLevelsSize()
AbstractBendableScore
AbstractBendableScore.getSoftLevelsSize()
equals AbstractBendableScore.getLevelsSize()
.getHardLevelsSize
in class AbstractBendableScore<BendableLongScore>
>= 0
and <
AbstractBendableScore.getLevelsSize()
public long getHardScore(int index)
index
- 0 <= index <
getHardLevelsSize()
public int getSoftLevelsSize()
AbstractBendableScore
AbstractBendableScore.getHardLevelsSize()
and this equals AbstractBendableScore.getLevelsSize()
.getSoftLevelsSize
in class AbstractBendableScore<BendableLongScore>
>= 0
and <
AbstractBendableScore.getLevelsSize()
public long getSoftScore(int index)
index
- 0 <= index <
getSoftLevelsSize()
public BendableLongScore toInitializedScore()
Score
-7init/0hard/-8soft
returns 0hard/-8soft
.toInitializedScore
in interface Score<BendableLongScore>
Score.getInitScore()
is 0
.public BendableLongScore withInitScore(int newInitScore)
Score
0hard/-8soft
with -7
returns -7init/0hard/-8soft
.withInitScore
in interface Score<BendableLongScore>
newInitScore
- always negative (except in statistical calculations), 0 if all planning variables are initializedScore.getInitScore()
is set to newInitScore
public int getLevelsSize()
getLevelsSize
in class AbstractBendableScore<BendableLongScore>
AbstractBendableScore.getHardLevelsSize()
+ AbstractBendableScore.getSoftLevelsSize()
public long getHardOrSoftScore(int index)
index
- 0 <= index <
getLevelsSize()
public boolean isFeasible()
FeasibilityScore
PlanningSolution
is feasible if it has no broken hard constraints
and Score.isSolutionInitialized()
is true.isFeasible
in interface FeasibilityScore<BendableLongScore>
Score.getInitScore()
is 0.public BendableLongScore add(BendableLongScore addend)
Score
add
in interface Score<BendableLongScore>
addend
- value to be added to this Scorepublic BendableLongScore subtract(BendableLongScore subtrahend)
Score
subtract
in interface Score<BendableLongScore>
subtrahend
- value to be subtracted from this Scorepublic BendableLongScore 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<BendableLongScore>
multiplicand
- value to be multiplied by this Score.public BendableLongScore 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<BendableLongScore>
divisor
- value by which this Score is to be dividedpublic BendableLongScore 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<BendableLongScore>
exponent
- value by which this Score is to be poweredpublic BendableLongScore negate()
Score
negate
in interface Score<BendableLongScore>
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<BendableLongScore>
ScoreDefinition.fromLevelNumbers(int, Number[])
public int compareTo(BendableLongScore other)
compareTo
in interface Comparable<BendableLongScore>
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<BendableLongScore>
public void validateCompatible(BendableLongScore other)
public boolean isCompatibleArithmeticArgument(Score otherScore)
isCompatibleArithmeticArgument
in interface Score<BendableLongScore>
otherScore
- never nullScore.add(Score)
, Score.subtract(Score)
and Comparable.compareTo(Object)
.Copyright © 2006–2020 JBoss by Red Hat. All rights reserved.