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

Feature: Simulation random seeding #103

Merged
merged 28 commits into from
Aug 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
d2bc653
add random_seed to environment
RHammond2 Aug 11, 2023
14187df
convert scipy weibull to numpy weibull use
RHammond2 Aug 11, 2023
c1043d5
modest speed bump from polars take vs slice
RHammond2 Aug 11, 2023
967ccd4
Merge branch 'develop' into feature/fixed_randomization
RHammond2 Aug 11, 2023
804d5ca
manually memoize data reading for subassemblies
RHammond2 Aug 11, 2023
557754b
update changelog
RHammond2 Aug 11, 2023
45208d1
create the rng at the environment level and pass through to Failures
RHammond2 Aug 11, 2023
b2c3d6a
get all tests working except timing-impacted tests
RHammond2 Aug 11, 2023
479b439
update docstring
RHammond2 Aug 14, 2023
905302e
add random seeding functionality to the Simulation API
RHammond2 Aug 14, 2023
8a00cc1
use the environment random generator throughout simulation code
RHammond2 Aug 15, 2023
f781b68
consistently seed test environments
RHammond2 Aug 15, 2023
d514d44
update test timing for new random seeding
RHammond2 Aug 15, 2023
462b292
remove skip
RHammond2 Aug 15, 2023
de54513
update the failure parameters to ensure timing can be reached
RHammond2 Aug 16, 2023
aecad90
update failing test for new, working timing with same logic
RHammond2 Aug 16, 2023
0e42739
comment out helper portion
RHammond2 Aug 16, 2023
236b3ba
update changelog
RHammond2 Aug 16, 2023
6fc2ac3
update the latest changes section
RHammond2 Aug 16, 2023
193ca16
bump Python requirements and documentation site build versions
RHammond2 Aug 16, 2023
ae10f78
add seeding to the configuration
RHammond2 Aug 16, 2023
013f327
fix typing for random generator
RHammond2 Aug 16, 2023
1a4bd20
fix logic bug in emissions
RHammond2 Aug 16, 2023
ad71c56
fix documentation versioning issues
RHammond2 Aug 16, 2023
2385249
update the how to instructions for updates and clarifications
RHammond2 Aug 16, 2023
2344877
update validation cases
RHammond2 Aug 16, 2023
77bff47
fix logic bug in emissions
RHammond2 Aug 16, 2023
28d69d5
update executed notebooks and sphinx settings
RHammond2 Aug 16, 2023
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
2 changes: 1 addition & 1 deletion .github/workflows/ci-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
python-version: ["3.8", "3.9", "3.10"]
python-version: ["3.9", "3.10"]

steps:
- uses: actions/checkout@v3
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/gh_pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.8'
python-version: '3.10'

- name: Install dependencies
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/python-publish-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.9'
python-version: '3.10'

- name: Build package
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.9'
python-version: '3.10'

- name: Build package
run: |
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,14 @@

- Adds a `non_stop_shift` attribute to `ServiceEquipmentData`, `UnscheduledServiceEquipmentData`, `ScheduledServiceEquipmentData`, and `PortConfig` that is set in the post-initialization hook or through `DateLimitsMixin._set_environment_shift()` to ensure it is updated appropriately. Additionally, all checks for a 24 hour shift now check for the `non_stop_shift` attribute.
- `Metrics.emissions()` has been added to the list of available metrics to calculate the emissions from idling at port or sea, tranisiting, and maneuvering. Co-authored by and inspired by analysis work from @hemezz.
- `Simulation` now accepts a `random_seed` or `random_generator` variable to seed the random number generators for Weibull failure timeouts and wait timing between event completions. Setting the `random_seed` to the same value from one simulation to the next will net the same results between different simulations, whereas the `random_generator` can be used to use the same generator for a batch of simulations.

### General

- All `assert` statements are now only called when type checking is performed
- Replaces all `.get(lamda x: x == request)` with a 10x faster `.get(lambda x: x is request)` to more efficiently filter out the desired event to be removed from the repair manager and port repair manangement.
- `WombatEnvironment.weather` is now a Polars DataFrame to improve efficiency and indexing bottlenecks introduced in Pandas 2.0.
- All subassembly cable files are read in once, and stored in a dictionary to provide a modest speed up for the simulation initialization.

## v0.7.1 (4 May 2023)

Expand Down
162 changes: 111 additions & 51 deletions docs/jupyter_execute/examples/how_to.ipynb

Large diffs are not rendered by default.

2,083 changes: 1,112 additions & 971 deletions docs/jupyter_execute/examples/metrics_demonstration.ipynb

Large diffs are not rendered by default.

116 changes: 58 additions & 58 deletions docs/jupyter_execute/examples/strategy_demonstration.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "markdown",
"id": "9b19e63f",
"id": "076d407c",
"metadata": {},
"source": [
"# Servicing Strategies\n",
Expand Down Expand Up @@ -43,7 +43,7 @@
{
"cell_type": "code",
"execution_count": 1,
"id": "8f91ade3",
"id": "d3d46b09",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -62,7 +62,7 @@
},
{
"cell_type": "markdown",
"id": "caaa3da2",
"id": "27b089bf",
"metadata": {},
"source": [
"## Simulation and results setup\n",
Expand All @@ -80,7 +80,7 @@
{
"cell_type": "code",
"execution_count": 2,
"id": "0a796a2f",
"id": "cb5f9624",
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -116,7 +116,7 @@
},
{
"cell_type": "markdown",
"id": "5ab3b4d3",
"id": "e3031503",
"metadata": {},
"source": [
"## Run the simulations and display the results"
Expand All @@ -125,7 +125,7 @@
{
"cell_type": "code",
"execution_count": 3,
"id": "48587f8c",
"id": "a9a0e635",
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -161,23 +161,23 @@
" <tbody>\n",
" <tr>\n",
" <th>base_scheduled</th>\n",
" <td>0.03</td>\n",
" <td>0.74</td>\n",
" <td>0.02</td>\n",
" <td>0.46</td>\n",
" </tr>\n",
" <tr>\n",
" <th>base_requests</th>\n",
" <td>0.03</td>\n",
" <td>0.87</td>\n",
" <td>0.02</td>\n",
" <td>0.46</td>\n",
" </tr>\n",
" <tr>\n",
" <th>base_downtime</th>\n",
" <td>0.03</td>\n",
" <td>0.83</td>\n",
" <td>0.02</td>\n",
" <td>0.49</td>\n",
" </tr>\n",
" <tr>\n",
" <th>base_tow_to_port</th>\n",
" <td>0.03</td>\n",
" <td>1.32</td>\n",
" <td>0.02</td>\n",
" <td>0.60</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
Expand All @@ -186,10 +186,10 @@
"text/plain": [
" Load Time (min) Run Time (min)\n",
"Scenario \n",
"base_scheduled 0.03 0.74\n",
"base_requests 0.03 0.87\n",
"base_downtime 0.03 0.83\n",
"base_tow_to_port 0.03 1.32"
"base_scheduled 0.02 0.46\n",
"base_requests 0.02 0.46\n",
"base_downtime 0.02 0.49\n",
"base_tow_to_port 0.02 0.60"
]
},
"execution_count": 3,
Expand Down Expand Up @@ -274,7 +274,7 @@
{
"cell_type": "code",
"execution_count": 4,
"id": "0e37f99e",
"id": "6ea5cea4",
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -335,31 +335,31 @@
" </tr>\n",
" <tr>\n",
" <th>power production</th>\n",
" <td>9,767.89</td>\n",
" <td>9,733.85</td>\n",
" <td>9,770.04</td>\n",
" <td>9,632.82</td>\n",
" <td>9,762.85</td>\n",
" <td>9,736.37</td>\n",
" <td>9,771.19</td>\n",
" <td>9,628.79</td>\n",
" </tr>\n",
" <tr>\n",
" <th>task completion rate</th>\n",
" <td>0.99</td>\n",
" <td>1.00</td>\n",
" <td>1.00</td>\n",
" <td>0.99</td>\n",
" <td>0.92</td>\n",
" <td>0.95</td>\n",
" </tr>\n",
" <tr>\n",
" <th>annual direct O&amp;M cost</th>\n",
" <td>16.48</td>\n",
" <td>13.93</td>\n",
" <td>5.47</td>\n",
" <td>12.25</td>\n",
" <td>17.93</td>\n",
" <td>15.83</td>\n",
" <td>5.49</td>\n",
" <td>11.20</td>\n",
" </tr>\n",
" <tr>\n",
" <th>annual vessel cost</th>\n",
" <td>11.27</td>\n",
" <td>8.31</td>\n",
" <td>12.23</td>\n",
" <td>9.83</td>\n",
" <td>1.92</td>\n",
" <td>2.09</td>\n",
" <td>2.07</td>\n",
" </tr>\n",
" <tr>\n",
" <th>ctv cost</th>\n",
Expand All @@ -371,14 +371,14 @@
" <tr>\n",
" <th>fsv cost</th>\n",
" <td>0.27</td>\n",
" <td>0.30</td>\n",
" <td>0.27</td>\n",
" <td>0.00</td>\n",
" <td>0.00</td>\n",
" </tr>\n",
" <tr>\n",
" <th>hlv cost</th>\n",
" <td>9.08</td>\n",
" <td>6.09</td>\n",
" <td>10.04</td>\n",
" <td>7.64</td>\n",
" <td>0.00</td>\n",
" <td>0.00</td>\n",
" </tr>\n",
Expand All @@ -387,14 +387,14 @@
" <td>0.00</td>\n",
" <td>0.00</td>\n",
" <td>0.00</td>\n",
" <td>0.17</td>\n",
" <td>0.16</td>\n",
" </tr>\n",
" <tr>\n",
" <th>annual repair cost</th>\n",
" <td>3.62</td>\n",
" <td>4.02</td>\n",
" <td>1.96</td>\n",
" <td>6.56</td>\n",
" <td>4.10</td>\n",
" <td>4.40</td>\n",
" <td>1.98</td>\n",
" <td>5.53</td>\n",
" </tr>\n",
" <tr>\n",
" <th>annual technician cost</th>\n",
Expand All @@ -419,7 +419,7 @@
" </tr>\n",
" <tr>\n",
" <th>hlv utilization</th>\n",
" <td>1.01</td>\n",
" <td>0.99</td>\n",
" <td>0.93</td>\n",
" <td>0.00</td>\n",
" <td>0.00</td>\n",
Expand All @@ -436,40 +436,40 @@
"</div>"
],
"text/plain": [
" base_scheduled base_requests base_downtime \n",
"availability - time based 0.97 0.97 0.97 \\\n",
" base_scheduled base_requests base_downtime \\\n",
"availability - time based 0.97 0.97 0.97 \n",
"availability - production based 0.97 0.97 0.97 \n",
"capacity factor - net 0.46 0.46 0.46 \n",
"capacity factor - gross 0.48 0.48 0.48 \n",
"power production 9,767.89 9,733.85 9,770.04 \n",
"task completion rate 0.99 1.00 0.99 \n",
"annual direct O&M cost 16.48 13.93 5.47 \n",
"annual vessel cost 11.27 8.31 1.92 \n",
"power production 9,762.85 9,736.37 9,771.19 \n",
"task completion rate 1.00 1.00 0.99 \n",
"annual direct O&M cost 17.93 15.83 5.49 \n",
"annual vessel cost 12.23 9.83 1.92 \n",
"ctv cost 1.92 1.92 1.92 \n",
"fsv cost 0.27 0.30 0.00 \n",
"hlv cost 9.08 6.09 0.00 \n",
"fsv cost 0.27 0.27 0.00 \n",
"hlv cost 10.04 7.64 0.00 \n",
"tow cost 0.00 0.00 0.00 \n",
"annual repair cost 3.62 4.02 1.96 \n",
"annual repair cost 4.10 4.40 1.98 \n",
"annual technician cost 1.60 1.60 1.60 \n",
"ctv utilization 1.00 1.00 1.00 \n",
"fsv utilization 1.00 0.93 0.00 \n",
"hlv utilization 1.01 0.93 0.00 \n",
"hlv utilization 0.99 0.93 0.00 \n",
"tow utilization 0.00 0.00 0.00 \n",
"\n",
" base_tow_to_port \n",
"availability - time based 0.96 \n",
"availability - production based 0.96 \n",
"capacity factor - net 0.46 \n",
"capacity factor - gross 0.48 \n",
"power production 9,632.82 \n",
"task completion rate 0.92 \n",
"annual direct O&M cost 12.25 \n",
"annual vessel cost 2.09 \n",
"power production 9,628.79 \n",
"task completion rate 0.95 \n",
"annual direct O&M cost 11.20 \n",
"annual vessel cost 2.07 \n",
"ctv cost 1.92 \n",
"fsv cost 0.00 \n",
"hlv cost 0.00 \n",
"tow cost 0.17 \n",
"annual repair cost 6.56 \n",
"tow cost 0.16 \n",
"annual repair cost 5.53 \n",
"annual technician cost 1.60 \n",
"ctv utilization 1.00 \n",
"fsv utilization 0.00 \n",
Expand Down Expand Up @@ -511,7 +511,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.10"
"version": "3.10.12"
},
"source_map": [
11,
Expand Down
7 changes: 4 additions & 3 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
# -- General configuration ---------------------------------------------------

# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# extensions coming with Sphinx (named "sphinx.ext.*") or your custom
# ones.
extensions = [
"myst_nb",
Expand Down Expand Up @@ -116,15 +116,16 @@
"use_repository_button": True,
"use_issues_button": True,
"path_to_docs": "docs/",
"show_navbar_depth": 2,
"navigation_depth": 2,
"home_page_in_toc": True,
"show_toc_level": 2,
# "show_nav_level": 2,
}

# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ["_static"]
# html_static_path = ["_static"]

# Napoleon options
napoleon_google_docstring = False
Expand Down
Loading