Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(v3.7.9) - VariabilityContextWrapper #473

Merged
merged 7 commits into from
Feb 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
~EplusEnv.info
~EplusEnv.render
~EplusEnv.reset
~EplusEnv.set_seed
~EplusEnv.set_wrapper_attr
~EplusEnv.step
~EplusEnv.update_context
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
sinergym.utils.wrappers.BaseLoggerWrapper
sinergym.utils.wrappers.BaseLoggerWrapper
=========================================

.. currentmodule:: sinergym.utils.wrappers
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
sinergym.utils.wrappers.CSVLogger
sinergym.utils.wrappers.CSVLogger
=================================

.. currentmodule:: sinergym.utils.wrappers
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
sinergym.utils.wrappers.DatetimeWrapper
sinergym.utils.wrappers.DatetimeWrapper
=======================================

.. currentmodule:: sinergym.utils.wrappers
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
sinergym.utils.wrappers.DeltaTempWrapper
sinergym.utils.wrappers.DeltaTempWrapper
========================================

.. currentmodule:: sinergym.utils.wrappers
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
sinergym.utils.wrappers.DiscreteIncrementalWrapper
sinergym.utils.wrappers.DiscreteIncrementalWrapper
==================================================

.. currentmodule:: sinergym.utils.wrappers
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
sinergym.utils.wrappers.DiscretizeEnv
sinergym.utils.wrappers.DiscretizeEnv
=====================================

.. currentmodule:: sinergym.utils.wrappers
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
sinergym.utils.wrappers.EnergyCostWrapper
sinergym.utils.wrappers.EnergyCostWrapper
=========================================

.. currentmodule:: sinergym.utils.wrappers
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
sinergym.utils.wrappers.IncrementalWrapper
sinergym.utils.wrappers.IncrementalWrapper
==========================================

.. currentmodule:: sinergym.utils.wrappers
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
sinergym.utils.wrappers.LoggerWrapper
sinergym.utils.wrappers.LoggerWrapper
=====================================

.. currentmodule:: sinergym.utils.wrappers
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
sinergym.utils.wrappers.MultiObjectiveReward
sinergym.utils.wrappers.MultiObjectiveReward
============================================

.. currentmodule:: sinergym.utils.wrappers
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
sinergym.utils.wrappers.MultiObsWrapper
sinergym.utils.wrappers.MultiObsWrapper
=======================================

.. currentmodule:: sinergym.utils.wrappers
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
sinergym.utils.wrappers.NormalizeAction
sinergym.utils.wrappers.NormalizeAction
=======================================

.. currentmodule:: sinergym.utils.wrappers
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
sinergym.utils.wrappers.NormalizeObservation
sinergym.utils.wrappers.NormalizeObservation
============================================

.. currentmodule:: sinergym.utils.wrappers
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
sinergym.utils.wrappers.OfficeGridStorageSmoothingActionConstraintsWrapper
sinergym.utils.wrappers.OfficeGridStorageSmoothingActionConstraintsWrapper
==========================================================================

.. currentmodule:: sinergym.utils.wrappers
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
sinergym.utils.wrappers.PreviousObservationWrapper
sinergym.utils.wrappers.PreviousObservationWrapper
==================================================

.. currentmodule:: sinergym.utils.wrappers
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
sinergym.utils.wrappers.ReduceObservationWrapper
sinergym.utils.wrappers.ReduceObservationWrapper
================================================

.. currentmodule:: sinergym.utils.wrappers
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
sinergym.utils.wrappers.VariabilityContextWrapper
=================================================

.. currentmodule:: sinergym.utils.wrappers

.. autoclass:: VariabilityContextWrapper
:members:
:undoc-members:


.. automethod:: __init__


.. rubric:: Methods

.. autosummary::

~VariabilityContextWrapper.__init__
~VariabilityContextWrapper.class_name
~VariabilityContextWrapper.close
~VariabilityContextWrapper.get_wrapper_attr
~VariabilityContextWrapper.has_wrapper_attr
~VariabilityContextWrapper.render
~VariabilityContextWrapper.reset
~VariabilityContextWrapper.set_wrapper_attr
~VariabilityContextWrapper.step
~VariabilityContextWrapper.wrapper_spec





.. rubric:: Attributes

.. autosummary::

~VariabilityContextWrapper.action_space
~VariabilityContextWrapper.logger
~VariabilityContextWrapper.metadata
~VariabilityContextWrapper.np_random
~VariabilityContextWrapper.np_random_seed
~VariabilityContextWrapper.observation_space
~VariabilityContextWrapper.render_mode
~VariabilityContextWrapper.spec
~VariabilityContextWrapper.unwrapped


Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
sinergym.utils.wrappers.WandBLogger
sinergym.utils.wrappers.WandBLogger
===================================

.. currentmodule:: sinergym.utils.wrappers
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
sinergym.utils.wrappers.WeatherForecastingWrapper
sinergym.utils.wrappers.WeatherForecastingWrapper
=================================================

.. currentmodule:: sinergym.utils.wrappers
Expand Down
1 change: 1 addition & 0 deletions docs/source/pages/modules/sinergym.utils.wrappers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
OfficeGridStorageSmoothingActionConstraintsWrapper
PreviousObservationWrapper
ReduceObservationWrapper
VariabilityContextWrapper
WandBLogger
WeatherForecastingWrapper

Expand Down
17 changes: 16 additions & 1 deletion docs/source/pages/wrappers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -233,4 +233,19 @@ It requires that the air temperature and setpoints variables are defined in the

If the environment has a unique setpoint variable for all zones, you can specify a single setpoint variable. Otherwise, you can specify a list of variables, one for each zone.

.. important:: The air temperature variables and setpoints variables should be specified in the same order. The length of these lists should be the same, in case you are not using the same setpoint for all zones.
.. important:: The air temperature variables and setpoints variables should be specified in the same order. The length of these lists should be the same, in case you are not using the same setpoint for all zones.

**************************
VariabilityContextWrapper
**************************

This wrapper introduces context changes (see :ref:`Context`) at specific steps based on a uniform distribution.

When the event is triggered, delta values for the context variables and a time (in steps) for the change to occur are randomly determined based on the specified arguments.

The configurable arguments include the space of the context variables, the range of possible delta values, and the range of steps in which the event can take place.

If applying the deltas results in values outside the defined space, they will be clipped to remain within bounds before being applied.

.. important:: If initial context values were not provided in environment initialization, initial context values will be selected randomly for this wrapper.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
package-mode = true
name = "sinergym"

version = "3.7.8"
version = "3.7.9"
description = "Sinergym provides a Gymnasium-based interface to interact with building simulations. This allows control in simulation time through custom controllers, including reinforcement learning agents"
license = "MIT"

Expand Down
11 changes: 6 additions & 5 deletions sinergym/envs/eplus_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ def __init__(
self.meters = meters
self.actuators = actuators
self.context = context
self.initial_context = initial_context

# ---------------------------------------------------------------------------- #
# Define observation and action variables #
Expand Down Expand Up @@ -160,8 +161,8 @@ def __init__(
# ---------------------------------------------------------------------------- #

# Set initial context if exists
if initial_context is not None:
self.update_context(initial_context)
if self.initial_context is not None:
self.update_context(self.initial_context)

# EnergyPlus simulator
self.energyplus_simulator = EnergyPlus(
Expand Down Expand Up @@ -399,9 +400,9 @@ def step(self,
reward, rw_terms = self.reward_fn(obs)

# Update info with
info.update({'action': action})
info.update({'timestep': self.timestep,
'reward': reward})
info.update({'action': action,
'timestep': self.timestep,
'reward': reward})
info.update(rw_terms)
self.last_info = info

Expand Down
8 changes: 0 additions & 8 deletions sinergym/utils/rewards.py
Original file line number Diff line number Diff line change
Expand Up @@ -676,14 +676,6 @@ def __call__(self, obs_dict: Dict[str, Any]
'comfort_threshold': self.comfort_threshold
}

# Add temp_violations per zone
reward_terms.update(
{
f'{temperature_variable}_violation': temp_violation for temperature_variable,
temp_violation in zip(
self.comfort_configuration.keys(),
temp_violations)})

return reward, reward_terms

def _get_energy_consumed(self, obs_dict: Dict[str,
Expand Down
Loading