Skip to content

Commit 4692c80

Browse files
committed
Revert to c6d862a
1 parent cb22c99 commit 4692c80

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+235219
-246315
lines changed

.github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ Please provide detailed steps to reproduce the issue.
2626
## Environment
2727

2828
- CityLearn version:
29-
- Dataset name/link:
3029
- Operating System:
3130
- Python version:
3231

.github/workflows/pypi_deploy.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
name: Upload Python Package
22

33
on:
4-
workflow_dispatch:
54
release:
65
types: [published]
76

87
jobs:
98
deploy:
109

1110
environment: pypi
12-
runs-on: ubuntu-24.04
11+
runs-on: ubuntu-20.04
1312
strategy:
1413
matrix:
1514
python-version: [3.11]

.github/workflows/run_tests.yml

Lines changed: 0 additions & 36 deletions
This file was deleted.

.github/workflows/sphinx.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
update:
1010

1111
environment: github-pages
12-
runs-on: ubuntu-24.04
12+
runs-on: ubuntu-20.04
1313
strategy:
1414
matrix:
1515
python-version: [3.11]

citylearn/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = '2.4.2'
1+
__version__ = '2.3.0'

citylearn/__main__.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
from citylearn.citylearn import CityLearnEnv
1919
from citylearn.data import DataSet, get_settings
2020
from citylearn.__init__ import __version__
21-
from citylearn.utilities import FileHandler
21+
from citylearn.utilities import read_pickle, write_json, write_pickle
2222
import pandas as pd
2323
import simplejson as json
2424

@@ -291,7 +291,7 @@ def __train(self, episodes: int):
291291
def __save_agent(self):
292292
if isinstance(self.agent, CityLearnAgent):
293293
filepath = os.path.join(self.output_directory, f'{self.simulation_id}-agent.pkl')
294-
FileHandler.write_pickle(filepath, self.agent)
294+
write_pickle(filepath, self.agent)
295295

296296
else:
297297
filepath = os.path.join(self.output_directory, f'{self.simulation_id}-agent')
@@ -307,7 +307,7 @@ def __set_agent(self) -> Union[CityLearnAgent, StableBaselines3Agent]:
307307

308308
else:
309309
if str(self.agent_filepath).endswith('.pkl'):
310-
agent = FileHandler.read_pickle(self.agent_filepath)
310+
agent = read_pickle(self.agent_filepath)
311311
agent.env = self.env
312312

313313
else:
@@ -349,15 +349,15 @@ def evaluate(cls, evaluation_episode_time_steps: Tuple[int, int] = None, **kwarg
349349
simulator = cls(**kwargs)
350350
simulator.__evaluate()
351351
filepath = os.path.join(simulator.output_directory, f'{simulator.simulation_id}-evaluation.json')
352-
FileHandler.write_json(filepath, simulator.__get_evaluation_summary())
352+
write_json(filepath, simulator.__get_evaluation_summary())
353353

354354
@classmethod
355355
def train(cls, episodes: int = None, evaluate: bool = None, evaluation_episode_time_steps: Tuple[int, int] = None, save_agent: bool = None, **kwargs):
356356
simulator = cls(**kwargs)
357357
episodes = 1 if episodes is None else episodes
358358
simulator.__train(episodes)
359359
filepath = os.path.join(simulator.output_directory, f'{simulator.simulation_id}-train.json')
360-
FileHandler.write_json(filepath, simulator.__get_training_summary())
360+
write_json(filepath, simulator.__get_training_summary())
361361

362362
if save_agent:
363363
simulator.__save_agent()

citylearn/agents/base.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ def __init__(self, env: CityLearnEnv, **kwargs: Any):
3333
seconds_per_time_step=self.env.unwrapped.seconds_per_time_step,
3434
random_seed=self.env.unwrapped.random_seed,
3535
episode_tracker=self.env.unwrapped.episode_tracker,
36-
time_step_ratio=self.env.unwrapped.time_step_ratio
3736
)
3837
self.reset()
3938

citylearn/agents/rbc.py

Lines changed: 2 additions & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ def action_map(self, action_map: Union[List[Mapping[str, Mapping[int, float]]],
343343

344344
for n in action_names:
345345
action_map[n] = {}
346-
346+
347347
if 'storage' in n:
348348
for hour in Building.get_periodic_observation_metadata()['hour']:
349349
if 6 <= hour <= 14:
@@ -387,100 +387,4 @@ def action_map(self, action_map: Union[List[Mapping[str, Mapping[int, float]]],
387387
else:
388388
raise ValueError(f'Unknown action name: {n}')
389389

390-
HourRBC.action_map.fset(self, action_map)
391-
392-
class BasicElectricVehicleRBC_ReferenceController(BasicRBC): #change the name
393-
r"""A rule-based controller that charges EVs to the maximum of the chargers and to the maximum of the battery upon connection.
394-
395-
The EV battery is charged at the maximum available charging power whenever it is connected.
396-
397-
Parameters
398-
----------
399-
env: CityLearnEnv
400-
CityLearn environment.
401-
402-
Other Parameters
403-
----------------
404-
**kwargs: Any
405-
Other keyword arguments used to initialize super class.
406-
"""
407-
408-
def __init__(self, env: CityLearnEnv, **kwargs: Any):
409-
super().__init__(env, **kwargs)
410-
411-
@HourRBC.action_map.setter
412-
def action_map(self, action_map: Union[
413-
List[Mapping[str, Mapping[int, float]]], Mapping[str, Mapping[int, float]], Mapping[int, float]]):
414-
if action_map is None:
415-
action_map = {}
416-
action_names = [a_ for a in self.action_names for a_ in a]
417-
action_names = list(set(action_names))
418-
419-
for n in action_names:
420-
action_map[n] = {}
421-
422-
if n == "electrical_storage":
423-
for hour in Building.get_periodic_observation_metadata()['hour']:
424-
if 9 <= hour <= 21:
425-
value = -0.08
426-
elif (1 <= hour <= 8) or (22 <= hour <= 24):
427-
value = 0.091
428-
else:
429-
value = 0.0
430-
431-
action_map[n][hour] = value
432-
433-
elif n == 'cooling_device':
434-
for hour in Building.get_periodic_observation_metadata()['hour']:
435-
if 9 <= hour <= 21:
436-
value = 0.8
437-
elif (1 <= hour <= 8) or (22 <= hour <= 24):
438-
value = 0.4
439-
else:
440-
value = 0.0
441-
442-
action_map[n][hour] = value
443-
444-
elif n == 'heating_device':
445-
for hour in Building.get_periodic_observation_metadata()['hour']:
446-
if 9 <= hour <= 21:
447-
value = 0.4
448-
elif (1 <= hour <= 8) or (22 <= hour <= 24):
449-
value = 0.8
450-
else:
451-
value = 0.0
452-
453-
action_map[n][hour] = value
454-
455-
elif n == 'cooling_or_heating_device':
456-
for hour in Building.get_periodic_observation_metadata()['hour']:
457-
if hour < 7:
458-
value = 0.4
459-
460-
elif hour < 21:
461-
value = -0.4
462-
463-
else:
464-
value = 0.8
465-
466-
action_map[n][hour] = value
467-
468-
elif "electric_vehicle" in n:
469-
for hour in Building.get_periodic_observation_metadata()['hour']:
470-
value = 1
471-
action_map[n][hour] = value
472-
473-
elif "dhw_storage" in n:
474-
for hour in Building.get_periodic_observation_metadata()['hour']:
475-
value = 1
476-
action_map[n][hour] = value
477-
478-
elif "washing_machine" in n:
479-
for hour in Building.get_periodic_observation_metadata()['hour']:
480-
value = 1
481-
action_map[n][hour] = value
482-
483-
else:
484-
raise ValueError(f'Unknown action name: {n}')
485-
486-
HourRBC.action_map.fset(self, action_map)
390+
HourRBC.action_map.fset(self, action_map)

citylearn/base.py

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -153,13 +153,12 @@ class Environment:
153153
DEFAULT_SECONDS_PER_TIME_STEP = 3600.0
154154
DEFAULT_RANDOM_SEED_RANGE = (0, 100_000_000)
155155

156-
def __init__(self, seconds_per_time_step: float = None, random_seed: int = None, episode_tracker: EpisodeTracker = None, time_step_ratio: int = None):
156+
def __init__(self, seconds_per_time_step: float = None, random_seed: int = None, episode_tracker: EpisodeTracker = None):
157157
self.seconds_per_time_step = seconds_per_time_step
158158
self.__uid = uuid.uuid4().hex
159159
self.random_seed = random_seed
160160
self.__time_step = None
161161
self.episode_tracker = episode_tracker
162-
self.time_step_ratio = time_step_ratio
163162

164163
@property
165164
def uid(self) -> str:
@@ -179,13 +178,6 @@ def episode_tracker(self) -> EpisodeTracker:
179178
current episode time steps for reading observations from data files."""
180179

181180
return self.__episode_tracker
182-
183-
@property
184-
def time_step_ratio(self) -> int:
185-
""":py:class:`citylearn.base.EpisodeTracker` object used to keep track of
186-
current episode time steps for reading observations from data files."""
187-
188-
return self.__time_step_ratio
189181

190182
@property
191183
def time_step(self) -> int:
@@ -221,14 +213,6 @@ def seconds_per_time_step(self, seconds_per_time_step: float):
221213
@episode_tracker.setter
222214
def episode_tracker(self, episode_tracker: EpisodeTracker):
223215
self.__episode_tracker = episode_tracker
224-
225-
@time_step_ratio.setter
226-
def time_step_ratio(self, time_step_ratio: int):
227-
self.__time_step_ratio = time_step_ratio
228-
229-
@time_step.setter
230-
def time_step(self, time_step: int):
231-
self.__time_step = time_step
232216

233217
def get_metadata(self) -> Mapping[str, Any]:
234218
"""Returns general static information."""
@@ -237,8 +221,7 @@ def get_metadata(self) -> Mapping[str, Any]:
237221
'uid': self.uid,
238222
'random_seed': self.random_seed,
239223
'simulation_time_steps': self.episode_tracker.simulation_time_steps,
240-
'seconds_per_time_step': self.seconds_per_time_step,
241-
'time_step_ratio': self.time_step_ratio,
224+
'seconds_per_time_step': self.seconds_per_time_step
242225
}
243226

244227
def next_time_step(self):

0 commit comments

Comments
 (0)