Skip to content

Commit

Permalink
Merge pull request #132 from intelligent-environments-lab/datasets-fr…
Browse files Browse the repository at this point in the history
…om-eulp-ev-learn

Datasets from eulp ev learn
  • Loading branch information
kingsleynweye authored Nov 5, 2024
2 parents 7bc1f4b + 9983490 commit 8848db4
Show file tree
Hide file tree
Showing 44 changed files with 412,092 additions and 8,577 deletions.
9 changes: 5 additions & 4 deletions citylearn/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import getpass
import importlib
import inspect
import logging
from multiprocessing import cpu_count
import os
from pathlib import Path
Expand Down Expand Up @@ -54,16 +55,16 @@ def run_work_order(work_order_filepath, max_workers=None, start_index=None, end_
max_workers = cpu_count() if max_workers is None else max_workers

with concurrent.futures.ProcessPoolExecutor(max_workers=max_workers) as executor:
print(f'Will use {max_workers} workers for job.')
print(f'Pooling {len(args)} jobs to run in parallel...')
logging.debug(f'Will use {max_workers} workers for job.')
logging.debug(f'Pooling {len(args)} jobs to run in parallel...')
results = [executor.submit(subprocess.run,**{'args':a, 'shell':True}) for a in args]

for future in concurrent.futures.as_completed(results):
try:
print(future.result())
logging.debug(future.result())

except Exception as e:
print(e)
logging.debug(e)

class Simulator:
def __init__(self, schema: str, agent_name: str = None, env_kwargs: Mapping[str, Any] = None, agent_kwargs: Mapping[str, Any] = None, wrappers: List[str] = None,
Expand Down
9 changes: 5 additions & 4 deletions citylearn/agents/sac.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import logging
from typing import Any, List, Union
import numpy as np
import numpy.typing as npt
Expand Down Expand Up @@ -223,10 +224,10 @@ def get_normalized_observations(self, index: int, observations: List[float]) ->
return (np.array(observations, dtype = float) - self.norm_mean[index])/self.norm_std[index]
except:
# self.time_step >= self.standardize_start_time_step and self.batch_size <= len(self.replay_buffer[i])
print('obs:',observations)
print('mean:',self.norm_mean[index])
print('std:',self.norm_std[index])
print(self.time_step, self.standardize_start_time_step, self.batch_size, len(self.replay_buffer[0]))
logging.debug('obs:',observations)
logging.debug('mean:',self.norm_mean[index])
logging.debug('std:',self.norm_std[index])
logging.debug(self.time_step, self.standardize_start_time_step, self.batch_size, len(self.replay_buffer[0]))
assert False

def get_encoded_observations(self, index: int, observations: List[float]) -> npt.NDArray[np.float64]:
Expand Down
786 changes: 517 additions & 269 deletions citylearn/building.py

Large diffs are not rendered by default.

471 changes: 342 additions & 129 deletions citylearn/citylearn.py
100755 → 100644

Large diffs are not rendered by default.

46 changes: 45 additions & 1 deletion citylearn/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -409,4 +409,48 @@ class CarbonIntensity(TimeSeriesData):

def __init__(self, carbon_intensity: Iterable[float], start_time_step: int = None, end_time_step: int = None):
super().__init__(start_time_step=start_time_step, end_time_step=end_time_step)
self.carbon_intensity = np.array(carbon_intensity, dtype='float32')
self.carbon_intensity = np.array(carbon_intensity, dtype='float32')


class ElectricVehicleSimulation(TimeSeriesData):
"""`Electric_Vehicle` `electric_vehicle_simulation` data class.

Month,Hour,Day Type,Location,Estimated Departure Time,Required Soc At Departure

Attributes
----------
electric_vehicle_charger_state : np.array
State of the electric_vehicle indicating whether it is 'parked ready to charge' represented as 0, 'in transit', represented as 1.
charger : np.array
(available only for 'in transit' state) Charger where the electric_vehicle will plug in the next "parked ready to charge" state.
It can be nan if no destination charger is specified or the charger id in the format "Charger_X_Y", where X is
the number of the building and Y the number of the charger within that building.
electric_vehicle_departure_time : np.array
Number of time steps expected until the vehicle departs (available only for 'parked ready to charge' state)
electric_vehicle_required_soc_departure : np.array
Estimated SOC percentage required for the electric_vehicle at departure time. (available only for 'parked ready to charge' state)
electric_vehicle_estimated_arrival_time : np.array
Number of time steps expected until the vehicle arrives at the charger (available only for 'in transit' state)
electric_vehicle_estimated_soc_arrival : np.array
Estimated SOC percentage for the electric_vehicle at arrival time. (available only for 'in transit' state)

"""

def __init__(
self, state: Iterable[str],
charger: Iterable[str], estimated_departure_time: Iterable[int], required_soc_departure: Iterable[float],
estimated_arrival_time: Iterable[int], estimated_soc_arrival: Iterable[float], start_time_step: int = None, end_time_step: int = None
):
r"""Initialize `ElectricVehicleSimulation`."""
super().__init__(start_time_step=start_time_step, end_time_step=end_time_step)
self.electric_vehicle_charger_state = np.array(state, dtype=int)
self.charger = np.array(charger, dtype=str)
# NaNs are considered and filled as -1, i.e., when they serve no value or no data is recorded from them
default_value = -1
self.electric_vehicle_departure_time = np.nan_to_num(np.array(estimated_departure_time, dtype=float),
nan=default_value).astype(int)
self.electric_vehicle_required_soc_departure = np.nan_to_num(np.array(required_soc_departure, dtype=float), nan=default_value)
self.electric_vehicle_estimated_arrival_time = np.nan_to_num(np.array(estimated_arrival_time, dtype=float),
nan=default_value).astype(int)
self.electric_vehicle_estimated_soc_arrival = np.nan_to_num(np.array(estimated_soc_arrival, dtype=float), nan=default_value)

Loading

0 comments on commit 8848db4

Please sign in to comment.