Interface ValueScale
- All Known Implementing Classes:
ValueScale.Anchored, ValueScale.Percent, ValueScale.Range, ValueScale.RatioToBest
public sealed interface ValueScale
permits ValueScale.Range, ValueScale.Percent, ValueScale.RatioToBest, ValueScale.Anchored
How an objective's raw value becomes a 0..100 score (100 = best) for the weighted ranking.
The choice matters. A scale that depends on the spread of the options being compared
(ValueScale.Range) turns any difference, however small, into the full 0..100 span: when every option
costs within 7% of every other, the dearest still scores 0 and the cheapest 100, so a trivial saving
outweighs a large, real difference in another objective. It also lets an irrelevant option change
the order of two others. The other scales are fixed by the objective's meaning, so a score says how
good a value is, not where it happens to fall among the candidates.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic final recordLinear between two fixed anchors, clamped.static final recordThe value is a percentage: it is the score when larger is better, and 100 minus it otherwise.static final recordMin-max over the options being ranked.static final recordThe ratio to the best value: an option 7% dearer than the cheapest scores about 93, one twice as dear scores 50. -
Method Summary
Modifier and TypeMethodDescriptionstatic ValueScaleanchored(double bestAt, double worstAt) describe()static ValueScalepercent()static ValueScalerange()static ValueScaledouble
-
Method Details
-
score
- Parameters:
value- the raw value (never NaN)best- the best value among the options being rankedworst- the worst value among the options being rankeddirection- whether smaller or larger is better- Returns:
- the score, 0..100
-
describe
String describe()- Returns:
- a one-line description for reports
-
range
- Returns:
- the scale relative to the spread of the options: the best scores 100, the worst 0
-
percent
- Returns:
- the scale for a value that already is a 0..100 percentage
-
ratioToBest
- Returns:
- the scale that scores a value by its ratio to the best one (for money and other positive amounts)
-
anchored
- Parameters:
bestAt- the value that scores 100 (and anything better)worstAt- the value that scores 0 (and anything worse)- Returns:
- a fixed linear scale between two anchors
-