Interface Score<Score_ extends Score<Score_>>
- 
- Type Parameters:
- Score_- the actual score type to allow addition, subtraction and other arithmetic
 - All Superinterfaces:
- Comparable<Score_>
 - All Known Implementing Classes:
- AbstractBendableScore,- AbstractScore,- BendableBigDecimalScore,- BendableLongScore,- BendableScore,- HardMediumSoftBigDecimalScore,- HardMediumSoftLongScore,- HardMediumSoftScore,- HardSoftBigDecimalScore,- HardSoftLongScore,- HardSoftScore,- SimpleBigDecimalScore,- SimpleLongScore,- SimpleScore
 
 public interface Score<Score_ extends Score<Score_>> extends Comparable<Score_> A Score is result of the score function (AKA fitness function) on a single possible solution.Implementations must be immutable. Implementations are allowed to optionally implement Pareto comparison and therefore slightly violate the transitive requirement of Comparable.compareTo(Object).An implementation must extend AbstractScoreto ensure backwards compatibility in future versions.- See Also:
- AbstractScore,- HardSoftScore
 
- 
- 
Method SummaryAll Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description Score_abs()Returns a Score whose value is the absolute value of the score, i.e.Score_add(Score_ addend)Returns a Score whose value is (this + addend).Score_divide(double divisor)Returns a Score whose value is (this / divisor).intgetInitScore()The init score is the negative of the number of uninitialized genuine planning variables.booleanisFeasible()APlanningSolutionis feasible if it has no broken hard constraints andisSolutionInitialized()is true.booleanisSolutionInitialized()Checks if thePlanningSolutionof this score was fully initialized when it was calculated.default booleanisZero()Score_multiply(double multiplicand)Returns a Score whose value is (this * multiplicand).Score_negate()Returns a Score whose value is (- this).Score_power(double exponent)Returns a Score whose value is (this ^ exponent).Score_subtract(Score_ subtrahend)Returns a Score whose value is (this - subtrahend).default double[]toLevelDoubles()As defined bytoLevelNumbers(), only returns double[] instead of Number[].Number[]toLevelNumbers()Returns an array of numbers representing the Score.StringtoShortString()LikeObject.toString(), but trims score levels which have a zero weight.Score_withInitScore(int newInitScore)For example0hard/-8softwith-7returns-7init/0hard/-8soft.Score_zero()Returns a Score, all levels of which are zero.- 
Methods inherited from interface java.lang.ComparablecompareTo
 
- 
 
- 
- 
- 
Method Detail- 
getInitScoreint getInitScore() The init score is the negative of the number of uninitialized genuine planning variables. If it's 0 (which it usually is), thePlanningSolutionis fully initialized and the score'sObject.toString()does not mention it.During Comparable.compareTo(Object), it's even more important than the hard score: if you don't want this behaviour, read about overconstrained planning in the reference manual.- Returns:
- higher is better, always negative (except in statistical calculations), 0 if all planning variables are initialized
 
 - 
isSolutionInitializedboolean isSolutionInitialized() Checks if thePlanningSolutionof this score was fully initialized when it was calculated.- Returns:
- true if getInitScore()is 0
 
 - 
withInitScoreScore_ withInitScore(int newInitScore) For example0hard/-8softwith-7returns-7init/0hard/-8soft.- Parameters:
- newInitScore- always negative (except in statistical calculations), 0 if all planning variables are initialized
- Returns:
- equals score except that getInitScore()is set tonewInitScore
 
 - 
addScore_ add(Score_ addend) Returns a Score whose value is (this + addend).- Parameters:
- addend- value to be added to this Score
- Returns:
- this + addend
 
 - 
subtractScore_ subtract(Score_ subtrahend) Returns a Score whose value is (this - subtrahend).- Parameters:
- subtrahend- value to be subtracted from this Score
- Returns:
- this - subtrahend, rounded as necessary
 
 - 
multiplyScore_ multiply(double multiplicand) Returns a Score whose value is (this * multiplicand). When rounding is needed, it should be floored (as defined byMath.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. - Parameters:
- multiplicand- value to be multiplied by this Score.
- Returns:
- this * multiplicand
 
 - 
divideScore_ divide(double divisor) Returns a Score whose value is (this / divisor). When rounding is needed, it should be floored (as defined byMath.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. - Parameters:
- divisor- value by which this Score is to be divided
- Returns:
- this / divisor
 
 - 
powerScore_ power(double exponent) Returns a Score whose value is (this ^ exponent). When rounding is needed, it should be floored (as defined byMath.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. - Parameters:
- exponent- value by which this Score is to be powered
- Returns:
- this ^ exponent
 
 - 
negateScore_ negate() Returns a Score whose value is (- this).- Returns:
- - this
 
 - 
absScore_ abs() Returns a Score whose value is the absolute value of the score, i.e. |this|.- Returns:
- never null
 
 - 
zeroScore_ zero() Returns a Score, all levels of which are zero.- Returns:
- never null
 
 - 
isZerodefault boolean isZero() - Returns:
- true when this is equal tozero().
 
 - 
toLevelNumbersNumber[] toLevelNumbers() Returns an array of numbers representing the Score. Each number represents 1 score level. A greater score level uses a lower array index than a lesser score level.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 specificScoreimplementation.For example: -0hard/-7softreturnsnew int{-0, -7}The level numbers do not contain the getInitScore(). For example:-3init/-0hard/-7softalso returnsnew int{-0, -7}- Returns:
- never null
 
 - 
toLevelDoublesdefault double[] toLevelDoubles() As defined bytoLevelNumbers(), only returns double[] instead of Number[].- Returns:
- never null
 
 - 
isFeasibleboolean isFeasible() APlanningSolutionis feasible if it has no broken hard constraints andisSolutionInitialized()is true. Simple scores (SimpleScore,SimpleLongScore,SimpleBigDecimalScore) are always feasible, if theirgetInitScore()is 0.- Returns:
- true if the hard score is 0 or higher and the getInitScore()is 0.
 
 - 
toShortStringString toShortString() LikeObject.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.- Returns:
- never null
 
 
- 
 
-