Class EnergyOptimiser

java.lang.Object
org.openremote.manager.energy.EnergyOptimiser

public class EnergyOptimiser extends Object
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected double
     
    protected double
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    EnergyOptimiser(double intervalSize, double financialWeighting)
    24 divided by intervalSize must be a whole number
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    applyEarningOpportunities(double[][] importCostAndPower, double[][] exportCostAndPower, double[] energyLevelMins, double[] energyLevelMaxs, double[] powerSetpoints, Function<Integer,Double> energyLevelCalculator, Function<Integer,Double> powerImportMaxCalculator, Function<Integer,Double> powerExportMaxCalculator)
    Will find the best earning opportunity for each interval (import or export) and will then try to apply them in chronological order (reallocating earlier import/exports if it cost beneficial).
    void
    applyEnergyMinImports(double[][] importCostAndPower, double[] energyLevelMins, double[] powerSetpoints, Function<Integer,Double> energyLevelCalculator, BiFunction<Integer,double[],double[]> importOptimiser, Function<Integer,Double> powerImportMaxCalculator)
    Will update the powerSetpoints in order to achieve the energyLevelMin values supplied.
    void
    applyEnergySchedule(double[] energyLevelMins, double[] energyLevelMaxs, double energyCapacity, int[][] energyLevelSchedule, LocalDateTime currentTime)
    Will take the supplied 24x7 energy schedule percentages and energy level min/max values and apply them to the supplied energyLevelMins also adjusting for any intervalSize difference.
    void
    applyExportOpportunity(double[][] importCostAndPower, double[][] exportCostAndPower, double[] energyLevelMins, double[] energyLevelMaxs, double[] powerSetpoints, Function<Integer,Double> energyLevelCalculator, Function<Integer,Double> powerImportMaxCalculator, Function<Integer,Double> powerExportMaxCalculator, int interval)
    Tries to apply the maximum export power as defined in the exportCostAndPower at the specified interval taking into consideration the maximum power and energy levels; if there is insufficient power or energy capacity at the interval then an earlier cost effective import opportunity will be attempted to offset the requirement.
    void
    applyImportOpportunity(double[][] importCostAndPower, double[][] exportCostAndPower, double[] energyLevelMins, double[] energyLevelMaxs, double[] powerSetpoints, Function<Integer,Double> energyLevelCalculator, Function<Integer,Double> powerImportMaxCalculator, Function<Integer,Double> powerExportMaxCalculator, int interval)
    Tries to apply the maximum import power as defined in the importCostAndPower at the specified interval taking into consideration the maximum power and energy levels; if there is insufficient power or energy capacity at the interval then an earlier cost effective export opportunity will be attempted to offset the requirement.
    int
     
    getExportOptimiser(double[] powerNets, double[] powerNetLimits, double[] tariffImports, double[] tariffExports, double assetExportCost)
    Returns a function that can be used to calculate any export saving (per kWh) and power band needed to achieve it based on requested interval index and power export max value (negative as this is for export).
    double
     
    BiFunction<Integer,double[],double[]>
    getImportOptimiser(double[] powerNets, double[] powerNetLimits, double[] tariffImports, double[] tariffExports, double assetImportCost)
    Returns a function that can be used to calculate the optimum cost (per kWh) and power band needed to achieve it based on requested interval index, power min and power max values.
    double
     
    protected boolean
    isExportOpportunity(double[] costAndPower, double powerSetpoint, int interval, Function<Integer,Double> powerExportMaxCalculator)
     
    protected boolean
    isImportOpportunity(double[] costAndPower, double powerSetpoint, int interval, Function<Integer,Double> powerImportMaxCalculator)
     
    void
    normaliseEnergyMinRequirements(double[] energyLevelMins, Function<Integer,Double> powerImportMaxCalculator, Function<Integer,Double> powerExportMaxCalculator, double energyLevel)
    Adjusts the supplied energyLevelMin values to match the physical characteristics (i.e.
    void
    retrospectiveEnergyAllocator(double[][] importCostAndPower, double[] energyLevelMins, double[] powerSetpoints, BiFunction<Integer,double[],double[]> importOptimiser, Function<Integer,Double> powerImportMaxCalculator, double energyLevel, int fromInterval, int toInterval)
    Creates earlier imports between fromInterval (inclusive) and toInterval (exclusive) in order to meet min energy level requirement at the specified interval based on the provided energy level at the start of fromInterval.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • intervalSize

      protected double intervalSize
    • financialWeighting

      protected double financialWeighting
  • Constructor Details

  • Method Details

    • getIntervalSize

      public double getIntervalSize()
    • getFinancialWeighting

      public double getFinancialWeighting()
    • get24HourIntervalCount

      public int get24HourIntervalCount()
    • applyEnergySchedule

      public void applyEnergySchedule(double[] energyLevelMins, double[] energyLevelMaxs, double energyCapacity, int[][] energyLevelSchedule, LocalDateTime currentTime)
      Will take the supplied 24x7 energy schedule percentages and energy level min/max values and apply them to the supplied energyLevelMins also adjusting for any intervalSize difference. The energy schedule should be in UTC time.
    • normaliseEnergyMinRequirements

      public void normaliseEnergyMinRequirements(double[] energyLevelMins, Function<Integer,Double> powerImportMaxCalculator, Function<Integer,Double> powerExportMaxCalculator, double energyLevel)
      Adjusts the supplied energyLevelMin values to match the physical characteristics (i.e. the charge and discharge rates).
    • applyEnergyMinImports

      public void applyEnergyMinImports(double[][] importCostAndPower, double[] energyLevelMins, double[] powerSetpoints, Function<Integer,Double> energyLevelCalculator, BiFunction<Integer,double[],double[]> importOptimiser, Function<Integer,Double> powerImportMaxCalculator)
      Will update the powerSetpoints in order to achieve the energyLevelMin values supplied.
    • retrospectiveEnergyAllocator

      public void retrospectiveEnergyAllocator(double[][] importCostAndPower, double[] energyLevelMins, double[] powerSetpoints, BiFunction<Integer,double[],double[]> importOptimiser, Function<Integer,Double> powerImportMaxCalculator, double energyLevel, int fromInterval, int toInterval)
      Creates earlier imports between fromInterval (inclusive) and toInterval (exclusive) in order to meet min energy level requirement at the specified interval based on the provided energy level at the start of fromInterval.
    • applyEarningOpportunities

      public void applyEarningOpportunities(double[][] importCostAndPower, double[][] exportCostAndPower, double[] energyLevelMins, double[] energyLevelMaxs, double[] powerSetpoints, Function<Integer,Double> energyLevelCalculator, Function<Integer,Double> powerImportMaxCalculator, Function<Integer,Double> powerExportMaxCalculator)
      Will find the best earning opportunity for each interval (import or export) and will then try to apply them in chronological order (reallocating earlier import/exports if it cost beneficial). The powerSetpoints will be updated as a result.
    • isImportOpportunity

      protected boolean isImportOpportunity(double[] costAndPower, double powerSetpoint, int interval, Function<Integer,Double> powerImportMaxCalculator)
    • isExportOpportunity

      protected boolean isExportOpportunity(double[] costAndPower, double powerSetpoint, int interval, Function<Integer,Double> powerExportMaxCalculator)
    • applyImportOpportunity

      public void applyImportOpportunity(double[][] importCostAndPower, double[][] exportCostAndPower, double[] energyLevelMins, double[] energyLevelMaxs, double[] powerSetpoints, Function<Integer,Double> energyLevelCalculator, Function<Integer,Double> powerImportMaxCalculator, Function<Integer,Double> powerExportMaxCalculator, int interval)
      Tries to apply the maximum import power as defined in the importCostAndPower at the specified interval taking into consideration the maximum power and energy levels; if there is insufficient power or energy capacity at the interval then an earlier cost effective export opportunity will be attempted to offset the requirement. The powerSetpoints will be updated as a result.
    • applyExportOpportunity

      public void applyExportOpportunity(double[][] importCostAndPower, double[][] exportCostAndPower, double[] energyLevelMins, double[] energyLevelMaxs, double[] powerSetpoints, Function<Integer,Double> energyLevelCalculator, Function<Integer,Double> powerImportMaxCalculator, Function<Integer,Double> powerExportMaxCalculator, int interval)
      Tries to apply the maximum export power as defined in the exportCostAndPower at the specified interval taking into consideration the maximum power and energy levels; if there is insufficient power or energy capacity at the interval then an earlier cost effective import opportunity will be attempted to offset the requirement. The powerSetpoints will be updated as a result.
    • getExportOptimiser

      public BiFunction<Integer,Double,double[]> getExportOptimiser(double[] powerNets, double[] powerNetLimits, double[] tariffImports, double[] tariffExports, double assetExportCost)
      Returns a function that can be used to calculate any export saving (per kWh) and power band needed to achieve it based on requested interval index and power export max value (negative as this is for export). This is used to determine whether there are export opportunities for earning/saving rather than using the grid.
    • getImportOptimiser

      public BiFunction<Integer,double[],double[]> getImportOptimiser(double[] powerNets, double[] powerNetLimits, double[] tariffImports, double[] tariffExports, double assetImportCost)
      Returns a function that can be used to calculate the optimum cost (per kWh) and power band needed to achieve it based on requested interval index, power min and power max values. The returned power band will satisfy the requested power min value but this could mean that cost is not optimum for that interval if a lower power could be used. If possible a 0 power min should be tried first for all applicable intervals and if more energy is required then another pass can be made with a high enough min power to allow desired energy levels to be reached. This is used to determine the best times and power values for importing energy to meet the requirements.