public final class BendableScore extends AbstractScore<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 Form| Modifier | Constructor and Description |
|---|---|
protected |
BendableScore(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() |
int |
getHardOrSoftScore(int index) |
int |
getHardScore(int index) |
int |
getLevelsSize() |
int |
getSoftLevelsSize() |
int |
getSoftScore(int index) |
int |
hashCode() |
boolean |
isCompatibleArithmeticArgument(Score otherScore) |
boolean |
isFeasible()
A
Solution is feasible if it has no broken hard constraints. |
BendableScore |
multiply(double multiplicand)
Returns a Score whose value is (this * multiplicand).
|
BendableScore |
negate()
Returns a Score whose value is (- this).
|
static BendableScore |
parseScore(int hardLevelsSize,
int softLevelsSize,
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).
|
Number[] |
toLevelNumbers()
Returns an array of numbers representing the Score.
|
String |
toString() |
void |
validateCompatible(BendableScore other) |
static BendableScore |
valueOf(int[] hardScores,
int[] softScores)
Creates a new
BendableScore. |
buildScorePattern, buildScorePattern, parseLevelAsBigDecimal, parseLevelAsDouble, parseLevelAsInt, parseLevelAsLong, parseLevelStrings, parseLevelStringsprotected BendableScore(int[] hardScores,
int[] softScores)
hardScores - never nullsoftScores - never nullpublic static BendableScore parseScore(int hardLevelsSize, int softLevelsSize, String scoreString)
hardLevelsSize - >= 0softLevelsSize - >= 0scoreString - never nullpublic 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 int getHardLevelsSize()
>= 0public int getHardScore(int index)
index - 0 <= index < getHardLevelsSize()public int getSoftLevelsSize()
>= 0public int getSoftScore(int index)
index - 0 <= index < getSoftLevelsSize()public int getLevelsSize()
getHardLevelsSize() + getSoftLevelsSize()public int getHardOrSoftScore(int index)
index - 0 <= index < getLevelsSize()public boolean isFeasible()
FeasibilityScoreSolution is feasible if it has no broken hard constraints.isFeasible in interface FeasibilityScore<BendableScore>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}
toLevelNumbers in interface Score<BendableScore>ScoreDefinition.fromLevelNumbers(Number[])public int compareTo(BendableScore other)
compareTo in interface Comparable<BendableScore>public void validateCompatible(BendableScore other)
public boolean isCompatibleArithmeticArgument(Score otherScore)
isCompatibleArithmeticArgument in interface Score<BendableScore>isCompatibleArithmeticArgument in class AbstractScore<BendableScore>otherScore - never nullScore.add(Score), Score.subtract(Score)
and Comparable.compareTo(Object).Copyright © 2006–2016 JBoss by Red Hat. All rights reserved.