Skip to content

Commit

Permalink
Fix System_Dynamics demo
Browse files Browse the repository at this point in the history
  • Loading branch information
joraojr committed May 16, 2022
1 parent 46b0fe6 commit abae456
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 145 deletions.
23 changes: 8 additions & 15 deletions demos/System_Dynamics/Compartment_Models/lab_notebook.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# SIR model\n",
"\n",
Expand Down Expand Up @@ -169,19 +168,13 @@
"In the first model built, the definition of parameters is up to the user and they are not time dependent, i.e., we have a deterministic and time-invariant system. This means that if we make a simulation with the same initial populations and parameters 100 times, we will get 100 equal results.\n",
"\n",
"Evidently, this is not how real world works and it will not allow us to reach our goal of creating multiple spread scenarios, so it's quite important that stochasticity is added to the model."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## SIR model stock and flow diagram\n",
"Before properly building the model, it's essential to graphically represent it so that our problem is conceptually understood.\n",
"\n",
"The following stock and flow diagram shows how the information flows through the SIR model stocks of populations.\n",
"\n",
"![SIR model mechanism](images/sir_model_stock_flow.png)"
]
],
"metadata": {
"collapsed": false,
"pycharm": {
"name": "#%% md\n"
}
}
},
{
"cell_type": "markdown",
Expand Down Expand Up @@ -813,4 +806,4 @@
},
"nbformat": 4,
"nbformat_minor": 4
}
}
181 changes: 54 additions & 127 deletions demos/System_Dynamics/prey_predator_sd/Predator_Prey_SD_model.ipynb

Large diffs are not rendered by default.

5 changes: 2 additions & 3 deletions demos/System_Dynamics/prey_predator_sd/model/run.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import pandas as pd
from model import config
from cadCAD.engine import ExecutionMode, ExecutionContext,Executor
from cadCAD import configs
from .config import exp

def run():
'''
Expand All @@ -12,7 +11,7 @@ def run():
exec_mode = ExecutionMode()
local_mode_ctx = ExecutionContext(context=exec_mode.local_mode)

simulation = Executor(exec_context=local_mode_ctx, configs=configs)
simulation = Executor(exec_context=local_mode_ctx, configs=exp.configs)
raw_system_events, tensor_field, sessions = simulation.execute()
# Result System Events DataFrame
df = pd.DataFrame(raw_system_events)
Expand Down

0 comments on commit abae456

Please sign in to comment.