Changing an environment registered in Sinergym

As discussed above, Sinergym has a list of available environments that we can call with gym.make(<environment_id>) as long as the sinergym package is imported into the python script.

[9]:
import gym
import numpy as np

import sinergym
env = gym.make('Eplus-5Zone-hot-continuous-stochastic-v1')
[2022-10-03 11:06:11,813] EPLUS_ENV_5Zone-hot-continuous-stochastic-v1_MainThread_ROOT INFO:Updating idf ExternalInterface object if it is not present...
[2022-10-03 11:06:11,813] EPLUS_ENV_5Zone-hot-continuous-stochastic-v1_MainThread_ROOT INFO:Updating idf ExternalInterface object if it is not present...
[2022-10-03 11:06:11,814] EPLUS_ENV_5Zone-hot-continuous-stochastic-v1_MainThread_ROOT INFO:Updating idf Site:Location and SizingPeriod:DesignDay(s) to weather and ddy file...
[2022-10-03 11:06:11,814] EPLUS_ENV_5Zone-hot-continuous-stochastic-v1_MainThread_ROOT INFO:Updating idf Site:Location and SizingPeriod:DesignDay(s) to weather and ddy file...
[2022-10-03 11:06:11,816] EPLUS_ENV_5Zone-hot-continuous-stochastic-v1_MainThread_ROOT INFO:Updating idf OutPut:Variable and variables XML tree model for BVCTB connection.
[2022-10-03 11:06:11,816] EPLUS_ENV_5Zone-hot-continuous-stochastic-v1_MainThread_ROOT INFO:Updating idf OutPut:Variable and variables XML tree model for BVCTB connection.
[2022-10-03 11:06:11,818] EPLUS_ENV_5Zone-hot-continuous-stochastic-v1_MainThread_ROOT INFO:Setting up extra configuration in building model if exists...
[2022-10-03 11:06:11,818] EPLUS_ENV_5Zone-hot-continuous-stochastic-v1_MainThread_ROOT INFO:Setting up extra configuration in building model if exists...
[2022-10-03 11:06:11,818] EPLUS_ENV_5Zone-hot-continuous-stochastic-v1_MainThread_ROOT INFO:Setting up action definition in building model if exists...
[2022-10-03 11:06:11,818] EPLUS_ENV_5Zone-hot-continuous-stochastic-v1_MainThread_ROOT INFO:Setting up action definition in building model if exists...
/usr/local/lib/python3.10/dist-packages/gym/spaces/box.py:73: UserWarning: WARN: Box bound precision lowered by casting to float32
  logger.warn(

These environment IDs have a number of components defined, not only the building design (IDF), but also the reward function, the action and observation spaces, the defining variables, etc.

If you want a new environment, you can define it from scratch in our environment list and run it locally.

Another option (recommended) is to start from one of our environments and change the components you want. You can combine components you want to change obviously.

The way to do that is to add in the gym.make(<environment_id>) those parameters of the constructor of the Sinergym environment we want to change. Let’s see what things we can change starting from any environment:

Adding a new reward

As mentioned above, simply add the appropriate parameters to gym.make() after specifying the environment ID.

[10]:
from sinergym.utils.rewards import LinearReward, ExpReward

env = gym.make('Eplus-5Zone-hot-continuous-v1', reward=ExpReward, reward_kwargs={
                                                                    'temperature_variable': 'Zone Air Temperature (SPACE1-1)',
                                                                    'energy_variable': 'Facility Total HVAC Electricity Demand Rate (Whole Building)',
                                                                    'range_comfort_winter': (20.0, 23.5),
                                                                    'range_comfort_summer': (23.0, 26.0),
                                                                    'energy_weight': 0.1})
[2022-10-03 11:06:15,333] EPLUS_ENV_5Zone-hot-continuous-v1_MainThread_ROOT INFO:Updating idf ExternalInterface object if it is not present...
[2022-10-03 11:06:15,333] EPLUS_ENV_5Zone-hot-continuous-v1_MainThread_ROOT INFO:Updating idf ExternalInterface object if it is not present...
[2022-10-03 11:06:15,334] EPLUS_ENV_5Zone-hot-continuous-v1_MainThread_ROOT INFO:Updating idf Site:Location and SizingPeriod:DesignDay(s) to weather and ddy file...
[2022-10-03 11:06:15,334] EPLUS_ENV_5Zone-hot-continuous-v1_MainThread_ROOT INFO:Updating idf Site:Location and SizingPeriod:DesignDay(s) to weather and ddy file...
[2022-10-03 11:06:15,336] EPLUS_ENV_5Zone-hot-continuous-v1_MainThread_ROOT INFO:Updating idf OutPut:Variable and variables XML tree model for BVCTB connection.
[2022-10-03 11:06:15,336] EPLUS_ENV_5Zone-hot-continuous-v1_MainThread_ROOT INFO:Updating idf OutPut:Variable and variables XML tree model for BVCTB connection.
[2022-10-03 11:06:15,337] EPLUS_ENV_5Zone-hot-continuous-v1_MainThread_ROOT INFO:Setting up extra configuration in building model if exists...
[2022-10-03 11:06:15,337] EPLUS_ENV_5Zone-hot-continuous-v1_MainThread_ROOT INFO:Setting up extra configuration in building model if exists...
[2022-10-03 11:06:15,338] EPLUS_ENV_5Zone-hot-continuous-v1_MainThread_ROOT INFO:Setting up action definition in building model if exists...
[2022-10-03 11:06:15,338] EPLUS_ENV_5Zone-hot-continuous-v1_MainThread_ROOT INFO:Setting up action definition in building model if exists...
/usr/local/lib/python3.10/dist-packages/gym/spaces/box.py:73: UserWarning: WARN: Box bound precision lowered by casting to float32
  logger.warn(

You have to specify the reward class you are going to use in the environment. A reward function class has several parameters that can be specified by user like temperature variables, weights, etc. Depending on the reward function you are using. In order to be able to define it, we have reward_kwargs parameter. See reward documentation for more information about reward classes and how to create a new one.

Adding other new components to the environment

In the same way that we can change the default reward function, as we have done in the second example, it is possible to substitute other default values of the environment ID.

You can change the weather file, the number of timesteps an action repeats (default 1), the last n episodes you want to be stored in the Sinergym output folder (default 10), the name of the environment or the variability in stochastic environments:

[11]:
env = gym.make('Eplus-5Zone-cool-continuous-stochastic-v1',
                weather_file='ESP_Granada.084190_SWEC.epw',
                weather_variability=(1.0,0.0,0.001),
                env_name='new_env_name',
                act_repeat=4,
                max_ep_data_store_num = 20)
[2022-10-03 11:06:19,050] EPLUS_ENV_new_env_name_MainThread_ROOT INFO:Updating idf ExternalInterface object if it is not present...
[2022-10-03 11:06:19,050] EPLUS_ENV_new_env_name_MainThread_ROOT INFO:Updating idf ExternalInterface object if it is not present...
[2022-10-03 11:06:19,052] EPLUS_ENV_new_env_name_MainThread_ROOT INFO:Updating idf Site:Location and SizingPeriod:DesignDay(s) to weather and ddy file...
[2022-10-03 11:06:19,052] EPLUS_ENV_new_env_name_MainThread_ROOT INFO:Updating idf Site:Location and SizingPeriod:DesignDay(s) to weather and ddy file...
[2022-10-03 11:06:19,054] EPLUS_ENV_new_env_name_MainThread_ROOT INFO:Updating idf OutPut:Variable and variables XML tree model for BVCTB connection.
[2022-10-03 11:06:19,054] EPLUS_ENV_new_env_name_MainThread_ROOT INFO:Updating idf OutPut:Variable and variables XML tree model for BVCTB connection.
[2022-10-03 11:06:19,056] EPLUS_ENV_new_env_name_MainThread_ROOT INFO:Setting up extra configuration in building model if exists...
[2022-10-03 11:06:19,056] EPLUS_ENV_new_env_name_MainThread_ROOT INFO:Setting up extra configuration in building model if exists...
[2022-10-03 11:06:19,057] EPLUS_ENV_new_env_name_MainThread_ROOT INFO:Setting up action definition in building model if exists...
[2022-10-03 11:06:19,057] EPLUS_ENV_new_env_name_MainThread_ROOT INFO:Setting up action definition in building model if exists...
/usr/local/lib/python3.10/dist-packages/gym/spaces/box.py:73: UserWarning: WARN: Box bound precision lowered by casting to float32
  logger.warn(

Changing observation and action spaces

By default, the IDs of the predefined environments in Sinergym already have a space of actions and observations set.

However, it can be overwritten by a new definition of them. On the one hand, we will have to define the name of the variables, and on the other hand, the definition of the spaces (and an action mapping if it is a discrete environment).

[13]:
import gym
import numpy as np

import sinergym

new_observation_variables=[
    'Site Outdoor Air Drybulb Temperature(Environment)',
    'Site Outdoor Air Relative Humidity(Environment)',
    'Site Wind Speed(Environment)',
    'Zone Thermal Comfort Fanger Model PPD(East Zone PEOPLE)',
    'Zone People Occupant Count(East Zone)',
    'People Air Temperature(East Zone PEOPLE)',
    'Facility Total HVAC Electricity Demand Rate(Whole Building)'
]

new_action_variables = [
    'Heating_Setpoint_RL',
    'Cooling_Setpoint_RL',
]

new_observation_space = gym.spaces.Box(
    low=-5e6,
    high=5e6,
    shape=(len(new_observation_variables) + 4,),
    dtype=np.float32)

new_action_mapping = {
    0: (15, 30),
    1: (16, 29),
    2: (17, 28),
    3: (18, 27),
    4: (19, 26),
    5: (20, 25),
    6: (21, 24),
    7: (22, 23),
    8: (22, 22),
    9: (21, 21)
}

new_action_space = gym.spaces.Discrete(10)

env = gym.make('Eplus-datacenter-cool-discrete-stochastic-v1',
                observation_variables=new_observation_variables,
                observation_space=new_observation_space,
                action_variables=new_action_variables,
                action_mapping=new_action_mapping,
                action_space=new_action_space
            )


for i in range(1):
    obs = env.reset()
    rewards = []
    done = False
    current_month = 0
    while not done:
        a = env.action_space.sample()
        obs, reward, done, info = env.step(a)
        rewards.append(reward)
        if info['month'] != current_month:  # display results every month
            current_month = info['month']
            print('Reward: ', sum(rewards), info)
    print(
        'Episode ',
        i,
        'Mean reward: ',
        np.mean(rewards),
        'Cumulative reward: ',
        sum(rewards))
env.close()
[2022-10-03 11:07:47,922] EPLUS_ENV_datacenter-cool-discrete-stochastic-v1_MainThread_ROOT INFO:Updating idf ExternalInterface object if it is not present...
[2022-10-03 11:07:47,922] EPLUS_ENV_datacenter-cool-discrete-stochastic-v1_MainThread_ROOT INFO:Updating idf ExternalInterface object if it is not present...
[2022-10-03 11:07:47,922] EPLUS_ENV_datacenter-cool-discrete-stochastic-v1_MainThread_ROOT INFO:Updating idf ExternalInterface object if it is not present...
[2022-10-03 11:07:47,922] EPLUS_ENV_datacenter-cool-discrete-stochastic-v1_MainThread_ROOT INFO:Updating idf ExternalInterface object if it is not present...
[2022-10-03 11:07:47,924] EPLUS_ENV_datacenter-cool-discrete-stochastic-v1_MainThread_ROOT INFO:Updating idf Site:Location and SizingPeriod:DesignDay(s) to weather and ddy file...
[2022-10-03 11:07:47,924] EPLUS_ENV_datacenter-cool-discrete-stochastic-v1_MainThread_ROOT INFO:Updating idf Site:Location and SizingPeriod:DesignDay(s) to weather and ddy file...
[2022-10-03 11:07:47,924] EPLUS_ENV_datacenter-cool-discrete-stochastic-v1_MainThread_ROOT INFO:Updating idf Site:Location and SizingPeriod:DesignDay(s) to weather and ddy file...
[2022-10-03 11:07:47,924] EPLUS_ENV_datacenter-cool-discrete-stochastic-v1_MainThread_ROOT INFO:Updating idf Site:Location and SizingPeriod:DesignDay(s) to weather and ddy file...
[2022-10-03 11:07:47,926] EPLUS_ENV_datacenter-cool-discrete-stochastic-v1_MainThread_ROOT INFO:Updating idf OutPut:Variable and variables XML tree model for BVCTB connection.
[2022-10-03 11:07:47,926] EPLUS_ENV_datacenter-cool-discrete-stochastic-v1_MainThread_ROOT INFO:Updating idf OutPut:Variable and variables XML tree model for BVCTB connection.
[2022-10-03 11:07:47,926] EPLUS_ENV_datacenter-cool-discrete-stochastic-v1_MainThread_ROOT INFO:Updating idf OutPut:Variable and variables XML tree model for BVCTB connection.
[2022-10-03 11:07:47,926] EPLUS_ENV_datacenter-cool-discrete-stochastic-v1_MainThread_ROOT INFO:Updating idf OutPut:Variable and variables XML tree model for BVCTB connection.
[2022-10-03 11:07:47,928] EPLUS_ENV_datacenter-cool-discrete-stochastic-v1_MainThread_ROOT INFO:Setting up extra configuration in building model if exists...
[2022-10-03 11:07:47,928] EPLUS_ENV_datacenter-cool-discrete-stochastic-v1_MainThread_ROOT INFO:Setting up extra configuration in building model if exists...
[2022-10-03 11:07:47,928] EPLUS_ENV_datacenter-cool-discrete-stochastic-v1_MainThread_ROOT INFO:Setting up extra configuration in building model if exists...
[2022-10-03 11:07:47,928] EPLUS_ENV_datacenter-cool-discrete-stochastic-v1_MainThread_ROOT INFO:Setting up extra configuration in building model if exists...
[2022-10-03 11:07:47,929] EPLUS_ENV_datacenter-cool-discrete-stochastic-v1_MainThread_ROOT INFO:Setting up action definition in building model if exists...
[2022-10-03 11:07:47,929] EPLUS_ENV_datacenter-cool-discrete-stochastic-v1_MainThread_ROOT INFO:Setting up action definition in building model if exists...
[2022-10-03 11:07:47,929] EPLUS_ENV_datacenter-cool-discrete-stochastic-v1_MainThread_ROOT INFO:Setting up action definition in building model if exists...
[2022-10-03 11:07:47,929] EPLUS_ENV_datacenter-cool-discrete-stochastic-v1_MainThread_ROOT INFO:Setting up action definition in building model if exists...
[2022-10-03 11:07:47,931] EPLUS_ENV_datacenter-cool-discrete-stochastic-v1_MainThread_ROOT INFO:Creating new EnergyPlus simulation episode...
[2022-10-03 11:07:47,931] EPLUS_ENV_datacenter-cool-discrete-stochastic-v1_MainThread_ROOT INFO:Creating new EnergyPlus simulation episode...
[2022-10-03 11:07:47,931] EPLUS_ENV_datacenter-cool-discrete-stochastic-v1_MainThread_ROOT INFO:Creating new EnergyPlus simulation episode...
[2022-10-03 11:07:47,931] EPLUS_ENV_datacenter-cool-discrete-stochastic-v1_MainThread_ROOT INFO:Creating new EnergyPlus simulation episode...
[2022-10-03 11:07:48,064] EPLUS_ENV_datacenter-cool-discrete-stochastic-v1_MainThread_ROOT INFO:EnergyPlus working directory is in /workspaces/sinergym/examples/Eplus-env-datacenter-cool-discrete-stochastic-v1-res4/Eplus-env-sub_run1
[2022-10-03 11:07:48,064] EPLUS_ENV_datacenter-cool-discrete-stochastic-v1_MainThread_ROOT INFO:EnergyPlus working directory is in /workspaces/sinergym/examples/Eplus-env-datacenter-cool-discrete-stochastic-v1-res4/Eplus-env-sub_run1
[2022-10-03 11:07:48,064] EPLUS_ENV_datacenter-cool-discrete-stochastic-v1_MainThread_ROOT INFO:EnergyPlus working directory is in /workspaces/sinergym/examples/Eplus-env-datacenter-cool-discrete-stochastic-v1-res4/Eplus-env-sub_run1
[2022-10-03 11:07:48,064] EPLUS_ENV_datacenter-cool-discrete-stochastic-v1_MainThread_ROOT INFO:EnergyPlus working directory is in /workspaces/sinergym/examples/Eplus-env-datacenter-cool-discrete-stochastic-v1-res4/Eplus-env-sub_run1
Reward:  -0.2153129771240179 {'timestep': 1, 'time_elapsed': 900, 'year': 1991, 'month': 1, 'day': 1, 'hour': 0, 'total_power': 4306.259542480358, 'total_power_no_units': -0.4306259542480358, 'comfort_penalty': -0.0, 'abs_comfort': 0.0, 'temperatures': [], 'out_temperature': 1.044000531676663, 'action_': [19, 26]}
Reward:  -660.6448328594148 {'timestep': 2976, 'time_elapsed': 2678400, 'year': 1991, 'month': 2, 'day': 1, 'hour': 0, 'total_power': 4157.813830820063, 'total_power_no_units': -0.41578138308200635, 'comfort_penalty': -0.0, 'abs_comfort': 0.0, 'temperatures': [], 'out_temperature': 8.755699132506065, 'action_': [18, 27]}
Reward:  -1244.0392548144782 {'timestep': 5664, 'time_elapsed': 5097600, 'year': 1991, 'month': 3, 'day': 1, 'hour': 0, 'total_power': 4725.134398205902, 'total_power_no_units': -0.4725134398205902, 'comfort_penalty': -0.0, 'abs_comfort': 0.0, 'temperatures': [], 'out_temperature': 3.388003680767862, 'action_': [20, 25]}
Reward:  -1847.362623921392 {'timestep': 8640, 'time_elapsed': 7776000, 'year': 1991, 'month': 4, 'day': 1, 'hour': 0, 'total_power': 2049.570777765625, 'total_power_no_units': -0.2049570777765625, 'comfort_penalty': -0.0, 'abs_comfort': 0.0, 'temperatures': [], 'out_temperature': 4.552775270130963, 'action_': [16, 29]}
Reward:  -2618.1218338983613 {'timestep': 11520, 'time_elapsed': 10368000, 'year': 1991, 'month': 5, 'day': 1, 'hour': 0, 'total_power': 3959.276280160218, 'total_power_no_units': -0.3959276280160218, 'comfort_penalty': -0.0, 'abs_comfort': 0.0, 'temperatures': [], 'out_temperature': 10.11681786642924, 'action_': [17, 28]}
Reward:  -3518.8119994042654 {'timestep': 14496, 'time_elapsed': 13046400, 'year': 1991, 'month': 6, 'day': 1, 'hour': 0, 'total_power': 3962.959903637627, 'total_power_no_units': -0.39629599036376273, 'comfort_penalty': -0.0, 'abs_comfort': 0.0, 'temperatures': [], 'out_temperature': 9.942164036459882, 'action_': [22, 23]}
Reward:  -4987.145205583042 {'timestep': 17376, 'time_elapsed': 15638400, 'year': 1991, 'month': 7, 'day': 1, 'hour': 0, 'total_power': 2957.592219109529, 'total_power_no_units': -0.29575922191095294, 'comfort_penalty': -0.0, 'abs_comfort': 0.0, 'temperatures': [], 'out_temperature': 9.949206675456736, 'action_': [18, 27]}
Reward:  -7041.095957436299 {'timestep': 20352, 'time_elapsed': 18316800, 'year': 1991, 'month': 8, 'day': 1, 'hour': 0, 'total_power': 4484.510318043606, 'total_power_no_units': -0.44845103180436063, 'comfort_penalty': -0.0, 'abs_comfort': 0.0, 'temperatures': [], 'out_temperature': 11.07359623673829, 'action_': [21, 24]}
Reward:  -9296.59688572278 {'timestep': 23328, 'time_elapsed': 20995200, 'year': 1991, 'month': 9, 'day': 1, 'hour': 0, 'total_power': 4077.687654856706, 'total_power_no_units': -0.40776876548567065, 'comfort_penalty': -0.0, 'abs_comfort': 0.0, 'temperatures': [], 'out_temperature': 11.79347434337422, 'action_': [22, 22]}
Reward:  -10863.569765398093 {'timestep': 26208, 'time_elapsed': 23587200, 'year': 1991, 'month': 10, 'day': 1, 'hour': 0, 'total_power': 3962.959903637627, 'total_power_no_units': -0.39629599036376273, 'comfort_penalty': -0.0, 'abs_comfort': 0.0, 'temperatures': [], 'out_temperature': 6.985007523418071, 'action_': [22, 22]}
Reward:  -11617.7046973911 {'timestep': 29184, 'time_elapsed': 26265600, 'year': 1991, 'month': 11, 'day': 1, 'hour': 0, 'total_power': 3747.895494409444, 'total_power_no_units': -0.3747895494409444, 'comfort_penalty': -0.0, 'abs_comfort': 0.0, 'temperatures': [], 'out_temperature': 4.43013838706209, 'action_': [18, 27]}
Reward:  -12213.685087327127 {'timestep': 32064, 'time_elapsed': 28857600, 'year': 1991, 'month': 12, 'day': 1, 'hour': 0, 'total_power': 3962.959903637627, 'total_power_no_units': -0.39629599036376273, 'comfort_penalty': -0.0, 'abs_comfort': 0.0, 'temperatures': [], 'out_temperature': 4.866732045629226, 'action_': [22, 22]}
Reward:  -12851.12643466358 {'timestep': 35040, 'time_elapsed': 31536000, 'year': 1992, 'month': 1, 'day': 1, 'hour': 0, 'total_power': 6205.54217205275, 'total_power_no_units': -0.620554217205275, 'comfort_penalty': -0.0, 'abs_comfort': 0.0, 'temperatures': [], 'out_temperature': -0.4835161520335998, 'action_': [21, 21]}
Episode  0 Mean reward:  -0.36675589140025355 Cumulative reward:  -12851.12643466358
[2022-10-03 11:08:18,405] EPLUS_ENV_datacenter-cool-discrete-stochastic-v1_MainThread_ROOT INFO:EnergyPlus simulation closed successfully.
[2022-10-03 11:08:18,405] EPLUS_ENV_datacenter-cool-discrete-stochastic-v1_MainThread_ROOT INFO:EnergyPlus simulation closed successfully.
[2022-10-03 11:08:18,405] EPLUS_ENV_datacenter-cool-discrete-stochastic-v1_MainThread_ROOT INFO:EnergyPlus simulation closed successfully.
[2022-10-03 11:08:18,405] EPLUS_ENV_datacenter-cool-discrete-stochastic-v1_MainThread_ROOT INFO:EnergyPlus simulation closed successfully.

In case the definition has some inconsistency, such as the IDF has not been adapted to the new actions, the spaces do not fit with the variables, the observation variables do not exist, etc. Sinergym will display an error.

Action variables defined must exists in IDF model like external interface. Then, you have two possibilities:

  • First, you can modify IDF file directly, but it is necessary to update several components depending in order to connect them to the external interface (requires knowledge of the building and EnergyPlus).

  • Second, you can use the action definition functionality of Sinergym (recommended). This functionality will modify the IDF file before starting the simulation automatically based on a simple definition of the components to be replaced by an external control. See “updating action definition” example to learn how to use it.

Getting information about building model with Sinergym

Sinergym can get the schedulers information automatically, in a Python dictionary and/or exporting that information in a excel file. This information lets you know what things can be controlled by an external interface in the building. The way to do it is very simple, just load the environment and call a method:

[15]:
import gym
import sinergym

from pprint import pprint

env = gym.make('Eplus-demo-v1')
schedulers=env.get_schedulers()
pprint(schedulers)
[2022-10-03 11:08:48,685] EPLUS_ENV_demo-v1_MainThread_ROOT INFO:Updating idf ExternalInterface object if it is not present...
[2022-10-03 11:08:48,685] EPLUS_ENV_demo-v1_MainThread_ROOT INFO:Updating idf ExternalInterface object if it is not present...
[2022-10-03 11:08:48,686] EPLUS_ENV_demo-v1_MainThread_ROOT INFO:Updating idf Site:Location and SizingPeriod:DesignDay(s) to weather and ddy file...
[2022-10-03 11:08:48,686] EPLUS_ENV_demo-v1_MainThread_ROOT INFO:Updating idf Site:Location and SizingPeriod:DesignDay(s) to weather and ddy file...
[2022-10-03 11:08:48,688] EPLUS_ENV_demo-v1_MainThread_ROOT INFO:Updating idf OutPut:Variable and variables XML tree model for BVCTB connection.
[2022-10-03 11:08:48,688] EPLUS_ENV_demo-v1_MainThread_ROOT INFO:Updating idf OutPut:Variable and variables XML tree model for BVCTB connection.
[2022-10-03 11:08:48,689] EPLUS_ENV_demo-v1_MainThread_ROOT INFO:Setting up extra configuration in building model if exists...
[2022-10-03 11:08:48,689] EPLUS_ENV_demo-v1_MainThread_ROOT INFO:Setting up extra configuration in building model if exists...
[2022-10-03 11:08:48,690] EPLUS_ENV_demo-v1_MainThread_ROOT INFO:Setting up action definition in building model if exists...
[2022-10-03 11:08:48,690] EPLUS_ENV_demo-v1_MainThread_ROOT INFO:Setting up action definition in building model if exists...
{'activitysch': {'Type': 'any number'},
 'actschd': {'Object1': {'object_field_name': 'activity_level_schedule_name',
                         'object_name': 'space1-1 people 1',
                         'object_type': 'People'},
             'Object2': {'object_field_name': 'activity_level_schedule_name',
                         'object_name': 'space2-1 people 1',
                         'object_type': 'People'},
             'Object3': {'object_field_name': 'activity_level_schedule_name',
                         'object_name': 'space3-1 people 1',
                         'object_type': 'People'},
             'Object4': {'object_field_name': 'activity_level_schedule_name',
                         'object_name': 'space4-1 people 1',
                         'object_type': 'People'},
             'Object5': {'object_field_name': 'activity_level_schedule_name',
                         'object_name': 'space5-1 people 1',
                         'object_type': 'People'},
             'Type': 'any number'},
 'airvelocitysch': {'Object1': {'object_field_name': 'air_velocity_schedule_name',
                                'object_name': 'space1-1 people 1',
                                'object_type': 'People'},
                    'Object2': {'object_field_name': 'air_velocity_schedule_name',
                                'object_name': 'space2-1 people 1',
                                'object_type': 'People'},
                    'Object3': {'object_field_name': 'air_velocity_schedule_name',
                                'object_name': 'space3-1 people 1',
                                'object_type': 'People'},
                    'Object4': {'object_field_name': 'air_velocity_schedule_name',
                                'object_name': 'space4-1 people 1',
                                'object_type': 'People'},
                    'Object5': {'object_field_name': 'air_velocity_schedule_name',
                                'object_name': 'space5-1 people 1',
                                'object_type': 'People'},
                    'Type': 'any number'},
 'basinheatersched': {'Object1': {'object_field_name': 'basin_heater_operating_schedule_name',
                                  'object_name': 'main cooling coil 1',
                                  'object_type': 'Coil:Cooling:DX:TwoSpeed'},
                      'Type': 'on/off'},
 'clg-setp-sch': {'Object1': {'object_field_name': 'cooling_setpoint_temperature_schedule_name',
                              'object_name': 'dualsetpoint',
                              'object_type': 'ThermostatSetpoint:DualSetpoint'},
                  'Object2': {'object_field_name': 'setpoint_temperature_schedule_name',
                              'object_name': 'coolingsetpoint',
                              'object_type': 'ThermostatSetpoint:SingleCooling'},
                  'Type': 'temperature'},
 'clothingsch': {'Type': 'any number'},
 'coolingcoilavailsched': {'Object1': {'object_field_name': 'availability_schedule_name',
                                       'object_name': 'main cooling coil 1',
                                       'object_type': 'Coil:Cooling:DX:TwoSpeed'},
                           'Object2': {'object_field_name': 'availability_schedule_name',
                                       'object_name': 'dx cooling coil system '
                                                      '1',
                                       'object_type': 'CoilSystem:Cooling:DX'},
                           'Type': 'fraction'},
 'equip-1': {'Object1': {'object_field_name': 'schedule_name',
                         'object_name': 'space1-1 eleceq 1',
                         'object_type': 'ElectricEquipment'},
             'Object2': {'object_field_name': 'schedule_name',
                         'object_name': 'space2-1 eleceq 1',
                         'object_type': 'ElectricEquipment'},
             'Object3': {'object_field_name': 'schedule_name',
                         'object_name': 'space3-1 eleceq 1',
                         'object_type': 'ElectricEquipment'},
             'Object4': {'object_field_name': 'schedule_name',
                         'object_name': 'space4-1 eleceq 1',
                         'object_type': 'ElectricEquipment'},
             'Object5': {'object_field_name': 'schedule_name',
                         'object_name': 'space5-1 eleceq 1',
                         'object_type': 'ElectricEquipment'},
             'Type': 'fraction'},
 'fanavailsched': {'Object1': {'object_field_name': 'schedule_name',
                               'object_name': 'vav sys 1 avail',
                               'object_type': 'AvailabilityManager:Scheduled'},
                   'Object2': {'object_field_name': 'availability_schedule_name',
                               'object_name': 'supply fan 1',
                               'object_type': 'Fan:VariableVolume'},
                   'Type': 'fraction'},
 'htg-setp-sch': {'Object1': {'object_field_name': 'heating_setpoint_temperature_schedule_name',
                              'object_name': 'dualsetpoint',
                              'object_type': 'ThermostatSetpoint:DualSetpoint'},
                  'Object2': {'object_field_name': 'setpoint_temperature_schedule_name',
                              'object_name': 'heatingsetpoint',
                              'object_type': 'ThermostatSetpoint:SingleHeating'},
                  'Type': 'temperature'},
 'infil-sch': {'Object1': {'object_field_name': 'schedule_name',
                           'object_name': 'space1-1 infil 1',
                           'object_type': 'ZoneInfiltration:DesignFlowRate'},
               'Object2': {'object_field_name': 'schedule_name',
                           'object_name': 'space2-1 infil 1',
                           'object_type': 'ZoneInfiltration:DesignFlowRate'},
               'Object3': {'object_field_name': 'schedule_name',
                           'object_name': 'space3-1 infil 1',
                           'object_type': 'ZoneInfiltration:DesignFlowRate'},
               'Object4': {'object_field_name': 'schedule_name',
                           'object_name': 'space4-1 infil 1',
                           'object_type': 'ZoneInfiltration:DesignFlowRate'},
               'Object5': {'object_field_name': 'schedule_name',
                           'object_name': 'space5-1 infil 1',
                           'object_type': 'ZoneInfiltration:DesignFlowRate'},
               'Type': 'fraction'},
 'lights-1': {'Object1': {'object_field_name': 'schedule_name',
                          'object_name': 'space1-1 lights 1',
                          'object_type': 'Lights'},
              'Object2': {'object_field_name': 'schedule_name',
                          'object_name': 'space2-1 lights 1',
                          'object_type': 'Lights'},
              'Object3': {'object_field_name': 'schedule_name',
                          'object_name': 'space3-1 lights 1',
                          'object_type': 'Lights'},
              'Object4': {'object_field_name': 'schedule_name',
                          'object_name': 'space4-1 lights 1',
                          'object_type': 'Lights'},
              'Object5': {'object_field_name': 'schedule_name',
                          'object_name': 'space5-1 lights 1',
                          'object_type': 'Lights'},
              'Type': 'fraction'},
 'min oa sched': {'Object1': {'object_field_name': 'minimum_outdoor_air_schedule_name',
                              'object_name': 'oa controller 1',
                              'object_type': 'Controller:OutdoorAir'},
                  'Type': 'fraction'},
 'min oarequirements sched': {'Object1': {'object_field_name': 'outdoor_air_schedule_name',
                                          'object_name': 'zoneminoarequirements',
                                          'object_type': 'DesignSpecification:OutdoorAir'},
                              'Type': 'any number'},
 'occupy-1': {'Object1': {'object_field_name': 'number_of_people_schedule_name',
                          'object_name': 'space1-1 people 1',
                          'object_type': 'People'},
              'Object2': {'object_field_name': 'number_of_people_schedule_name',
                          'object_name': 'space2-1 people 1',
                          'object_type': 'People'},
              'Object3': {'object_field_name': 'number_of_people_schedule_name',
                          'object_name': 'space3-1 people 1',
                          'object_type': 'People'},
              'Object4': {'object_field_name': 'number_of_people_schedule_name',
                          'object_name': 'space4-1 people 1',
                          'object_type': 'People'},
              'Object5': {'object_field_name': 'number_of_people_schedule_name',
                          'object_name': 'space5-1 people 1',
                          'object_type': 'People'},
              'Type': 'fraction'},
 'plenumclg-setp-sch': {'Object1': {'object_field_name': 'setpoint_temperature_schedule_name',
                                    'object_name': 'plenumcoolingsetpoint',
                                    'object_type': 'ThermostatSetpoint:SingleCooling'},
                        'Type': 'temperature'},
 'plenumhtg-setp-sch': {'Object1': {'object_field_name': 'setpoint_temperature_schedule_name',
                                    'object_name': 'plenumheatingsetpoint',
                                    'object_type': 'ThermostatSetpoint:SingleHeating'},
                        'Type': 'temperature'},
 'reheatcoilavailsched': {'Object1': {'object_field_name': 'availability_schedule_name',
                                      'object_name': 'space1-1 vav reheat',
                                      'object_type': 'AirTerminal:SingleDuct:VAV:Reheat'},
                          'Object10': {'object_field_name': 'availability_schedule_name',
                                       'object_name': 'space5-1 zone coil',
                                       'object_type': 'Coil:Heating:Electric'},
                          'Object11': {'object_field_name': 'availability_schedule_name',
                                       'object_name': 'main heating coil 1',
                                       'object_type': 'Coil:Heating:Electric'},
                          'Object2': {'object_field_name': 'availability_schedule_name',
                                      'object_name': 'space2-1 vav reheat',
                                      'object_type': 'AirTerminal:SingleDuct:VAV:Reheat'},
                          'Object3': {'object_field_name': 'availability_schedule_name',
                                      'object_name': 'space3-1 vav reheat',
                                      'object_type': 'AirTerminal:SingleDuct:VAV:Reheat'},
                          'Object4': {'object_field_name': 'availability_schedule_name',
                                      'object_name': 'space4-1 vav reheat',
                                      'object_type': 'AirTerminal:SingleDuct:VAV:Reheat'},
                          'Object5': {'object_field_name': 'availability_schedule_name',
                                      'object_name': 'space5-1 vav reheat',
                                      'object_type': 'AirTerminal:SingleDuct:VAV:Reheat'},
                          'Object6': {'object_field_name': 'availability_schedule_name',
                                      'object_name': 'space1-1 zone coil',
                                      'object_type': 'Coil:Heating:Electric'},
                          'Object7': {'object_field_name': 'availability_schedule_name',
                                      'object_name': 'space2-1 zone coil',
                                      'object_type': 'Coil:Heating:Electric'},
                          'Object8': {'object_field_name': 'availability_schedule_name',
                                      'object_name': 'space3-1 zone coil',
                                      'object_type': 'Coil:Heating:Electric'},
                          'Object9': {'object_field_name': 'availability_schedule_name',
                                      'object_name': 'space4-1 zone coil',
                                      'object_type': 'Coil:Heating:Electric'},
                          'Type': 'fraction'},
 'seasonal reset supply air temp sch': {'Type': 'temperature'},
 'shadetranssch': {'Object1': {'object_field_name': 'transmittance_schedule_name',
                               'object_name': 'main south overhang',
                               'object_type': 'Shading:Zone:Detailed'},
                   'Object2': {'object_field_name': 'transmittance_schedule_name',
                               'object_name': 'south door overhang',
                               'object_type': 'Shading:Zone:Detailed'},
                   'Type': 'fraction'},
 'workeffsch': {'Object1': {'object_field_name': 'work_efficiency_schedule_name',
                            'object_name': 'space1-1 people 1',
                            'object_type': 'People'},
                'Object2': {'object_field_name': 'work_efficiency_schedule_name',
                            'object_name': 'space2-1 people 1',
                            'object_type': 'People'},
                'Object3': {'object_field_name': 'work_efficiency_schedule_name',
                            'object_name': 'space3-1 people 1',
                            'object_type': 'People'},
                'Object4': {'object_field_name': 'work_efficiency_schedule_name',
                            'object_name': 'space4-1 people 1',
                            'object_type': 'People'},
                'Object5': {'object_field_name': 'work_efficiency_schedule_name',
                            'object_name': 'space5-1 people 1',
                            'object_type': 'People'},
                'Type': 'fraction'},
 'zone control type sched': {'Object1': {'object_field_name': 'control_type_schedule_name',
                                         'object_name': 'space1-1 control',
                                         'object_type': 'ZoneControl:Thermostat'},
                             'Object2': {'object_field_name': 'control_type_schedule_name',
                                         'object_name': 'space2-1 control',
                                         'object_type': 'ZoneControl:Thermostat'},
                             'Object3': {'object_field_name': 'control_type_schedule_name',
                                         'object_name': 'space3-1 control',
                                         'object_type': 'ZoneControl:Thermostat'},
                             'Object4': {'object_field_name': 'control_type_schedule_name',
                                         'object_name': 'space4-1 control',
                                         'object_type': 'ZoneControl:Thermostat'},
                             'Object5': {'object_field_name': 'control_type_schedule_name',
                                         'object_name': 'space5-1 control',
                                         'object_type': 'ZoneControl:Thermostat'},
                             'Type': 'control type'}}

The way to export an excel file with such organized information is by specifying a path to the method:

[17]:
actuators=env.get_schedulers(path='./example.xlsx')

It is possible to know the zones available in the environment too. You only have to do the next:

[18]:
print(env.get_zones())
['plenum-1', 'space1-1', 'space2-1', 'space3-1', 'space4-1', 'space5-1']

Updating the action definition of the environment

As we have explained in the action and observation space example, one of the problems that can arise when modifying the space of actions and observations is that the IDF is not adapted to the new space of actions established.

For this purpose, the Sinergym action definition is available. With a dictionary we can build a definition of what scheduler we want to be replaced in the building by the external control.

For this example, we are going to add lights control to the external interface for the agent. Then, is not only necessary to update that action definition, the list of the action variables and space is necessary to be updated too.

[19]:
import gym
import numpy as np

new_action_variables=[
'Heating_Setpoint_RL',
'Cooling_Setpoint_RL',
'light_control'
]

new_action_space=gym.spaces.Box(
    low=np.array([15.0, 22.5, 0.0]),
    high=np.array([22.5, 30.0, 1.0]),
    shape=(3,),
    dtype=np.float32
)

new_action_definition={
    'Htg-SetP-Sch': {'name': 'Heating_Setpoint_RL', 'initial_value': 21},
    'Clg-SetP-Sch': {'name': 'Cooling_Setpoint_RL', 'initial_value': 25},
    'LIGHTS-1':{'name':'light_control','initial_value':0.2}

}

env = gym.make('Eplus-5Zone-cool-continuous-stochastic-v1',
                action_variables=new_action_variables,
                action_space=new_action_space,
                action_definition=new_action_definition
                )

for i in range(1):
    obs = env.reset()
    rewards = []
    done = False
    current_month = 0
    while not done:
        a = env.action_space.sample()
        obs, reward, done, info = env.step(a)
        rewards.append(reward)
        if info['month'] != current_month:  # display results every month
            current_month = info['month']
            print('Reward: ', sum(rewards), info)
    print(
        'Episode ',
        i,
        'Mean reward: ',
        np.mean(rewards),
        'Cumulative reward: ',
        sum(rewards))
env.close()
/usr/local/lib/python3.10/dist-packages/gym/spaces/box.py:73: UserWarning: WARN: Box bound precision lowered by casting to float32
  logger.warn(
[2022-10-03 11:09:11,535] EPLUS_ENV_5Zone-cool-continuous-stochastic-v1_MainThread_ROOT INFO:Updating idf ExternalInterface object if it is not present...
[2022-10-03 11:09:11,535] EPLUS_ENV_5Zone-cool-continuous-stochastic-v1_MainThread_ROOT INFO:Updating idf ExternalInterface object if it is not present...
[2022-10-03 11:09:11,535] EPLUS_ENV_5Zone-cool-continuous-stochastic-v1_MainThread_ROOT INFO:Updating idf ExternalInterface object if it is not present...
[2022-10-03 11:09:11,537] EPLUS_ENV_5Zone-cool-continuous-stochastic-v1_MainThread_ROOT INFO:Updating idf Site:Location and SizingPeriod:DesignDay(s) to weather and ddy file...
[2022-10-03 11:09:11,537] EPLUS_ENV_5Zone-cool-continuous-stochastic-v1_MainThread_ROOT INFO:Updating idf Site:Location and SizingPeriod:DesignDay(s) to weather and ddy file...
[2022-10-03 11:09:11,537] EPLUS_ENV_5Zone-cool-continuous-stochastic-v1_MainThread_ROOT INFO:Updating idf Site:Location and SizingPeriod:DesignDay(s) to weather and ddy file...
[2022-10-03 11:09:11,539] EPLUS_ENV_5Zone-cool-continuous-stochastic-v1_MainThread_ROOT INFO:Updating idf OutPut:Variable and variables XML tree model for BVCTB connection.
[2022-10-03 11:09:11,539] EPLUS_ENV_5Zone-cool-continuous-stochastic-v1_MainThread_ROOT INFO:Updating idf OutPut:Variable and variables XML tree model for BVCTB connection.
[2022-10-03 11:09:11,539] EPLUS_ENV_5Zone-cool-continuous-stochastic-v1_MainThread_ROOT INFO:Updating idf OutPut:Variable and variables XML tree model for BVCTB connection.
[2022-10-03 11:09:11,541] EPLUS_ENV_5Zone-cool-continuous-stochastic-v1_MainThread_ROOT INFO:Setting up extra configuration in building model if exists...
[2022-10-03 11:09:11,541] EPLUS_ENV_5Zone-cool-continuous-stochastic-v1_MainThread_ROOT INFO:Setting up extra configuration in building model if exists...
[2022-10-03 11:09:11,541] EPLUS_ENV_5Zone-cool-continuous-stochastic-v1_MainThread_ROOT INFO:Setting up extra configuration in building model if exists...
[2022-10-03 11:09:11,541] EPLUS_ENV_5Zone-cool-continuous-stochastic-v1_MainThread_ROOT INFO:Setting up action definition in building model if exists...
[2022-10-03 11:09:11,541] EPLUS_ENV_5Zone-cool-continuous-stochastic-v1_MainThread_ROOT INFO:Setting up action definition in building model if exists...
[2022-10-03 11:09:11,541] EPLUS_ENV_5Zone-cool-continuous-stochastic-v1_MainThread_ROOT INFO:Setting up action definition in building model if exists...
/usr/local/lib/python3.10/dist-packages/gym/spaces/box.py:73: UserWarning: WARN: Box bound precision lowered by casting to float32
  logger.warn(
[2022-10-03 11:09:11,543] EPLUS_ENV_5Zone-cool-continuous-stochastic-v1_MainThread_ROOT INFO:Creating new EnergyPlus simulation episode...
[2022-10-03 11:09:11,543] EPLUS_ENV_5Zone-cool-continuous-stochastic-v1_MainThread_ROOT INFO:Creating new EnergyPlus simulation episode...
[2022-10-03 11:09:11,543] EPLUS_ENV_5Zone-cool-continuous-stochastic-v1_MainThread_ROOT INFO:Creating new EnergyPlus simulation episode...
[2022-10-03 11:09:11,685] EPLUS_ENV_5Zone-cool-continuous-stochastic-v1_MainThread_ROOT INFO:EnergyPlus working directory is in /workspaces/sinergym/examples/Eplus-env-5Zone-cool-continuous-stochastic-v1-res3/Eplus-env-sub_run1
[2022-10-03 11:09:11,685] EPLUS_ENV_5Zone-cool-continuous-stochastic-v1_MainThread_ROOT INFO:EnergyPlus working directory is in /workspaces/sinergym/examples/Eplus-env-5Zone-cool-continuous-stochastic-v1-res3/Eplus-env-sub_run1
[2022-10-03 11:09:11,685] EPLUS_ENV_5Zone-cool-continuous-stochastic-v1_MainThread_ROOT INFO:EnergyPlus working directory is in /workspaces/sinergym/examples/Eplus-env-5Zone-cool-continuous-stochastic-v1-res3/Eplus-env-sub_run1
Reward:  -0.4534218472503313 {'timestep': 1, 'time_elapsed': 900, 'year': 1991, 'month': 1, 'day': 1, 'hour': 0, 'total_power': 2877.012363757218, 'total_power_no_units': -0.2877012363757218, 'comfort_penalty': -0.6191424581249407, 'abs_comfort': 0.6191424581249407, 'temperatures': [19.38085754187506], 'out_temperature': 2.365503840332209, 'action_': [17.785645, 29.71652, 0.22971705]}
Reward:  -1357.8271189188051 {'timestep': 2976, 'time_elapsed': 2678400, 'year': 1991, 'month': 2, 'day': 1, 'hour': 0, 'total_power': 11100.46077251977, 'total_power_no_units': -1.110046077251977, 'comfort_penalty': -0.0, 'abs_comfort': 0.0, 'temperatures': [21.21328190545486], 'out_temperature': 8.522913717556069, 'action_': [22.275938, 25.327274, 0.4951168]}
Reward:  -2677.3228805407884 {'timestep': 5664, 'time_elapsed': 5097600, 'year': 1991, 'month': 3, 'day': 1, 'hour': 0, 'total_power': 701.0042651760367, 'total_power_no_units': -0.07010042651760368, 'comfort_penalty': -0.9436218379550496, 'abs_comfort': 0.9436218379550496, 'temperatures': [19.05637816204495], 'out_temperature': 5.40854483151097, 'action_': [17.999592, 24.87681, 0.37235415]}
Reward:  -3562.8096013573713 {'timestep': 8640, 'time_elapsed': 7776000, 'year': 1991, 'month': 4, 'day': 1, 'hour': 0, 'total_power': 3024.567675350499, 'total_power_no_units': -0.3024567675350499, 'comfort_penalty': -0.8064452618224003, 'abs_comfort': 0.8064452618224003, 'temperatures': [19.1935547381776], 'out_temperature': 3.431054112168333, 'action_': [17.694782, 24.154045, 0.0044727325]}
Reward:  -4450.951932642561 {'timestep': 11520, 'time_elapsed': 10368000, 'year': 1991, 'month': 5, 'day': 1, 'hour': 0, 'total_power': 8207.782406117527, 'total_power_no_units': -0.8207782406117528, 'comfort_penalty': -0.0, 'abs_comfort': 0.0, 'temperatures': [21.55825762211984], 'out_temperature': 9.197726971145151, 'action_': [21.769848, 26.523382, 0.999089]}
Reward:  -5156.415876501385 {'timestep': 14496, 'time_elapsed': 13046400, 'year': 1991, 'month': 6, 'day': 1, 'hour': 0, 'total_power': 156.5268202959072, 'total_power_no_units': -0.015652682029590723, 'comfort_penalty': -2.0777900257891204, 'abs_comfort': 2.0777900257891204, 'temperatures': [20.92220997421088], 'out_temperature': 10.73331677835388, 'action_': [17.877337, 24.082777, 0.6383258]}
Reward:  -6840.042123890393 {'timestep': 17376, 'time_elapsed': 15638400, 'year': 1991, 'month': 7, 'day': 1, 'hour': 0, 'total_power': 120.4056020773604, 'total_power_no_units': -0.01204056020773604, 'comfort_penalty': -1.9790344535710993, 'abs_comfort': 1.9790344535710993, 'temperatures': [21.0209655464289], 'out_temperature': 9.82478126302217, 'action_': [16.911224, 23.718214, 0.75081384]}
Reward:  -8538.664312876315 {'timestep': 20352, 'time_elapsed': 18316800, 'year': 1991, 'month': 8, 'day': 1, 'hour': 0, 'total_power': 170.1233311699604, 'total_power_no_units': -0.017012333116996042, 'comfort_penalty': -2.59502313830032, 'abs_comfort': 2.59502313830032, 'temperatures': [20.40497686169968], 'out_temperature': 10.4490846080284, 'action_': [16.818777, 23.734867, 0.241808]}
Reward:  -10273.83205152557 {'timestep': 23328, 'time_elapsed': 20995200, 'year': 1991, 'month': 9, 'day': 1, 'hour': 0, 'total_power': 120.4056020773604, 'total_power_no_units': -0.01204056020773604, 'comfort_penalty': -1.768018008172639, 'abs_comfort': 1.768018008172639, 'temperatures': [21.23198199182736], 'out_temperature': 12.96124535280048, 'action_': [19.102827, 28.182596, 0.08341339]}
Reward:  -12224.318447785688 {'timestep': 26208, 'time_elapsed': 23587200, 'year': 1991, 'month': 10, 'day': 1, 'hour': 0, 'total_power': 469.4587430154137, 'total_power_no_units': -0.046945874301541374, 'comfort_penalty': -0.0, 'abs_comfort': 0.0, 'temperatures': [20.06553825688241], 'out_temperature': 6.844933137569515, 'action_': [15.480132, 23.393116, 0.51604635]}
Reward:  -13041.260744220324 {'timestep': 29184, 'time_elapsed': 26265600, 'year': 1991, 'month': 11, 'day': 1, 'hour': 0, 'total_power': 658.9345665037555, 'total_power_no_units': -0.06589345665037555, 'comfort_penalty': -0.9947529958024113, 'abs_comfort': 0.9947529958024113, 'temperatures': [19.00524700419759], 'out_temperature': 6.139674604783751, 'action_': [15.60221, 23.140676, 0.7023196]}
Reward:  -14028.556676010696 {'timestep': 32064, 'time_elapsed': 28857600, 'year': 1991, 'month': 12, 'day': 1, 'hour': 0, 'total_power': 140.0534103456761, 'total_power_no_units': -0.01400534103456761, 'comfort_penalty': -0.0, 'abs_comfort': 0.0, 'temperatures': [20.12511560374498], 'out_temperature': 5.961020408807885, 'action_': [15.309132, 28.84229, 0.020878673]}
Reward:  -15380.029536325419 {'timestep': 35040, 'time_elapsed': 31536000, 'year': 1992, 'month': 1, 'day': 1, 'hour': 0, 'total_power': 10410.81751368661, 'total_power_no_units': -1.041081751368661, 'comfort_penalty': -0.4320504567081187, 'abs_comfort': 0.4320504567081187, 'temperatures': [19.56794954329188], 'out_temperature': -0.7071846842980632, 'action_': [19.668835, 28.38713, 0.0763033]}
Episode  0 Mean reward:  -0.4389277835709471 Cumulative reward:  -15380.029536325419
[2022-10-03 11:09:23,032] EPLUS_ENV_5Zone-cool-continuous-stochastic-v1_MainThread_ROOT INFO:EnergyPlus simulation closed successfully.
[2022-10-03 11:09:23,032] EPLUS_ENV_5Zone-cool-continuous-stochastic-v1_MainThread_ROOT INFO:EnergyPlus simulation closed successfully.
[2022-10-03 11:09:23,032] EPLUS_ENV_5Zone-cool-continuous-stochastic-v1_MainThread_ROOT INFO:EnergyPlus simulation closed successfully.

Previously, it is recommended to know what controllers are available in the specific building model, see the previous example of this notebook. For more information about the format of the action definition dictionaries, visit the section called action definition.

Adding more extra configuration

You can even add a dictionary with extra parameters that update IDF with some new context concerned with simulation directly.

This new IDF version, which also adapts to the new weather you put in, is saved in the Sinergym output folder, leaving the original intact:

[20]:
extra_conf={
    'timesteps_per_hour':6,
    'runperiod':(1,1,1991,2,1,1992),
}

env = gym.make('Eplus-datacenter-cool-continuous-stochastic-v1',
                config_params=extra_conf
                )
[2022-10-03 11:10:20,132] EPLUS_ENV_datacenter-cool-continuous-stochastic-v1_MainThread_ROOT INFO:Updating idf ExternalInterface object if it is not present...
[2022-10-03 11:10:20,133] EPLUS_ENV_datacenter-cool-continuous-stochastic-v1_MainThread_ROOT INFO:Updating idf Site:Location and SizingPeriod:DesignDay(s) to weather and ddy file...
[2022-10-03 11:10:20,136] EPLUS_ENV_datacenter-cool-continuous-stochastic-v1_MainThread_ROOT INFO:Updating idf OutPut:Variable and variables XML tree model for BVCTB connection.
[2022-10-03 11:10:20,141] EPLUS_ENV_datacenter-cool-continuous-stochastic-v1_MainThread_ROOT INFO:Setting up extra configuration in building model if exists...
[2022-10-03 11:10:20,143] EPLUS_ENV_datacenter-cool-continuous-stochastic-v1_MainThread_ROOT INFO:Setting up action definition in building model if exists...
/usr/local/lib/python3.10/dist-packages/gym/spaces/box.py:73: UserWarning: WARN: Box bound precision lowered by casting to float32
  logger.warn(

For more information about extra configuration parameters, see our Extra configuration documentation