test notebook update and folder cleanup

This commit is contained in:
Markus 2018-11-26 14:46:20 -02:00
parent fc733b5283
commit cfbbb73e31
5 changed files with 165 additions and 3244 deletions

File diff suppressed because it is too large Load Diff

View File

@ -1,877 +0,0 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 491,
"metadata": {},
"outputs": [],
"source": [
"import pandas as pd\n",
"from scipy.stats import poisson\n",
"import numpy as np\n",
"import math\n",
"import seaborn as sns\n",
"import matplotlib as mpl\n",
"import matplotlib.pyplot as plt"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# UTILS"
]
},
{
"cell_type": "code",
"execution_count": 492,
"metadata": {},
"outputs": [],
"source": [
"def bound_norm_random(low, high):\n",
" res = np.random.normal((high+low)/2,(high-low)/6)\n",
" if (res<low or res>high):\n",
" res = bound_norm_random(low, high)\n",
" return res"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# TYPE/PHASE"
]
},
{
"cell_type": "code",
"execution_count": 493,
"metadata": {},
"outputs": [],
"source": [
"EXPERIMENT_TYPES = ['1 off run', 'Monte Carlo', 'Monte Carlo Parameter Sweep', 'Monte Carlo Pairwise']\n",
"\n",
"experiment_type = EXPERIMENT_TYPES[1]\n",
"monte_carlo_runs = 100\n",
"\n",
"#correct number of runs if inconsistent with experiment type\n",
"if (experiment_type == EXPERIMENT_TYPES[0]):\n",
" monte_carlo_runs = 1"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# TIMESCALE"
]
},
{
"cell_type": "code",
"execution_count": 494,
"metadata": {},
"outputs": [],
"source": [
"SECOND = 1\n",
"MINUTE = 60*SECOND\n",
"HOUR = 60*MINUTE\n",
"DAY = 24*HOUR\n",
"DURATION_OF_A_STEP = 1*DAY\n",
"\n",
"experiment_steps = 1000\n",
"experiment_duration = experiment_steps * DURATION_OF_A_STEP\n",
"time_array = np.arange(0,experiment_steps*DURATION_OF_A_STEP,DURATION_OF_A_STEP)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# MECHANISMS (dimension)"
]
},
{
"cell_type": "code",
"execution_count": 495,
"metadata": {},
"outputs": [],
"source": [
"mechanisms_names = ['mech_one', 'mech_two', 'mech_three']"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# STATES (dimension)"
]
},
{
"cell_type": "code",
"execution_count": 496,
"metadata": {},
"outputs": [],
"source": [
"states_names = ['a', 'b', 'c']\n",
"states_data = [[np.zeros(experiment_steps)]*len(states_names)]*monte_carlo_runs\n",
"states_data = np.zeros((monte_carlo_runs, experiment_steps, len(states_names)), dtype=int)\n",
"# states_data is a 3-dimensional array - montecarlo, time, states\n",
"# montecarlo[time[states]]"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Initial Conditions"
]
},
{
"cell_type": "code",
"execution_count": 497,
"metadata": {},
"outputs": [],
"source": [
"states_0 = {\n",
" 'a': 0,\n",
" 'b': 0,\n",
" 'c': 300\n",
"}\n",
"# an initial condition must be set for every state\n",
"assert np.array([k in states_0 for k in states_names]).all(), 'Error: The initial condition of one or more states is unkonwn'\n",
"\n",
"# copy initial condition to the states dataset\n",
"for i in range(len(states_names)):\n",
" states_data[:,0,i] = states_0[states_names[i]]"
]
},
{
"cell_type": "code",
"execution_count": 498,
"metadata": {},
"outputs": [],
"source": [
"T_0 = 0\n",
"time_array = T_0 + time_array"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Mechanisms Coef (params)"
]
},
{
"cell_type": "code",
"execution_count": 499,
"metadata": {},
"outputs": [],
"source": [
"mech_one_coef_A = 0.05"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# MECHANISMS EQUATIONS (func)"
]
},
{
"cell_type": "code",
"execution_count": 500,
"metadata": {},
"outputs": [],
"source": [
"# state/mechanism matrix\n",
"def mech_one(_states_data, _time_array, _run, _step, args):\n",
"# print('mech 1')\n",
" _states_data[_run, _step, states_names.index('a')] += (1-mech_one_coef_A)*args[0]\n",
" _states_data[_run, _step, states_names.index('b')] += mech_one_coef_A*args[0]\n",
" return _states_data\n",
"\n",
"def mech_two(_states_data, _time_array, _run, _step, args):\n",
"# print('mech 2')\n",
" _states_data[_run, _step, states_names.index('a')] -= args[0]\n",
" return _states_data\n",
"\n",
"def mech_three(_states_data, _time_array, _run, _step, args):\n",
"# print('mech 3')\n",
" _states_data[_run, _step, states_names.index('b')] -= args[0]\n",
" return _states_data\n",
"\n",
"def mech_four(_states_data, _time_array, _run, _step):\n",
"# print('mech 4')\n",
" _states_data[_run, _step, states_names.index('a')] = _states_data[_run, _step-1, states_names.index('a')]\n",
" _states_data[_run, _step, states_names.index('b')] = _states_data[_run, _step-1, states_names.index('b')] \n",
" return _states_data\n",
"\n",
"mechanisms = [eval(m) for m in mechanisms_names]"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Behavioral Model Coef (params) "
]
},
{
"cell_type": "code",
"execution_count": 501,
"metadata": {},
"outputs": [],
"source": [
"behavior_one_coef_A = 0.01\n",
"behavior_one_coef_B = -0.01\n",
"\n",
"behavior_two_coef_A = 1"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# BEHAVIORAL MODEL (func)"
]
},
{
"cell_type": "code",
"execution_count": 502,
"metadata": {},
"outputs": [],
"source": [
"behaviors_names = ['behavior_one', 'behavior_two']\n",
"def behavior_one(_states_data, _time_array, _run, _step): \n",
" c_var = ( _states_data[_run, _step, states_names.index('c')]\n",
" - _states_data[_run, _step-1, states_names.index('c')] )\n",
" c_var_perc = c_var / _states_data[_run, _step-1, states_names.index('c')]\n",
" \n",
" if (c_var_perc > behavior_one_coef_A):\n",
" return mech_one(_states_data, _time_array, _run, _step, [c_var])\n",
" elif (c_var_perc < behavior_one_coef_B):\n",
" return mech_two(_states_data, _time_array, _run, _step, [-c_var])\n",
" return _states_data\n",
"\n",
"def behavior_two(_states_data, _time_array, _run, _step):\n",
" b_balance = _states_data[_run, _step-1, states_names.index('b')]\n",
" if (b_balance > behavior_two_coef_A):\n",
" return mech_three(_states_data, _time_array, _run, _step, [b_balance])\n",
" return _states_data\n",
"\n",
"behaviors = [eval(b) for b in behaviors_names] "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# ENVIRONMENTAL PROCESS (dimension)"
]
},
{
"cell_type": "code",
"execution_count": 503,
"metadata": {},
"outputs": [],
"source": [
"env_proc_names = ['proc_one']"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Stochastic Process Coef (params)"
]
},
{
"cell_type": "code",
"execution_count": 504,
"metadata": {},
"outputs": [],
"source": [
"proc_one_coef_A = 0.7\n",
"proc_one_coef_B = 1.3"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# ENVIRONMENTAL PROCESS (func)"
]
},
{
"cell_type": "code",
"execution_count": 505,
"metadata": {},
"outputs": [],
"source": [
"def proc_one(_states_data, _time_array, _run, _step):\n",
" _states_data[_run, _step, states_names.index('a')] = _states_data[_run, _step-1, states_names.index('a')]\n",
" _states_data[_run, _step, states_names.index('b')] = _states_data[_run, _step-1, states_names.index('b')] \n",
" _states_data[_run, _step, states_names.index('c')] = ( _states_data[_run, _step-1, states_names.index('c')]\n",
" * bound_norm_random(proc_one_coef_A, proc_one_coef_B) )\n",
" return _states_data\n",
"\n",
"env_proc = [eval(p) for p in env_proc_names]"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# ENGINE"
]
},
{
"cell_type": "code",
"execution_count": 506,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"/Users/markusbkoch/.local/share/virtualenvs/DiffyQ-SimCAD-4_qpgnP9/lib/python3.6/site-packages/ipykernel_launcher.py:5: RuntimeWarning: invalid value encountered in long_scalars\n",
" \"\"\"\n"
]
}
],
"source": [
"for i in range(monte_carlo_runs):\n",
" for t in range(1,experiment_steps):\n",
" for p in env_proc:\n",
" states_data = p(_states_data=states_data,\n",
" _time_array=time_array, \n",
" _run=i, \n",
" _step=t)\n",
" for b in behaviors:\n",
" states_data = b(_states_data=states_data,\n",
" _time_array=time_array, \n",
" _run=i, \n",
" _step=t) #behaviors have access to exogenous data @ step-1, not @ step"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# DATA COLLECTION"
]
},
{
"cell_type": "code",
"execution_count": 507,
"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></th>\n",
" <th>a</th>\n",
" <th>b</th>\n",
" <th>c</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th rowspan=\"30\" valign=\"top\">0</th>\n",
" <th>0</th>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>300</td>\n",
" </tr>\n",
" <tr>\n",
" <th>86400</th>\n",
" <td>-7</td>\n",
" <td>0</td>\n",
" <td>293</td>\n",
" </tr>\n",
" <tr>\n",
" <th>172800</th>\n",
" <td>-20</td>\n",
" <td>0</td>\n",
" <td>280</td>\n",
" </tr>\n",
" <tr>\n",
" <th>259200</th>\n",
" <td>-86</td>\n",
" <td>0</td>\n",
" <td>214</td>\n",
" </tr>\n",
" <tr>\n",
" <th>345600</th>\n",
" <td>-67</td>\n",
" <td>1</td>\n",
" <td>234</td>\n",
" </tr>\n",
" <tr>\n",
" <th>432000</th>\n",
" <td>-67</td>\n",
" <td>1</td>\n",
" <td>233</td>\n",
" </tr>\n",
" <tr>\n",
" <th>518400</th>\n",
" <td>-91</td>\n",
" <td>1</td>\n",
" <td>209</td>\n",
" </tr>\n",
" <tr>\n",
" <th>604800</th>\n",
" <td>-99</td>\n",
" <td>1</td>\n",
" <td>201</td>\n",
" </tr>\n",
" <tr>\n",
" <th>691200</th>\n",
" <td>-93</td>\n",
" <td>1</td>\n",
" <td>207</td>\n",
" </tr>\n",
" <tr>\n",
" <th>777600</th>\n",
" <td>-104</td>\n",
" <td>1</td>\n",
" <td>196</td>\n",
" </tr>\n",
" <tr>\n",
" <th>864000</th>\n",
" <td>-101</td>\n",
" <td>1</td>\n",
" <td>199</td>\n",
" </tr>\n",
" <tr>\n",
" <th>950400</th>\n",
" <td>-86</td>\n",
" <td>1</td>\n",
" <td>214</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1036800</th>\n",
" <td>-92</td>\n",
" <td>1</td>\n",
" <td>208</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1123200</th>\n",
" <td>-92</td>\n",
" <td>1</td>\n",
" <td>210</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1209600</th>\n",
" <td>-99</td>\n",
" <td>1</td>\n",
" <td>203</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1296000</th>\n",
" <td>-122</td>\n",
" <td>1</td>\n",
" <td>180</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1382400</th>\n",
" <td>-135</td>\n",
" <td>1</td>\n",
" <td>167</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1468800</th>\n",
" <td>-161</td>\n",
" <td>1</td>\n",
" <td>141</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1555200</th>\n",
" <td>-161</td>\n",
" <td>1</td>\n",
" <td>141</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1641600</th>\n",
" <td>-187</td>\n",
" <td>1</td>\n",
" <td>115</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1728000</th>\n",
" <td>-195</td>\n",
" <td>1</td>\n",
" <td>107</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1814400</th>\n",
" <td>-201</td>\n",
" <td>1</td>\n",
" <td>101</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1900800</th>\n",
" <td>-189</td>\n",
" <td>1</td>\n",
" <td>113</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1987200</th>\n",
" <td>-189</td>\n",
" <td>1</td>\n",
" <td>112</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2073600</th>\n",
" <td>-189</td>\n",
" <td>1</td>\n",
" <td>111</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2160000</th>\n",
" <td>-191</td>\n",
" <td>1</td>\n",
" <td>109</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2246400</th>\n",
" <td>-200</td>\n",
" <td>1</td>\n",
" <td>100</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2332800</th>\n",
" <td>-206</td>\n",
" <td>1</td>\n",
" <td>94</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2419200</th>\n",
" <td>-206</td>\n",
" <td>1</td>\n",
" <td>94</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2505600</th>\n",
" <td>-218</td>\n",
" <td>1</td>\n",
" <td>82</td>\n",
" </tr>\n",
" <tr>\n",
" <th>...</th>\n",
" <th>...</th>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" </tr>\n",
" <tr>\n",
" <th rowspan=\"30\" valign=\"top\">99</th>\n",
" <th>83808000</th>\n",
" <td>-386</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>83894400</th>\n",
" <td>-386</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>83980800</th>\n",
" <td>-386</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>84067200</th>\n",
" <td>-386</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>84153600</th>\n",
" <td>-386</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>84240000</th>\n",
" <td>-386</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>84326400</th>\n",
" <td>-386</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>84412800</th>\n",
" <td>-386</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>84499200</th>\n",
" <td>-386</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>84585600</th>\n",
" <td>-386</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>84672000</th>\n",
" <td>-386</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>84758400</th>\n",
" <td>-386</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>84844800</th>\n",
" <td>-386</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>84931200</th>\n",
" <td>-386</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>85017600</th>\n",
" <td>-386</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>85104000</th>\n",
" <td>-386</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>85190400</th>\n",
" <td>-386</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>85276800</th>\n",
" <td>-386</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>85363200</th>\n",
" <td>-386</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>85449600</th>\n",
" <td>-386</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>85536000</th>\n",
" <td>-386</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>85622400</th>\n",
" <td>-386</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>85708800</th>\n",
" <td>-386</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>85795200</th>\n",
" <td>-386</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>85881600</th>\n",
" <td>-386</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>85968000</th>\n",
" <td>-386</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>86054400</th>\n",
" <td>-386</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>86140800</th>\n",
" <td>-386</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>86227200</th>\n",
" <td>-386</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>86313600</th>\n",
" <td>-386</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>100000 rows × 3 columns</p>\n",
"</div>"
],
"text/plain": [
" a b c\n",
"0 0 0 0 300\n",
" 86400 -7 0 293\n",
" 172800 -20 0 280\n",
" 259200 -86 0 214\n",
" 345600 -67 1 234\n",
" 432000 -67 1 233\n",
" 518400 -91 1 209\n",
" 604800 -99 1 201\n",
" 691200 -93 1 207\n",
" 777600 -104 1 196\n",
" 864000 -101 1 199\n",
" 950400 -86 1 214\n",
" 1036800 -92 1 208\n",
" 1123200 -92 1 210\n",
" 1209600 -99 1 203\n",
" 1296000 -122 1 180\n",
" 1382400 -135 1 167\n",
" 1468800 -161 1 141\n",
" 1555200 -161 1 141\n",
" 1641600 -187 1 115\n",
" 1728000 -195 1 107\n",
" 1814400 -201 1 101\n",
" 1900800 -189 1 113\n",
" 1987200 -189 1 112\n",
" 2073600 -189 1 111\n",
" 2160000 -191 1 109\n",
" 2246400 -200 1 100\n",
" 2332800 -206 1 94\n",
" 2419200 -206 1 94\n",
" 2505600 -218 1 82\n",
"... ... .. ...\n",
"99 83808000 -386 0 0\n",
" 83894400 -386 0 0\n",
" 83980800 -386 0 0\n",
" 84067200 -386 0 0\n",
" 84153600 -386 0 0\n",
" 84240000 -386 0 0\n",
" 84326400 -386 0 0\n",
" 84412800 -386 0 0\n",
" 84499200 -386 0 0\n",
" 84585600 -386 0 0\n",
" 84672000 -386 0 0\n",
" 84758400 -386 0 0\n",
" 84844800 -386 0 0\n",
" 84931200 -386 0 0\n",
" 85017600 -386 0 0\n",
" 85104000 -386 0 0\n",
" 85190400 -386 0 0\n",
" 85276800 -386 0 0\n",
" 85363200 -386 0 0\n",
" 85449600 -386 0 0\n",
" 85536000 -386 0 0\n",
" 85622400 -386 0 0\n",
" 85708800 -386 0 0\n",
" 85795200 -386 0 0\n",
" 85881600 -386 0 0\n",
" 85968000 -386 0 0\n",
" 86054400 -386 0 0\n",
" 86140800 -386 0 0\n",
" 86227200 -386 0 0\n",
" 86313600 -386 0 0\n",
"\n",
"[100000 rows x 3 columns]"
]
},
"execution_count": 507,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"data = pd.DataFrame(states_data[0], \n",
" index=[[0]*experiment_steps, time_array], \n",
" columns=states_names)\n",
"for i in range(1,monte_carlo_runs):\n",
" b = pd.DataFrame(states_data[i],\n",
" index=[[i]*experiment_steps, time_array], \n",
" columns=states_names)\n",
" data = data.append(b)\n",
"data"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "DiffyQ-SimCAD Env",
"language": "python",
"name": "diffyq-simcad"
},
"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.6.5"
}
},
"nbformat": 4,
"nbformat_minor": 2
}

View File

@ -1,35 +0,0 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import pandas as pd\n",
"assert pd.__version__ == '0.23.4'"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"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.6.5"
}
},
"nbformat": 4,
"nbformat_minor": 2
}

View File

@ -1,748 +0,0 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"import pandas as pd\n",
"from functools import partial, reduce"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"# Behaviors per Mechanism\n",
"def b1m1(step, sL, s):\n",
" return s['s1'] + 1\n",
"def b2m1(step, sL, s):\n",
" return s['s1'] + 1\n",
"\n",
"def b1m2(step, sL, s):\n",
" return s['s1'] + 1\n",
"def b2m2(step, sL, s):\n",
" return s['s1'] + 1\n",
"\n",
"def b1m3(step, sL, s):\n",
" return s['s1'] + 1\n",
"def b2m3(step, sL, s):\n",
" return s['s2'] + 1\n",
"\n",
"\n",
"# Internal States per Mechanism\n",
"def s1m1(step, sL, s, _input):\n",
" y = 's1'\n",
" x = s['s1'] + _input\n",
" return (y, x)\n",
"def s2m1(step, sL, s, _input):\n",
" y = 's2'\n",
" x = s['s2'] + _input\n",
" return (y, x)\n",
"\n",
"def s1m2(step, sL, s, _input):\n",
" y = 's1'\n",
" x = s['s1'] + _input\n",
" return (y, x)\n",
"def s2m2(step, sL, s, _input):\n",
" y = 's2'\n",
" x = s['s2'] + _input\n",
" return (y, x)\n",
"\n",
"def s1m3(step, sL, s, _input):\n",
" y = 's1'\n",
" x = s['s1'] + _input\n",
" return (y, x)\n",
"def s2m3(step, sL, s, _input):\n",
" y = 's2'\n",
" x = s['s2'] + _input\n",
" return (y, x)\n",
"\n",
"# Exogenous States\n",
"proc_one_coef_A = 0.7\n",
"proc_one_coef_B = 1.3\n",
"def es3p1(step, sL, s, _input):\n",
" y = 's3'\n",
" x = s['s3'] * bound_norm_random(seed['a'], proc_one_coef_A, proc_one_coef_B)\n",
" return (y, x)\n",
"def es4p2(step, sL, s, _input):\n",
" y = 's4'\n",
" x = s['s4'] * bound_norm_random(seed['b'], proc_one_coef_A, proc_one_coef_B)\n",
" return (y, x)\n",
"def es5p2(step, sL, s, _input): # accept timedelta instead of timedelta params\n",
" y = 'timestamp'\n",
" x = ep_time_step(s, s['timestamp'], seconds=1)\n",
" return (y, x)\n",
"\n",
"\n",
"\n",
"# Environment States\n",
"def env_a(x):\n",
" return 10\n",
"def env_b(x):\n",
" return 10\n",
"\n",
"\n",
"exogenous_states = {\n",
" \"s3\": es3p1,\n",
" \"s4\": es4p2,\n",
" \"timestamp\": es5p2\n",
"}\n",
"\n",
"ep = list(exogenous_states.values())\n",
"\n",
"mechanisms = {\n",
" \"m1\": {\n",
" \"behaviors\": {\n",
" \"b1\": b1m1, # lambda step, sL, s: s['s1'] + 1,\n",
" \"b2\": b2m1\n",
" },\n",
" \"states\": {\n",
" \"s1\": s1m1,\n",
" \"s2\": s2m1,\n",
" }\n",
" },\n",
" \"m2\": {\n",
" \"behaviors\": {\n",
" \"b1\": b1m2,\n",
" \"b2\": b2m2\n",
" },\n",
" \"states\": {\n",
" \"s1\": s1m2,\n",
" # \"s2\": s2m2,\n",
" }\n",
" },\n",
" \"m3\": {\n",
" \"behaviors\": {\n",
" # \"b1\": b1m3,\n",
" # \"b2\": b2m3\n",
" },\n",
" \"states\": {\n",
" \"s1\": s1m3,\n",
" # \"s2\": s2m3,\n",
" }\n",
" }\n",
"}\n",
"\n",
"\n",
"def state_identity(k):\n",
" def identity(step, sL, s, _input):\n",
" return (k, s[k])\n",
" return identity\n",
"\n",
"def behavior_identity(k):\n",
" def identity(step, sL, s):\n",
" return s[k]\n",
" return identity\n",
"\n",
"def key_filter(mechanisms, keyname): \n",
" return [ v[keyname] for k, v in mechanisms.items() ]\n",
"\n",
"def fillna_with_id(identity, df, col):\n",
" return df[[col]].fillna(value=identity(col))\n",
"\n",
"def apply_identity_funcs(identity, df, cols):\n",
" return list(map(lambda col: fillna_with_id(identity, df, col), cols))\n",
"\n",
"def create_matrix_field(mechanisms, key):\n",
" if key == 'states':\n",
" identity = state_identity\n",
" else:\n",
" identity = behavior_identity\n",
" df = pd.DataFrame(key_filter(mechanisms, key))\n",
" col_list = apply_identity_funcs(identity, df, list(df.columns))\n",
" return reduce((lambda x, y: pd.concat([x, y], axis=1)), col_list)\n",
"\n",
"def create_tensor_field(mechanisms, env_poc=ep, keys=['behaviors', 'states']):\n",
" dfs = [ create_matrix_field(mechanisms, k) for k in keys ]\n",
" df = pd.concat(dfs, axis=1)\n",
" for es, i in zip(env_poc, range(len(env_poc))):\n",
" df['es'+str(i)] = es\n",
" df['m'] = df.index + 1\n",
" return df\n",
"\n",
"def generate_config(mechanisms, env_poc=ep):\n",
" bdf = create_matrix_field(mechanisms,'behaviors')\n",
" sdf = create_matrix_field(mechanisms,'states')\n",
" zipped_list = list(zip(sdf.values.tolist(), bdf.values.tolist()))\n",
" return list(map(lambda x: (x[0] + env_poc, x[1]), zipped_list))"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"[[<function __main__.b1m1(step, sL, s)>,\n",
" <function __main__.b2m1(step, sL, s)>],\n",
" [<function __main__.b1m2(step, sL, s)>,\n",
" <function __main__.b2m2(step, sL, s)>],\n",
" [<function __main__.behavior_identity.<locals>.identity(step, sL, s)>,\n",
" <function __main__.behavior_identity.<locals>.identity(step, sL, s)>]]"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"create_matrix_field(mechanisms,'behaviors').values.tolist()\n",
" \n",
"# exdf[exdf.index == 0].values.tolist() #['b1','b2']"
]
},
{
"cell_type": "code",
"execution_count": 4,
"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>b1</th>\n",
" <th>b2</th>\n",
" <th>s1</th>\n",
" <th>s2</th>\n",
" <th>es0</th>\n",
" <th>es1</th>\n",
" <th>es2</th>\n",
" <th>m</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>&lt;function b1m1 at 0x10af42158&gt;</td>\n",
" <td>&lt;function b2m1 at 0x10af42268&gt;</td>\n",
" <td>&lt;function s1m1 at 0x10af42510&gt;</td>\n",
" <td>&lt;function s2m1 at 0x10af42598&gt;</td>\n",
" <td>&lt;function es3p1 at 0x10af42840&gt;</td>\n",
" <td>&lt;function es4p2 at 0x10af428c8&gt;</td>\n",
" <td>&lt;function es5p2 at 0x10af42950&gt;</td>\n",
" <td>1</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>&lt;function b1m2 at 0x10af422f0&gt;</td>\n",
" <td>&lt;function b2m2 at 0x10af42400&gt;</td>\n",
" <td>&lt;function s1m2 at 0x10af42620&gt;</td>\n",
" <td>&lt;function state_identity.&lt;locals&gt;.identity at ...</td>\n",
" <td>&lt;function es3p1 at 0x10af42840&gt;</td>\n",
" <td>&lt;function es4p2 at 0x10af428c8&gt;</td>\n",
" <td>&lt;function es5p2 at 0x10af42950&gt;</td>\n",
" <td>2</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>&lt;function behavior_identity.&lt;locals&gt;.identity ...</td>\n",
" <td>&lt;function behavior_identity.&lt;locals&gt;.identity ...</td>\n",
" <td>&lt;function s1m3 at 0x10af42730&gt;</td>\n",
" <td>&lt;function state_identity.&lt;locals&gt;.identity at ...</td>\n",
" <td>&lt;function es3p1 at 0x10af42840&gt;</td>\n",
" <td>&lt;function es4p2 at 0x10af428c8&gt;</td>\n",
" <td>&lt;function es5p2 at 0x10af42950&gt;</td>\n",
" <td>3</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" b1 \\\n",
"0 <function b1m1 at 0x10af42158> \n",
"1 <function b1m2 at 0x10af422f0> \n",
"2 <function behavior_identity.<locals>.identity ... \n",
"\n",
" b2 \\\n",
"0 <function b2m1 at 0x10af42268> \n",
"1 <function b2m2 at 0x10af42400> \n",
"2 <function behavior_identity.<locals>.identity ... \n",
"\n",
" s1 \\\n",
"0 <function s1m1 at 0x10af42510> \n",
"1 <function s1m2 at 0x10af42620> \n",
"2 <function s1m3 at 0x10af42730> \n",
"\n",
" s2 \\\n",
"0 <function s2m1 at 0x10af42598> \n",
"1 <function state_identity.<locals>.identity at ... \n",
"2 <function state_identity.<locals>.identity at ... \n",
"\n",
" es0 es1 \\\n",
"0 <function es3p1 at 0x10af42840> <function es4p2 at 0x10af428c8> \n",
"1 <function es3p1 at 0x10af42840> <function es4p2 at 0x10af428c8> \n",
"2 <function es3p1 at 0x10af42840> <function es4p2 at 0x10af428c8> \n",
"\n",
" es2 m \n",
"0 <function es5p2 at 0x10af42950> 1 \n",
"1 <function es5p2 at 0x10af42950> 2 \n",
"2 <function es5p2 at 0x10af42950> 3 "
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# generate_config(mechanisms, ep)\n",
"create_tensor_field(mechanisms)"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"[([<function __main__.s1m1(step, sL, s, _input)>,\n",
" <function __main__.s2m1(step, sL, s, _input)>,\n",
" <function __main__.es3p1(step, sL, s, _input)>,\n",
" <function __main__.es4p2(step, sL, s, _input)>,\n",
" <function __main__.es5p2(step, sL, s, _input)>],\n",
" [<function __main__.b1m1(step, sL, s)>,\n",
" <function __main__.b2m1(step, sL, s)>]),\n",
" ([<function __main__.s1m2(step, sL, s, _input)>,\n",
" <function __main__.es3p1(step, sL, s, _input)>,\n",
" <function __main__.es4p2(step, sL, s, _input)>,\n",
" <function __main__.es5p2(step, sL, s, _input)>],\n",
" [<function __main__.b1m2(step, sL, s)>,\n",
" <function __main__.b2m2(step, sL, s)>]),\n",
" ([<function __main__.s1m3(step, sL, s, _input)>,\n",
" <function __main__.es3p1(step, sL, s, _input)>,\n",
" <function __main__.es4p2(step, sL, s, _input)>,\n",
" <function __main__.es5p2(step, sL, s, _input)>],\n",
" [])]"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# def generate_config(mechanisms, exogenous_states):\n",
"# es_funcs = list(exogenous_states.values())\n",
"# # es_funcs = [ exogenous_states[state] for state in list(exogenous_states.keys()) ]\n",
"# config = list(\n",
"# map(\n",
"# lambda m: (\n",
"# list(mechanisms[m][\"states\"].values()) + es_funcs,\n",
"# list(mechanisms[m][\"behaviors\"].values())\n",
"# ),\n",
"# list(mechanisms.keys())\n",
"# )\n",
"# )\n",
"# return config\n",
"# generate_config(mechanisms, exogenous_states)"
]
},
{
"cell_type": "code",
"execution_count": 170,
"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>b1</th>\n",
" <th>b2</th>\n",
" <th>s1</th>\n",
" <th>s2</th>\n",
" <th>es0</th>\n",
" <th>es1</th>\n",
" <th>es2</th>\n",
" <th>m</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>&lt;function b1m1 at 0x118771e18&gt;</td>\n",
" <td>&lt;function b2m1 at 0x1188d7d90&gt;</td>\n",
" <td>&lt;function s1m1 at 0x1188d7730&gt;</td>\n",
" <td>&lt;function s2m1 at 0x1188ed730&gt;</td>\n",
" <td>&lt;function es3p1 at 0x1188ed400&gt;</td>\n",
" <td>&lt;function es4p2 at 0x1188ed378&gt;</td>\n",
" <td>&lt;function es5p2 at 0x1188ed158&gt;</td>\n",
" <td>1</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>&lt;function b1m2 at 0x1188d70d0&gt;</td>\n",
" <td>&lt;function b2m2 at 0x1188d7840&gt;</td>\n",
" <td>&lt;function s1m2 at 0x1188ed620&gt;</td>\n",
" <td>&lt;function state_identity.&lt;locals&gt;.identity at ...</td>\n",
" <td>&lt;function es3p1 at 0x1188ed400&gt;</td>\n",
" <td>&lt;function es4p2 at 0x1188ed378&gt;</td>\n",
" <td>&lt;function es5p2 at 0x1188ed158&gt;</td>\n",
" <td>2</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>&lt;function b1m3 at 0x1188d7ea0&gt;</td>\n",
" <td>&lt;function behavior_identity.&lt;locals&gt;.identity ...</td>\n",
" <td>&lt;function s1m3 at 0x1188d7a60&gt;</td>\n",
" <td>&lt;function s2m3 at 0x1188ed268&gt;</td>\n",
" <td>&lt;function es3p1 at 0x1188ed400&gt;</td>\n",
" <td>&lt;function es4p2 at 0x1188ed378&gt;</td>\n",
" <td>&lt;function es5p2 at 0x1188ed158&gt;</td>\n",
" <td>3</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" b1 \\\n",
"0 <function b1m1 at 0x118771e18> \n",
"1 <function b1m2 at 0x1188d70d0> \n",
"2 <function b1m3 at 0x1188d7ea0> \n",
"\n",
" b2 \\\n",
"0 <function b2m1 at 0x1188d7d90> \n",
"1 <function b2m2 at 0x1188d7840> \n",
"2 <function behavior_identity.<locals>.identity ... \n",
"\n",
" s1 \\\n",
"0 <function s1m1 at 0x1188d7730> \n",
"1 <function s1m2 at 0x1188ed620> \n",
"2 <function s1m3 at 0x1188d7a60> \n",
"\n",
" s2 \\\n",
"0 <function s2m1 at 0x1188ed730> \n",
"1 <function state_identity.<locals>.identity at ... \n",
"2 <function s2m3 at 0x1188ed268> \n",
"\n",
" es0 es1 \\\n",
"0 <function es3p1 at 0x1188ed400> <function es4p2 at 0x1188ed378> \n",
"1 <function es3p1 at 0x1188ed400> <function es4p2 at 0x1188ed378> \n",
"2 <function es3p1 at 0x1188ed400> <function es4p2 at 0x1188ed378> \n",
"\n",
" es2 m \n",
"0 <function es5p2 at 0x1188ed158> 1 \n",
"1 <function es5p2 at 0x1188ed158> 2 \n",
"2 <function es5p2 at 0x1188ed158> 3 "
]
},
"execution_count": 170,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"create_tensor_field(mechanisms)"
]
},
{
"cell_type": "code",
"execution_count": 53,
"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>b1</th>\n",
" <th>b2</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>&lt;function b1m1 at 0x1108c88c8&gt;</td>\n",
" <td>&lt;function b2m1 at 0x1108c89d8&gt;</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>&lt;function b1m2 at 0x1108c8d90&gt;</td>\n",
" <td>&lt;function b2m2 at 0x1108c8a60&gt;</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>&lt;function b1m3 at 0x1108c8c80&gt;</td>\n",
" <td>&lt;function behavior_identity.&lt;locals&gt;.identity ...</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" b1 \\\n",
"0 <function b1m1 at 0x1108c88c8> \n",
"1 <function b1m2 at 0x1108c8d90> \n",
"2 <function b1m3 at 0x1108c8c80> \n",
"\n",
" b2 \n",
"0 <function b2m1 at 0x1108c89d8> \n",
"1 <function b2m2 at 0x1108c8a60> \n",
"2 <function behavior_identity.<locals>.identity ... "
]
},
"execution_count": 53,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"create_matrix_field(mechanisms,'behaviors')\n",
"create_matrix_field(mechanisms,'states')"
]
},
{
"cell_type": "code",
"execution_count": 60,
"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>b1</th>\n",
" <th>b2</th>\n",
" <th>s1</th>\n",
" <th>s2</th>\n",
" <th>es0</th>\n",
" <th>es1</th>\n",
" <th>es2</th>\n",
" <th>m</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>&lt;function b1m1 at 0x1105ed9d8&gt;</td>\n",
" <td>&lt;function b2m1 at 0x1105edbf8&gt;</td>\n",
" <td>&lt;function s1m1 at 0x1105c69d8&gt;</td>\n",
" <td>&lt;function s2m1 at 0x1105ede18&gt;</td>\n",
" <td>&lt;function es3p1 at 0x1187710d0&gt;</td>\n",
" <td>&lt;function es4p2 at 0x118771158&gt;</td>\n",
" <td>&lt;function es5p2 at 0x1187711e0&gt;</td>\n",
" <td>1</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>&lt;function b1m2 at 0x1105edc80&gt;</td>\n",
" <td>&lt;function b2m2 at 0x1105edd08&gt;</td>\n",
" <td>&lt;function s1m2 at 0x1105edea0&gt;</td>\n",
" <td>&lt;function state_identity.&lt;locals&gt;.identity at ...</td>\n",
" <td>&lt;function es3p1 at 0x1187710d0&gt;</td>\n",
" <td>&lt;function es4p2 at 0x118771158&gt;</td>\n",
" <td>&lt;function es5p2 at 0x1187711e0&gt;</td>\n",
" <td>2</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>&lt;function b1m3 at 0x1105edb70&gt;</td>\n",
" <td>&lt;function behavior_identity.&lt;locals&gt;.identity ...</td>\n",
" <td>&lt;function s1m3 at 0x1105ed0d0&gt;</td>\n",
" <td>&lt;function s2m3 at 0x118771048&gt;</td>\n",
" <td>&lt;function es3p1 at 0x1187710d0&gt;</td>\n",
" <td>&lt;function es4p2 at 0x118771158&gt;</td>\n",
" <td>&lt;function es5p2 at 0x1187711e0&gt;</td>\n",
" <td>3</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" b1 \\\n",
"0 <function b1m1 at 0x1105ed9d8> \n",
"1 <function b1m2 at 0x1105edc80> \n",
"2 <function b1m3 at 0x1105edb70> \n",
"\n",
" b2 \\\n",
"0 <function b2m1 at 0x1105edbf8> \n",
"1 <function b2m2 at 0x1105edd08> \n",
"2 <function behavior_identity.<locals>.identity ... \n",
"\n",
" s1 \\\n",
"0 <function s1m1 at 0x1105c69d8> \n",
"1 <function s1m2 at 0x1105edea0> \n",
"2 <function s1m3 at 0x1105ed0d0> \n",
"\n",
" s2 \\\n",
"0 <function s2m1 at 0x1105ede18> \n",
"1 <function state_identity.<locals>.identity at ... \n",
"2 <function s2m3 at 0x118771048> \n",
"\n",
" es0 es1 \\\n",
"0 <function es3p1 at 0x1187710d0> <function es4p2 at 0x118771158> \n",
"1 <function es3p1 at 0x1187710d0> <function es4p2 at 0x118771158> \n",
"2 <function es3p1 at 0x1187710d0> <function es4p2 at 0x118771158> \n",
"\n",
" es2 m \n",
"0 <function es5p2 at 0x1187711e0> 1 \n",
"1 <function es5p2 at 0x1187711e0> 2 \n",
"2 <function es5p2 at 0x1187711e0> 3 "
]
},
"execution_count": 60,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"tensor_field_report(mechanisms)"
]
},
{
"cell_type": "code",
"execution_count": 39,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"('a', 0)\n",
"('b', 1)\n",
"('c', 2)\n"
]
}
],
"source": [
"\n",
"for x, i in zip(['a', 'b', 'c'], range(3)):\n",
" print((x, i))"
]
},
{
"cell_type": "code",
"execution_count": 41,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"3"
]
},
"execution_count": 41,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"len(env_poc)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"def create_tensor_field2(mechanisms, env_poc=ep):\n",
" beh_df = create_matrix_field(mechanisms, 'behaviors')\n",
" state_df = create_matrix_field(mechanisms, 'states')\n",
" ep_df = pd.DataFrame({'m' : range(len(env_poc))})\n",
" for es, i in zip(env_poc, range(len(env_poc))):\n",
" ep_df['es'+str(i)] = es\n",
" \n",
" return beh_df"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"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.6.5"
}
},
"nbformat": 4,
"nbformat_minor": 2
}

View File

@ -2,55 +2,180 @@
"cells": [
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 1,
"metadata": {
"scrolled": false
},
"outputs": [
{
"ename": "ImportError",
"evalue": "cannot import name 'run'",
"traceback": [
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[1;31mImportError\u001b[0m Traceback (most recent call last)",
"\u001b[1;32m<ipython-input-5-a6e895c51fc0>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m()\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[1;32mfrom\u001b[0m \u001b[0mengine\u001b[0m \u001b[1;32mimport\u001b[0m \u001b[0mrun\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 2\u001b[0m \u001b[0mrun\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mmain\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
"\u001b[1;31mImportError\u001b[0m: cannot import name 'run'"
],
"output_type": "error"
"name": "stdout",
"output_type": "stream",
"text": [
"Simulation Run 1\n",
"\n",
"single_proc: [<SimCAD.Configuration object at 0x10fc1a8d0>]\n",
"+----+-------------+-------+------------+-----------+----------+----------+-------------+---------------------+\n",
"| | mech_step | run | s1 | s2 | s3 | s4 | time_step | timestamp |\n",
"|----+-------------+-------+------------+-----------+----------+----------+-------------+---------------------|\n",
"| 0 | 0 | 2 | 0 | 0 | 1 | 1 | 0 | 2018-10-01 15:16:24 |\n",
"| 1 | 1 | 1 | 1 | 4 | 10 | 10 | 1 | 2018-10-01 15:16:25 |\n",
"| 2 | 2 | 1 | ab | 6 | 10 | 10 | 1 | 2018-10-01 15:16:25 |\n",
"| 3 | 3 | 1 | ['c', 'd'] | [ 30 300] | 10 | 10 | 1 | 2018-10-01 15:16:25 |\n",
"| 4 | 1 | 1 | 1 | 4 | 9.94373 | 10.4365 | 2 | 2018-10-01 15:16:26 |\n",
"| 5 | 2 | 1 | ab | 6 | 9.94373 | 10.4365 | 2 | 2018-10-01 15:16:26 |\n",
"| 6 | 3 | 1 | ['c', 'd'] | [ 30 300] | 9.94373 | 10.4365 | 2 | 2018-10-01 15:16:26 |\n",
"| 7 | 1 | 1 | 1 | 4 | 7.81956 | 10.5372 | 3 | 2018-10-01 15:16:27 |\n",
"| 8 | 2 | 1 | ab | 6 | 7.81956 | 10.5372 | 3 | 2018-10-01 15:16:27 |\n",
"| 9 | 3 | 1 | ['c', 'd'] | [ 30 300] | 7.81956 | 10.5372 | 3 | 2018-10-01 15:16:27 |\n",
"| 10 | 1 | 1 | 1 | 4 | 9.10218 | 8.57362 | 4 | 2018-10-01 15:16:28 |\n",
"| 11 | 2 | 1 | ab | 6 | 9.10218 | 8.57362 | 4 | 2018-10-01 15:16:28 |\n",
"| 12 | 3 | 1 | ['c', 'd'] | [ 30 300] | 9.10218 | 8.57362 | 4 | 2018-10-01 15:16:28 |\n",
"| 13 | 1 | 1 | 1 | 4 | 7.46976 | 8.33579 | 5 | 2018-10-01 15:16:29 |\n",
"| 14 | 2 | 1 | ab | 6 | 7.46976 | 8.33579 | 5 | 2018-10-01 15:16:29 |\n",
"| 15 | 3 | 1 | ['c', 'd'] | [ 30 300] | 7.46976 | 8.33579 | 5 | 2018-10-01 15:16:29 |\n",
"| 16 | 0 | 2 | 0 | 0 | 1 | 1 | 0 | 2018-10-01 15:16:24 |\n",
"| 17 | 1 | 2 | 1 | 4 | 10 | 10 | 1 | 2018-10-01 15:16:25 |\n",
"| 18 | 2 | 2 | ab | 6 | 10 | 10 | 1 | 2018-10-01 15:16:25 |\n",
"| 19 | 3 | 2 | ['c', 'd'] | [ 30 300] | 10 | 10 | 1 | 2018-10-01 15:16:25 |\n",
"| 20 | 1 | 2 | 1 | 4 | 10.5029 | 9.91726 | 2 | 2018-10-01 15:16:26 |\n",
"| 21 | 2 | 2 | ab | 6 | 10.5029 | 9.91726 | 2 | 2018-10-01 15:16:26 |\n",
"| 22 | 3 | 2 | ['c', 'd'] | [ 30 300] | 10.5029 | 9.91726 | 2 | 2018-10-01 15:16:26 |\n",
"| 23 | 1 | 2 | 1 | 4 | 9.19497 | 9.29545 | 3 | 2018-10-01 15:16:27 |\n",
"| 24 | 2 | 2 | ab | 6 | 9.19497 | 9.29545 | 3 | 2018-10-01 15:16:27 |\n",
"| 25 | 3 | 2 | ['c', 'd'] | [ 30 300] | 9.19497 | 9.29545 | 3 | 2018-10-01 15:16:27 |\n",
"| 26 | 1 | 2 | 1 | 4 | 8.22219 | 9.25471 | 4 | 2018-10-01 15:16:28 |\n",
"| 27 | 2 | 2 | ab | 6 | 8.22219 | 9.25471 | 4 | 2018-10-01 15:16:28 |\n",
"| 28 | 3 | 2 | ['c', 'd'] | [ 30 300] | 8.22219 | 9.25471 | 4 | 2018-10-01 15:16:28 |\n",
"| 29 | 1 | 2 | 1 | 4 | 7.47478 | 8.81306 | 5 | 2018-10-01 15:16:29 |\n",
"| 30 | 2 | 2 | ab | 6 | 7.47478 | 8.81306 | 5 | 2018-10-01 15:16:29 |\n",
"| 31 | 3 | 2 | ['c', 'd'] | [ 30 300] | 7.47478 | 8.81306 | 5 | 2018-10-01 15:16:29 |\n",
"+----+-------------+-------+------------+-----------+----------+----------+-------------+---------------------+\n",
"\n",
"Simulation Run 2: Pairwise Execution\n",
"\n",
"multi_proc: [<SimCAD.Configuration object at 0x10fc1a8d0>, <SimCAD.Configuration object at 0x10fc1aeb8>]\n",
"+----+--------------------------------+--------------------------------+--------------------------------+--------------------------------+-----------------------------------------------------+-----------------------------------------------------+-----------------------------------------------------+-----+\n",
"| | b1 | b2 | s1 | s2 | es1 | es2 | es3 | m |\n",
"|----+--------------------------------+--------------------------------+--------------------------------+--------------------------------+-----------------------------------------------------+-----------------------------------------------------+-----------------------------------------------------+-----|\n",
"| 0 | <function b1m1 at 0x10faedd08> | <function b2m1 at 0x10fc230d0> | <function s1m1 at 0x10fc23378> | <function s2m1 at 0x10fc23400> | <function curried.<locals>._curried at 0x10fc23ae8> | <function curried.<locals>._curried at 0x10fc23b70> | <function curried.<locals>._curried at 0x10fc23bf8> | 1 |\n",
"| 1 | <function b1m2 at 0x10fc23158> | <function b2m2 at 0x10fc231e0> | <function s1m2 at 0x10fc23488> | <function s2m2 at 0x10fc23510> | <function curried.<locals>._curried at 0x10fc23ae8> | <function curried.<locals>._curried at 0x10fc23b70> | <function curried.<locals>._curried at 0x10fc23bf8> | 2 |\n",
"| 2 | <function b1m3 at 0x10fc23268> | <function b2m3 at 0x10fc232f0> | <function s1m3 at 0x10fc23598> | <function s2m3 at 0x10fc23620> | <function curried.<locals>._curried at 0x10fc23ae8> | <function curried.<locals>._curried at 0x10fc23b70> | <function curried.<locals>._curried at 0x10fc23bf8> | 3 |\n",
"+----+--------------------------------+--------------------------------+--------------------------------+--------------------------------+-----------------------------------------------------+-----------------------------------------------------+-----------------------------------------------------+-----+\n",
"+----+--------------------------------+--------------------------------+--------------------------------+------------------------------------------------------------+-----------------------------------------------------+-----------------------------------------------------+-----------------------------------------------------+-----+\n",
"| | b1 | b2 | s1 | s2 | es1 | es2 | es3 | m |\n",
"|----+--------------------------------+--------------------------------+--------------------------------+------------------------------------------------------------+-----------------------------------------------------+-----------------------------------------------------+-----------------------------------------------------+-----|\n",
"| 0 | <function b1m1 at 0x10fc23d08> | <function b2m1 at 0x10fc23d90> | <function s1m1 at 0x10fc290d0> | <function state_identity.<locals>.<lambda> at 0x10d4f6598> | <function curried.<locals>._curried at 0x10fc29840> | <function curried.<locals>._curried at 0x10fc298c8> | <function curried.<locals>._curried at 0x10fc29950> | 1 |\n",
"| 1 | <function b1m2 at 0x10fc23e18> | <function b2m2 at 0x10fc23ea0> | <function s1m2 at 0x10fc291e0> | <function state_identity.<locals>.<lambda> at 0x10d4f6598> | <function curried.<locals>._curried at 0x10fc29840> | <function curried.<locals>._curried at 0x10fc298c8> | <function curried.<locals>._curried at 0x10fc29950> | 2 |\n",
"| 2 | <function b1m3 at 0x10fc23f28> | <function b2m3 at 0x10fc29048> | <function s1m3 at 0x10fc292f0> | <function s2m3 at 0x10fc29378> | <function curried.<locals>._curried at 0x10fc29840> | <function curried.<locals>._curried at 0x10fc298c8> | <function curried.<locals>._curried at 0x10fc29950> | 3 |\n",
"+----+--------------------------------+--------------------------------+--------------------------------+------------------------------------------------------------+-----------------------------------------------------+-----------------------------------------------------+-----------------------------------------------------+-----+\n",
"+----+-------------+-------+------------+-----------+----------+----------+-------------+---------------------+\n",
"| | mech_step | run | s1 | s2 | s3 | s4 | time_step | timestamp |\n",
"|----+-------------+-------+------------+-----------+----------+----------+-------------+---------------------|\n",
"| 0 | 0 | 2 | 0 | 0 | 1 | 1 | 0 | 2018-10-01 15:16:24 |\n",
"| 1 | 1 | 1 | 1 | 4 | 10 | 10 | 1 | 2018-10-01 15:16:25 |\n",
"| 2 | 2 | 1 | ab | 6 | 10 | 10 | 1 | 2018-10-01 15:16:25 |\n",
"| 3 | 3 | 1 | ['c', 'd'] | [ 30 300] | 10 | 10 | 1 | 2018-10-01 15:16:25 |\n",
"| 4 | 1 | 1 | 1 | 4 | 12.2922 | 10.8846 | 2 | 2018-10-01 15:16:26 |\n",
"| 5 | 2 | 1 | ab | 6 | 12.2922 | 10.8846 | 2 | 2018-10-01 15:16:26 |\n",
"| 6 | 3 | 1 | ['c', 'd'] | [ 30 300] | 12.2922 | 10.8846 | 2 | 2018-10-01 15:16:26 |\n",
"| 7 | 1 | 1 | 1 | 4 | 12.3433 | 11.8439 | 3 | 2018-10-01 15:16:27 |\n",
"| 8 | 2 | 1 | ab | 6 | 12.3433 | 11.8439 | 3 | 2018-10-01 15:16:27 |\n",
"| 9 | 3 | 1 | ['c', 'd'] | [ 30 300] | 12.3433 | 11.8439 | 3 | 2018-10-01 15:16:27 |\n",
"| 10 | 1 | 1 | 1 | 4 | 10.9634 | 13.8687 | 4 | 2018-10-01 15:16:28 |\n",
"| 11 | 2 | 1 | ab | 6 | 10.9634 | 13.8687 | 4 | 2018-10-01 15:16:28 |\n",
"| 12 | 3 | 1 | ['c', 'd'] | [ 30 300] | 10.9634 | 13.8687 | 4 | 2018-10-01 15:16:28 |\n",
"| 13 | 1 | 1 | 1 | 4 | 11.5544 | 13.9381 | 5 | 2018-10-01 15:16:29 |\n",
"| 14 | 2 | 1 | ab | 6 | 11.5544 | 13.9381 | 5 | 2018-10-01 15:16:29 |\n",
"| 15 | 3 | 1 | ['c', 'd'] | [ 30 300] | 11.5544 | 13.9381 | 5 | 2018-10-01 15:16:29 |\n",
"| 16 | 0 | 2 | 0 | 0 | 1 | 1 | 0 | 2018-10-01 15:16:24 |\n",
"| 17 | 1 | 2 | 1 | 4 | 10 | 10 | 1 | 2018-10-01 15:16:25 |\n",
"| 18 | 2 | 2 | ab | 6 | 10 | 10 | 1 | 2018-10-01 15:16:25 |\n",
"| 19 | 3 | 2 | ['c', 'd'] | [ 30 300] | 10 | 10 | 1 | 2018-10-01 15:16:25 |\n",
"| 20 | 1 | 2 | 1 | 4 | 9.98087 | 9.45464 | 2 | 2018-10-01 15:16:26 |\n",
"| 21 | 2 | 2 | ab | 6 | 9.98087 | 9.45464 | 2 | 2018-10-01 15:16:26 |\n",
"| 22 | 3 | 2 | ['c', 'd'] | [ 30 300] | 9.98087 | 9.45464 | 2 | 2018-10-01 15:16:26 |\n",
"| 23 | 1 | 2 | 1 | 4 | 11.1536 | 7.9925 | 3 | 2018-10-01 15:16:27 |\n",
"| 24 | 2 | 2 | ab | 6 | 11.1536 | 7.9925 | 3 | 2018-10-01 15:16:27 |\n",
"| 25 | 3 | 2 | ['c', 'd'] | [ 30 300] | 11.1536 | 7.9925 | 3 | 2018-10-01 15:16:27 |\n",
"| 26 | 1 | 2 | 1 | 4 | 10.3195 | 8.77766 | 4 | 2018-10-01 15:16:28 |\n",
"| 27 | 2 | 2 | ab | 6 | 10.3195 | 8.77766 | 4 | 2018-10-01 15:16:28 |\n",
"| 28 | 3 | 2 | ['c', 'd'] | [ 30 300] | 10.3195 | 8.77766 | 4 | 2018-10-01 15:16:28 |\n",
"| 29 | 1 | 2 | 1 | 4 | 10.3288 | 7.81118 | 5 | 2018-10-01 15:16:29 |\n",
"| 30 | 2 | 2 | ab | 6 | 10.3288 | 7.81118 | 5 | 2018-10-01 15:16:29 |\n",
"| 31 | 3 | 2 | ['c', 'd'] | [ 30 300] | 10.3288 | 7.81118 | 5 | 2018-10-01 15:16:29 |\n",
"+----+-------------+-------+------------+-----------+----------+----------+-------------+---------------------+\n",
"+----+-------------+-------+------------+-----------+----------+----------+-------------+---------------------+\n",
"| | mech_step | run | s1 | s2 | s3 | s4 | time_step | timestamp |\n",
"|----+-------------+-------+------------+-----------+----------+----------+-------------+---------------------|\n",
"| 0 | 0 | 2 | 0 | 0 | 1 | 1 | 0 | 2018-10-01 15:16:24 |\n",
"| 1 | 1 | 1 | 1 | 0 | 10 | 10 | 1 | 2018-10-01 15:16:25 |\n",
"| 2 | 2 | 1 | ab | 0 | 10 | 10 | 1 | 2018-10-01 15:16:25 |\n",
"| 3 | 3 | 1 | ['c', 'd'] | [ 30 300] | 10 | 10 | 1 | 2018-10-01 15:16:25 |\n",
"| 4 | 1 | 1 | 1 | [ 30 300] | 9.94373 | 10.4365 | 2 | 2018-10-01 15:16:26 |\n",
"| 5 | 2 | 1 | ab | [ 30 300] | 9.94373 | 10.4365 | 2 | 2018-10-01 15:16:26 |\n",
"| 6 | 3 | 1 | ['c', 'd'] | [ 30 300] | 9.94373 | 10.4365 | 2 | 2018-10-01 15:16:26 |\n",
"| 7 | 1 | 1 | 1 | [ 30 300] | 7.81956 | 10.5372 | 3 | 2018-10-01 15:16:27 |\n",
"| 8 | 2 | 1 | ab | [ 30 300] | 7.81956 | 10.5372 | 3 | 2018-10-01 15:16:27 |\n",
"| 9 | 3 | 1 | ['c', 'd'] | [ 30 300] | 7.81956 | 10.5372 | 3 | 2018-10-01 15:16:27 |\n",
"| 10 | 1 | 1 | 1 | [ 30 300] | 9.10218 | 8.57362 | 4 | 2018-10-01 15:16:28 |\n",
"| 11 | 2 | 1 | ab | [ 30 300] | 9.10218 | 8.57362 | 4 | 2018-10-01 15:16:28 |\n",
"| 12 | 3 | 1 | ['c', 'd'] | [ 30 300] | 9.10218 | 8.57362 | 4 | 2018-10-01 15:16:28 |\n",
"| 13 | 1 | 1 | 1 | [ 30 300] | 7.46976 | 8.33579 | 5 | 2018-10-01 15:16:29 |\n",
"| 14 | 2 | 1 | ab | [ 30 300] | 7.46976 | 8.33579 | 5 | 2018-10-01 15:16:29 |\n",
"| 15 | 3 | 1 | ['c', 'd'] | [ 30 300] | 7.46976 | 8.33579 | 5 | 2018-10-01 15:16:29 |\n",
"| 16 | 0 | 2 | 0 | 0 | 1 | 1 | 0 | 2018-10-01 15:16:24 |\n",
"| 17 | 1 | 2 | 1 | 0 | 10 | 10 | 1 | 2018-10-01 15:16:25 |\n",
"| 18 | 2 | 2 | ab | 0 | 10 | 10 | 1 | 2018-10-01 15:16:25 |\n",
"| 19 | 3 | 2 | ['c', 'd'] | [ 30 300] | 10 | 10 | 1 | 2018-10-01 15:16:25 |\n",
"| 20 | 1 | 2 | 1 | [ 30 300] | 10.5029 | 9.91726 | 2 | 2018-10-01 15:16:26 |\n",
"| 21 | 2 | 2 | ab | [ 30 300] | 10.5029 | 9.91726 | 2 | 2018-10-01 15:16:26 |\n",
"| 22 | 3 | 2 | ['c', 'd'] | [ 30 300] | 10.5029 | 9.91726 | 2 | 2018-10-01 15:16:26 |\n",
"| 23 | 1 | 2 | 1 | [ 30 300] | 9.19497 | 9.29545 | 3 | 2018-10-01 15:16:27 |\n",
"| 24 | 2 | 2 | ab | [ 30 300] | 9.19497 | 9.29545 | 3 | 2018-10-01 15:16:27 |\n",
"| 25 | 3 | 2 | ['c', 'd'] | [ 30 300] | 9.19497 | 9.29545 | 3 | 2018-10-01 15:16:27 |\n",
"| 26 | 1 | 2 | 1 | [ 30 300] | 8.22219 | 9.25471 | 4 | 2018-10-01 15:16:28 |\n",
"| 27 | 2 | 2 | ab | [ 30 300] | 8.22219 | 9.25471 | 4 | 2018-10-01 15:16:28 |\n",
"| 28 | 3 | 2 | ['c', 'd'] | [ 30 300] | 8.22219 | 9.25471 | 4 | 2018-10-01 15:16:28 |\n",
"| 29 | 1 | 2 | 1 | [ 30 300] | 7.47478 | 8.81306 | 5 | 2018-10-01 15:16:29 |\n",
"| 30 | 2 | 2 | ab | [ 30 300] | 7.47478 | 8.81306 | 5 | 2018-10-01 15:16:29 |\n",
"| 31 | 3 | 2 | ['c', 'd'] | [ 30 300] | 7.47478 | 8.81306 | 5 | 2018-10-01 15:16:29 |\n",
"+----+-------------+-------+------------+-----------+----------+----------+-------------+---------------------+\n",
"\n"
]
}
],
"source": [
"from engine import run\n",
"run.main()"
"import pandas as pd\n",
"from tabulate import tabulate\n",
"\n",
"from SimCAD.engine import ExecutionMode, ExecutionContext, Executor\n",
"from sandboxUX import config1, config2\n",
"from SimCAD import configs\n",
"\n",
"# ToDo: pass ExecutionContext with execution method as ExecutionContext input\n",
"\n",
"exec_mode = ExecutionMode()\n",
"\n",
"print(\"Simulation Run 1\")\n",
"print()\n",
"single_config = [configs[0]]\n",
"single_proc_ctx = ExecutionContext(exec_mode.single_proc)\n",
"run1 = Executor(single_proc_ctx, single_config)\n",
"run1_raw_result = run1.main()\n",
"result = pd.DataFrame(run1_raw_result)\n",
"print(tabulate(result, headers='keys', tablefmt='psql'))\n",
"print()\n",
"\n",
"print(\"Simulation Run 2: Pairwise Execution\")\n",
"print()\n",
"multi_proc_ctx = ExecutionContext(exec_mode.multi_proc)\n",
"run2 = Executor(multi_proc_ctx, configs)\n",
"run2_raw_results = run2.main()\n",
"for raw_result in run2_raw_results:\n",
" result = pd.DataFrame(raw_result)\n",
" print(tabulate(result, headers='keys', tablefmt='psql'))\n",
"print()"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {