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

OpenCLSim Demo Notebooks #130

Draft
wants to merge 104 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
104 commits
Select commit Hold shift + click to select a range
a554532
make openclsim moving compatible with opentnsim moving, use opentnsim…
Dec 29, 2022
a42d4a3
Example with a depth varying path
markvankoningsveld Jan 10, 2023
c32edbe
Merge branch 'master' into feature/opentnsim-openclsim-demo-notebooks
Feb 3, 2023
8cbbc00
add networkx module
Feb 3, 2023
02bf885
Merge branch 'feature/opentnsim-openclsim-demo-notebooks' of github.c…
Feb 3, 2023
0cd9a79
flake8
Feb 3, 2023
e013f98
fix typo in attribute name, flake8
Feb 3, 2023
5acce42
implement separation between moving over geometries and moving over n…
Feb 3, 2023
9418763
rename
Feb 13, 2023
987aadb
missing dep
Feb 13, 2023
e06e1b3
notebook for opentnsim + openclsim with opentnsim moving and openclsi…
Feb 17, 2023
5538cde
add demo of dredging with routing
Feb 22, 2023
6fb89fc
Create priority.py
arashsepehri Feb 28, 2023
7faf979
Merge branch 'feature/opentnsim-openclsim-demo-notebooks' of https://…
arashsepehri Feb 28, 2023
a102c29
add opentnsim compatible log entry functions
Feb 28, 2023
6203ab8
Merge branch 'feature/opentnsim-openclsim-demo-notebooks' of github.c…
Feb 28, 2023
0994eaa
extra asserts for openclsim/opentnsim compatibility
Feb 28, 2023
32b6a33
make openclsim moving compatible with opentnsim moving, use opentnsim…
Dec 29, 2022
c6ef440
add networkx module
Feb 3, 2023
ec30e46
flake8
Feb 3, 2023
594b19e
fix typo in attribute name, flake8
Feb 3, 2023
3df890b
implement separation between moving over geometries and moving over n…
Feb 3, 2023
b550284
rename
Feb 13, 2023
74a7341
missing dep
Feb 13, 2023
d145eb3
notebook for opentnsim + openclsim with opentnsim moving and openclsi…
Feb 17, 2023
789fc73
add demo of dredging with routing
Feb 22, 2023
647166f
add opentnsim compatible log entry functions
Feb 28, 2023
8c429de
extra asserts for openclsim/opentnsim compatibility
Feb 28, 2023
177b725
source of module, multiple with same name
Mar 6, 2023
f650146
make log modules of opentnsim and openclsim compatible, warn if incon…
Mar 6, 2023
e1e8503
test with opentnsim + openclsim logging
Mar 6, 2023
2da47cb
remove self assignment
Mar 6, 2023
138300a
rename function
Mar 6, 2023
438cf8d
default engine order, full power
Mar 6, 2023
6c03b6f
remove duplicated code
Mar 6, 2023
e1625ee
code issues in movable
Mar 6, 2023
6726e29
line length
Mar 8, 2023
a08e274
fix unit tests for movable
Mar 8, 2023
cef5306
fix while activity tests
Mar 8, 2023
0dc1013
support empty logs
Mar 8, 2023
a54dd9a
formatting
Mar 8, 2023
8954390
fixing flake/black/isort
Mar 8, 2023
912584d
flake / black / isort
Mar 8, 2023
9a83f85
Merge branch 'master' into feature/opentnsim-openclsim-connection
Mar 8, 2023
410df00
Merging with latest feature/opentnsim-openclsim-connection, together …
Mar 9, 2023
e29c957
Complex example for interaction between seagoing vessels and dredging
arashsepehri Mar 9, 2023
886d393
Update __init__.py
arashsepehri Mar 13, 2023
ab17a57
Hopper Cutter Notebook
arashsepehri Apr 4, 2023
0f70a7b
Single Run with Priority
arashsepehri Apr 4, 2023
ac3c00c
Update Priority Mixin
arashsepehri Apr 5, 2023
b004b98
Update _init_.
arashsepehri Apr 5, 2023
7decccc
Update Notebook 35
arashsepehri Apr 11, 2023
eab07a5
update priority.py
arashsepehri Apr 17, 2023
4ab815e
update location.py
arashsepehri Apr 17, 2023
feab235
update notebook 35
arashsepehri Apr 18, 2023
196fc81
Add Indicator Module
arashsepehri Apr 25, 2023
76a86f4
update priority.py
arashsepehri Apr 25, 2023
94edc03
update __init__.py
arashsepehri Apr 25, 2023
e74a445
use shared registry, switch from directed to undirected graph, make t…
Apr 26, 2023
be26f71
Update indicators.py
arashsepehri May 3, 2023
0224df2
update init.py and indicators.py
arashsepehri May 8, 2023
c32937d
update priority.py
arashsepehri May 9, 2023
b8c2bb6
update __init__.py
arashsepehri May 9, 2023
d3222a7
add notebook 37
arashsepehri May 12, 2023
d4331cb
update __init__.py
arashsepehri May 12, 2023
3df69cd
update notebook 37
arashsepehri May 16, 2023
1481c1a
update priority.py
arashsepehri May 30, 2023
e4a9028
update priority.py and __init__.py
arashsepehri May 31, 2023
f3369f8
update some mixins
arashsepehri Jul 4, 2023
aa5a3cc
Notebook 38
Aug 10, 2023
f2ad8d0
Update notebook 33
Aug 10, 2023
2d2681e
Update access.py and __init__.py
Aug 21, 2023
4e868ed
update access.py and __initi__.py
Aug 23, 2023
72ccaad
update notebook 33
Aug 23, 2023
cf68b71
Update modules
Aug 31, 2023
857add5
add depth plugin from feature/depth_plugin branch
Aug 31, 2023
e9303c6
load plugins as module variables
Aug 31, 2023
e155b22
integrating depth plugin
Aug 31, 2023
04ad515
Add depth plugin parameters and some tidal window
Sep 4, 2023
3e24aad
update notebook 33
Sep 13, 2023
4eb3b40
Update Notebook 33
Sep 14, 2023
cc17110
update access
Sep 14, 2023
43a72aa
prepare layout for accessibility plugin
Sep 14, 2023
3b5db37
some updates
Sep 25, 2023
d04d6e7
update notebook 38
Sep 27, 2023
7faee26
updates on access.py and notebook 33
Oct 5, 2023
23ee691
implement sedimentation rate + wait for sedimentation
Oct 9, 2023
68361a8
adding excel files for Notebook 39
Oct 17, 2023
5b026a7
integrating notebook 33
Oct 18, 2023
b54d91c
Cleanups
Oct 19, 2023
589d722
add tidal window initial version
Feb 2, 2024
7d0190f
rename function
Feb 7, 2024
5f12f6c
Add WID Notebook
Apr 5, 2024
be14135
update
Apr 5, 2024
0be640d
add WID notebook
Apr 5, 2024
9865e9f
WID module
Apr 8, 2024
f5c43b7
updates WID
Apr 8, 2024
62186f9
update WID notebook
Apr 8, 2024
569ef58
Add exercise
Apr 22, 2024
8c25b34
backhoe barge notebook
Apr 23, 2024
75c0fcb
updates on tide criteria
May 7, 2024
2f8d8c5
Implement wait for tide
May 8, 2024
e05b93a
update notebook 40
Jun 5, 2024
ed2685f
Some updtes
arashsepehri Sep 9, 2024
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 notebooks/10_MultiContainer.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -1628,7 +1628,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.12"
"version": "3.9.13"
}
},
"nbformat": 4,
Expand Down
2 changes: 1 addition & 1 deletion notebooks/14_SingleRun.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -5735,7 +5735,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.12"
"version": "3.9.13"
}
},
"nbformat": 4,
Expand Down
275 changes: 275 additions & 0 deletions notebooks/32_openclsim_opentnsim.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,275 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"id": "bf80dcb5",
"metadata": {},
"outputs": [],
"source": [
"import datetime\n",
"import time\n",
"\n",
"import simpy\n",
"import pandas as pd\n",
"import shapely\n",
"\n",
"import openclsim\n",
"import openclsim.model\n",
"import opentnsim\n",
"import networkx as nx\n",
"\n",
"import logging\n",
"logging.basicConfig()"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "3e4a3b86",
"metadata": {},
"outputs": [],
"source": [
"# setup environment\n",
"simulation_start = 0\n",
"my_env = simpy.Environment(initial_time=simulation_start)\n",
"graph = nx.Graph()\n",
"my_env.graph = graph"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "3be50ba8",
"metadata": {},
"outputs": [],
"source": [
"# create a Site object based on desired mixin classes\n",
"Site = type(\n",
" \"Site\",\n",
" (\n",
" openclsim.core.Identifiable,\n",
" openclsim.core.Log,\n",
" openclsim.core.Locatable,\n",
" openclsim.core.HasContainer,\n",
" openclsim.core.HasResource,\n",
" ),\n",
" {},\n",
")\n",
"\n",
"# create a TransportProcessingResource object based on desired mixin classes\n",
"TransportProcessingResource = type(\n",
" \"TransportProcessingResource\",\n",
" (\n",
" opentnsim.core.Movable,\n",
" openclsim.core.Identifiable,\n",
" openclsim.core.Log,\n",
" openclsim.core.HasResource,\n",
" openclsim.core.HasContainer,\n",
" openclsim.core.Processor,\n",
" # capture extra metadata to make sure we don't have leftover arguments\n",
" opentnsim.core.ExtraMetadata\n",
" ),\n",
" {},\n",
")"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "b2ee2d9a",
"metadata": {},
"outputs": [],
"source": [
"# prepare input data for from_site (note: in this example we only need the start location)\n",
"location_from_site = shapely.geometry.Point(4.18055556, 52.18664444)\n",
"\n",
"# prepare input data for to_site\n",
"location_to_site = shapely.geometry.Point(4.25222222, 52.11428333)\n",
"data_to_site = {\n",
" \"env\": my_env,\n",
" \"name\": \"to_site\",\n",
" \"geometry\": location_to_site,\n",
" \"capacity\": 100,\n",
" \"level\": 100\n",
"}\n",
"# instantiate to_site \n",
"to_site = Site(**data_to_site)\n"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "5bba2225",
"metadata": {},
"outputs": [],
"source": [
"# create a location based graph (with geometry as nodes)\n",
"my_env.graph.add_node(location_from_site, **{\"geometry\": location_from_site})\n",
"my_env.graph.add_node(location_to_site, **{\"geometry\": location_to_site})\n",
"my_env.graph.add_edge(location_from_site, location_to_site)\n"
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "bed66786",
"metadata": {},
"outputs": [],
"source": [
"# prepare input data for vessel_01\n",
"data_vessel01 = {\n",
" \"env\": my_env,\n",
" \"name\": \"vessel01\",\n",
" \"geometry\": location_from_site, \n",
" \"capacity\": 5,\n",
" \"v\": 10,\n",
" \"route\": [location_from_site, location_to_site]\n",
"}\n",
"# instantiate vessel_01 \n",
"vessel01 = TransportProcessingResource(**data_vessel01)\n",
"assert not vessel01.metadata"
]
},
{
"cell_type": "code",
"execution_count": 7,
"id": "34f963b3",
"metadata": {},
"outputs": [],
"source": [
"# initialise registry\n",
"registry = {}"
]
},
{
"cell_type": "code",
"execution_count": 8,
"id": "88cabb7c",
"metadata": {},
"outputs": [],
"source": [
"activity = openclsim.model.MoveActivity(\n",
" env=my_env,\n",
" name=\"Move activity\",\n",
" registry=registry,\n",
" mover=vessel01,\n",
" destination=to_site,\n",
")"
]
},
{
"cell_type": "code",
"execution_count": 9,
"id": "485057d1",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"mover vessel01 destination to_site\n",
"getting location from to_site\n",
"moving to POINT (4.25222222 52.11428333)\n",
"moving over (<POINT (4.181 52.187)>, <POINT (4.252 52.114)>)\n",
"mover vessel01 is now at POINT (4.25222222 52.11428333)\n",
"mover vessel01 is now at POINT (4.25222222 52.11428333)\n"
]
}
],
"source": [
"# initate the simpy processes defined in the 'move activity' and run simpy\n",
"openclsim.model.register_processes([activity])\n",
"my_env.run()"
]
},
{
"cell_type": "code",
"execution_count": 10,
"id": "44e6f1a7",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>Activity</th>\n",
" <th>Timestamp</th>\n",
" <th>ActivityState</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>7017847c-7178-4b59-bc7d-95ae3bf5ba85</td>\n",
" <td>1970-01-01 00:00:00.000000</td>\n",
" <td>START</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>7017847c-7178-4b59-bc7d-95ae3bf5ba85</td>\n",
" <td>1970-01-01 00:15:42.824591</td>\n",
" <td>STOP</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" Activity Timestamp \\\n",
"0 7017847c-7178-4b59-bc7d-95ae3bf5ba85 1970-01-01 00:00:00.000000 \n",
"1 7017847c-7178-4b59-bc7d-95ae3bf5ba85 1970-01-01 00:15:42.824591 \n",
"\n",
" ActivityState \n",
"0 START \n",
"1 STOP "
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"display(openclsim.plot.get_log_dataframe(activity))"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.16"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
Loading