public final class SimpleScore extends AbstractScore<SimpleScore>
Score is based on 1 level of int constraints.
This class is immutable.
Score,
Serialized Form| Modifier and Type | Field and Description |
|---|---|
static SimpleScore |
ONE |
static SimpleScore |
ZERO |
INIT_LABEL, initScore| Modifier and Type | Method and Description |
|---|---|
SimpleScore |
add(SimpleScore addend)
Returns a Score whose value is (this + addend).
|
int |
compareTo(SimpleScore other) |
SimpleScore |
divide(double divisor)
Returns a Score whose value is (this / divisor).
|
boolean |
equals(Object o) |
int |
getScore()
The total of the broken negative constraints and fulfilled positive constraints.
|
int |
hashCode() |
boolean |
isCompatibleArithmeticArgument(Score otherScore) |
boolean |
isFeasible()
A
PlanningSolution is feasible if it has no broken hard constraints
and Score.isSolutionInitialized() is true. |
SimpleScore |
multiply(double multiplicand)
Returns a Score whose value is (this * multiplicand).
|
SimpleScore |
negate()
Returns a Score whose value is (- this).
|
static SimpleScore |
of(int score) |
static SimpleScore |
ofUninitialized(int initScore,
int score) |
static SimpleScore |
parseScore(String scoreString) |
SimpleScore |
power(double exponent)
Returns a Score whose value is (this ^ exponent).
|
SimpleScore |
subtract(SimpleScore subtrahend)
Returns a Score whose value is (this - subtrahend).
|
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() |
static SimpleScore |
valueOf(int score)
Deprecated.
in favor of
of(int) |
static SimpleScore |
valueOfUninitialized(int initScore,
int score)
Deprecated.
in favor of
ofUninitialized(int, int) |
SimpleScore |
withInitScore(int newInitScore)
For example
0hard/-8soft with -7 returns -7init/0hard/-8soft. |
assertNoInitScore, buildScorePattern, buildShortString, getInitPrefix, getInitScore, isSolutionInitialized, parseInitScore, parseLevelAsBigDecimal, parseLevelAsDouble, parseLevelAsInt, parseLevelAsLong, parseScoreTokensclone, finalize, getClass, notify, notifyAll, wait, wait, waittoInitializedScorepublic static final SimpleScore ZERO
public static final SimpleScore ONE
public static SimpleScore parseScore(String scoreString)
public static SimpleScore ofUninitialized(int initScore, int score)
@Deprecated public static SimpleScore valueOfUninitialized(int initScore, int score)
ofUninitialized(int, int)public static SimpleScore of(int score)
@Deprecated public static SimpleScore valueOf(int score)
of(int)public int getScore()
public SimpleScore withInitScore(int newInitScore)
Score0hard/-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 newInitScorepublic SimpleScore add(SimpleScore addend)
Scoreaddend - value to be added to this Scorepublic SimpleScore subtract(SimpleScore subtrahend)
Scoresubtrahend - value to be subtracted from this Scorepublic SimpleScore 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.
multiplicand - value to be multiplied by this Score.public SimpleScore 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.
divisor - value by which this Score is to be dividedpublic SimpleScore 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.
exponent - value by which this Score is to be poweredpublic SimpleScore negate()
Scorepublic boolean isFeasible()
ScorePlanningSolution 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(SimpleScore other)
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.
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.