Observation

Submodules

Observer base class

class fleetrl.utils.observation.observer.Observer[source]

Bases: object

Parent class for observer modules.

get_obs(db, price_lookahead, bl_pv_lookahead, time, ev_conf, load_calc, aux, target_soc)[source]
Parameters:
  • db (DataFrame) – database from the env

  • price_lookahead (int) – lookahead window for spot price

  • bl_pv_lookahead (int) – lookahead window for building load and pv

  • time (Timestamp) – current time of time step

  • ev_conf (EvConfig) – EV config needed for batt capacity and other params

  • load_calc (LoadCalculation) – Load calc module needed for grid connection and other params

  • aux (bool) – Include auxiliary information that might help the agent to learn the problem

  • target_soc (list) – A list of target soc values, one for each car

Return type:

dict

Returns:

Returns a list of np arrays that make up different parts of the observation.

static get_trip_len(db, car, time)[source]
Parameters:
  • db (DataFrame) – from the env

  • car (int) – car ID

  • time (Timestamp) – current timestamp

Return type:

float

Returns:

length of trip in hours as a float

Building load and PV

class fleetrl.utils.observation.observer_bl_pv.ObserverWithBoth[source]

Bases: Observer

Observer for price, PV, and load (full model).

get_obs(db, price_lookahead, bl_pv_lookahead, time, ev_conf, load_calc, aux, target_soc)[source]
  • define the starting and ending time via lookahead, np.where returns the index in the dataframe

  • add lookahead + 2 here because of rounding issues with the resample function on square times (00:00)

  • get data of price and date from the specific indices

  • resample data to only include one value per hour (the others are duplicates)

  • only take into account the current value, and the specified hours of lookahead

Parameters:
  • db (DataFrame) – Database from env

  • price_lookahead (int) – Lookahead in hours for price

  • bl_pv_lookahead (int) – Lookahead in hours for PV and building

  • time (Timestamp) – Current time

  • ev_conf (EvConfig) – EV config data, used for battery capacity, etc.

  • load_calc (LoadCalculation) – Load calc module, used for grid connection, etc.

  • aux (bool) – Flag to include extra information on the problem or not. Can help with training

  • target_soc (list) – List for the current target SOC of each car

Return type:

dict

Returns:

Dict of lists with different parts of the observation

static get_trip_len(db, car, time)[source]
Parameters:
  • db (DataFrame) – from the env

  • car (int) – car ID

  • time (Timestamp) – current timestamp

Return type:

float

Returns:

length of trip in hours as a float

Price only

class fleetrl.utils.observation.observer_price_only.ObserverPriceOnly[source]

Bases: Observer

Observer for a model that only takes into account the price, but disregards PV and building load.

get_obs(db, price_lookahead, bl_pv_lookahead, time, ev_conf, load_calc, aux, target_soc)[source]
  • define the starting and ending time via lookahead, np.where returns the index in the dataframe

  • add lookahead + 2 here because of rounding issues with the resample function on square times (00:00)

  • get data of price and date from the specific indices

  • resample data to only include one value per hour (the others are duplicates)

  • only take into account the current value, and the specified hours of lookahead

Parameters:
  • db (DataFrame) – Database from env

  • price_lookahead (int) – Lookahead in hours for price

  • bl_pv_lookahead (int) – Lookahead in hours for PV and building

  • time (Timestamp) – Current time

  • ev_conf (EvConfig) – EV config data, used for battery capacity, etc.

  • load_calc (LoadCalculation) – Load calc module, used for grid connection, etc.

  • aux (bool) – Flag to include extra information on the problem or not. Can help with training

  • target_soc (list) – List for the current target SOC of each car

Return type:

dict

Returns:

Dict of lists with different parts of the observation

static get_trip_len(db, car, time)[source]
Parameters:
  • db (DataFrame) – from the env

  • car (int) – car ID

  • time (Timestamp) – current timestamp

Return type:

float

Returns:

length of trip in hours as a float

SOC and time only

class fleetrl.utils.observation.observer_soc_time_only.ObserverSocTimeOnly[source]

Bases: Observer

Observer that only regards SOC and time left, but not charging cost, PV or building laod

get_obs(db, price_lookahead, bl_pv_lookahead, time, ev_conf, load_calc, aux, target_soc)[source]
  • define the starting and ending time via lookahead, np.where returns the index in the dataframe

  • add lookahead + 2 here because of rounding issues with the resample function on square times (00:00)

  • get data of price and date from the specific indices

  • resample data to only include one value per hour (the others are duplicates)

  • only take into account the current value, and the specified hours of lookahead

Parameters:
  • db (DataFrame) – Database from env

  • price_lookahead (int) – Lookahead in hours for price

  • bl_pv_lookahead (int) – Lookahead in hours for PV and building

  • time (Timestamp) – Current time

  • ev_conf (EvConfig) – EV config data, used for battery capacity, etc.

  • load_calc (LoadCalculation) – Load calc module, used for grid connection, etc.

  • aux (bool) – Flag to include extra information on the problem or not. Can help with training

  • target_soc (list) – List for the current target SOC of each car

Return type:

dict

Returns:

Dict of lists with different parts of the observation

static get_trip_len(db, car, time)[source]
Parameters:
  • db (DataFrame) – from the env

  • car (int) – car ID

  • time (Timestamp) – current timestamp

Return type:

float

Returns:

length of trip in hours as a float

Building load

class fleetrl.utils.observation.observer_with_building_load.ObserverWithBuildingLoad[source]

Bases: Observer

Observer that takes into account price, and building load.

get_obs(db, price_lookahead, bl_pv_lookahead, time, ev_conf, load_calc, aux, target_soc)[source]
  • define the starting and ending time via lookahead, np.where returns the index in the dataframe

  • add lookahead + 2 here because of rounding issues with the resample function on square times (00:00)

  • get data of price and date from the specific indices

  • resample data to only include one value per hour (the others are duplicates)

  • only take into account the current value, and the specified hours of lookahead

Parameters:
  • db (DataFrame) – Database from env

  • price_lookahead (int) – Lookahead in hours for price

  • bl_pv_lookahead (int) – Lookahead in hours for PV and building

  • time (Timestamp) – Current time

  • ev_conf (EvConfig) – EV config data, used for battery capacity, etc.

  • load_calc (LoadCalculation) – Load calc module, used for grid connection, etc.

  • aux (bool) – Flag to include extra information on the problem or not. Can help with training

  • target_soc (list) – List for the current target SOC of each car

Return type:

dict

Returns:

Dict of lists with different parts of the observation

static get_trip_len(db, car, time)[source]
Parameters:
  • db (DataFrame) – from the env

  • car (int) – car ID

  • time (Timestamp) – current timestamp

Return type:

float

Returns:

length of trip in hours as a float

PV

class fleetrl.utils.observation.observer_with_pv.ObserverWithPV[source]

Bases: Observer

Observer that regards price, and PV.

get_obs(db, price_lookahead, bl_pv_lookahead, time, ev_conf, load_calc, aux, target_soc)[source]
  • define the starting and ending time via lookahead, np.where returns the index in the dataframe

  • add lookahead + 2 here because of rounding issues with the resample function on square times (00:00)

  • get data of price and date from the specific indices

  • resample data to only include one value per hour (the others are duplicates)

  • only take into account the current value, and the specified hours of lookahead

Parameters:
  • db (DataFrame) – Database from env

  • price_lookahead (int) – Lookahead in hours for price

  • bl_pv_lookahead (int) – Lookahead in hours for PV and building

  • time (Timestamp) – Current time

  • ev_conf (EvConfig) – EV config data, used for battery capacity, etc.

  • load_calc (LoadCalculation) – Load calc module, used for grid connection, etc.

  • aux (bool) – Flag to include extra information on the problem or not. Can help with training

  • target_soc (list) – List for the current target SOC of each car

Return type:

dict

Returns:

Dict of lists with different parts of the observation

static get_trip_len(db, car, time)[source]
Parameters:
  • db (DataFrame) – from the env

  • car (int) – car ID

  • time (Timestamp) – current timestamp

Return type:

float

Returns:

length of trip in hours as a float