Skip to contents

See the formulation of the optimization problems in the documentation website.

Usage

add_battery_optimization(
  opt_data,
  opt_objective = "grid",
  Bcap,
  Bc,
  Bd,
  SOCmin = 0,
  SOCmax = 100,
  SOCini = NULL,
  window_days = 1,
  window_start_hour = 0,
  flex_window_hours = 24,
  lambda = 0,
  mc.cores = 1
)

Arguments

opt_data

tibble, optimization contextual data. The first column must be named datetime (mandatory) containing the date time sequence where the optimization algorithm is applied. The other columns can be (optional):

  • static: static power demand (in kW) from other sectors like buildings, offices, etc.

  • import_capacity: maximum imported power from the grid (in kW), for example the contracted power with the energy company.

  • export_capacity: maximum exported power from the grid (in kW), for example the contracted power with the energy company.

  • production: local power generation (in kW). This is used when opt_objective = "grid".

  • price_imported: price for imported energy (€/kWh). This is used when opt_objective = "cost".

  • price_exported: price for exported energy (€/kWh). This is used when opt_objective = "cost".

  • price_turn_down: price for turn-down energy use (€/kWh). This is used when opt_objective = "cost".

  • price_turn_up: price for turn-up energy use (€/kWh). This is used when opt_objective = "cost".

opt_objective

character, optimization objective being "grid" (default) or "cost"

Bcap

numeric, capacity of the battery

Bc

numeric, maximum charging power

Bd

numeric, maximum discharging power

SOCmin

numeric, minimum State-of-Charge of the battery

SOCmax

numeric, maximum State-of-Charge of the battery

SOCini

numeric, required State-of-Charge at the beginning/end of optimization window

window_days

integer, number of days to consider as optimization window.

window_start_hour

integer, starting hour of the optimization window.

flex_window_hours

integer, flexibility window length, in hours. This optional feature lets you apply flexibility only during few hours from the window_start_hour. It must be lower than window_days*24 hours.

lambda

numeric, penalty on change for the flexible load.

mc.cores

integer, number of cores to use. Must be at least one, and parallelization requires at least two cores.

Value

numeric vector

Examples

library(dplyr)
#> 
#> Attaching package: ‘dplyr’
#> The following objects are masked from ‘package:stats’:
#> 
#>     filter, lag
#> The following objects are masked from ‘package:base’:
#> 
#>     intersect, setdiff, setequal, union
opt_data <- flextools::energy_profiles %>%
  filter(lubridate::isoweek(datetime) == 18) %>%
  rename(
    production = "solar"
  ) %>%
  select(any_of(c(
    "datetime", "production", "building", "price_imported", "price_exported"
  ))) %>%
  mutate(
    static = .data$building
  )
  opt_battery <- opt_data %>%
    add_battery_optimization(
      opt_objective = 0.5,
      Bcap = 50, Bc = 4, Bd = 4,
      window_start_hour = 5
    )