This module contains the algorithm for optimizing the costs of energy systems.


The interval for how long one auto_optimize will forecast and for how long one specific workload is set. Note, that this constant also represents a compromise: Shorter intervals can adjust to quick changes, f.e. electricity demands changes, while longer intervals can incorporate more forecasts, but wont be able to adjust quickly. The interval of one hour lead to good results in our tests.


Tries to optimize the cost and sets the cu.overwrite_workload

The method forecasts from with different cu workloads and finds the one with the lowest cost. The length of the forecast is DEFAULT_FORECAST_INTERVAL.

Parameters:forecast – the forecast to be optimized
find_optimal_config(initial_time, forecast)[source]

Internal Method Main method, which optimizes the costs by running a global approximation for the best configuration and then running a local minimization method on this approximation

estimate_cost(params, *args)[source]

Internal Method copies the devices and environment, forwards it and returns the costs.

  • params (list) – parameter to be optimized (CU.workload for now)
  • args – (initial_time, forecast, prices, rewards)
simplified_forecast(env, initial_time, devices)[source]

runs the forward loop only executing the step function

total_costs(devices, prices, rewards)[source]

Internal Method Returns the cost of a forecast run. The function uses the prices which are stored in the db deviceconfiguration. It is also constrained by boundaries, f.e. the heatstorage should never go below min temperature.

  • devices – The devices after the forecast
  • prices, rewards (dict) – Cached prices and rewards
class BilanceResult(cost, params)[source]

wrapper for storing a optimization result