Skip to content

Commit

Permalink
Documentation source update detected and pushed compilation build dir…
Browse files Browse the repository at this point in the history
…ectory for Github Pages
  • Loading branch information
jajimer authored and actions-user committed Mar 31, 2022
1 parent cf2932a commit dbcd290
Show file tree
Hide file tree
Showing 32 changed files with 773 additions and 221 deletions.
Binary file modified docs/compilation/doctrees/environment.pickle
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified docs/compilation/doctrees/pages/modules/sinergym.utils.doctree
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified docs/compilation/doctrees/pages/rewards.doctree
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
sinergym.utils.rewards.BaseReward
=================================

.. currentmodule:: sinergym.utils.rewards

.. autoclass:: BaseReward
:members:
:undoc-members:


.. automethod:: __init__


.. rubric:: Methods

.. autosummary::

~BaseReward.__init__






Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ sinergym.utils.rewards.ExpReward
.. autosummary::

~ExpReward.__init__
~ExpReward.calculate



Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
sinergym.utils.rewards.HourlyLinearReward
=========================================

.. currentmodule:: sinergym.utils.rewards

.. autoclass:: HourlyLinearReward
:members:
:undoc-members:


.. automethod:: __init__


.. rubric:: Methods

.. autosummary::

~HourlyLinearReward.__init__






Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ sinergym.utils.rewards.LinearReward
.. autosummary::

~LinearReward.__init__
~LinearReward.calculate



Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
sinergym.utils.rewards
sinergym.utils.rewards
======================

.. automodule:: sinergym.utils.rewards
Expand All @@ -19,7 +19,9 @@ sinergym.utils.rewards
:toctree:
:template: custom-class-template.rst

BaseReward
ExpReward
HourlyLinearReward
LinearReward


Expand Down
51 changes: 38 additions & 13 deletions docs/compilation/html/_sources/pages/rewards.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,51 @@
Rewards
#######

Defining a reward function is one of the most important things in reinforcement learning. Consequently, our team has designed an structure which let you use our
reward class or defining a new one and integrate in available environments if you want:
Defining a reward function is one of the most important things in reinforcement learning. Consequently, Sinergym allows you to define your own reward functions or use
the ones we have already implemented (see code below).

.. literalinclude:: ../../../sinergym/utils/rewards.py
:language: python
- ``LinearReward`` implements a linear reward function, where both energy consumption and thermal discomfort are normalized and add together with different weights. The
discomfort is calculated as the absolute difference between current temperature and comfort range (so if the temperature is inside that range, the discomfort would be 0).
This is a typically used function where thermal satisfaction of people inside the controlled building has been taken into account.

``LinearReward()`` class implements an evaluation which consists in taking into account **power consumption** and **temperature comfort**. This class is used
inner environment as an attribute.
- ``ExpReward`` is very similar, but in this case the discomfort is calculated using the exponential difference between current temperature and comfort ranges. That means
that the penalty for the discomfort is higher is we are far from the target temperatures.

``ExpReward()`` class is the same than ``LinearReward()`` class, but comfort penalty is exponential instead of lineal.
- ``HourlyLinearReward`` is a slight modification of the linear function, but the weight given to the discomfort depends on the hour of the day. If the current hour of the
simulation is in working hours (by default, from 9 AM to 7 PM) both comfort and energy consumption weights equally, but outside those hours only energy is considered.

Reward is always negative. This means that perfect reward would be 0 (perfect power consumption and perfect temperature comfort), we apply penalties in both factors.
Notice there are two temperature comfort ranges in that class, those ranges are used rely on the specific date on the simulation. Moreover, notice there are
two weights in the reward function, this allows you to adjust how important each aspect is when making a general evaluation of the environment.

By default, all environments in gym register will use LinearReward() with default parameters. However, this configuration can be overwriting in ``gym.make()``, for example:
These rewards are always negative, meaning that perfect behavior has a cumulative reward of 0. Notice also that there are two temperature comfort ranges defined, one for the
summer period and other for the winter period. The weights of each term in the reward allow to adjust the importance of each aspect when evaluating the environments.

By default, all environments use ``LinearReward`` with default parameters. But you can change this configuration using ``gym.make()`` as follows:

.. code:: python
env = gym.make('Eplus-discrete-stochastic-mixed-v1', reward=ExpReward(energy_weight=0.5))
from sinergym.utils.rewards import ExpReward
env = gym.make('Eplus-discrete-stochastic-mixed-v1', reward=ExpReward, reward_kwargs={'energy_weight': 0.1})
It is also pretty simple to define your own classes. For example, imagine you want a reward signal which returns always -1 (however we do not recommend using it for training agents :)).
The only requirement is that the calculation is performed using ``__call__`` method, which returns the reward and a dictionary with extra information. The below code implements this.

.. code:: python
.. note:: *Currently, it is only available these classes. However, more reward functions could be designed in the future!*
from sinergym.utils.rewards import BaseReward
class CustomReward(BaseReward):
"""Naive reward function."""
def __init__(self, env):
super(CustomReward, self).__init__(env)
def __call__(self):
return -1.0, {}
env = gym.make('Eplus-discrete-stochastic-mixed-v1', reward=CustomReward)
More reward functions will be included in the future, so stay tuned!


.. literalinclude:: ../../../sinergym/utils/rewards.py
:language: python
23 changes: 17 additions & 6 deletions docs/compilation/html/genindex.html
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ <h1 id="index">Index</h1>
| <a href="#D"><strong>D</strong></a>
| <a href="#E"><strong>E</strong></a>
| <a href="#G"><strong>G</strong></a>
| <a href="#H"><strong>H</strong></a>
| <a href="#I"><strong>I</strong></a>
| <a href="#L"><strong>L</strong></a>
| <a href="#M"><strong>M</strong></a>
Expand Down Expand Up @@ -122,8 +123,12 @@ <h2 id="_">_</h2>
<li><a href="pages/modules/sinergym.utils.controllers.RandomController.html#sinergym.utils.controllers.RandomController.__init__">(sinergym.utils.controllers.RandomController method)</a>
</li>
<li><a href="pages/modules/sinergym.utils.controllers.RuleBasedController.html#sinergym.utils.controllers.RuleBasedController.__init__">(sinergym.utils.controllers.RuleBasedController method)</a>
</li>
<li><a href="pages/modules/sinergym.utils.rewards.BaseReward.html#sinergym.utils.rewards.BaseReward.__init__">(sinergym.utils.rewards.BaseReward method)</a>
</li>
<li><a href="pages/modules/sinergym.utils.rewards.ExpReward.html#sinergym.utils.rewards.ExpReward.__init__">(sinergym.utils.rewards.ExpReward method)</a>
</li>
<li><a href="pages/modules/sinergym.utils.rewards.HourlyLinearReward.html#sinergym.utils.rewards.HourlyLinearReward.__init__">(sinergym.utils.rewards.HourlyLinearReward method)</a>
</li>
<li><a href="pages/modules/sinergym.utils.rewards.LinearReward.html#sinergym.utils.rewards.LinearReward.__init__">(sinergym.utils.rewards.LinearReward method)</a>
</li>
Expand Down Expand Up @@ -163,6 +168,10 @@ <h2 id="A">A</h2>

<h2 id="B">B</h2>
<table style="width: 100%" class="indextable genindextable"><tr>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="pages/modules/sinergym.utils.rewards.BaseReward.html#sinergym.utils.rewards.BaseReward">BaseReward (class in sinergym.utils.rewards)</a>
</li>
</ul></td>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="pages/modules/sinergym.simulators.base.BaseSimulator.html#sinergym.simulators.base.BaseSimulator">BaseSimulator (class in sinergym.simulators.base)</a>
</li>
Expand All @@ -172,12 +181,6 @@ <h2 id="B">B</h2>
<h2 id="C">C</h2>
<table style="width: 100%" class="indextable genindextable"><tr>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="pages/modules/sinergym.utils.rewards.ExpReward.html#sinergym.utils.rewards.ExpReward.calculate">calculate() (sinergym.utils.rewards.ExpReward method)</a>

<ul>
<li><a href="pages/modules/sinergym.utils.rewards.LinearReward.html#sinergym.utils.rewards.LinearReward.calculate">(sinergym.utils.rewards.LinearReward method)</a>
</li>
</ul></li>
<li><a href="pages/modules/sinergym.envs.eplus_env.EplusEnv.html#sinergym.envs.eplus_env.EplusEnv.close">close() (sinergym.envs.eplus_env.EplusEnv method)</a>

<ul>
Expand Down Expand Up @@ -261,6 +264,14 @@ <h2 id="G">G</h2>
</ul></td>
</tr></table>

<h2 id="H">H</h2>
<table style="width: 100%" class="indextable genindextable"><tr>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="pages/modules/sinergym.utils.rewards.HourlyLinearReward.html#sinergym.utils.rewards.HourlyLinearReward">HourlyLinearReward (class in sinergym.utils.rewards)</a>
</li>
</ul></td>
</tr></table>

<h2 id="I">I</h2>
<table style="width: 100%" class="indextable genindextable"><tr>
<td style="width: 33%; vertical-align: top;"><ul>
Expand Down
Binary file modified docs/compilation/html/objects.inv
Binary file not shown.
Loading

0 comments on commit dbcd290

Please sign in to comment.