reorg and cleanup
This commit is contained in:
parent
bdbda2685d
commit
437fd81f08
|
|
@ -11,7 +11,7 @@
|
|||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"single_proc: [<SimCAD.configuration.Configuration object at 0x10e8bb940>]\n"
|
||||
"single_proc: [<SimCAD.configuration.Configuration object at 0x10defb4a8>]\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
|
@ -126,7 +126,7 @@
|
|||
"from tabulate import tabulate\n",
|
||||
"\n",
|
||||
"from SimCAD.engine import ExecutionMode, ExecutionContext, Executor\n",
|
||||
"from simulations.demo import simple_tracker\n",
|
||||
"from demos import simple_tracker_config\n",
|
||||
"from SimCAD import configs\n",
|
||||
"\n",
|
||||
"exec_mode = ExecutionMode()\n",
|
||||
|
|
@ -147,7 +147,7 @@
|
|||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"<matplotlib.axes._subplots.AxesSubplot at 0x10e8d9e10>"
|
||||
"<matplotlib.axes._subplots.AxesSubplot at 0x10df22cf8>"
|
||||
]
|
||||
},
|
||||
"execution_count": 2,
|
||||
File diff suppressed because it is too large
Load Diff
|
|
@ -1,42 +0,0 @@
|
|||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 1,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import pandas as pd\n",
|
||||
"assert pd.__version__ == '0.23.4'"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": []
|
||||
}
|
||||
],
|
||||
"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.7.0"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 2
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
|
@ -1,482 +0,0 @@
|
|||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## SimCAD Application Notebook\n",
|
||||
"## Experiment Type 2"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"### Name of Config File or System Description\n",
|
||||
"#### 20 MonteCarlo Runs \n",
|
||||
"#### Behaviors: EMHers, Herders, HODLers, EIUers, and Human EIUers"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 1,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"Simulation Run 1\n",
|
||||
"single_proc: [<SimCAD.Configuration object at 0x000001EA1AAA6630>]\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"ename": "TypeError",
|
||||
"evalue": "unsupported operand type(s) for *: 'float' and 'decimal.Decimal'",
|
||||
"output_type": "error",
|
||||
"traceback": [
|
||||
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
|
||||
"\u001b[1;31mTypeError\u001b[0m Traceback (most recent call last)",
|
||||
"\u001b[1;32m<ipython-input-1-0d9ea96d7f5c>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m()\u001b[0m\n\u001b[0;32m 15\u001b[0m \u001b[0msingle_proc_ctx\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mExecutionContext\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mexec_mode\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0msingle_proc\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 16\u001b[0m \u001b[0mrun1\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mExecutor\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0msingle_proc_ctx\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0msingle_config\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m---> 17\u001b[1;33m \u001b[0mrun1_raw_result\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mrun1\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[0m\u001b[0;32m 18\u001b[0m \u001b[0mdf\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mpd\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mDataFrame\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mrun1_raw_result\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 19\u001b[0m \u001b[1;31m# print(tabulate(result, headers='keys', tablefmt='psql'))\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
|
||||
"\u001b[1;32m~\\staging\\21f1155\\SimCAD\\engine\\__init__.py\u001b[0m in \u001b[0;36mexecute\u001b[1;34m(self)\u001b[0m\n\u001b[0;32m 71\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 72\u001b[0m \u001b[1;32mif\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mexec_context\u001b[0m \u001b[1;33m==\u001b[0m \u001b[0mExecutionMode\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0msingle_proc\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m---> 73\u001b[1;33m \u001b[1;32mreturn\u001b[0m \u001b[0msingle_proc_exec\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0msimulation_execs\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mstates_lists\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mconfigs_structs\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0menv_processes_list\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mTs\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mNs\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 74\u001b[0m \u001b[1;32melif\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mexec_context\u001b[0m \u001b[1;33m==\u001b[0m \u001b[0mExecutionMode\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mmulti_proc\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 75\u001b[0m \u001b[1;32mif\u001b[0m \u001b[0mlen\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mconfigs\u001b[0m\u001b[1;33m)\u001b[0m \u001b[1;33m>\u001b[0m \u001b[1;36m1\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
|
||||
"\u001b[1;32m~\\staging\\21f1155\\SimCAD\\engine\\__init__.py\u001b[0m in \u001b[0;36msingle_proc_exec\u001b[1;34m(simulation_execs, states_lists, configs_structs, env_processes_list, Ts, Ns)\u001b[0m\n\u001b[0;32m 67\u001b[0m \u001b[0msimulation\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mstates_list\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mconfig\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0menv_processes\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mT\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mN\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mlist\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mmap\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;32mlambda\u001b[0m \u001b[0mx\u001b[0m\u001b[1;33m:\u001b[0m \u001b[0mx\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mpop\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0ml\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 68\u001b[0m \u001b[1;31m# print(states_list)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m---> 69\u001b[1;33m \u001b[0mresult\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0msimulation\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mstates_list\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mconfig\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0menv_processes\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mT\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mN\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 70\u001b[0m \u001b[1;32mreturn\u001b[0m \u001b[0mflatten\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mresult\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 71\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n",
|
||||
"\u001b[1;32m~\\staging\\21f1155\\SimCAD\\engine\\simulation.py\u001b[0m in \u001b[0;36msimulation\u001b[1;34m(self, states_list, configs, env_processes, time_seq, runs)\u001b[0m\n\u001b[0;32m 100\u001b[0m \u001b[1;31m# print(\"Run: \"+str(run))\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 101\u001b[0m \u001b[0mstates_list_copy\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mdeepcopy\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mstates_list\u001b[0m\u001b[1;33m)\u001b[0m \u001b[1;31m# WHY ???\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 102\u001b[1;33m \u001b[0mhead\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;33m*\u001b[0m\u001b[0mtail\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mpipe\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mstates_list_copy\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mconfigs\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0menv_processes\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mtime_seq\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mrun\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 103\u001b[0m \u001b[0mgenesis\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mhead\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mpop\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 104\u001b[0m \u001b[0mgenesis\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;34m'mech_step'\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mgenesis\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;34m'time_step'\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mgenesis\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;34m'run'\u001b[0m\u001b[1;33m]\u001b[0m \u001b[1;33m=\u001b[0m \u001b[1;36m0\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;36m0\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mrun\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
|
||||
"\u001b[1;32m~\\staging\\21f1155\\SimCAD\\engine\\simulation.py\u001b[0m in \u001b[0;36mpipe\u001b[1;34m(self, states_list, configs, env_processes, time_seq, run)\u001b[0m\n\u001b[0;32m 86\u001b[0m \u001b[1;32mfor\u001b[0m \u001b[0mtime_step\u001b[0m \u001b[1;32min\u001b[0m \u001b[0mtime_seq\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 87\u001b[0m \u001b[1;31m# print(run)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m---> 88\u001b[1;33m \u001b[0mpipe_run\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mblock_gen\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0msimulation_list\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;33m-\u001b[0m\u001b[1;36m1\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mconfigs\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0menv_processes\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mtime_step\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mrun\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 89\u001b[0m \u001b[0m_\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;33m*\u001b[0m\u001b[0mpipe_run\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mpipe_run\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 90\u001b[0m \u001b[0msimulation_list\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mappend\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mpipe_run\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
|
||||
"\u001b[1;32m~\\staging\\21f1155\\SimCAD\\engine\\simulation.py\u001b[0m in \u001b[0;36mblock_gen\u001b[1;34m(self, states_list, configs, env_processes, t_step, run)\u001b[0m\n\u001b[0;32m 72\u001b[0m \u001b[1;32mfor\u001b[0m \u001b[0mconfig\u001b[0m \u001b[1;32min\u001b[0m \u001b[0mconfigs\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 73\u001b[0m \u001b[0ms_conf\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mb_conf\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mconfig\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;36m0\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mconfig\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;36m1\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m---> 74\u001b[1;33m \u001b[0mstates_list\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mmech_step\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mm_step\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mstates_list\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0ms_conf\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mb_conf\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0menv_processes\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mt_step\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mrun\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 75\u001b[0m \u001b[0mm_step\u001b[0m \u001b[1;33m+=\u001b[0m \u001b[1;36m1\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 76\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n",
|
||||
"\u001b[1;32m~\\staging\\21f1155\\SimCAD\\engine\\simulation.py\u001b[0m in \u001b[0;36mmech_step\u001b[1;34m(self, m_step, sL, state_funcs, behavior_funcs, env_processes, t_step, run)\u001b[0m\n\u001b[0;32m 42\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 43\u001b[0m \u001b[1;31m# *** add env_proc value here as wrapper function ***\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m---> 44\u001b[1;33m \u001b[0mlast_in_copy\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mdict\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m[\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mexception_handler\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mf\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mm_step\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0msL\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mlast_in_obj\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0m_input\u001b[0m\u001b[1;33m)\u001b[0m \u001b[1;32mfor\u001b[0m \u001b[0mf\u001b[0m \u001b[1;32min\u001b[0m \u001b[0mstate_funcs\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 45\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 46\u001b[0m \u001b[1;32mfor\u001b[0m \u001b[0mk\u001b[0m \u001b[1;32min\u001b[0m \u001b[0mlast_in_obj\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
|
||||
"\u001b[1;32m~\\staging\\21f1155\\SimCAD\\engine\\simulation.py\u001b[0m in \u001b[0;36m<listcomp>\u001b[1;34m(.0)\u001b[0m\n\u001b[0;32m 42\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 43\u001b[0m \u001b[1;31m# *** add env_proc value here as wrapper function ***\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m---> 44\u001b[1;33m \u001b[0mlast_in_copy\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mdict\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m[\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mexception_handler\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mf\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mm_step\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0msL\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mlast_in_obj\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0m_input\u001b[0m\u001b[1;33m)\u001b[0m \u001b[1;32mfor\u001b[0m \u001b[0mf\u001b[0m \u001b[1;32min\u001b[0m \u001b[0mstate_funcs\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 45\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 46\u001b[0m \u001b[1;32mfor\u001b[0m \u001b[0mk\u001b[0m \u001b[1;32min\u001b[0m \u001b[0mlast_in_obj\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
|
||||
"\u001b[1;32m~\\staging\\21f1155\\SimCAD\\engine\\simulation.py\u001b[0m in \u001b[0;36mexception_handler\u001b[1;34m(self, f, m_step, sL, last_mut_obj, _input)\u001b[0m\n\u001b[0;32m 28\u001b[0m \u001b[1;32mdef\u001b[0m \u001b[0mexception_handler\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mf\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mm_step\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0msL\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mlast_mut_obj\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0m_input\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 29\u001b[0m \u001b[1;32mtry\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m---> 30\u001b[1;33m \u001b[1;32mreturn\u001b[0m \u001b[0mf\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mm_step\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0msL\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mlast_mut_obj\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0m_input\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 31\u001b[0m \u001b[1;32mexcept\u001b[0m \u001b[0mKeyError\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 32\u001b[0m \u001b[0mprint\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m\"Exception\"\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
|
||||
"\u001b[1;32m~\\staging\\21f1155\\sandboxUX\\config6b.py\u001b[0m in \u001b[0;36ms2m3\u001b[1;34m(step, sL, s, _input)\u001b[0m\n\u001b[0;32m 179\u001b[0m \u001b[0my\u001b[0m \u001b[1;33m=\u001b[0m \u001b[1;34m'Price'\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 180\u001b[0m \u001b[1;31m#var1 = Decimal.from_float(s['Buy_Log'])\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 181\u001b[1;33m \u001b[0mx\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0ms\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;34m'Price'\u001b[0m\u001b[1;33m]\u001b[0m \u001b[1;33m+\u001b[0m \u001b[0ms\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;34m'Buy_Log'\u001b[0m\u001b[1;33m]\u001b[0m \u001b[1;33m/\u001b[0m \u001b[1;33m(\u001b[0m\u001b[0ms\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;34m'Z'\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m)\u001b[0m \u001b[1;33m-\u001b[0m \u001b[1;36m0.1\u001b[0m \u001b[1;33m*\u001b[0m \u001b[0ms\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;34m'Sell_Log'\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m/\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0ms\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;34m'Z'\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m+\u001b[0m \u001b[0ms\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;34m'Buy_Log'\u001b[0m\u001b[1;33m]\u001b[0m \u001b[1;33m+\u001b[0m \u001b[0ms\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;34m'Sell_Log'\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 182\u001b[0m \u001b[1;31m#+ np.divide(s['Buy_Log'],s['Z']) - np.divide() # / Psignal_int\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 183\u001b[0m \u001b[1;32mreturn\u001b[0m \u001b[1;33m(\u001b[0m\u001b[0my\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mx\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
|
||||
"\u001b[1;31mTypeError\u001b[0m: unsupported operand type(s) for *: 'float' and 'decimal.Decimal'"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"import pandas as pd\n",
|
||||
"from tabulate import tabulate\n",
|
||||
"\n",
|
||||
"from SimCAD.engine import ExecutionMode, ExecutionContext, Executor\n",
|
||||
"from sandboxUX import config6b #, 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",
|
||||
"df = 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": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"#df = pd.DataFrame(run1_raw_result)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"df.head()"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# Standard Library Imports\n",
|
||||
"#import pandas as pd\n",
|
||||
"import numpy as np\n",
|
||||
"import matplotlib as mpl\n",
|
||||
"import matplotlib.pyplot as plt\n",
|
||||
"import seaborn as sns\n",
|
||||
"#from tabulate import tabulate\n",
|
||||
"\n",
|
||||
"sns.set_style('whitegrid')\n",
|
||||
"\n",
|
||||
"%matplotlib inline"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# SimCAD Specific\n",
|
||||
"# from SimCAD.engine import ExecutionMode, ExecutionContext, Executor\n",
|
||||
"# from sandboxUX import config1 , config2\n",
|
||||
"# from SimCAD import configs"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"#Convert data type of output to float. MPL works OK with strings, seaborn does not\n",
|
||||
"names = df.keys()[:-3] # [:-3] only affects state variables\n",
|
||||
"for n in names:\n",
|
||||
" df[n]=df[n].apply(float)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"#Check\n",
|
||||
"df.head(10)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"df.iloc[2995:3005]"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"df.tail(10)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"df.corr()"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"aggregate_dimension = 'time_step'\n",
|
||||
"\n",
|
||||
"mean_df = df.groupby(aggregate_dimension).mean().reset_index()\n",
|
||||
"median_df = df.groupby(aggregate_dimension).median().reset_index()\n",
|
||||
"std_df = df.groupby(aggregate_dimension).std().reset_index()\n",
|
||||
"min_df = df.groupby(aggregate_dimension).min().reset_index()"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"mean_df.head(10)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"scrolled": true
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"mean_df.tail(10)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"def dist_plot(x, y,lx=False,ly=False, suppMin=False): \n",
|
||||
" plt.figure(figsize=(12,8))\n",
|
||||
" if not(suppMin):\n",
|
||||
" plt.plot(mean_df[x].values, mean_df[y].values,\n",
|
||||
" mean_df[x].values,median_df[y].values,\n",
|
||||
" mean_df[x].values,mean_df[y].values+std_df[y].values,\n",
|
||||
" mean_df[x].values,min_df[y].values)\n",
|
||||
" plt.legend(['mean', 'median', 'mean+ 1*std', 'min'],bbox_to_anchor=(1.05, 1), loc=2, borderaxespad=0.)\n",
|
||||
" \n",
|
||||
" else:\n",
|
||||
" plt.plot(mean_df[x].values, mean_df[y].values,\n",
|
||||
" mean_df[x].values,median_df[y].values,\n",
|
||||
" mean_df[x].values,mean_df[y].values+std_df[y].values,\n",
|
||||
" mean_df[x].values,mean_df[y].values-std_df[y].values)\n",
|
||||
" plt.legend(['mean', 'median', 'mean+ 1*std', 'mean - 1*std'],bbox_to_anchor=(1.05, 1), loc=2, borderaxespad=0.)\n",
|
||||
"\n",
|
||||
" plt.xlabel(x)\n",
|
||||
" plt.ylabel(y)\n",
|
||||
" if lx:\n",
|
||||
" plt.xscale('log')\n",
|
||||
" \n",
|
||||
" if ly:\n",
|
||||
" plt.yscale('log')"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"dist_plot('time_step', 'P_Ext_Markets',suppMin=True)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"dist_plot('time_step', 'Price',suppMin=True)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"plt.figure(figsize=(12,8))\n",
|
||||
"plt.plot(mean_df['time_step'][1:],mean_df['Price'][1:]) #, df['Zeus_LT']], figsize=(15,10)) #, logy=True)\n",
|
||||
"plt.plot(mean_df['time_step'][1:],(1/250)*mean_df['P_Ext_Markets'][1:])\n",
|
||||
"#plt.plot(df['time_step'],df['Zeus_LT'])\n",
|
||||
"plt.legend(bbox_to_anchor=(1.05, 1), loc=2, borderaxespad=0.)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"print(np.std(mean_df))"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"plt.figure(figsize=(12,8))\n",
|
||||
"plt.plot(mean_df['time_step'][1:],mean_df['Buy_Log'][1:]) #, df['Zeus_LT']], figsize=(15,10)) #, logy=True)\n",
|
||||
"plt.plot(mean_df['time_step'][1:],mean_df['Sell_Log'][1:])\n",
|
||||
"#plt.plot(df['time_step'],df['Zeus_LT'])\n",
|
||||
"plt.legend(bbox_to_anchor=(1.05, 1), loc=2, borderaxespad=0.)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"buy_delta = mean_df['Buy_Log'].diff()\n",
|
||||
"sell_delta = mean_df['Sell_Log'].diff()\n",
|
||||
"ext_delta = mean_df['P_Ext_Markets'].diff()\n",
|
||||
"# df_delta['Buy_Log'] = buy_delta\n",
|
||||
"# df_delta['Sell_Log'] = sell_delta\n",
|
||||
"# df_delta = df_delta.append(ext_delta)\n",
|
||||
"# df_delta.head()\n",
|
||||
"sell_delta.head(20)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"plt.figure(figsize=(12,8))\n",
|
||||
"plt.plot(mean_df['time_step'][1:],buy_delta[1:]) #, df['Zeus_LT']], figsize=(15,10)) #, logy=True)\n",
|
||||
"plt.plot(mean_df['time_step'][1:],sell_delta[1:])\n",
|
||||
"plt.plot(mean_df['time_step'][1:],ext_delta[1:])\n",
|
||||
"plt.ylim(-400,400)\n",
|
||||
"#plt.plot(df['time_step'],df['Zeus_LT'])\n",
|
||||
"plt.legend(bbox_to_anchor=(1.05, 1), loc=2, borderaxespad=0.)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"sns.pairplot(mean_df)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"plt.figure(figsize=(12,8))\n",
|
||||
"plt.plot(mean_df['time_step'],mean_df['Z']/mean_df['P_Ext_Markets'])\n",
|
||||
"plt.title('Z per External Stock Market Price')"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# plt.figure(figsize=(12,8))\n",
|
||||
"# plt.plot(df['time_step'],(df['TDR_Int']-df['TDR_Ext'])/df['TDR_Ext'])\n",
|
||||
"# plt.title('Availability of TDR arbitrage opportunity')"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# plt.figure(figsize=(12,8))\n",
|
||||
"# plt.plot(df['time_step'],(df['Zeus_LT']/df['Zeus_ST']-1))\n",
|
||||
"# plt.title('Availability of LT vs ST arbitrage opportunity')"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# vol_df = df.rolling(window = 21).mean()\n",
|
||||
"vol_df = pd.DataFrame()\n",
|
||||
"rolling_days = 63 # days = number * mechanisms\n",
|
||||
"for n in names:\n",
|
||||
" vol_df[n] = mean_df[n].rolling(rolling_days).mean().shift()\n",
|
||||
" \n",
|
||||
"vol_df = vol_df.dropna() #(vol_df.iloc[0:rolling_days])\n",
|
||||
"# vol_df[n].iloc[:rolling_days], axis=1)\n",
|
||||
"vol_df.head()"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"plt.figure(figsize=(12,8))\n",
|
||||
"plt.plot(vol_df['Z'])\n",
|
||||
"plt.title('Rolling Average of Z')"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"plt.figure(figsize=(12,8))\n",
|
||||
"plt.plot(vol_df['P_Ext_Markets'])\n",
|
||||
"plt.title('Rolling Average of External Stock Market Price')"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"plt.figure(figsize=(12,8))\n",
|
||||
"plt.plot(vol_df['Price'])\n",
|
||||
"plt.plot(vol_df['P_Ext_Markets']/250)\n",
|
||||
"plt.legend()\n",
|
||||
"plt.title('Rolling Average of Zeus Price')"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"df[\"Price\"].min()"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"df[\"Price\"].max()"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": []
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": []
|
||||
}
|
||||
],
|
||||
"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
|
||||
}
|
||||
Loading…
Reference in New Issue