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_LABELINIT_LABEL, initScore| Modifier | Constructor and Description |
|---|---|
protected |
BendableLongScore(int initScore,
long[] hardScores,
long[] softScores) |
| Modifier and Type | Method and Description |
|---|---|
BendableLongScore |
add(BendableLongScore augment)
Returns a Score whose value is (this + augment).
|
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 |
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)
Creates a new
BendableLongScore. |
static BendableLongScore |
valueOfUninitialized(int initScore,
long[] hardScores,
long[] softScores)
Creates a new
BendableLongScore. |
BendableLongScore |
withInitScore(int newInitScore)
For example
0hard/-8soft with -7 returns -7init/0hard/-8soft. |
static BendableLongScore |
zero(int hardLevelsSize,
int softLevelsSize) |
buildBendableShortString, parseBendableScoreTokensassertNoInitScore, buildScorePattern, buildShortString, getInitPrefix, getInitScore, isSolutionInitialized, parseInitScore, parseLevelAsBigDecimal, parseLevelAsDouble, parseLevelAsInt, parseLevelAsLong, parseScoreTokensclone, finalize, getClass, notify, notifyAll, wait, wait, waitgetInitScore, isSolutionInitializedprotected 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 valueOfUninitialized(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 immutablepublic static BendableLongScore valueOf(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 immutablepublic static BendableLongScore zero(int hardLevelsSize, int softLevelsSize)
public long[] getHardScores()
public long[] getSoftScores()
public int getHardLevelsSize()
AbstractBendableScoreAbstractBendableScore.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()
AbstractBendableScoreAbstractBendableScore.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)
Score0hard/-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 newInitScorepublic int getLevelsSize()
getLevelsSize in class AbstractBendableScore<BendableLongScore>AbstractBendableScore.getHardLevelsSize() + AbstractBendableScore.getSoftLevelsSize()public long getHardOrSoftScore(int index)
index - 0 <= index < getLevelsSize()public boolean isFeasible()
FeasibilityScorePlanningSolution 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 augment)
Scoreadd in interface Score<BendableLongScore>augment - value to be added to this Scorepublic BendableLongScore subtract(BendableLongScore subtrahend)
Scoresubtract in interface Score<BendableLongScore>subtrahend - value to be subtracted from this Scorepublic BendableLongScore 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<BendableLongScore>multiplicand - value to be multiplied by this Score.public BendableLongScore 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<BendableLongScore>divisor - value by which this Score is to be dividedpublic BendableLongScore 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<BendableLongScore>exponent - value by which this Score is to be poweredpublic BendableLongScore negate()
Scorenegate 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()
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<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–2017 JBoss by Red Hat. All rights reserved.