Class Prediction

java.lang.Object
io.openems.edge.predictor.api.prediction.Prediction

public class Prediction extends Object
Holds a prediction - one value per 15 minutes.

Values have the same unit as the base Channel, i.e. if the Prediction relates to _sum/ProductionGridActivePower, the value is in unit Watt and represents the average Watt within a 15 minutes period.

  • Field Details

    • EMPTY_PREDICTION

      public static final Prediction EMPTY_PREDICTION
      Holds an 'empty' Prediction object, i.e. `valuePerQuarter` map is empty.
    • valuePerQuarter

      public final SortedMap<ZonedDateTime,Integer> valuePerQuarter
      Unmodifiable Map of Quarters (rounded to 15 minutes) and their respective predicted values. Values can be null.
  • Method Details

    • sum

      public static Prediction sum(Prediction... predictions)
      Sums up the given Predictions. If any source value is null, the result value is also null.
      Parameters:
      predictions - the given Prediction
      Returns:
      a Prediction holding the sum of all predictions.
    • getValueRange

      public static io.openems.edge.predictor.api.prediction.Prediction.ValueRange getValueRange(Sum sum, ChannelAddress channelAddress)
      Gets the Prediction.ValueRange for the given ChannelAddress.
      Parameters:
      sum - the Sum
      channelAddress - the ChannelAddress
      Returns:
      a Prediction.ValueRange
    • from

      public static Prediction from(ZonedDateTime time, Integer... values)
      Constructs a Prediction object with Prediction.ValueRange.

      Trailing `nulls` are cut out.

      Parameters:
      time - the base time of the prediction values, rounded down to 15 minutes
      values - the quarterly prediction values.
      Returns:
      a Prediction object
    • from

      public static Prediction from(Sum sum, ChannelAddress channelAddress, ZonedDateTime time, Integer... values)
      Constructs a Prediction object with the default Prediction.ValueRange for the given ChannelAddress.

      Trailing `nulls` are cut out.

      Parameters:
      sum - the Sum
      channelAddress - the ChannelAddress
      time - the base time of the prediction values, rounded down to 15 minutes
      values - the quarterly prediction values.
      Returns:
      a Prediction object
    • from

      public static Prediction from(io.openems.edge.predictor.api.prediction.Prediction.ValueRange valueRange, ZonedDateTime time, Integer... values)
      Constructs a Prediction object.

      Trailing `nulls` are cut out.

      Parameters:
      valueRange - the Prediction.ValueRange
      time - the base time of the prediction values, rounded down to 15 minutes
      values - the quarterly prediction values.
      Returns:
      a Prediction object
    • from

      public static Prediction from(io.openems.edge.predictor.api.prediction.Prediction.ValueRange valueRange, SortedMap<ZonedDateTime,Integer> map)
      Constructs a Prediction object.

      Postprocessing is applied:

      • Map keys are rounded down to full quarters (15 minutes)
      • Gaps in keys are filled (value = null)
      • Trailing null values are removed
      Parameters:
      valueRange - the Prediction.ValueRange
      map - a SortedMap of times and prices
      Returns:
      a Prediction object
    • from

      public static Prediction from(ZonedDateTime time, Prediction prediction)
      Returns a Prediction object by deriving data from given `prediction`, but skipping values before given `time`.

      If time of given object is still valid, the object is returned. Otherwise a new object is created.

      Parameters:
      time - the base time of the prices, rounded down to 15 minutes
      prediction - the source Prediction object
      Returns:
      a Prediction object
    • isEmpty

      public boolean isEmpty()
      Returns true if this map contains no predictions.
      Returns:
      true if this map contains no predictions
    • asArray

      public Integer[] asArray()
      Gets the prediction values as an array of Integers.
      Returns:
      values array
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • buildMap

      protected static SortedMap<ZonedDateTime,Integer> buildMap(ZonedDateTime time, Integer... values)
    • postprocessMap

      protected static SortedMap<ZonedDateTime,Integer> postprocessMap(io.openems.edge.predictor.api.prediction.Prediction.ValueRange valueRange, SortedMap<ZonedDateTime,Integer> map)