Skip to content

Commit

Permalink
deploy: b4bb42f
Browse files Browse the repository at this point in the history
  • Loading branch information
kingsleynweye committed Feb 4, 2024
1 parent 79fb47c commit e0c8e58
Show file tree
Hide file tree
Showing 24 changed files with 2,070 additions and 3,826 deletions.
Binary file modified .doctrees/api/citylearn.agents.base.doctree
Binary file not shown.
Binary file modified .doctrees/api/citylearn.agents.q_learning.doctree
Binary file not shown.
Binary file modified .doctrees/environment.pickle
Binary file not shown.
2,055 changes: 736 additions & 1,319 deletions .doctrees/nbsphinx/quickstart.ipynb

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions .doctrees/nbsphinx/usage/cli.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"metadata": {},
"outputs": [],
"source": [
"!pip install CityLearn==2.0.0"
"%pip install CityLearn"
]
},
{
Expand Down Expand Up @@ -62,7 +62,7 @@
}
],
"source": [
"!python -m citylearn -h"
"%python -m citylearn -h"
]
},
{
Expand Down Expand Up @@ -116,7 +116,7 @@
}
],
"source": [
"!python -m citylearn learn -h"
"%python -m citylearn learn -h"
]
},
{
Expand All @@ -133,7 +133,7 @@
"metadata": {},
"outputs": [],
"source": [
"!python -m citylearn learn citylearn_challenge_2022_phase_1 -k -l 100 -e 1"
"%python -m citylearn learn citylearn_challenge_2022_phase_1 -k -l 100 -e 1"
]
},
{
Expand Down
2 changes: 1 addition & 1 deletion .doctrees/nbsphinx/usage/load_environment.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"metadata": {},
"outputs": [],
"source": [
"!pip install CityLearn==2.0.0"
"%pip install CityLearn"
]
},
{
Expand Down
Binary file modified .doctrees/quickstart.doctree
Binary file not shown.
Binary file modified .doctrees/usage/cli.doctree
Binary file not shown.
Binary file modified .doctrees/usage/load_environment.doctree
Binary file not shown.
40 changes: 37 additions & 3 deletions _modules/citylearn/agents/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -310,11 +310,45 @@ <h1>Source code for citylearn.agents.base</h1><div class="highlight"><pre>
<span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">reset</span><span class="p">()</span>
<span class="bp">self</span><span class="o">.</span><span class="n">__actions</span> <span class="o">=</span> <span class="p">[[[]]</span> <span class="k">for</span> <span class="n">_</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">action_space</span><span class="p">]</span></div></div>

<div class="viewcode-block" id="DummyController"><a class="viewcode-back" href="../../../api/citylearn.agents.base.html#citylearn.agents.base.DummyController">[docs]</a><span class="k">class</span> <span class="nc">DummyController</span><span class="p">(</span><span class="n">Agent</span><span class="p">):</span>
<div class="viewcode-block" id="DummyAgent"><a class="viewcode-back" href="../../../api/citylearn.agents.base.html#citylearn.agents.base.DummyAgent">[docs]</a><span class="k">class</span> <span class="nc">DummyAgent</span><span class="p">(</span><span class="n">Agent</span><span class="p">):</span>
<span class="w"> </span><span class="sa">r</span><span class="sd">&quot;&quot;&quot;Agent class for business-as-usual simulation where the storage systems and heat pumps are not controlled.</span>

<span class="sd"> This agent will provide results for when there is no storage for load shifting and no heat pump partial load. </span>
<span class="sd"> The storage actions prescribed will be 0.0 and the heat pump will have no action, i.e. `None`, causing it to </span>
<span class="sd"> deliver the ideal load in the building time series files. </span>
<span class="sd"> </span>
<span class="sd"> To ensure that the environment does not expect non-zero and non-null actions, the buildings in the parsed `env` </span>
<span class="sd"> will be set to have no active actions. This means that you must initialize a new `env` if you want to simulate</span>
<span class="sd"> with a new agent type. </span>
<span class="sd"> </span>
<span class="sd"> This agent class is best used to establish a baseline simulation that can then be compared </span>
<span class="sd"> to RBC, RLC, or MPC control algorithms.</span>

<span class="sd"> Parameters</span>
<span class="sd"> ----------</span>
<span class="sd"> env : CityLearnEnv</span>
<span class="sd"> CityLearn environment.</span>

<span class="sd"> Other Parameters</span>
<span class="sd"> ----------------</span>
<span class="sd"> **kwargs : dict</span>
<span class="sd"> Other keyword arguments used to initialize super class.</span>
<span class="sd"> &quot;&quot;&quot;</span>

<span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">env</span><span class="p">:</span> <span class="n">CityLearnEnv</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">:</span> <span class="n">Any</span><span class="p">):</span>
<span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="n">env</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
<span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">__deactivate_actions</span><span class="p">(</span><span class="n">env</span><span class="p">),</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>

<span class="k">def</span> <span class="nf">__deactivate_actions</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">env</span><span class="p">:</span> <span class="n">CityLearnEnv</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="n">CityLearnEnv</span><span class="p">:</span>
<span class="k">for</span> <span class="n">b</span> <span class="ow">in</span> <span class="n">env</span><span class="o">.</span><span class="n">unwrapped</span><span class="o">.</span><span class="n">buildings</span><span class="p">:</span>
<span class="k">for</span> <span class="n">a</span> <span class="ow">in</span> <span class="n">b</span><span class="o">.</span><span class="n">action_metadata</span><span class="p">:</span>
<span class="n">b</span><span class="o">.</span><span class="n">action_metadata</span><span class="p">[</span><span class="n">a</span><span class="p">]</span> <span class="o">=</span> <span class="kc">False</span>

<span class="n">b</span><span class="o">.</span><span class="n">action_space</span> <span class="o">=</span> <span class="n">b</span><span class="o">.</span><span class="n">estimate_action_space</span><span class="p">()</span>
<span class="n">b</span><span class="o">.</span><span class="n">observation_space</span> <span class="o">=</span> <span class="n">b</span><span class="o">.</span><span class="n">estimate_observation_space</span><span class="p">()</span>

<span class="k">return</span> <span class="n">env</span>

<div class="viewcode-block" id="DummyController.predict"><a class="viewcode-back" href="../../../api/citylearn.agents.base.html#citylearn.agents.base.DummyController.predict">[docs]</a> <span class="k">def</span> <span class="nf">predict</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">observations</span><span class="p">:</span> <span class="n">List</span><span class="p">[</span><span class="n">List</span><span class="p">[</span><span class="nb">float</span><span class="p">]],</span> <span class="n">deterministic</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">None</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="n">List</span><span class="p">[</span><span class="n">List</span><span class="p">[</span><span class="nb">float</span><span class="p">]]:</span>
<div class="viewcode-block" id="DummyAgent.predict"><a class="viewcode-back" href="../../../api/citylearn.agents.base.html#citylearn.agents.base.DummyAgent.predict">[docs]</a> <span class="k">def</span> <span class="nf">predict</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">observations</span><span class="p">:</span> <span class="n">List</span><span class="p">[</span><span class="n">List</span><span class="p">[</span><span class="nb">float</span><span class="p">]],</span> <span class="n">deterministic</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">None</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="n">List</span><span class="p">[</span><span class="n">List</span><span class="p">[</span><span class="nb">float</span><span class="p">]]:</span>
<span class="n">actions</span> <span class="o">=</span> <span class="p">[[</span><span class="mf">0.0</span> <span class="k">if</span> <span class="s1">&#39;storage&#39;</span> <span class="ow">in</span> <span class="n">n</span> <span class="k">else</span> <span class="kc">None</span> <span class="k">for</span> <span class="n">n</span> <span class="ow">in</span> <span class="n">a</span><span class="p">]</span> <span class="k">for</span> <span class="n">a</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">action_names</span><span class="p">]</span>
<span class="bp">self</span><span class="o">.</span><span class="n">actions</span> <span class="o">=</span> <span class="n">actions</span>
<span class="bp">self</span><span class="o">.</span><span class="n">next_time_step</span><span class="p">()</span>
Expand Down
4 changes: 3 additions & 1 deletion _modules/citylearn/agents/q_learning.html
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ <h1>Source code for citylearn.agents.q_learning</h1><div class="highlight"><pre>

<span class="k">return</span> <span class="n">actions</span>

<div class="viewcode-block" id="TabularQLearning.update"><a class="viewcode-back" href="../../../api/citylearn.agents.q_learning.html#citylearn.agents.q_learning.TabularQLearning.update">[docs]</a> <span class="k">def</span> <span class="nf">update</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">observations</span><span class="p">:</span> <span class="n">List</span><span class="p">[</span><span class="n">List</span><span class="p">[</span><span class="nb">float</span><span class="p">]],</span> <span class="n">actions</span><span class="p">:</span> <span class="n">List</span><span class="p">[</span><span class="n">List</span><span class="p">[</span><span class="nb">float</span><span class="p">]],</span> <span class="n">reward</span><span class="p">:</span> <span class="n">List</span><span class="p">[</span><span class="nb">float</span><span class="p">],</span> <span class="n">next_observations</span><span class="p">:</span> <span class="n">List</span><span class="p">[</span><span class="n">List</span><span class="p">[</span><span class="nb">float</span><span class="p">]]):</span>
<div class="viewcode-block" id="TabularQLearning.update"><a class="viewcode-back" href="../../../api/citylearn.agents.q_learning.html#citylearn.agents.q_learning.TabularQLearning.update">[docs]</a> <span class="k">def</span> <span class="nf">update</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">observations</span><span class="p">:</span> <span class="n">List</span><span class="p">[</span><span class="n">List</span><span class="p">[</span><span class="nb">float</span><span class="p">]],</span> <span class="n">actions</span><span class="p">:</span> <span class="n">List</span><span class="p">[</span><span class="n">List</span><span class="p">[</span><span class="nb">float</span><span class="p">]],</span> <span class="n">reward</span><span class="p">:</span> <span class="n">List</span><span class="p">[</span><span class="nb">float</span><span class="p">],</span> <span class="n">next_observations</span><span class="p">:</span> <span class="n">List</span><span class="p">[</span><span class="n">List</span><span class="p">[</span><span class="nb">float</span><span class="p">]],</span> <span class="n">done</span><span class="p">:</span> <span class="nb">bool</span><span class="p">):</span>
<span class="w"> </span><span class="sa">r</span><span class="sd">&quot;&quot;&quot;Update Q-Table using Bellman equation.</span>

<span class="sd"> Parameters</span>
Expand All @@ -207,6 +207,8 @@ <h1>Source code for citylearn.agents.q_learning</h1><div class="highlight"><pre>
<span class="sd"> Current time step reward.</span>
<span class="sd"> next_observations : List[List[float]]</span>
<span class="sd"> Current time step observations.</span>
<span class="sd"> done : bool</span>
<span class="sd"> Indication that episode has ended.</span>
<span class="sd"> &quot;&quot;&quot;</span>

<span class="c1"># Compute temporal difference target and error to udpate q-function</span>
Expand Down
7 changes: 7 additions & 0 deletions _modules/citylearn/building.html
Original file line number Diff line number Diff line change
Expand Up @@ -746,6 +746,13 @@ <h1>Source code for citylearn.building</h1><div class="highlight"><pre>
<span class="nd">@Environment</span><span class="o">.</span><span class="n">random_seed</span><span class="o">.</span><span class="n">setter</span>
<span class="k">def</span> <span class="nf">random_seed</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">seed</span><span class="p">:</span> <span class="nb">int</span><span class="p">):</span>
<span class="n">Environment</span><span class="o">.</span><span class="n">random_seed</span><span class="o">.</span><span class="n">fset</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">seed</span><span class="p">)</span>
<span class="bp">self</span><span class="o">.</span><span class="n">cooling_device</span><span class="o">.</span><span class="n">random_seed</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">random_seed</span>
<span class="bp">self</span><span class="o">.</span><span class="n">heating_device</span><span class="o">.</span><span class="n">random_seed</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">random_seed</span>
<span class="bp">self</span><span class="o">.</span><span class="n">dhw_device</span><span class="o">.</span><span class="n">random_seed</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">random_seed</span>
<span class="bp">self</span><span class="o">.</span><span class="n">cooling_storage</span><span class="o">.</span><span class="n">random_seed</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">random_seed</span>
<span class="bp">self</span><span class="o">.</span><span class="n">heating_storage</span><span class="o">.</span><span class="n">random_seed</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">random_seed</span>
<span class="bp">self</span><span class="o">.</span><span class="n">electrical_storage</span><span class="o">.</span><span class="n">random_seed</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">random_seed</span>
<span class="bp">self</span><span class="o">.</span><span class="n">pv</span><span class="o">.</span><span class="n">random_seed</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">random_seed</span>

<span class="nd">@Environment</span><span class="o">.</span><span class="n">episode_tracker</span><span class="o">.</span><span class="n">setter</span>
<span class="k">def</span> <span class="nf">episode_tracker</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">episode_tracker</span><span class="p">:</span> <span class="n">EpisodeTracker</span><span class="p">):</span>
Expand Down
2 changes: 1 addition & 1 deletion _modules/citylearn/energy_model.html
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,7 @@ <h1>Source code for citylearn.energy_model</h1><div class="highlight"><pre>
<span class="k">if</span> <span class="n">loss_coefficient</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
<span class="bp">self</span><span class="o">.</span><span class="n">__loss_coefficient</span> <span class="o">=</span> <span class="mf">0.006</span>
<span class="k">else</span><span class="p">:</span>
<span class="k">assert</span> <span class="mi">0</span> <span class="o">&lt;=</span> <span class="n">loss_coefficient</span> <span class="o">&lt;=</span> <span class="mi">1</span><span class="p">,</span> <span class="s1">&#39;initial_soc must be &gt;= 0 and &lt;= 1.&#39;</span>
<span class="k">assert</span> <span class="mi">0</span> <span class="o">&lt;=</span> <span class="n">loss_coefficient</span> <span class="o">&lt;=</span> <span class="mi">1</span><span class="p">,</span> <span class="s1">&#39;loss_coefficient must be &gt;= 0 and &lt;= 1.&#39;</span>
<span class="bp">self</span><span class="o">.</span><span class="n">__loss_coefficient</span> <span class="o">=</span> <span class="n">loss_coefficient</span>

<span class="nd">@initial_soc</span><span class="o">.</span><span class="n">setter</span>
Expand Down
Loading

0 comments on commit e0c8e58

Please sign in to comment.