Interface ValueScale

All Known Implementing Classes:
ValueScale.Anchored, ValueScale.Percent, ValueScale.Range, ValueScale.RatioToBest

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 Classes
    Modifier and Type
    Interface
    Description
    static final record 
    Linear between two fixed anchors, clamped.
    static final record 
    The value is a percentage: it is the score when larger is better, and 100 minus it otherwise.
    static final record 
    Min-max over the options being ranked.
    static final record 
    The 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 Type
    Method
    Description
    static ValueScale
    anchored(double bestAt, double worstAt)
     
     
    static ValueScale
     
    static ValueScale
     
    static ValueScale
     
    double
    score(double value, double best, double worst, Direction direction)
     
  • Method Details

    • score

      double score(double value, double best, double worst, Direction direction)
      Parameters:
      value - the raw value (never NaN)
      best - the best value among the options being ranked
      worst - the worst value among the options being ranked
      direction - whether smaller or larger is better
      Returns:
      the score, 0..100
    • describe

      String describe()
      Returns:
      a one-line description for reports
    • range

      static ValueScale range()
      Returns:
      the scale relative to the spread of the options: the best scores 100, the worst 0
    • percent

      static ValueScale percent()
      Returns:
      the scale for a value that already is a 0..100 percentage
    • ratioToBest

      static ValueScale ratioToBest()
      Returns:
      the scale that scores a value by its ratio to the best one (for money and other positive amounts)
    • anchored

      static ValueScale anchored(double bestAt, double worstAt)
      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