From 577ac24b9659e0601a7e03f2162869df28879d28 Mon Sep 17 00:00:00 2001 From: "Joshua E. Jodesty" Date: Tue, 9 Oct 2018 15:12:10 -0400 Subject: [PATCH] init packaging --- engine/__init__.py | 0 engine/configProcessor.py | 13 + engine/mechanismExecutor.py | 79 + engine/run.py | 16 + engine/utils.py | 54 + .../CAD_Engine-checkpoint.ipynb | 1544 +++++++++++++++++ .../CAD_Engine.ipynb | 132 +- .../Sim_CAD_Engine.ipynb | 0 .../TestNotebook.ipynb | 0 setup.py | 0 ui/__pycache__/config.cpython-36.pyc | Bin 0 -> 3245 bytes ui/config.py | 120 ++ ui/test.py | 2 + 13 files changed, 1853 insertions(+), 107 deletions(-) create mode 100644 engine/__init__.py create mode 100644 engine/configProcessor.py create mode 100644 engine/mechanismExecutor.py create mode 100644 engine/run.py create mode 100644 engine/utils.py create mode 100644 notebooks/.ipynb_checkpoints/CAD_Engine-checkpoint.ipynb rename CAD_Engine.ipynb => notebooks/CAD_Engine.ipynb (94%) rename Sim_CAD_Engine.ipynb => notebooks/Sim_CAD_Engine.ipynb (100%) rename TestNotebook.ipynb => notebooks/TestNotebook.ipynb (100%) create mode 100644 setup.py create mode 100644 ui/__pycache__/config.cpython-36.pyc create mode 100644 ui/config.py create mode 100644 ui/test.py diff --git a/engine/__init__.py b/engine/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/engine/configProcessor.py b/engine/configProcessor.py new file mode 100644 index 0000000..5d4c0be --- /dev/null +++ b/engine/configProcessor.py @@ -0,0 +1,13 @@ +# if beh list empty, repeat 0 x n_states in list +def generate_config(mechanisms, exogenous_states): + es_funcs = [exogenous_states[state] for state in list(exogenous_states.keys())] + config = list( + map( + lambda m: ( + list(mechanisms[m]["states"].values()) + es_funcs, + list(mechanisms[m]["behaviors"].values()) + ), + list(mechanisms.keys()) + ) + ) + return config \ No newline at end of file diff --git a/engine/mechanismExecutor.py b/engine/mechanismExecutor.py new file mode 100644 index 0000000..b3fe0f3 --- /dev/null +++ b/engine/mechanismExecutor.py @@ -0,0 +1,79 @@ +from copy import deepcopy +from fn import op, _ + +def getColResults(step, sL, s, funcs): + return list(map(lambda f: f(step, sL, s), funcs)) + + +def getBehaviorInput(step, sL, s, funcs): + return op.foldr(_ + _)(getColResults(step, sL, s, funcs)) + + +def apply_env_proc(env_processes, state_dict, step): + for state in state_dict.keys(): + if state in list(env_processes.keys()): + state_dict[state] = env_processes[state](step)(state_dict[state]) + + +def mech_step(m_step, sL, state_funcs, behavior_funcs, env_processes, t_step): + in_copy, mutatable_copy, out_copy = deepcopy(sL), deepcopy(sL), deepcopy(sL) + last_in_obj, last_mut_obj = in_copy[-1], mutatable_copy[-1] + + _input = getBehaviorInput(m_step, sL, last_in_obj, behavior_funcs) + + for f in state_funcs: + f(m_step, sL, last_mut_obj, _input) + + apply_env_proc(env_processes, last_mut_obj, last_mut_obj['timestamp']) + + last_mut_obj["mech_step"], last_mut_obj["time_step"] = m_step, t_step + out_copy.append(last_mut_obj) + + del last_in_obj, last_mut_obj, in_copy, mutatable_copy, + + return out_copy + + +def block_gen(states_list, configs, env_processes, t_step): + m_step = 0 + states_list_copy = deepcopy(states_list) + genesis_states = states_list_copy[-1] + genesis_states['mech_step'], genesis_states['time_step'] = m_step, t_step + states_list = [genesis_states] + + m_step += 1 + for config in configs: + s_conf, b_conf = config[0], config[1] + states_list = mech_step(m_step, states_list, s_conf, b_conf, env_processes, t_step) + m_step += 1 + + t_step += 1 + + return states_list + + +def pipeline(states_list, configs, env_processes, time_seq): + time_seq = [x + 1 for x in time_seq] + simulation_list = [states_list] + for time_step in time_seq: + pipeline_run = block_gen(simulation_list[-1], configs, env_processes, time_step) + head, *pipeline_run = pipeline_run + simulation_list.append(pipeline_run) + + return simulation_list + + +def simulation(states_list, configs, env_processes, time_seq, runs): + pipeline_run = [] + for run in range(runs): + if run == 0: + head, *tail = pipeline(states_list, configs, env_processes, time_seq) + head[-1]['mech_step'], head[-1]['time_step'] = 0, 0 + simulation_list = [head] + tail + pipeline_run += simulation_list + else: + transient_states_list = [pipeline_run[-1][-1]] + head, *tail = pipeline(transient_states_list, configs, env_processes, time_seq) + pipeline_run += tail + + return pipeline_run \ No newline at end of file diff --git a/engine/run.py b/engine/run.py new file mode 100644 index 0000000..f9bacf4 --- /dev/null +++ b/engine/run.py @@ -0,0 +1,16 @@ +from ui.config import state_dict, mechanisms, exogenous_states, env_processes, sim_config +from engine.configProcessor import generate_config +from engine.mechanismExecutor import simulation +from engine.utils import flatten + +from tabulate import tabulate +import pandas as pd + +def main(): + states_list = [state_dict] + configs = generate_config(mechanisms, exogenous_states) + # p = pipeline(states_list, configs, env_processes, range(10)) + N = sim_config['N'] + s = simulation(states_list, configs, env_processes, range(5), N) + result = pd.DataFrame(flatten(s)) + print(tabulate(result, headers='keys', tablefmt='psql')) diff --git a/engine/utils.py b/engine/utils.py new file mode 100644 index 0000000..d040ba7 --- /dev/null +++ b/engine/utils.py @@ -0,0 +1,54 @@ +from datetime import datetime, timedelta +from decimal import Decimal +from functools import partial + +flatten = lambda l: [item for sublist in l for item in sublist] + +def flatmap(f, items): + return list(map(f, items)) + + +def datetime_range(start, end, delta, dt_format='%Y-%m-%d %H:%M:%S'): + reverse_head = end + [start, end] = [datetime.strptime(x, dt_format) for x in [start, end]] + + def _datetime_range(start, end, delta): + current = start + while current < end: + yield current + current += delta + + reverse_tail = [dt.strftime(dt_format) for dt in _datetime_range(start, end, delta)] + return reverse_tail + [reverse_head] + +def last_index(l): + return len(l)-1 + +def retrieve_state(l, offset): + return l[last_index(l) + offset + 1] + +def bound_norm_random(rng, low, high): + # Add RNG Seed + res = rng.normal((high+low)/2,(high-low)/6) + if (reshigh): + res = bound_norm_random(rng, low, high) + return Decimal(res) + +def env_proc(trigger_step, update_f): + def env_step_trigger(trigger_step, update_f, step): + if step == trigger_step: + return update_f + else: + return lambda x: x + return partial(env_step_trigger, trigger_step, update_f) + +def time_step(dt_str, dt_format='%Y-%m-%d %H:%M:%S', days=0, minutes=0, seconds=30): + dt = datetime.strptime(dt_str, dt_format) + t = dt + timedelta(days=days, minutes=minutes, seconds=seconds) + return t.strftime(dt_format) + +def ep_time_step(s, dt_str, fromat_str='%Y-%m-%d %H:%M:%S', days=0, minutes=0, seconds=1): + if s['mech_step'] == 0: + return time_step(dt_str, fromat_str, days, minutes, seconds) + else: + return dt_str \ No newline at end of file diff --git a/notebooks/.ipynb_checkpoints/CAD_Engine-checkpoint.ipynb b/notebooks/.ipynb_checkpoints/CAD_Engine-checkpoint.ipynb new file mode 100644 index 0000000..ae29c4b --- /dev/null +++ b/notebooks/.ipynb_checkpoints/CAD_Engine-checkpoint.ipynb @@ -0,0 +1,1544 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 1, + "metadata": {}, + "outputs": [], + "source": [ + "from fn import op, _, F\n", + "from operator import add, mul\n", + "from itertools import repeat, chain\n", + "from functools import reduce\n", + "# from objproxies import LazyProxy\n", + "import json\n", + "from copy import deepcopy, copy\n", + "from pipetools import pipe\n", + "from functools import partial\n", + "import numpy as np\n", + "from datetime import datetime, timedelta\n", + "from decimal import Decimal, getcontext, ROUND_DOWN\n", + "TWOPLACES = Decimal(10) ** -2 # same as Decimal('0.01')\n", + "import pandas as pd\n", + "import pprint\n", + "# getcontext().prec=None\n", + "# getcontext().rounding = ROUND_DOWN" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": {}, + "outputs": [], + "source": [ + "flatten = lambda l: [item for sublist in l for item in sublist]\n", + "\n", + "def flatmap(f, items):\n", + " return list(map(f, items))\n", + " \n", + "def datetime_range(start, end, delta, dt_format='%Y-%m-%d %H:%M:%S'):\n", + " reverse_head = end\n", + " [start, end] = [datetime.strptime(x, dt_format) for x in [start, end]]\n", + " def _datetime_range(start, end, delta):\n", + " current = start\n", + " while current < end:\n", + " yield current\n", + " current += delta\n", + " \n", + " reverse_tail = [dt.strftime(dt_format) for dt in _datetime_range(start, end, delta)]\n", + " return reverse_tail + [reverse_head]\n", + " \n", + "def last_index(l):\n", + " return len(l)-1\n", + "\n", + "def retrieve_state(l, offset):\n", + " return l[last_index(l) + offset + 1]\n", + "\n", + "def bound_norm_random(rng, low, high):\n", + " # Add RNG Seed\n", + " res = rng.normal((high+low)/2,(high-low)/6)\n", + " if (reshigh):\n", + " res = bound_norm_random(rng, low, high)\n", + " return Decimal(res)\n", + "\n", + "def env_proc(trigger_step, update_f):\n", + " def env_step_trigger(trigger_step, update_f, step):\n", + " if step == trigger_step:\n", + " return update_f\n", + " else:\n", + " return lambda x: x\n", + " return partial(env_step_trigger, trigger_step, update_f)\n", + "\n", + "def time_step(dt_str, dt_format='%Y-%m-%d %H:%M:%S', days=0, minutes=0, seconds=30):\n", + " dt = datetime.strptime(dt_str, dt_format)\n", + " t = dt + timedelta(days=days, minutes=minutes, seconds=seconds)\n", + " return t.strftime(dt_format)\n", + "\n", + "def ep_time_step(s, dt_str, fromat_str='%Y-%m-%d %H:%M:%S', days=0, minutes=0, seconds=1):\n", + " if s['mech_step'] == 0:\n", + " return time_step(dt_str, fromat_str, days, minutes, seconds)\n", + " else: \n", + " return dt_str\n", + "\n", + "def round_down(x, fp=TWOPLACES):\n", + " return x.quantize(TWOPLACES, rounding=ROUND_DOWN)" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": {}, + "outputs": [], + "source": [ + "# esceptions:\n", + "# point to line giving problems and pass a sentinel" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": {}, + "outputs": [], + "source": [ + "seed = {\n", + " 'z': np.random.RandomState(1),\n", + " 'a': np.random.RandomState(2),\n", + " 'b': np.random.RandomState(3),\n", + " 'c': np.random.RandomState(3)\n", + "}\n", + "\n", + "# UI 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", + "# UI Internal States per Mechanism\n", + "def s1m1(step, sL, s, _input):\n", + " s['s1'] = s['s1'] + _input\n", + "def s2m1(step, sL, s, _input):\n", + " s['s2'] = s['s2'] + _input\n", + "\n", + "def s1m2(step, sL, s, _input):\n", + " s['s1'] = s['s1'] + _input\n", + "def s2m2(step, sL, s, _input):\n", + " s['s2'] = s['s2'] + _input\n", + " \n", + "def s1m3(step, sL, s, _input):\n", + " s['s1'] = s['s1'] + _input\n", + "def s2m3(step, sL, s, _input):\n", + " s['s2'] = s['s2'] + _input\n", + "\n", + "# UI Exogenous States #per Mechanism\n", + "proc_one_coef_A = 0.7\n", + "proc_one_coef_B = 1.3\n", + "def es3p1(step, sL, s, _input):\n", + " s['s3'] = s['s3'] * bound_norm_random(seed['a'], proc_one_coef_A, proc_one_coef_B)\n", + "def es4p2(step, sL, s, _input):\n", + " s['s4'] = s['s4'] * bound_norm_random(seed['b'], proc_one_coef_A, proc_one_coef_B) \n", + "def es5p2(step, sL, s, _input):\n", + " s['timestamp'] = ep_time_step(s, s['timestamp'], seconds=1)\n", + "\n", + "def env_a(x): \n", + " return 10\n", + "def env_b(x): \n", + " return 10\n", + "def what_ever(x): \n", + " return x + 1\n", + "\n", + "# Genesis States \n", + "state_dict = {\n", + " 's1': Decimal(0.0),\n", + " 's2': Decimal(0.0),\n", + " 's3': Decimal(1.0),\n", + " 's4': Decimal(1.0),\n", + " 'timestamp': '2018-10-01 15:16:24'\n", + "}\n", + "\n", + "sim_config = {\n", + " \"N\": 2\n", + "}\n", + "\n", + "exogenous_states = {\n", + " \"s3\": es3p1,\n", + " \"s4\": es4p2,\n", + " \"timestamp\": es5p2\n", + "}\n", + "\n", + "env_processes = {\n", + " \"s3\": env_proc('2018-10-01 15:16:25', env_a),\n", + " \"s4\": env_proc('2018-10-01 15:16:25', env_b)\n", + "}\n", + " \n", + "mechanisms = {\n", + " \"m1\": {\n", + " \"behaviors\": {\n", + " \"b1\": b1m1,\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", + "}" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": {}, + "outputs": [], + "source": [ + "# if beh list empty, repeat 0 x n_states in list \n", + "def generate_config(mechanisms, exogenous_states):\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", + "\n", + "# partials = list(map(lambda f: partial(f, step, sL), funcs))\n", + "def getColResults(step, sL, s, funcs):\n", + " return list(map(lambda f: f(step, sL, s), funcs))\n", + "\n", + "def getBehaviorInput(step, sL, s, funcs): \n", + " return op.foldr(_ + _)(getColResults(step, sL, s, funcs))\n", + "\n", + "def apply_env_proc(env_processes, state_dict, step):\n", + " for state in state_dict.keys(): \n", + " if state in list(env_processes.keys()):\n", + " state_dict[state] = env_processes[state](step)(state_dict[state])\n", + "# return state_dict\n", + " \n", + "def mech_step(m_step, sL, state_funcs, behavior_funcs, env_processes, t_step):\n", + " in_copy, mutatable_copy, out_copy = deepcopy(sL), deepcopy(sL), deepcopy(sL)\n", + " last_in_obj, last_mut_obj = in_copy[-1], mutatable_copy[-1]\n", + " \n", + " _input = getBehaviorInput(m_step, sL, last_in_obj, behavior_funcs)\n", + "\n", + " for f in state_funcs:\n", + " f(m_step, sL, last_mut_obj, _input)\n", + " \n", + " apply_env_proc(env_processes, last_mut_obj, last_mut_obj['timestamp'])\n", + " \n", + " last_mut_obj[\"mech_step\"], last_mut_obj[\"time_step\"] = m_step, t_step\n", + " out_copy.append(last_mut_obj)\n", + " \n", + " del last_in_obj, last_mut_obj, in_copy, mutatable_copy,\n", + " return out_copy\n", + "\n", + "def block_gen(states_list, configs, env_processes, t_step):\n", + " m_step = 0\n", + " states_list_copy = deepcopy(states_list)\n", + " genesis_states = states_list_copy[-1]\n", + " genesis_states['mech_step'], genesis_states['time_step'] = m_step, t_step\n", + " states_list = [genesis_states]\n", + " \n", + " m_step += 1\n", + " for config in configs:\n", + " s_conf, b_conf = config[0], config[1]\n", + " states_list = mech_step(m_step, states_list, s_conf, b_conf, env_processes, t_step) \n", + " m_step += 1 \n", + " \n", + " t_step += 1\n", + " \n", + " return states_list\n", + "\n", + "def pipeline(states_list, configs, env_processes, time_seq):\n", + " time_seq = [x + 1 for x in time_seq]\n", + " simulation_list = [states_list]\n", + " for time_step in time_seq:\n", + " pipeline_run = block_gen(simulation_list[-1], configs, env_processes, time_step)\n", + " head, *pipeline_run = pipeline_run\n", + " simulation_list.append(pipeline_run)\n", + " \n", + " return simulation_list\n", + "\n", + "def simulation(states_list, configs, env_processes, time_seq, runs):\n", + " pipeline_run = []\n", + " for run in range(runs):\n", + " if run == 0:\n", + " head, *tail = pipeline(states_list, configs, env_processes, time_seq)\n", + " head[-1]['mech_step'], head[-1]['time_step'] = 0, 0\n", + " simulation_list = [head] + tail\n", + " pipeline_run += simulation_list\n", + " else:\n", + " transient_states_list = [pipeline_run[-1][-1]]\n", + " head, *tail = pipeline(transient_states_list, configs, env_processes, time_seq)\n", + " pipeline_run += tail\n", + " \n", + " return pipeline_run" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": {}, + "outputs": [], + "source": [ + "states_list = [state_dict]\n", + "configs = generate_config(mechanisms, exogenous_states)\n", + "p = pipeline(states_list, configs, env_processes, range(10))\n", + "N = sim_config['N']\n", + "s = simulation(states_list, configs, env_processes, range(5), N)\n", + "# x = flatten(s)\n", + "# transient_state = p[-1][1]\n", + "# transient_state['mech_step'], transient_state['time_step'] = 0, 0\n", + "# head, *tail = pipeline([transient_state], configs, env_processes, range(1))\n", + "# head" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
mech_steps1s2s3s4time_steptimestamp
00001102018-10-01 15:16:24
1122101012018-10-01 15:16:25
2288101012018-10-01 15:16:25
332626101012018-10-01 15:16:25
41808010.112726504816649253370997039.37358308881163115877654945522018-10-01 15:16:26
5224224210.487346933264530942349835278.62016626166331414223691548622018-10-01 15:16:26
6372872811.913242135270736405637596086.53487634630409385728984067922018-10-01 15:16:26
712186218612.511116777442378299065991315.93118968315566923726363952432018-10-01 15:16:27
826560656011.454911154069123325574886575.32390954820124880401133424332018-10-01 15:16:27
93196821968211.454922335748109247037327945.92230524696739109178457843432018-10-01 15:16:27
101590485904812.076182995004145018523314635.84418161166074604232339800642018-10-01 15:16:28
11217714617714611.697584759271524237502733504.89550411635805911556400983142018-10-01 15:16:28
12353144053144012.599482274917543854537877695.21208435021169347331059511542018-10-01 15:16:28
1311594322159432210.245784765906019155373231625.02639302523665195708717849052018-10-01 15:16:29
1424782968478296812.019519313673296568461037904.15022183022198659782350351052018-10-01 15:16:29
153143489061434890613.783597733107369420213878283.90259899343079757840645896252018-10-01 15:16:29
161430467204304672013.320913592874087304819022983.67289421005976134574243413012018-10-01 15:16:30
17212914016212914016214.135275362924263979021941143.35192648688727431701794896012018-10-01 15:16:30
18338742048838742048814.203083115462195268554008013.36188633936078126094148887512018-10-01 15:16:30
1911162261466116226146613.025455373078228464709385942.60604763174302514928546198222018-10-01 15:16:31
2023486784400348678440013.139701926642296107045657042.53626761436770894889616035022018-10-01 15:16:31
213104603532021046035320214.454152883328036879921982482.79323804947474113589163469322018-10-01 15:16:31
221313810596083138105960813.903315932242113053109733563.03144478726104496774484686232018-10-01 15:16:32
232941431788269414317882613.381010864727075518935673553.36738570925962364852446784732018-10-01 15:16:32
24328242953648028242953648013.281361455988187967283749923.74432771883958405206048476132018-10-01 15:16:32
25184728860944284728860944213.857103600947317486522392684.30131261704849550334644855142018-10-01 15:16:33
2622541865828328254186582832815.628566944464974852221883993.82029653270196969121269357842018-10-01 15:16:33
2737625597484986762559748498614.636654143538757371444815344.14342997592437414219689284642018-10-01 15:16:33
281228767924549602287679245496015.380776140741954938013357143.37238343031412003190807879252018-10-01 15:16:34
292686303773648826863037736488215.713179332019243508422954943.16906745680040532299196548052018-10-01 15:16:34
30320589113209464820589113209464812.792708358832171308040157612.56235835182925122342346616352018-10-01 15:16:34
\n", + "
" + ], + "text/plain": [ + " mech_step s1 s2 \\\n", + "0 0 0 0 \n", + "1 1 2 2 \n", + "2 2 8 8 \n", + "3 3 26 26 \n", + "4 1 80 80 \n", + "5 2 242 242 \n", + "6 3 728 728 \n", + "7 1 2186 2186 \n", + "8 2 6560 6560 \n", + "9 3 19682 19682 \n", + "10 1 59048 59048 \n", + "11 2 177146 177146 \n", + "12 3 531440 531440 \n", + "13 1 1594322 1594322 \n", + "14 2 4782968 4782968 \n", + "15 3 14348906 14348906 \n", + "16 1 43046720 43046720 \n", + "17 2 129140162 129140162 \n", + "18 3 387420488 387420488 \n", + "19 1 1162261466 1162261466 \n", + "20 2 3486784400 3486784400 \n", + "21 3 10460353202 10460353202 \n", + "22 1 31381059608 31381059608 \n", + "23 2 94143178826 94143178826 \n", + "24 3 282429536480 282429536480 \n", + "25 1 847288609442 847288609442 \n", + "26 2 2541865828328 2541865828328 \n", + "27 3 7625597484986 7625597484986 \n", + "28 1 22876792454960 22876792454960 \n", + "29 2 68630377364882 68630377364882 \n", + "30 3 205891132094648 205891132094648 \n", + "\n", + " s3 s4 time_step \\\n", + "0 1 1 0 \n", + "1 10 10 1 \n", + "2 10 10 1 \n", + "3 10 10 1 \n", + "4 10.11272650481664925337099703 9.373583088811631158776549455 2 \n", + "5 10.48734693326453094234983527 8.620166261663314142236915486 2 \n", + "6 11.91324213527073640563759608 6.534876346304093857289840679 2 \n", + "7 12.51111677744237829906599131 5.931189683155669237263639524 3 \n", + "8 11.45491115406912332557488657 5.323909548201248804011334243 3 \n", + "9 11.45492233574810924703732794 5.922305246967391091784578434 3 \n", + "10 12.07618299500414501852331463 5.844181611660746042323398006 4 \n", + "11 11.69758475927152423750273350 4.895504116358059115564009831 4 \n", + "12 12.59948227491754385453787769 5.212084350211693473310595115 4 \n", + "13 10.24578476590601915537323162 5.026393025236651957087178490 5 \n", + "14 12.01951931367329656846103790 4.150221830221986597823503510 5 \n", + "15 13.78359773310736942021387828 3.902598993430797578406458962 5 \n", + "16 13.32091359287408730481902298 3.672894210059761345742434130 1 \n", + "17 14.13527536292426397902194114 3.351926486887274317017948960 1 \n", + "18 14.20308311546219526855400801 3.361886339360781260941488875 1 \n", + "19 13.02545537307822846470938594 2.606047631743025149285461982 2 \n", + "20 13.13970192664229610704565704 2.536267614367708948896160350 2 \n", + "21 14.45415288332803687992198248 2.793238049474741135891634693 2 \n", + "22 13.90331593224211305310973356 3.031444787261044967744846862 3 \n", + "23 13.38101086472707551893567355 3.367385709259623648524467847 3 \n", + "24 13.28136145598818796728374992 3.744327718839584052060484761 3 \n", + "25 13.85710360094731748652239268 4.301312617048495503346448551 4 \n", + "26 15.62856694446497485222188399 3.820296532701969691212693578 4 \n", + "27 14.63665414353875737144481534 4.143429975924374142196892846 4 \n", + "28 15.38077614074195493801335714 3.372383430314120031908078792 5 \n", + "29 15.71317933201924350842295494 3.169067456800405322991965480 5 \n", + "30 12.79270835883217130804015761 2.562358351829251223423466163 5 \n", + "\n", + " timestamp \n", + "0 2018-10-01 15:16:24 \n", + "1 2018-10-01 15:16:25 \n", + "2 2018-10-01 15:16:25 \n", + "3 2018-10-01 15:16:25 \n", + "4 2018-10-01 15:16:26 \n", + "5 2018-10-01 15:16:26 \n", + "6 2018-10-01 15:16:26 \n", + "7 2018-10-01 15:16:27 \n", + "8 2018-10-01 15:16:27 \n", + "9 2018-10-01 15:16:27 \n", + "10 2018-10-01 15:16:28 \n", + "11 2018-10-01 15:16:28 \n", + "12 2018-10-01 15:16:28 \n", + "13 2018-10-01 15:16:29 \n", + "14 2018-10-01 15:16:29 \n", + "15 2018-10-01 15:16:29 \n", + "16 2018-10-01 15:16:30 \n", + "17 2018-10-01 15:16:30 \n", + "18 2018-10-01 15:16:30 \n", + "19 2018-10-01 15:16:31 \n", + "20 2018-10-01 15:16:31 \n", + "21 2018-10-01 15:16:31 \n", + "22 2018-10-01 15:16:32 \n", + "23 2018-10-01 15:16:32 \n", + "24 2018-10-01 15:16:32 \n", + "25 2018-10-01 15:16:33 \n", + "26 2018-10-01 15:16:33 \n", + "27 2018-10-01 15:16:33 \n", + "28 2018-10-01 15:16:34 \n", + "29 2018-10-01 15:16:34 \n", + "30 2018-10-01 15:16:34 " + ] + }, + "execution_count": 7, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "pd.DataFrame(flatten(s))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": {}, + "outputs": [], + "source": [ + "# pd.DataFrame(flatten(p))" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "metadata": {}, + "outputs": [], + "source": [ + "# flatten(pipeline(states_list, configs, env_processes, range(10)))" + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
mech_steps1s2s3s4time_steptimestamp
00001102018-10-01 15:16:24
1122101012018-10-01 15:16:25
2288101012018-10-01 15:16:25
332626101012018-10-01 15:16:25
41808010.3260034333869810119210797011.7746450314059347697082103022018-10-01 15:16:26
522422428.21916515274784955205371299110.9801773387214634804305097322018-10-01 15:16:26
637287288.25718333114068459995979706311.1455573279124922629545779522018-10-01 15:16:26
71218621867.69761418303725988415748507911.3160238377322023420946343232018-10-01 15:16:27
82656065606.58958955625320624245355845710.1117779289454360207806075732018-10-01 15:16:27
9319682196826.93507938421090996234107250610.5546198167452742497326965132018-10-01 15:16:27
10159048590487.44500160717102196461960229712.6011378649838055327415438142018-10-01 15:16:28
1121771461771466.95865667781136112301155569011.3096083396823127488043278442018-10-01 15:16:28
1235314405314407.54489308076341439053948261912.3267248984101325124126510442018-10-01 15:16:28
131159432215943227.25704297441675434129273706612.1362685525819409923474763752018-10-01 15:16:29
142478296847829687.30529433408675028875311565914.2839357716573656718733737352018-10-01 15:16:29
15314348906143489066.50263319367367710575799849814.9749759400775891229965018052018-10-01 15:16:29
16143046720430467207.53296700646015886683024862215.9876083719011149813759189962018-10-01 15:16:30
1721291401621291401625.52961250543163593871152160917.0158726368362632068794171462018-10-01 15:16:30
1833874204883874204885.47904274871256495704604649817.4397154045538409948107159962018-10-01 15:16:30
191116226146611622614665.85990175186463137404836714815.0055435787421793737865330072018-10-01 15:16:31
202348678440034867844004.66831033426642853326666637117.0938094196505573185825817172018-10-01 15:16:31
21310460353202104603532024.57986020161816165272325721714.7508139318520774978598645372018-10-01 15:16:31
22131381059608313810596084.54449513239095366886914084415.1027140580688841666002539582018-10-01 15:16:32
23294143178826941431788264.91928101177860913117888377016.0301371246650606644045462482018-10-01 15:16:32
2432824295364802824295364805.53331202367358005176345704114.6869522616793077505417237282018-10-01 15:16:32
2518472886094428472886094425.30982582865393698162295633314.9000059117257340823484719292018-10-01 15:16:33
262254186582832825418658283284.57467053107137237917651360616.6401512087351580090579643392018-10-01 15:16:33
273762559748498676255974849865.20013569135900153491197292216.6000410060559880661690522992018-10-01 15:16:33
28122876792454960228767924549605.83345274620393831999132966515.12486604838650902185343711102018-10-01 15:16:34
29268630377364882686303773648825.56394410950931399948902225610.71485175557766753591769425102018-10-01 15:16:34
3032058911320946482058911320946485.7591765064867251346787523629.673539064064506702922033631102018-10-01 15:16:34
\n", + "
" + ], + "text/plain": [ + " mech_step s1 s2 \\\n", + "0 0 0 0 \n", + "1 1 2 2 \n", + "2 2 8 8 \n", + "3 3 26 26 \n", + "4 1 80 80 \n", + "5 2 242 242 \n", + "6 3 728 728 \n", + "7 1 2186 2186 \n", + "8 2 6560 6560 \n", + "9 3 19682 19682 \n", + "10 1 59048 59048 \n", + "11 2 177146 177146 \n", + "12 3 531440 531440 \n", + "13 1 1594322 1594322 \n", + "14 2 4782968 4782968 \n", + "15 3 14348906 14348906 \n", + "16 1 43046720 43046720 \n", + "17 2 129140162 129140162 \n", + "18 3 387420488 387420488 \n", + "19 1 1162261466 1162261466 \n", + "20 2 3486784400 3486784400 \n", + "21 3 10460353202 10460353202 \n", + "22 1 31381059608 31381059608 \n", + "23 2 94143178826 94143178826 \n", + "24 3 282429536480 282429536480 \n", + "25 1 847288609442 847288609442 \n", + "26 2 2541865828328 2541865828328 \n", + "27 3 7625597484986 7625597484986 \n", + "28 1 22876792454960 22876792454960 \n", + "29 2 68630377364882 68630377364882 \n", + "30 3 205891132094648 205891132094648 \n", + "\n", + " s3 s4 time_step \\\n", + "0 1 1 0 \n", + "1 10 10 1 \n", + "2 10 10 1 \n", + "3 10 10 1 \n", + "4 10.32600343338698101192107970 11.77464503140593476970821030 2 \n", + "5 8.219165152747849552053712991 10.98017733872146348043050973 2 \n", + "6 8.257183331140684599959797063 11.14555732791249226295457795 2 \n", + "7 7.697614183037259884157485079 11.31602383773220234209463432 3 \n", + "8 6.589589556253206242453558457 10.11177792894543602078060757 3 \n", + "9 6.935079384210909962341072506 10.55461981674527424973269651 3 \n", + "10 7.445001607171021964619602297 12.60113786498380553274154381 4 \n", + "11 6.958656677811361123011555690 11.30960833968231274880432784 4 \n", + "12 7.544893080763414390539482619 12.32672489841013251241265104 4 \n", + "13 7.257042974416754341292737066 12.13626855258194099234747637 5 \n", + "14 7.305294334086750288753115659 14.28393577165736567187337373 5 \n", + "15 6.502633193673677105757998498 14.97497594007758912299650180 5 \n", + "16 7.532967006460158866830248622 15.98760837190111498137591899 6 \n", + "17 5.529612505431635938711521609 17.01587263683626320687941714 6 \n", + "18 5.479042748712564957046046498 17.43971540455384099481071599 6 \n", + "19 5.859901751864631374048367148 15.00554357874217937378653300 7 \n", + "20 4.668310334266428533266666371 17.09380941965055731858258171 7 \n", + "21 4.579860201618161652723257217 14.75081393185207749785986453 7 \n", + "22 4.544495132390953668869140844 15.10271405806888416660025395 8 \n", + "23 4.919281011778609131178883770 16.03013712466506066440454624 8 \n", + "24 5.533312023673580051763457041 14.68695226167930775054172372 8 \n", + "25 5.309825828653936981622956333 14.90000591172573408234847192 9 \n", + "26 4.574670531071372379176513606 16.64015120873515800905796433 9 \n", + "27 5.200135691359001534911972922 16.60004100605598806616905229 9 \n", + "28 5.833452746203938319991329665 15.12486604838650902185343711 10 \n", + "29 5.563944109509313999489022256 10.71485175557766753591769425 10 \n", + "30 5.759176506486725134678752362 9.673539064064506702922033631 10 \n", + "\n", + " timestamp \n", + "0 2018-10-01 15:16:24 \n", + "1 2018-10-01 15:16:25 \n", + "2 2018-10-01 15:16:25 \n", + "3 2018-10-01 15:16:25 \n", + "4 2018-10-01 15:16:26 \n", + "5 2018-10-01 15:16:26 \n", + "6 2018-10-01 15:16:26 \n", + "7 2018-10-01 15:16:27 \n", + "8 2018-10-01 15:16:27 \n", + "9 2018-10-01 15:16:27 \n", + "10 2018-10-01 15:16:28 \n", + "11 2018-10-01 15:16:28 \n", + "12 2018-10-01 15:16:28 \n", + "13 2018-10-01 15:16:29 \n", + "14 2018-10-01 15:16:29 \n", + "15 2018-10-01 15:16:29 \n", + "16 2018-10-01 15:16:30 \n", + "17 2018-10-01 15:16:30 \n", + "18 2018-10-01 15:16:30 \n", + "19 2018-10-01 15:16:31 \n", + "20 2018-10-01 15:16:31 \n", + "21 2018-10-01 15:16:31 \n", + "22 2018-10-01 15:16:32 \n", + "23 2018-10-01 15:16:32 \n", + "24 2018-10-01 15:16:32 \n", + "25 2018-10-01 15:16:33 \n", + "26 2018-10-01 15:16:33 \n", + "27 2018-10-01 15:16:33 \n", + "28 2018-10-01 15:16:34 \n", + "29 2018-10-01 15:16:34 \n", + "30 2018-10-01 15:16:34 " + ] + }, + "execution_count": 10, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "states_list = [state_dict]\n", + "configs = generate_config(mechanisms, exogenous_states)\n", + "# type(pipeline(states_list, configs, env_processes, range(10)))\n", + "pd.DataFrame(flatten(pipeline(states_list, configs, env_processes, range(10))))" + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "[0, 1]" + ] + }, + "execution_count": 11, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "list(range(2))" + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "metadata": {}, + "outputs": [ + { + "ename": "NameError", + "evalue": "name 'non_numeric' is not defined", + "output_type": "error", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------\u001b[0m", + "\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)", + "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m()\u001b[0m\n\u001b[1;32m 3\u001b[0m \u001b[0mstate_dict\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;34m{\u001b[0m\u001b[0;34m's1'\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0mDecimal\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'3323'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m's2'\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0mDecimal\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'2572'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m's3'\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0mDecimal\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'2.657'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m's4'\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0mDecimal\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'7.914'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m'timestamp'\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0;34m'2018-10-01 15:16:26'\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m'mech_step'\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0;36m1\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m'time_step'\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0;36m2\u001b[0m\u001b[0;34m}\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 4\u001b[0m \u001b[0mstate_dict\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;34m{\u001b[0m\u001b[0mk\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0mv\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mquantize\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mTWOPLACES\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mROUND_DOWN\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;32mfor\u001b[0m \u001b[0mk\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mv\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mstate_dict\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mitems\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mtype\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mv\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;34m==\u001b[0m \u001b[0mDecimal\u001b[0m\u001b[0;34m}\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 5\u001b[0;31m \u001b[0mstate_dict\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mupdate\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mnon_numeric\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 6\u001b[0m \u001b[0mstate_dict\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;31mNameError\u001b[0m: name 'non_numeric' is not defined" + ] + } + ], + "source": [ + "# Decimal('240.0').quantize(Decimal('0.01'), ROUND_DOWN)\n", + "# round(Decimal('240.01'), 2)\n", + "state_dict = {'s1': Decimal('3323'), 's2': Decimal('2572'), 's3': Decimal('2.657'), 's4': Decimal('7.914'), 'timestamp': '2018-10-01 15:16:26', 'mech_step': 1, 'time_step': 2}\n", + "state_dict = {k: v.quantize(TWOPLACES, ROUND_DOWN) for k, v in state_dict.items() if type(v) == Decimal}\n", + "state_dict.update(non_numeric)\n", + "state_dict" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "states_list = [state_dict]\n", + "states_list\n", + "# {'s1': 8.742503764992283e+170,\n", + "# 's2': 1.119720780594405e+171,\n", + "# 's3': 4.251811100418906,\n", + "# 's4': 6.92728042985628,\n", + "# 'timestamp': '2018-10-01 15:16:31',\n", + "# 'mech_step': 3,\n", + "# 'time_step': 7}\n", + "# {'s1': Decimal('2.221384236472411425810660220E+330'),\n", + "# 's2': Decimal('2.845096899831187764579913612E+330'),\n", + "# 's3': Decimal('3.622519693611211445932083740'),\n", + "# 's4': Decimal('5.161487081026327858663750787'),\n", + "# 'timestamp': '2018-10-01 15:16:32',\n", + "# 'mech_step': 3,\n", + "# 'time_step': 8}" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "from decimal import Decimal, MAX_EMAX\n", + "# Decimal(2.5347751615574597e+167)**2\n", + "MAX_EMAX**5" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "scrolled": true + }, + "outputs": [], + "source": [ + "1000 * 1000" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "scrolled": true + }, + "outputs": [], + "source": [ + "from datetime import datetime, timedelta\n", + "# from datetime import timedelta \n", + "# st = datetime.fromtimestamp(ts).strftime('%Y-%m-%d %H:%M:%S')\n", + "st = datetime.now()\n", + "print(st)\n", + "x = st + timedelta(seconds=60)\n", + "print(x)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "s = datetime.now().strftime('%Y-%m-%d %H:%M:%S')\n", + "datetime_object = datetime.strptime(s, '%Y-%m-%d %H:%M:%S')\n", + "datetime_object" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "datetime.fromtimestamp()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "from datetime import datetime, timedelta\n", + "\n", + "# def time_step_func(year, month, day, hour, minute, second):\n", + "a = datetime(2016, 11, 15, 9, 59, 25)#.strftime(\"%Y-%m-%d %H:%M:%S\")\n", + "b = a + timedelta(seconds=60) # days, seconds, then other fields.\n", + "print(a)\n", + "print(b)\n", + "st = datetime.fromtimestamp(ts).strftime('%Y-%m-%d %H:%M:%S')\n", + "def time_step_func(dt_str, fromat_str='%Y-%m-%d %H:%M:%S', days=0, minutes=0, seconds=1):\n", + " dt = datetime.strptime(dt_str, fromat_str)\n", + " t = dt + timedelta(days=days, minutes=minutes, seconds=seconds)\n", + " return t.strftime(fromat_str)\n", + "\n", + "time_step_func('2018-10-01 15:16:24')" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def time_step_func(x, y):\n", + " return x + y" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "for m in M: #M is the parameter sweep array\n", + " # for Pairwise, run below separately\n", + " for n in N: #N is the total number of Montecarlo runs\n", + " for t in T: #T[len(T)]-T[0] is the duration of each simulation\n", + " # Pipeline\n", + " for b in Behaviors:\n", + " for M in Mechanisms:\n", + " for s in States:\n", + " update(s)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "[{'s1': 2}] + [{'s1': 3}]\n", + "list(zip([block_gen] * 2, range(2)))\n", + "len([0,1])" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "states_list = [state_dict]\n", + "configs = generate_config(mechanisms, exogenous_states)\n", + "def step_func(x, y):\n", + " return x + y\n", + "pipeline(states_list, configs, env_processes, step_func)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# def s3step1(step, sL, s, _input):\n", + "# s['s3'] = s['s3'] \n", + "# # def s3step2(step, sL, s, _input):\n", + "# s['s3'] = s['s3'] + 1\n", + "# def s3step3(step, sL, s, _input):\n", + "# s['s3'] = s['s3'] * bound_norm_random(proc_one_coef_A, proc_one_coef_B)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# 15 + 28.933333333333334 + 4" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# def multiply(x,y,z):\n", + "# return x * y * z\n", + "\n", + "# # create a new function that multiplies by 2\n", + "# dbl = partial(partial(multiply,2), multiply, 2)\n", + "# print(dbl(2))" + ] + } + ], + "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 +} diff --git a/CAD_Engine.ipynb b/notebooks/CAD_Engine.ipynb similarity index 94% rename from CAD_Engine.ipynb rename to notebooks/CAD_Engine.ipynb index 5ffa1a3..ae29c4b 100644 --- a/CAD_Engine.ipynb +++ b/notebooks/CAD_Engine.ipynb @@ -29,59 +29,6 @@ "cell_type": "code", "execution_count": 2, "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "['2018-10-01 01:00:00',\n", - " '2018-10-01 01:15:00',\n", - " '2018-10-01 01:30:00',\n", - " '2018-10-01 01:45:00',\n", - " '2018-10-01 02:00:00']" - ] - }, - "execution_count": 2, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "def datetime_range(start, end, delta, dt_format='%Y-%m-%d %H:%M:%S'):\n", - " reverse_head = end\n", - " [start, end] = [datetime.strptime(x, dt_format) for x in [start, end]]\n", - " def _datetime_range(start, end, delta):\n", - " current = start\n", - " while current < end:\n", - " yield current\n", - " current += delta\n", - " \n", - " reverse_tail = [dt.strftime(dt_format) for dt in _datetime_range(start, end, delta)]\n", - " return reverse_tail + [reverse_head]\n", - "\n", - "\n", - "datetime_range('2018-10-01 01:00:00', '2018-10-01 02:00:00', timedelta(minutes=15))\n", - "\n", - "# # datetime(2018, 10, 1, 1, 0, 0) + timedelta(seconds=30)\n", - "# # datetime.strptime('2018-10-01 15:16:24', '%Y-%m-%d %H:%M:%S')\n", - "\n", - "# def time_step(dt_str, dt_format='%Y-%m-%d %H:%M:%S', days=0, minutes=0, seconds=30):\n", - "# dt = datetime.strptime(dt_str, dt_format)\n", - "# t = dt + timedelta(days=days, minutes=minutes, seconds=seconds)\n", - "# return t.strftime(dt_format)\n", - "\n", - "# def es_time_step(s, dt_str, fromat_str='%Y-%m-%d %H:%M:%S', days=0, minutes=0, seconds=1):\n", - "# if s['mech_step'] == 0:\n", - "# return time_step(dt_str, fromat_str, days, minutes, seconds)\n", - "# else: \n", - "# return dt_str\n", - "\n", - "# time_step('2018-10-01 15:16:24')" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": {}, "outputs": [], "source": [ "flatten = lambda l: [item for sublist in l for item in sublist]\n", @@ -106,8 +53,7 @@ "\n", "def retrieve_state(l, offset):\n", " return l[last_index(l) + offset + 1]\n", - "# Stochastic Process\n", - "# Input RNG Seed\n", + "\n", "def bound_norm_random(rng, low, high):\n", " # Add RNG Seed\n", " res = rng.normal((high+low)/2,(high-low)/6)\n", @@ -118,10 +64,8 @@ "def env_proc(trigger_step, update_f):\n", " def env_step_trigger(trigger_step, update_f, step):\n", " if step == trigger_step:\n", - "# print('trigered: '+step)\n", " return update_f\n", " else:\n", - "# print('NOT trigered: '+step)\n", " return lambda x: x\n", " return partial(env_step_trigger, trigger_step, update_f)\n", "\n", @@ -137,28 +81,22 @@ " return dt_str\n", "\n", "def round_down(x, fp=TWOPLACES):\n", - " return x.quantize(TWOPLACES, rounding=ROUND_DOWN)\n", - " \n", - "# def round_down(f, fp=TWOPLACES):\n", - "# return (f).quantize(fp, ROUND_DOWN)" + " return x.quantize(TWOPLACES, rounding=ROUND_DOWN)" ] }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 3, "metadata": {}, "outputs": [], "source": [ - "\n", - "\n", - "\n", "# esceptions:\n", "# point to line giving problems and pass a sentinel" ] }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 4, "metadata": {}, "outputs": [], "source": [ @@ -211,14 +149,10 @@ "def es5p2(step, sL, s, _input):\n", " s['timestamp'] = ep_time_step(s, s['timestamp'], seconds=1)\n", "\n", - "\n", - "# add env process f(s) read from time es\n", - "# funcs execute in order\n", "def env_a(x): \n", " return 10\n", "def env_b(x): \n", " return 10\n", - " \n", "def what_ever(x): \n", " return x + 1\n", "\n", @@ -231,9 +165,9 @@ " 'timestamp': '2018-10-01 15:16:24'\n", "}\n", "\n", - "# simulation = {\n", - "# \"s3\": es3p1\n", - "# }\n", + "sim_config = {\n", + " \"N\": 2\n", + "}\n", "\n", "exogenous_states = {\n", " \"s3\": es3p1,\n", @@ -241,8 +175,6 @@ " \"timestamp\": es5p2\n", "}\n", "\n", - "# Update time at the end of each pipeline (once per 'block')\n", - "# Enable the acceptance of user defined time\n", "env_processes = {\n", " \"s3\": env_proc('2018-10-01 15:16:25', env_a),\n", " \"s4\": env_proc('2018-10-01 15:16:25', env_b)\n", @@ -284,7 +216,7 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 5, "metadata": {}, "outputs": [], "source": [ @@ -316,16 +248,11 @@ "# return state_dict\n", " \n", "def mech_step(m_step, sL, state_funcs, behavior_funcs, env_processes, t_step):\n", - " # Truncate reffs\n", " in_copy, mutatable_copy, out_copy = deepcopy(sL), deepcopy(sL), deepcopy(sL)\n", " last_in_obj, last_mut_obj = in_copy[-1], mutatable_copy[-1]\n", " \n", - " # * force eval of _input withing state functions\n", " _input = getBehaviorInput(m_step, sL, last_in_obj, behavior_funcs)\n", "\n", - " \n", - "# apply_env_proc(env_processes, last_mut_obj, t_step)\n", - "\n", " for f in state_funcs:\n", " f(m_step, sL, last_mut_obj, _input)\n", " \n", @@ -382,34 +309,25 @@ }, { "cell_type": "code", - "execution_count": 15, - "metadata": {}, - "outputs": [], - "source": [ - "time_seq = datetime_range('2018-10-01 15:16:24', '2018-10-01 15:16:34', timedelta(seconds=1))" - ] - }, - { - "cell_type": "code", - "execution_count": 7, + "execution_count": 6, "metadata": {}, "outputs": [], "source": [ "states_list = [state_dict]\n", "configs = generate_config(mechanisms, exogenous_states)\n", "p = pipeline(states_list, configs, env_processes, range(10))\n", - "s = simulation(states_list, configs, env_processes, range(5), 2)\n", - "x = flatten(s)\n", + "N = sim_config['N']\n", + "s = simulation(states_list, configs, env_processes, range(5), N)\n", + "# x = flatten(s)\n", "# transient_state = p[-1][1]\n", "# transient_state['mech_step'], transient_state['time_step'] = 0, 0\n", "# head, *tail = pipeline([transient_state], configs, env_processes, range(1))\n", - "# head\n", - "datetime_range('2018-10-01 15:16:24', '2018-10-01 15:16:34', timedelta(seconds=1))" + "# head" ] }, { "cell_type": "code", - "execution_count": 8, + "execution_count": 7, "metadata": {}, "outputs": [ { @@ -858,7 +776,7 @@ "30 2018-10-01 15:16:34 " ] }, - "execution_count": 8, + "execution_count": 7, "metadata": {}, "output_type": "execute_result" } @@ -876,7 +794,7 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": 8, "metadata": {}, "outputs": [], "source": [ @@ -885,7 +803,7 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": 9, "metadata": {}, "outputs": [], "source": [ @@ -894,7 +812,7 @@ }, { "cell_type": "code", - "execution_count": 11, + "execution_count": 10, "metadata": {}, "outputs": [ { @@ -1343,7 +1261,7 @@ "30 2018-10-01 15:16:34 " ] }, - "execution_count": 11, + "execution_count": 10, "metadata": {}, "output_type": "execute_result" } @@ -1357,7 +1275,7 @@ }, { "cell_type": "code", - "execution_count": 12, + "execution_count": 11, "metadata": {}, "outputs": [ { @@ -1366,7 +1284,7 @@ "[0, 1]" ] }, - "execution_count": 12, + "execution_count": 11, "metadata": {}, "output_type": "execute_result" } @@ -1377,7 +1295,7 @@ }, { "cell_type": "code", - "execution_count": 13, + "execution_count": 12, "metadata": {}, "outputs": [ { @@ -1385,9 +1303,9 @@ "evalue": "name 'non_numeric' is not defined", "output_type": "error", "traceback": [ - "\u001b[0;31m--------------------------------------------------------------------------\u001b[0m", - "\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)", - "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m()\u001b[0m\n\u001b[1;32m 3\u001b[0m \u001b[0mstate_dict\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;34m{\u001b[0m\u001b[0;34m's1'\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0mDecimal\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'3323'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m's2'\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0mDecimal\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'2572'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m's3'\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0mDecimal\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'2.657'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m's4'\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0mDecimal\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'7.914'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m'timestamp'\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0;34m'2018-10-01 15:16:26'\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m'mech_step'\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0;36m1\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m'time_step'\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0;36m2\u001b[0m\u001b[0;34m}\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 4\u001b[0m \u001b[0mstate_dict\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;34m{\u001b[0m\u001b[0mk\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0mv\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mquantize\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mTWOPLACES\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mROUND_DOWN\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;32mfor\u001b[0m \u001b[0mk\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mv\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mstate_dict\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mitems\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mtype\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mv\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;34m==\u001b[0m \u001b[0mDecimal\u001b[0m\u001b[0;34m}\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 5\u001b[0;31m \u001b[0mstate_dict\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mupdate\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mnon_numeric\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 6\u001b[0m \u001b[0mstate_dict\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;31m---------------------------------------------------------------\u001b[0m", + "\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)", + "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m()\u001b[0m\n\u001b[1;32m 3\u001b[0m \u001b[0mstate_dict\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;34m{\u001b[0m\u001b[0;34m's1'\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0mDecimal\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'3323'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m's2'\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0mDecimal\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'2572'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m's3'\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0mDecimal\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'2.657'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m's4'\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0mDecimal\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'7.914'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m'timestamp'\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0;34m'2018-10-01 15:16:26'\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m'mech_step'\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0;36m1\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m'time_step'\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0;36m2\u001b[0m\u001b[0;34m}\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 4\u001b[0m \u001b[0mstate_dict\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;34m{\u001b[0m\u001b[0mk\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0mv\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mquantize\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mTWOPLACES\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mROUND_DOWN\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;32mfor\u001b[0m \u001b[0mk\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mv\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mstate_dict\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mitems\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mtype\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mv\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;34m==\u001b[0m \u001b[0mDecimal\u001b[0m\u001b[0;34m}\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 5\u001b[0;31m \u001b[0mstate_dict\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mupdate\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mnon_numeric\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 6\u001b[0m \u001b[0mstate_dict\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", "\u001b[0;31mNameError\u001b[0m: name 'non_numeric' is not defined" ] } diff --git a/Sim_CAD_Engine.ipynb b/notebooks/Sim_CAD_Engine.ipynb similarity index 100% rename from Sim_CAD_Engine.ipynb rename to notebooks/Sim_CAD_Engine.ipynb diff --git a/TestNotebook.ipynb b/notebooks/TestNotebook.ipynb similarity index 100% rename from TestNotebook.ipynb rename to notebooks/TestNotebook.ipynb diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..e69de29 diff --git a/ui/__pycache__/config.cpython-36.pyc b/ui/__pycache__/config.cpython-36.pyc new file mode 100644 index 0000000000000000000000000000000000000000..66450cbb60dfe66bb91997154518b07bdc19f1f6 GIT binary patch literal 3245 zcmcgu&2HO95aupPNtP{J{*V7+Cw6|A#F0taX=)g8^K&eOwni`PL69_Sn}$gWyHpwn zMlUYVQ{TWZ(0Aw~v@gJGfdaYp&{IyGSy>M4s6gT(U14X2!_~|z_uHANmP*Bix4(Y( z(|}?8VPr-Q>x7+2 z_PLbHN{~Ob{2~-!;77wBgdz+gAA%t$Auqu&j36I|GK?Z0fiW0IUWN&nL_P{rFpYc+ zuE7lQahQcUAZ#4I!4ovza3Utzu~POr zWsQ_IQ`TyciUx67^BkudLUPQ3&EO$V8yJFFOSy6-q2d>c#M17#`Z8ro4x?6+x7EtG zN=Q{XIEX>0=j z$#J9~9G5KNY8{vk!7=3sDau4fiJV6#$M6xod7(>hd)_8c{)FD#(4+nIyiI;uZ(it; zhn}~oPwUMMtJgB#ra#6T;>r8SW2??)oXwCk3keP41YiwbI?yh7kIiWvCcgN)ZDl=pV^_;Y*j_upvz zy?r4L8<%Kc)7mbu6C+{3XN-g==7~9x1-Z`DRawNfh;hoOn5>0>bcE_cJ&r`Z6^q^a z)60ry?_G($7_o(_wp|bH_AUeg=D!BKE(hNQEN`MLmx-)&wU<(QzZ-*bt+%~(T;Gd} zAk{xE`hS8Styki}{MjV=EKgXqbbxBAN*ZBX=O~Byc_px9fpVCnO!L7XYoqNw$^_+5 zP*jj<5T~h6mvY!Kr72eHCJL6aSC{jGO$ENOiA#ICypQsS8kB_hz9ySn8Iy$13ntI| zf&#ud#%56W1ei{#A24MCncAzQt8!v-c zDnEyZo(P344i8EimiZlmT8exn<<9WvhqIJE_mij}02EvZ&ZDxs1}o1`)$DeFs0!jf{Lq!cBWh@4*z zNw-fD)FnYn5*#EQpro&y7WH=O5VVrCEMCQXB8oc-n?>4WTI#inLMePKhN89KhyoR& ztbz~|1@&kd!028|w^4dctZG9O(YY%z=q5sqhHx7@Pc_ZZREXY%VHM8=dOkq a>>TU<3KnOa;W{>)<1A-#R