Skip to content

Commit

Permalink
adjust for colab
Browse files Browse the repository at this point in the history
  • Loading branch information
mikhailsirenko committed Mar 14, 2021
1 parent 2c13223 commit e52ce14
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 663 deletions.
21 changes: 17 additions & 4 deletions sa_demo_virus_on_network.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
"ema_logging.log_to_stderr(ema_logging.INFO)\n",
"\n",
"# Import Mesa virus on network model\n",
"from virus_on_network import model"
"from SSF2021.virus_on_network import model"
]
},
{
Expand Down Expand Up @@ -127,7 +127,7 @@
" gain_resistance_chance=1,\n",
" steps=10):\n",
" \n",
" from virus_on_network import model\n",
" from SSF2021.virus_on_network import model\n",
" \n",
" # Initialising the model\n",
" virus_on_network = model.VirusOnNetwork(num_nodes=num_nodes, \n",
Expand Down Expand Up @@ -509,7 +509,20 @@
"metadata": {},
"outputs": [],
"source": [
"from ema_workbench.util.utilities import save_results, load_results"
"from ema_workbench.util.utilities import save_results, load_results\n",
"import os"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Creaet a directory to store the results\n",
"directory = 'results/virus_on_network'\n",
"if not os.path.exists(directory):\n",
" os.makedirs(directory)"
]
},
{
Expand Down Expand Up @@ -560,7 +573,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Before we proceed further, we have to do a bit of preprocessing. Let's take a closer look at the outcomes. We have 4 outcomes, 100 scenarios, 10 replications and we run the model for 30 steps. This is what you see down below:"
"Before we proceed further, we have to do a bit of preprocessing. Let's take a closer look at the outcomes. We have 4 outcomes, 1400 scenarios, 10 replications and we run the model for 30 steps. This is what you see down below:"
]
},
{
Expand Down
36 changes: 28 additions & 8 deletions sa_practice_virus_on_network.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"source": [
"This is the main notebook of the workshop on *sensitivity analysis* (SA) at the Social Simulation Festival 2021. Here we will demonstrate how to do Variance-based SA also know as [Sobol SA](https://en.wikipedia.org/wiki/Variance-based_sensitivity_analysis) on a relatively simple model [virus on network](https://ccl.northwestern.edu/netlogo/models/VirusonaNetwork). The idea is that you reuse (read copy-paste) this code your own model. Therefore, we tried to keep simple and avoid extensive side steps from.\n",
"\n",
"This notebook is tuned to be run on [Google Colab](https://colab.research.google.com/) and has a couple of extra lines of code. If you want to use it on your local machine please use `sa_demo_local_machine.ipynb`.\n",
"This notebook is tuned to be run on [Google Colab](https://colab.research.google.com/) and has a couple of extra lines of code.\n",
"\n",
"The core packages used in this notebook are [Mesa](https://mesa.readthedocs.io/en/stable/) to define an ABM model in Python, [EMA Workbench](https://emaworkbench.readthedocs.io/en/latest/) to design and run experiments, [SALib](https://salib.readthedocs.io/en/latest/) to conduct SA (within EMA Workbench). Also, we used one pretty plotting function of [pyNetLogo](https://pynetlogo.readthedocs.io/en/latest/).\n",
"\n",
Expand Down Expand Up @@ -94,7 +94,7 @@
"ema_logging.log_to_stderr(ema_logging.INFO)\n",
"\n",
"# Import Mesa virus on network model\n",
"from src import model"
"from SSF2021.src import model"
]
},
{
Expand Down Expand Up @@ -144,7 +144,7 @@
" gain_resistance_chance=1,\n",
" steps=10):\n",
" \n",
" from src import model\n",
" from SSF2021.virus_on_network import model\n",
" \n",
" # Initialising the model\n",
" virus_on_network = model.VirusOnNetwork(num_nodes=num_nodes, \n",
Expand Down Expand Up @@ -500,13 +500,33 @@
"### Epic save"
]
},
{
"source": [
"<center><img src=\"img/save.jpg\" width=200 height=260/><center>"
],
"cell_type": "markdown",
"metadata": {}
},
{
"cell_type": "code",
"execution_count": 32,
"metadata": {},
"outputs": [],
"source": [
"from ema_workbench.util.utilities import save_results, load_results"
"from ema_workbench.util.utilities import save_results, load_results\n",
"import os"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Creaet a directory to store the results\n",
"directory = 'results/virus_on_network'\n",
"if not os.path.exists(directory):\n",
" os.makedirs(directory)"
]
},
{
Expand Down Expand Up @@ -565,7 +585,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Before we proceed further, we have to do a bit of preprocessing. Let's take a closer look at the outcomes. We have 4 outcomes, 100 scenarios, 10 replications and we run the model for 30 steps. This is what you see down below:"
"Before we proceed further, we have to do a bit of preprocessing. Let's take a closer look at the outcomes. We have 4 outcomes, 800 scenarios, 10 replications and we run the model for 30 steps. This is what you see down below:"
]
},
{
Expand Down Expand Up @@ -700,7 +720,7 @@
"source": [
"from SALib.analyze import sobol\n",
"from ema_workbench.em_framework.salib_samplers import get_SALib_problem\n",
"from src.plot import plot_sobol_indices\n",
"from SSF2021.src.plot import plot_sobol_indices\n",
"sns.set_style('white')"
]
},
Expand Down Expand Up @@ -823,9 +843,9 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.5"
"version": "3.8.3-final"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
}
Loading

0 comments on commit e52ce14

Please sign in to comment.