org.optaplanner.core.api.score

## Class AbstractScore<S extends Score>

- java.lang.Object
- - org.optaplanner.core.api.score.AbstractScore<S>

- Type Parameters:
    `S` - the actual score type
  All Implemented Interfaces:
    Serializable, Comparable<S>, Score<S>
  Direct Known Subclasses:
    AbstractBendableScore, HardMediumSoftBigDecimalScore, HardMediumSoftLongScore, HardMediumSoftScore, HardSoftBigDecimalScore, HardSoftDoubleScore, HardSoftLongScore, HardSoftScore, SimpleBigDecimalScore, SimpleDoubleScore, SimpleLongScore, SimpleScore

      public abstract class AbstractScore<S extends Score>
      extends Object
      implements Score<S>, Serializable

  Abstract superclass for `Score`.

  Subclasses must be immutable.

  See Also:
    `Score`, `HardSoftScore`, Serialized Form

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected static String` | `INIT_LABEL`
    `protected int` | `initScore`

  - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `AbstractScore(int initScore)`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected void` | `assertNoInitScore()`
    `protected static String` | `buildScorePattern(boolean bendable, String... levelSuffixes)`
    `protected String` | `buildShortString(Predicate<Number> notZero, String... levelLabels)`
    `protected String` | `getInitPrefix()`
    `int` | `getInitScore()` The init score is the negative of the number of uninitialized genuine planning variables.
    `boolean` | `isSolutionInitialized()` Checks if the `PlanningSolution` of this score was fully initialized when it was calculated.
    `protected static int` | `parseInitScore(Class<? extends Score> scoreClass, String scoreString, String initScoreString)`
    `protected static BigDecimal` | `parseLevelAsBigDecimal(Class<? extends Score> scoreClass, String scoreString, String levelString)`
    `protected static double` | `parseLevelAsDouble(Class<? extends Score> scoreClass, String scoreString, String levelString)`
    `protected static int` | `parseLevelAsInt(Class<? extends Score> scoreClass, String scoreString, String levelString)`
    `protected static long` | `parseLevelAsLong(Class<? extends Score> scoreClass, String scoreString, String levelString)`
    `protected static String[]` | `parseScoreTokens(Class<? extends Score> scoreClass, String scoreString, String... levelSuffixes)`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

    - ### Methods inherited from interface org.optaplanner.core.api.score.Score

      `add, divide, isCompatibleArithmeticArgument, multiply, negate, power, subtract, toInitializedScore, toLevelNumbers, toShortString, withInitScore`

    - ### Methods inherited from interface java.lang.Comparable

      `compareTo`

- - ### Field Detail

    - #### INIT_LABEL

          protected static final String INIT_LABEL

      See Also:
        Constant Field Values

    - #### initScore

          protected final int initScore

  - ### Constructor Detail

    - #### AbstractScore

          protected AbstractScore(int initScore)

      Parameters:
        `initScore` - see `Score.getInitScore()`

  - ### Method Detail

    - #### parseScoreTokens

          protected static String[] parseScoreTokens(Class<? extends Score> scoreClass,
                                                     String scoreString,
                                                     String... levelSuffixes)

    - #### parseInitScore

          protected static int parseInitScore(Class<? extends Score> scoreClass,
                                              String scoreString,
                                              String initScoreString)

    - #### parseLevelAsInt

          protected static int parseLevelAsInt(Class<? extends Score> scoreClass,
                                               String scoreString,
                                               String levelString)

    - #### parseLevelAsLong

          protected static long parseLevelAsLong(Class<? extends Score> scoreClass,
                                                 String scoreString,
                                                 String levelString)

    - #### parseLevelAsDouble

          protected static double parseLevelAsDouble(Class<? extends Score> scoreClass,
                                                     String scoreString,
                                                     String levelString)

    - #### parseLevelAsBigDecimal

          protected static BigDecimal parseLevelAsBigDecimal(Class<? extends Score> scoreClass,
                                                             String scoreString,
                                                             String levelString)

    - #### buildScorePattern

          protected static String buildScorePattern(boolean bendable,
                                                    String... levelSuffixes)

    - #### getInitScore

          public int getInitScore()

      Description copied from interface: `Score`
      The init score is the negative of the number of uninitialized genuine planning variables. If it's 0 (which it usually is), the `PlanningSolution` is fully initialized and the score's `Object.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.

      Specified by:
        `getInitScore` in interface `Score<S extends Score>`
      Returns:
        higher is better, always negative (except in statistical calculations), 0 if all planning variables are initialized

    - #### isSolutionInitialized

          public boolean isSolutionInitialized()

      Description copied from interface: `Score`
      Checks if the `PlanningSolution` of this score was fully initialized when it was calculated.
      Specified by:
        `isSolutionInitialized` in interface `Score<S extends Score>`
      Returns:
        true if `Score.getInitScore()` is 0

    - #### assertNoInitScore

          protected void assertNoInitScore()

    - #### getInitPrefix

          protected String getInitPrefix()

    - #### buildShortString

          protected String buildShortString(Predicate<Number> notZero,
                                            String... levelLabels)

Copyright © 2006–2020 JBoss by Red Hat. All rights reserved.