public final class BendableScore extends AbstractBendableScore<BendableScore> implements FeasibilityScore<BendableScore>
Score is based on n levels of int 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
BendableScoreDefinition used.
Score,
Serialized FormHARD_LABEL, LEVEL_SUFFIXES, SOFT_LABELINIT_LABEL, initScore| Modifier | Constructor and Description |
|---|---|
protected |
BendableScore(int initScore,
int[] hardScores,
int[] softScores) |
| Modifier and Type | Method and Description |
|---|---|
BendableScore |
add(BendableScore augment)
Returns a Score whose value is (this + augment).
|
int |
compareTo(BendableScore other) |
BendableScore |
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(). |
int |
getHardOrSoftScore(int level) |
int |
getHardScore(int hardLevel) |
int[] |
getHardScores() |
int |
getLevelsSize() |
int |
getSoftLevelsSize()
The sum of
AbstractBendableScore.getHardLevelsSize() and this equals AbstractBendableScore.getLevelsSize(). |
int |
getSoftScore(int softLevel) |
int[] |
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. |
BendableScore |
multiply(double multiplicand)
Returns a Score whose value is (this * multiplicand).
|
BendableScore |
negate()
Returns a Score whose value is (- this).
|
static BendableScore |
parseScore(String scoreString) |
BendableScore |
power(double exponent)
Returns a Score whose value is (this ^ exponent).
|
BendableScore |
subtract(BendableScore subtrahend)
Returns a Score whose value is (this - subtrahend).
|
BendableScore |
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(BendableScore other) |
static BendableScore |
valueOf(int[] hardScores,
int[] softScores)
Creates a new
BendableScore. |
static BendableScore |
valueOfUninitialized(int initScore,
int[] hardScores,
int[] softScores)
Creates a new
BendableScore. |
BendableScore |
withInitScore(int newInitScore)
For example
0hard/-8soft with -7 returns -7init/0hard/-8soft. |
static BendableScore |
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 BendableScore(int initScore,
int[] hardScores,
int[] softScores)
initScore - see Score.getInitScore()hardScores - never nullsoftScores - never nullpublic static BendableScore parseScore(String scoreString)
scoreString - never nullpublic static BendableScore valueOfUninitialized(int initScore, int[] hardScores, int[] softScores)
BendableScore.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 BendableScore valueOf(int[] hardScores, int[] softScores)
BendableScore.hardScores - never null, never change that array afterwards: it must be immutablesoftScores - never null, never change that array afterwards: it must be immutablepublic static BendableScore zero(int hardLevelsSize, int softLevelsSize)
public int[] getHardScores()
public int[] getSoftScores()
public int getHardLevelsSize()
AbstractBendableScoreAbstractBendableScore.getSoftLevelsSize() equals AbstractBendableScore.getLevelsSize().getHardLevelsSize in class AbstractBendableScore<BendableScore>>= 0 and < AbstractBendableScore.getLevelsSize()public int getHardScore(int hardLevel)
hardLevel - 0 <= hardLevel < getHardLevelsSize().
The scoreLevel is hardLevel for hard levels and softLevel + hardLevelSize for soft levels.public int getSoftLevelsSize()
AbstractBendableScoreAbstractBendableScore.getHardLevelsSize() and this equals AbstractBendableScore.getLevelsSize().getSoftLevelsSize in class AbstractBendableScore<BendableScore>>= 0 and < AbstractBendableScore.getLevelsSize()public int getSoftScore(int softLevel)
softLevel - 0 <= softLevel < getSoftLevelsSize().
The scoreLevel is hardLevel for hard levels and softLevel + hardLevelSize for soft levels.public BendableScore toInitializedScore()
Score-7init/0hard/-8soft returns 0hard/-8soft.toInitializedScore in interface Score<BendableScore>Score.getInitScore() is 0.public BendableScore withInitScore(int newInitScore)
Score0hard/-8soft with -7 returns -7init/0hard/-8soft.withInitScore in interface Score<BendableScore>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<BendableScore>AbstractBendableScore.getHardLevelsSize() + AbstractBendableScore.getSoftLevelsSize()public int getHardOrSoftScore(int level)
level - 0 <= level < getLevelsSize()public boolean isFeasible()
FeasibilityScorePlanningSolution is feasible if it has no broken hard constraints
and Score.isSolutionInitialized() is true.isFeasible in interface FeasibilityScore<BendableScore>Score.getInitScore() is 0.public BendableScore add(BendableScore augment)
Scoreadd in interface Score<BendableScore>augment - value to be added to this Scorepublic BendableScore subtract(BendableScore subtrahend)
Scoresubtract in interface Score<BendableScore>subtrahend - value to be subtracted from this Scorepublic BendableScore 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<BendableScore>multiplicand - value to be multiplied by this Score.public BendableScore 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<BendableScore>divisor - value by which this Score is to be dividedpublic BendableScore 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<BendableScore>exponent - value by which this Score is to be poweredpublic BendableScore negate()
Scorenegate in interface Score<BendableScore>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<BendableScore>ScoreDefinition.fromLevelNumbers(int, Number[])public int compareTo(BendableScore other)
compareTo in interface Comparable<BendableScore>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<BendableScore>public void validateCompatible(BendableScore other)
public boolean isCompatibleArithmeticArgument(Score otherScore)
isCompatibleArithmeticArgument in interface Score<BendableScore>otherScore - never nullScore.add(Score), Score.subtract(Score)
and Comparable.compareTo(Object).Copyright © 2006–2017 JBoss by Red Hat. All rights reserved.