diff --git a/CAD_Engine.ipynb b/CAD_Engine.ipynb index e32980f..a3fd59e 100644 --- a/CAD_Engine.ipynb +++ b/CAD_Engine.ipynb @@ -2,7 +2,7 @@ "cells": [ { "cell_type": "code", - "execution_count": 1, + "execution_count": 65, "metadata": {}, "outputs": [], "source": [ @@ -18,13 +18,15 @@ "import numpy as np\n", "from datetime import datetime, timedelta\n", "from decimal import Decimal, getcontext, ROUND_DOWN\n", - "getcontext().prec=4\n", - "getcontext().rounding = ROUND_DOWN" + "TWOPLACES = Decimal(10) ** -2 # same as Decimal('0.01')\n", + "import pandas as pd\n", + "# getcontext().prec=None\n", + "# getcontext().rounding = ROUND_DOWN" ] }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 14, "metadata": {}, "outputs": [], "source": [ @@ -55,38 +57,35 @@ " return lambda x: x\n", " return partial(env_step_trigger, trigger_step, update_f)\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(s, dt_str, fromat_str='%Y-%m-%d %H:%M:%S', days=0, minutes=0, seconds=1):\n", " if s['mech_step'] == 0:\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", " else: \n", - " return dt_str" + " 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)" ] }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 15, "metadata": {}, "outputs": [], "source": [ - "# def pipeline(*steps):\n", - "# return reduce(lambda x, y: y(x), list(steps))\n", - "# def compose(*funcs):\n", - "# return lambda x: reduce(lambda f, g: g(f), list(funcs), x)" + "\n", + "# esceptions:\n", + "# point to line giving problems and pass a sentinel" ] }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 16, "metadata": {}, "outputs": [], "source": [ @@ -95,29 +94,8 @@ " 'a': np.random.RandomState(2),\n", " 'b': np.random.RandomState(3),\n", " 'c': np.random.RandomState(3)\n", - "}\n" - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "metadata": {}, - "outputs": [], - "source": [ - "a = np.random.RandomState(1)\n", - "proc_one_coef_B = 1.3\n", - "b = np.random.RandomState(2)\n", + "}\n", "\n", - "def pipe_f(x):\n", - " return x" - ] - }, - { - "cell_type": "code", - "execution_count": 7, - "metadata": {}, - "outputs": [], - "source": [ "# UI Behaviors per Mechanism\n", "def b1m1(step, sL, s):\n", " return s['s1']\n", @@ -138,7 +116,7 @@ "# UI Internal States per Mechanism\n", "def s1m1(step, sL, s, _input):\n", "# print(s['s1'])\n", - " s['s1'] = s['s1']**2 + _input\n", + " s['s1'] = s['s1'] + _input\n", "def s2m1(step, sL, s, _input):\n", " s['s2'] = s['s2'] + 1 + _input\n", "\n", @@ -152,8 +130,7 @@ "def s2m3(step, sL, s, _input):\n", " s['s2'] = s['s2'] + _input\n", "\n", - "# UI Exogenous States //per Mechanism \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", @@ -164,7 +141,7 @@ " s['timestamp'] = time_step(s, s['timestamp'], seconds=1)\n", "\n", "\n", - "#add env process f(s) read from time es\n", + "# add env process f(s) read from time es\n", "# funcs execute in order\n", "def env_a(x): \n", " return x + 1\n", @@ -189,7 +166,8 @@ " \"timestamp\": es5p2\n", "}\n", "\n", - "# update time at the end of each pipeline (once per 'block')\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(1, env_a),\n", " \"s4\": env_proc(1, pipe | env_b | what_ever)\n", @@ -231,7 +209,7 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": 73, "metadata": {}, "outputs": [], "source": [ @@ -273,6 +251,12 @@ "\n", " apply_env_proc(env_processes, last_mut_obj, t_step)\n", " \n", + "# print(last_mut_obj)\n", + " \n", + "# non_numeric = {k: v for k, v in last_mut_obj.items() if type(v) != Decimal}\n", + "# last_mut_obj = {k: round_down(v) for k, v in last_mut_obj.items() if type(v) == Decimal}\n", + "# last_mut_obj.update(non_numeric)\n", + "\n", " for f in state_funcs:\n", " f(m_step, sL, last_mut_obj, _input)\n", " \n", @@ -310,54 +294,39 @@ " # should only occur once for genesis state, placed before loop\n", " head, *tail = simulation_list\n", " head[-1]['mech_step'], head[-1]['time_step'] = 0, 0\n", - " simulation_list = head, *tail\n", + " simulation_list = [head] + tail\n", " return simulation_list" ] }, { "cell_type": "code", - "execution_count": 9, + "execution_count": 31, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "{'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}" + "{'s1': Decimal('2'),\n", + " 's2': Decimal('4'),\n", + " 's3': Decimal('0'),\n", + " 's4': Decimal('0'),\n", + " 'timestamp': '2018-10-01 15:16:24',\n", + " 'mech_step': 0,\n", + " 'time_step': 0}" ] }, - "execution_count": 9, + "execution_count": 31, "metadata": {}, "output_type": "execute_result" } ], "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}" + "states_list[-1]" ] }, { "cell_type": "code", - "execution_count": 19, + "execution_count": 71, "metadata": { "collapsed": true }, @@ -365,443 +334,863 @@ { "data": { "text/plain": [ - "([{'s1': Decimal('2'),\n", - " 's2': Decimal('4'),\n", - " 's3': Decimal('0'),\n", - " 's4': Decimal('0'),\n", - " 'timestamp': '2018-10-01 15:16:24',\n", - " 'mech_step': 0,\n", - " 'time_step': 0}],\n", - " [{'s1': Decimal('14'),\n", - " 's2': Decimal('15'),\n", - " 's3': Decimal('1.150'),\n", - " 's4': Decimal('3.045'),\n", - " 'timestamp': '2018-10-01 15:16:25',\n", - " 'mech_step': 1,\n", - " 'time_step': 1},\n", - " {'s1': Decimal('28.93'),\n", - " 's2': Decimal('15'),\n", - " 's3': Decimal('2.336'),\n", - " 's4': Decimal('6.033'),\n", - " 'timestamp': '2018-10-01 15:16:25',\n", - " 'mech_step': 2,\n", - " 'time_step': 1},\n", - " {'s1': Decimal('28.93'),\n", - " 's2': Decimal('544.9'),\n", - " 's3': Decimal('2.973'),\n", - " 's4': Decimal('9.469'),\n", - " 'timestamp': '2018-10-01 15:16:25',\n", - " 'mech_step': 3,\n", - " 'time_step': 1}],\n", - " [{'s1': Decimal('1.661E+4'),\n", - " 's2': Decimal('1.632E+4'),\n", - " 's3': Decimal('3.170'),\n", - " 's4': Decimal('10.19'),\n", - " 'timestamp': '2018-10-01 15:16:26',\n", - " 'mech_step': 1,\n", - " 'time_step': 2},\n", - " {'s1': Decimal('3.322E+4'),\n", - " 's2': Decimal('1.632E+4'),\n", - " 's3': Decimal('3.402'),\n", - " 's4': Decimal('11.58'),\n", - " 'timestamp': '2018-10-01 15:16:26',\n", - " 'mech_step': 2,\n", - " 'time_step': 2},\n", - " {'s1': Decimal('3.322E+4'),\n", - " 's2': Decimal('5.012E+4'),\n", - " 's3': Decimal('3.040'),\n", - " 's4': Decimal('12.90'),\n", - " 'timestamp': '2018-10-01 15:16:26',\n", - " 'mech_step': 3,\n", - " 'time_step': 2}],\n", - " [{'s1': Decimal('2.767E+9'),\n", - " 's2': Decimal('1.664E+9'),\n", - " 's3': Decimal('3.007'),\n", - " 's4': Decimal('12.75'),\n", - " 'timestamp': '2018-10-01 15:16:27',\n", - " 'mech_step': 1,\n", - " 'time_step': 3},\n", - " {'s1': Decimal('5.534E+9'),\n", - " 's2': Decimal('1.664E+9'),\n", - " 's3': Decimal('2.450'),\n", - " 's4': Decimal('13.24'),\n", - " 'timestamp': '2018-10-01 15:16:27',\n", - " 'mech_step': 2,\n", - " 'time_step': 3},\n", - " {'s1': Decimal('5.534E+9'),\n", - " 's2': Decimal('7.198E+9'),\n", - " 's3': Decimal('2.530'),\n", - " 's4': Decimal('12.72'),\n", - " 'timestamp': '2018-10-01 15:16:27',\n", - " 'mech_step': 3,\n", - " 'time_step': 3}],\n", - " [{'s1': Decimal('7.045E+19'),\n", - " 's2': Decimal('3.983E+19'),\n", - " 's3': Decimal('2.450'),\n", - " 's4': Decimal('11.97'),\n", - " 'timestamp': '2018-10-01 15:16:28',\n", - " 'mech_step': 1,\n", - " 'time_step': 4},\n", - " {'s1': Decimal('1.409E+20'),\n", - " 's2': Decimal('3.983E+19'),\n", - " 's3': Decimal('2.119'),\n", - " 's4': Decimal('14.25'),\n", - " 'timestamp': '2018-10-01 15:16:28',\n", - " 'mech_step': 2,\n", - " 'time_step': 4},\n", - " {'s1': Decimal('1.409E+20'),\n", - " 's2': Decimal('1.807E+20'),\n", - " 's3': Decimal('1.971'),\n", - " 's4': Decimal('13.59'),\n", - " 'timestamp': '2018-10-01 15:16:28',\n", - " 'mech_step': 3,\n", - " 'time_step': 4}],\n", - " [{'s1': Decimal('4.531E+40'),\n", - " 's2': Decimal('2.546E+40'),\n", - " 's3': Decimal('2.018'),\n", - " 's4': Decimal('16.29'),\n", - " 'timestamp': '2018-10-01 15:16:29',\n", - " 'mech_step': 1,\n", - " 'time_step': 5},\n", - " {'s1': Decimal('9.062E+40'),\n", - " 's2': Decimal('2.546E+40'),\n", - " 's3': Decimal('1.906'),\n", - " 's4': Decimal('15.72'),\n", - " 'timestamp': '2018-10-01 15:16:29',\n", - " 'mech_step': 2,\n", - " 'time_step': 5},\n", - " {'s1': Decimal('9.062E+40'),\n", - " 's2': Decimal('1.160E+41'),\n", - " 's3': Decimal('1.963'),\n", - " 's4': Decimal('16.11'),\n", - " 'timestamp': '2018-10-01 15:16:29',\n", - " 'mech_step': 3,\n", - " 'time_step': 5}],\n", - " [{'s1': Decimal('1.872E+82'),\n", - " 's2': Decimal('1.051E+82'),\n", - " 's3': Decimal('2.071'),\n", - " 's4': Decimal('17.86'),\n", - " 'timestamp': '2018-10-01 15:16:30',\n", - " 'mech_step': 1,\n", - " 'time_step': 6},\n", - " {'s1': Decimal('3.744E+82'),\n", - " 's2': Decimal('1.051E+82'),\n", - " 's3': Decimal('1.896'),\n", - " 's4': Decimal('17.90'),\n", - " 'timestamp': '2018-10-01 15:16:30',\n", - " 'mech_step': 2,\n", - " 'time_step': 6},\n", - " {'s1': Decimal('3.744E+82'),\n", - " 's2': Decimal('4.795E+82'),\n", - " 's3': Decimal('1.836'),\n", - " 's4': Decimal('18.60'),\n", - " 'timestamp': '2018-10-01 15:16:30',\n", - " 'mech_step': 3,\n", - " 'time_step': 6}],\n", - " [{'s1': Decimal('3.196E+165'),\n", - " 's2': Decimal('1.795E+165'),\n", - " 's3': Decimal('2.229'),\n", - " 's4': Decimal('18.15'),\n", - " 'timestamp': '2018-10-01 15:16:31',\n", - " 'mech_step': 1,\n", - " 'time_step': 7},\n", - " {'s1': Decimal('6.392E+165'),\n", - " 's2': Decimal('1.795E+165'),\n", - " 's3': Decimal('2.255'),\n", - " 's4': Decimal('17.28'),\n", - " 'timestamp': '2018-10-01 15:16:31',\n", - " 'mech_step': 2,\n", - " 'time_step': 7},\n", - " {'s1': Decimal('6.392E+165'),\n", - " 's2': Decimal('8.187E+165'),\n", - " 's3': Decimal('2.064'),\n", - " 's4': Decimal('16.99'),\n", - " 'timestamp': '2018-10-01 15:16:31',\n", - " 'mech_step': 3,\n", - " 'time_step': 7}],\n", - " [{'s1': Decimal('9.318E+331'),\n", - " 's2': Decimal('5.233E+331'),\n", - " 's3': Decimal('2.076'),\n", - " 's4': Decimal('15.88'),\n", - " 'timestamp': '2018-10-01 15:16:32',\n", - " 'mech_step': 1,\n", - " 'time_step': 8},\n", - " {'s1': Decimal('1.863E+332'),\n", - " 's2': Decimal('5.233E+331'),\n", - " 's3': Decimal('1.798'),\n", - " 's4': Decimal('18.47'),\n", - " 'timestamp': '2018-10-01 15:16:32',\n", - " 'mech_step': 2,\n", - " 'time_step': 8},\n", - " {'s1': Decimal('1.863E+332'),\n", - " 's2': Decimal('2.386E+332'),\n", - " 's3': Decimal('2.001'),\n", - " 's4': Decimal('18.16'),\n", - " 'timestamp': '2018-10-01 15:16:32',\n", - " 'mech_step': 3,\n", - " 'time_step': 8}],\n", - " [{'s1': Decimal('7.915E+664'),\n", - " 's2': Decimal('4.445E+664'),\n", - " 's3': Decimal('2.075'),\n", - " 's4': Decimal('21.28'),\n", - " 'timestamp': '2018-10-01 15:16:33',\n", - " 'mech_step': 1,\n", - " 'time_step': 9},\n", - " {'s1': Decimal('1.583E+665'),\n", - " 's2': Decimal('4.445E+664'),\n", - " 's3': Decimal('2.300'),\n", - " 's4': Decimal('15.56'),\n", - " 'timestamp': '2018-10-01 15:16:33',\n", - " 'mech_step': 2,\n", - " 'time_step': 9},\n", - " {'s1': Decimal('1.583E+665'),\n", - " 's2': Decimal('2.027E+665'),\n", - " 's3': Decimal('2.507'),\n", - " 's4': Decimal('15.58'),\n", - " 'timestamp': '2018-10-01 15:16:33',\n", - " 'mech_step': 3,\n", - " 'time_step': 9}],\n", - " [{'s1': Decimal('5.713E+1330'),\n", - " 's2': Decimal('3.208E+1330'),\n", - " 's3': Decimal('2.604'),\n", - " 's4': Decimal('16.45'),\n", - " 'timestamp': '2018-10-01 15:16:34',\n", - " 'mech_step': 1,\n", - " 'time_step': 10},\n", - " {'s1': Decimal('1.142E+1331'),\n", - " 's2': Decimal('3.208E+1330'),\n", - " 's3': Decimal('2.858'),\n", - " 's4': Decimal('15.96'),\n", - " 'timestamp': '2018-10-01 15:16:34',\n", - " 'mech_step': 2,\n", - " 'time_step': 10},\n", - " {'s1': Decimal('1.142E+1331'),\n", - " 's2': Decimal('1.462E+1331'),\n", - " 's3': Decimal('2.912'),\n", - " 's4': Decimal('17.70'),\n", - " 'timestamp': '2018-10-01 15:16:34',\n", - " 'mech_step': 3,\n", - " 'time_step': 10}],\n", - " [{'s1': Decimal('2.973E+2662'),\n", - " 's2': Decimal('1.669E+2662'),\n", - " 's3': Decimal('2.719'),\n", - " 's4': Decimal('18.83'),\n", - " 'timestamp': '2018-10-01 15:16:35',\n", - " 'mech_step': 1,\n", - " 'time_step': 11},\n", - " {'s1': Decimal('5.946E+2662'),\n", - " 's2': Decimal('1.669E+2662'),\n", - " 's3': Decimal('2.440'),\n", - " 's4': Decimal('18.31'),\n", - " 'timestamp': '2018-10-01 15:16:35',\n", - " 'mech_step': 2,\n", - " 'time_step': 11},\n", - " {'s1': Decimal('5.946E+2662'),\n", - " 's2': Decimal('7.615E+2662'),\n", - " 's3': Decimal('2.330'),\n", - " 's4': Decimal('19.10'),\n", - " 'timestamp': '2018-10-01 15:16:35',\n", - " 'mech_step': 3,\n", - " 'time_step': 11}],\n", - " [{'s1': Decimal('8.062E+5325'),\n", - " 's2': Decimal('4.527E+5325'),\n", - " 's3': Decimal('1.746'),\n", - " 's4': Decimal('24.47'),\n", - " 'timestamp': '2018-10-01 15:16:36',\n", - " 'mech_step': 1,\n", - " 'time_step': 12},\n", - " {'s1': Decimal('1.612E+5326'),\n", - " 's2': Decimal('4.527E+5325'),\n", - " 's3': Decimal('2.064'),\n", - " 's4': Decimal('25.08'),\n", - " 'timestamp': '2018-10-01 15:16:36',\n", - " 'mech_step': 2,\n", - " 'time_step': 12},\n", - " {'s1': Decimal('1.612E+5326'),\n", - " 's2': Decimal('2.064E+5326'),\n", - " 's3': Decimal('1.710'),\n", - " 's4': Decimal('25.83'),\n", - " 'timestamp': '2018-10-01 15:16:36',\n", - " 'mech_step': 3,\n", - " 'time_step': 12}],\n", - " [{'s1': Decimal('5.925E+10652'),\n", - " 's2': Decimal('3.327E+10652'),\n", - " 's3': Decimal('1.696'),\n", - " 's4': Decimal('24.69'),\n", - " 'timestamp': '2018-10-01 15:16:37',\n", - " 'mech_step': 1,\n", - " 'time_step': 13},\n", - " {'s1': Decimal('1.185E+10653'),\n", - " 's2': Decimal('3.327E+10652'),\n", - " 's3': Decimal('1.472'),\n", - " 's4': Decimal('25.01'),\n", - " 'timestamp': '2018-10-01 15:16:37',\n", - " 'mech_step': 2,\n", - " 'time_step': 13},\n", - " {'s1': Decimal('1.185E+10653'),\n", - " 's2': Decimal('1.517E+10653'),\n", - " 's3': Decimal('1.173'),\n", - " 's4': Decimal('21.78'),\n", - " 'timestamp': '2018-10-01 15:16:37',\n", - " 'mech_step': 3,\n", - " 'time_step': 13}],\n", - " [{'s1': Decimal('3.201E+21306'),\n", - " 's2': Decimal('1.797E+21306'),\n", - " 's3': Decimal('1.163'),\n", - " 's4': Decimal('21.34'),\n", - " 'timestamp': '2018-10-01 15:16:38',\n", - " 'mech_step': 1,\n", - " 'time_step': 14},\n", - " {'s1': Decimal('6.402E+21306'),\n", - " 's2': Decimal('1.797E+21306'),\n", - " 's3': Decimal('1.127'),\n", - " 's4': Decimal('26.58'),\n", - " 'timestamp': '2018-10-01 15:16:38',\n", - " 'mech_step': 2,\n", - " 'time_step': 14},\n", - " {'s1': Decimal('6.402E+21306'),\n", - " 's2': Decimal('8.199E+21306'),\n", - " 's3': Decimal('1.108'),\n", - " 's4': Decimal('29.41'),\n", - " 'timestamp': '2018-10-01 15:16:38',\n", - " 'mech_step': 3,\n", - " 'time_step': 14}],\n", - " [{'s1': Decimal('9.346E+42613'),\n", - " 's2': Decimal('5.248E+42613'),\n", - " 's3': Decimal('1.168'),\n", - " 's4': Decimal('31.29'),\n", - " 'timestamp': '2018-10-01 15:16:39',\n", - " 'mech_step': 1,\n", - " 'time_step': 15},\n", - " {'s1': Decimal('1.869E+42614'),\n", - " 's2': Decimal('5.248E+42613'),\n", - " 's3': Decimal('1.095'),\n", - " 's4': Decimal('34.74'),\n", - " 'timestamp': '2018-10-01 15:16:39',\n", - " 'mech_step': 2,\n", - " 'time_step': 15},\n", - " {'s1': Decimal('1.869E+42614'),\n", - " 's2': Decimal('2.393E+42614'),\n", - " 's3': Decimal('1.136'),\n", - " 's4': Decimal('41.27'),\n", - " 'timestamp': '2018-10-01 15:16:39',\n", - " 'mech_step': 3,\n", - " 'time_step': 15}],\n", - " [{'s1': Decimal('7.965E+85228'),\n", - " 's2': Decimal('4.472E+85228'),\n", - " 's3': Decimal('1.194'),\n", - " 's4': Decimal('43.71'),\n", - " 'timestamp': '2018-10-01 15:16:40',\n", - " 'mech_step': 1,\n", - " 'time_step': 16},\n", - " {'s1': Decimal('1.593E+85229'),\n", - " 's2': Decimal('4.472E+85228'),\n", - " 's3': Decimal('1.154'),\n", - " 's4': Decimal('52.76'),\n", - " 'timestamp': '2018-10-01 15:16:40',\n", - " 'mech_step': 2,\n", - " 'time_step': 16},\n", - " {'s1': Decimal('1.593E+85229'),\n", - " 's2': Decimal('2.040E+85229'),\n", - " 's3': Decimal('1.121'),\n", - " 's4': Decimal('58.40'),\n", - " 'timestamp': '2018-10-01 15:16:40',\n", - " 'mech_step': 3,\n", - " 'time_step': 16}],\n", - " [{'s1': Decimal('5.786E+170458'),\n", - " 's2': Decimal('3.249E+170458'),\n", - " 's3': Decimal('1.181'),\n", - " 's4': Decimal('59.37'),\n", - " 'timestamp': '2018-10-01 15:16:41',\n", - " 'mech_step': 1,\n", - " 'time_step': 17},\n", - " {'s1': Decimal('1.157E+170459'),\n", - " 's2': Decimal('3.249E+170458'),\n", - " 's3': Decimal('1.187'),\n", - " 's4': Decimal('69.57'),\n", - " 'timestamp': '2018-10-01 15:16:41',\n", - " 'mech_step': 2,\n", - " 'time_step': 17},\n", - " {'s1': Decimal('1.157E+170459'),\n", - " 's2': Decimal('1.481E+170459'),\n", - " 's3': Decimal('1.205'),\n", - " 's4': Decimal('53.15'),\n", - " 'timestamp': '2018-10-01 15:16:41',\n", - " 'mech_step': 3,\n", - " 'time_step': 17}],\n", - " [{'s1': Decimal('3.051E+340918'),\n", - " 's2': Decimal('1.713E+340918'),\n", - " 's3': Decimal('0.9188'),\n", - " 's4': Decimal('50.11'),\n", - " 'timestamp': '2018-10-01 15:16:42',\n", - " 'mech_step': 1,\n", - " 'time_step': 18},\n", - " {'s1': Decimal('6.102E+340918'),\n", - " 's2': Decimal('1.713E+340918'),\n", - " 's3': Decimal('0.9241'),\n", - " 's4': Decimal('51.44'),\n", - " 'timestamp': '2018-10-01 15:16:42',\n", - " 'mech_step': 2,\n", - " 'time_step': 18},\n", - " {'s1': Decimal('6.102E+340918'),\n", - " 's2': Decimal('7.815E+340918'),\n", - " 's3': Decimal('0.9588'),\n", - " 's4': Decimal('46.74'),\n", - " 'timestamp': '2018-10-01 15:16:42',\n", - " 'mech_step': 3,\n", - " 'time_step': 18}],\n", - " [{'s1': Decimal('8.491E+681837'),\n", - " 's2': Decimal('4.768E+681837'),\n", - " 's3': Decimal('0.9458'),\n", - " 's4': Decimal('46.01'),\n", - " 'timestamp': '2018-10-01 15:16:43',\n", - " 'mech_step': 1,\n", - " 'time_step': 19},\n", - " {'s1': Decimal('1.698E+681838'),\n", - " 's2': Decimal('4.768E+681837'),\n", - " 's3': Decimal('0.9775'),\n", - " 's4': Decimal('43.07'),\n", - " 'timestamp': '2018-10-01 15:16:43',\n", - " 'mech_step': 2,\n", - " 'time_step': 19},\n", - " {'s1': Decimal('1.698E+681838'),\n", - " 's2': Decimal('2.174E+681838'),\n", - " 's3': Decimal('1.163'),\n", - " 's4': Decimal('40.25'),\n", - " 'timestamp': '2018-10-01 15:16:43',\n", - " 'mech_step': 3,\n", - " 'time_step': 19}])" + "\"[{'s1': Decimal('2'), 's2': Decimal('4'), 's3': Decimal('0'), 's4': Decimal('0'), 'timestamp': '2018-10-01 15:16:24', 'mech_step': 0, 'time_step': 0}, {'s1': Decimal('12'), 's2': Decimal('15'), 's3': Decimal('1.027943375654487123682656602'), 's4': Decimal('2.873162181767157652423350100'), 'timestamp': '2018-10-01 15:16:25', 'mech_step': 1, 'time_step': 1}, {'s1': Decimal('24.8'), 's2': Decimal('15'), 's3': Decimal('1.658405192679980226295085390'), 's4': Decimal('5.350515951995874829597979645'), 'timestamp': '2018-10-01 15:16:25', 'mech_step': 2, 'time_step': 1}, {'s1': Decimal('24.8'), 's2': Decimal('513.8'), 's3': Decimal('2.771923735333028371712141099'), 's4': Decimal('7.030344993582647198055332758'), 'timestamp': '2018-10-01 15:16:25', 'mech_step': 3, 'time_step': 1}, {'s1': Decimal('12791.84'), 's2': Decimal('13281.84'), 's3': Decimal('2.884737635508387705829249992'), 's4': Decimal('6.383750387315317896150130866'), 'timestamp': '2018-10-01 15:16:26', 'mech_step': 1, 'time_step': 2}, {'s1': Decimal('25584.64310752124705613077706'), 's2': Decimal('13281.84'), 's3': Decimal('2.641176859741037975691526862'), 's4': Decimal('7.563409402906505259061057559'), 'timestamp': '2018-10-01 15:16:26', 'mech_step': 2, 'time_step': 2}, {'s1': Decimal('25584.64310752124705613077706'), 's2': Decimal('39578.28310752124705613077706'), 's3': Decimal('2.493318466952763629633252152'), 's4': Decimal('5.891297175440944153224023488'), 'timestamp': '2018-10-01 15:16:26', 'mech_step': 3, 'time_step': 2}, {'s1': Decimal('1012647417.400583119401298502'), 's2': Decimal('1012661412.040583119401298502'), 's3': Decimal('2.343589605293861443271839926'), 's4': Decimal('5.974841965491865064823816188'), 'timestamp': '2018-10-01 15:16:27', 'mech_step': 1, 'time_step': 3}, {'s1': Decimal('2025294835.801152419139051417'), 's2': Decimal('1012661412.040583119401298502'), 's3': Decimal('2.722049618518731799375577601'), 's4': Decimal('6.419153303484813228317291423'), 'timestamp': '2018-10-01 15:16:27', 'mech_step': 2, 'time_step': 3}, {'s1': Decimal('2025294835.801152419139051417'), 's2': Decimal('3037996532.124843059787406050'), 's3': Decimal('2.829557844805450150205458129'), 's4': Decimal('6.506538668695062046307737283'), 'timestamp': '2018-10-01 15:16:27', 'mech_step': 3, 'time_step': 3}, {'s1': Decimal('6152838691744844166.823201459'), 's2': Decimal('6152838692757545864.146892100'), 's3': Decimal('2.488931860190471537369309149'), 's4': Decimal('6.300408321924320755651096195'), 'timestamp': '2018-10-01 15:16:28', 'mech_step': 1, 'time_step': 4}, {'s1': Decimal('12305677383489688334.64640292'), 's2': Decimal('6152838692757545864.146892100'), 's3': Decimal('2.178444472215797343328528750'), 's4': Decimal('6.784326268377325448300165109'), 'timestamp': '2018-10-01 15:16:28', 'mech_step': 2, 'time_step': 4}, {'s1': Decimal('12305677383489688334.64640292'), 's2': Decimal('18458516079285231057.91813808'), 's3': Decimal('2.161551452331358618745550185'), 's4': Decimal('6.035792378762528032341888172'), 'timestamp': '2018-10-01 15:16:28', 'mech_step': 3, 'time_step': 4}, {'s1': Decimal('2.271445438496410226588727850E+38'), 's2': Decimal('2.271445438496410226650256237E+38'), 's3': Decimal('2.158667996440737307324876748'), 's4': Decimal('6.371107803673317814010318446'), 'timestamp': '2018-10-01 15:16:29', 'mech_step': 1, 'time_step': 5}, {'s1': Decimal('4.542890876992820453177455700E+38'), 's2': Decimal('2.271445438496410226650256237E+38'), 's3': Decimal('1.992812515458891464887812476'), 's4': Decimal('7.282620522632285439020785561'), 'timestamp': '2018-10-01 15:16:29', 'mech_step': 2, 'time_step': 5}, {'s1': Decimal('4.542890876992820453177455700E+38'), 's2': Decimal('6.814336315489230680012297098E+38'), 's3': Decimal('2.050849993464547990799409445'), 's4': Decimal('6.524227074744597056029341316'), 'timestamp': '2018-10-01 15:16:29', 'mech_step': 3, 'time_step': 5}, {'s1': Decimal('3.095678628039689600133475180E+77'), 's2': Decimal('3.095678628039689600133475180E+77'), 's3': Decimal('2.010380376097353148038039474'), 's4': Decimal('5.989349144044895224884420424'), 'timestamp': '2018-10-01 15:16:30', 'mech_step': 1, 'time_step': 6}, {'s1': Decimal('6.191357256079379200266950360E+77'), 's2': Decimal('3.095678628039689600133475180E+77'), 's3': Decimal('2.226864095678880891887671486'), 's4': Decimal('6.070768581048944995923972497'), 'timestamp': '2018-10-01 15:16:30', 'mech_step': 2, 'time_step': 6}, {'s1': Decimal('6.191357256079379200266950360E+77'), 's2': Decimal('9.287035884119068800400425540E+77'), 's3': Decimal('2.324269409720218352898828188'), 's4': Decimal('6.671515324796301588344886525'), 'timestamp': '2018-10-01 15:16:30', 'mech_step': 3, 'time_step': 6}, {'s1': Decimal('5.749935700861016926665423233E+155'), 's2': Decimal('5.749935700861016926665423233E+155'), 's3': Decimal('2.302607714744926584899159503'), 's4': Decimal('7.564930163192297989174091445'), 'timestamp': '2018-10-01 15:16:31', 'mech_step': 1, 'time_step': 7}, {'s1': Decimal('1.149987140172203385333084647E+156'), 's2': Decimal('5.749935700861016926665423233E+155'), 's3': Decimal('2.333838309242175687275651869'), 's4': Decimal('8.079819700247225677794342322'), 'timestamp': '2018-10-01 15:16:31', 'mech_step': 2, 'time_step': 7}, {'s1': Decimal('1.149987140172203385333084647E+156'), 's2': Decimal('1.724980710258305077999626970E+156'), 's3': Decimal('2.127828342872591238967325177'), 's4': Decimal('7.538873530077748135396698368'), 'timestamp': '2018-10-01 15:16:31', 'mech_step': 3, 'time_step': 7}, {'s1': Decimal('1.983705633842164435837016890E+312'), 's2': Decimal('1.983705633842164435837016890E+312'), 's3': Decimal('2.316086720133955499001671373'), 's4': Decimal('6.698731880418827259665498103'), 'timestamp': '2018-10-01 15:16:32', 'mech_step': 1, 'time_step': 8}, {'s1': Decimal('3.967411267684328871674033780E+312'), 's2': Decimal('1.983705633842164435837016890E+312'), 's3': Decimal('2.404840197025546934576512657'), 's4': Decimal('6.861496713777041844809717113'), 'timestamp': '2018-10-01 15:16:32', 'mech_step': 2, 'time_step': 8}, {'s1': Decimal('3.967411267684328871674033780E+312'), 's2': Decimal('5.951116901526493307511050670E+312'), 's3': Decimal('2.304559767911563562114836868'), 's4': Decimal('7.134761053609609291468324912'), 'timestamp': '2018-10-01 15:16:32', 'mech_step': 3, 'time_step': 8}, {'s1': Decimal('2.361052825042286016164133532E+625'), 's2': Decimal('2.361052825042286016164133532E+625'), 's3': Decimal('2.331706686848056480258922690'), 's4': Decimal('6.349543276872486350505972604'), 'timestamp': '2018-10-01 15:16:33', 'mech_step': 1, 'time_step': 9}, {'s1': Decimal('4.722105650084572032328267064E+625'), 's2': Decimal('2.361052825042286016164133532E+625'), 's3': Decimal('2.206567414513102300934412097'), 's4': Decimal('6.387507504315002156007687646'), 'timestamp': '2018-10-01 15:16:33', 'mech_step': 2, 'time_step': 9}, {'s1': Decimal('4.722105650084572032328267064E+625'), 's2': Decimal('7.083158475126858048492400596E+625'), 's3': Decimal('2.755381458293744817475387505'), 's4': Decimal('6.599724434632028086026631189'), 'timestamp': '2018-10-01 15:16:33', 'mech_step': 3, 'time_step': 9}, {'s1': Decimal('3.344742265584095796507860632E+1251'), 's2': Decimal('3.344742265584095796507860632E+1251'), 's3': Decimal('2.631014270278374984244193109'), 's4': Decimal('7.289437871820951073267599940'), 'timestamp': '2018-10-01 15:16:34', 'mech_step': 1, 'time_step': 10}, {'s1': Decimal('6.689484531168191593015721264E+1251'), 's2': Decimal('3.344742265584095796507860632E+1251'), 's3': Decimal('2.767520795662379664467196631'), 's4': Decimal('6.567373343213126668766057155'), 'timestamp': '2018-10-01 15:16:34', 'mech_step': 2, 'time_step': 10}, {'s1': Decimal('6.689484531168191593015721264E+1251'), 's2': Decimal('1.003422679675228738952358190E+1252'), 's3': Decimal('2.868382538980392112200644477'), 's4': Decimal('6.933152742813279229430635728'), 'timestamp': '2018-10-01 15:16:34', 'mech_step': 3, 'time_step': 10}]\"" ] }, - "execution_count": 19, + "execution_count": 71, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "configs = generate_config(mechanisms, exogenous_states)\n", - "\n", - "pipeline(states_list, configs, env_processes, range(19))\n", - "# a = block_gen(states_list, configs, env_processes, 1)\n", - "# b = block_gen(a, configs, env_processes, 2)" + "flatten(pipeline(states_list, configs, env_processes, range(10)))" ] }, { "cell_type": "code", - "execution_count": 11, + "execution_count": 75, + "metadata": { + "collapsed": true + }, + "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
00240002018-10-01 15:16:24
1112150.91347900357833378137684121612.50224537938149438343060637612018-10-01 15:16:25
2224.8152.2486857305845532188692197125.51287007746884128939653377412018-10-01 15:16:25
3324.8548.83.4312752329536155393127174849.15222284342932628210604571712018-10-01 15:16:25
4113659.8414184.843.3228146720543445445725350397.70881538225254456160390488022018-10-01 15:16:26
5227320.6429886554941754718417714184.842.8976416333156811794413001447.87144037939911266527043420522018-10-01 15:16:26
6327320.6429886554941754718417743033.282988655494175471841773.1099373514674137757517211948.63077690792905289331599721422018-10-01 15:16:26
711175751602.4488157878316257271175767316.0888157878316257273.1762283649007351571365985979.47687555402766473298349093332018-10-01 15:16:27
822351503205.8976182110801532681175767316.0888157878316257273.6693420853932657385847473939.07896932290232850017764210932018-10-01 15:16:27
932351503205.8976182110801532683527313580.2694226544059544673.34975996098706446435798834811.1714439114040052636610562632018-10-01 15:16:27
1018294489196912759452.9706154948294489198088569828.3424199373.29162106267578062636028319811.7915857380119372108952702142018-10-01 15:16:28
11216588978393825518906.941230998294489198088569828.3424199373.19026040135236422790237030910.8352100528422372882380039242018-10-01 15:16:28
12316588978393825518906.9412309924883467595441402812.553073583.12108558165304708498273819911.9017186296980778069815841242018-10-01 15:16:28
1314.127913063042348695585266519E+384.127913063042348695668211411E+383.45118238249576888355648036310.5656460156203145282810118152018-10-01 15:16:29
1428.255826126084697391170533038E+384.127913063042348695668211411E+383.74189940679731861037715655111.5115560290072500272497913152018-10-01 15:16:29
1538.255826126084697391170533038E+381.238373918912704608708757912E+393.50226109299384254562003403510.0587350995908767698616463452018-10-01 15:16:29
1611.022379975362139926212390600E+781.022379975362139926212390600E+783.46992706653546389898112219310.8539209327031011426828305962018-10-01 15:16:30
1722.044759950724279852424781200E+781.022379975362139926212390600E+783.38983663612009305381756851710.2205276041921032039322294162018-10-01 15:16:30
1832.044759950724279852424781200E+783.067139926086419778637171800E+783.69123457683711874967611059811.3777857442305618148252315062018-10-01 15:16:30
1916.271564884128939055277180913E+1566.271564884128939055277180913E+1563.62617801935823680686355156612.2205126370512860614055141272018-10-01 15:16:31
2021.254312976825787811055436183E+1576.271564884128939055277180913E+1563.22078515043333255599060413412.7670236400115368185243901172018-10-01 15:16:31
2131.254312976825787811055436183E+1571.881469465238681716583154274E+1573.10956878027570033382925798112.8418798070583525716279923472018-10-01 15:16:31
2212.359951565750353965511297842E+3142.359951565750353965511297842E+3143.09471215038725924287956726114.2378130192524730069674725482018-10-01 15:16:32
2324.719903131500707931022595684E+3142.359951565750353965511297842E+3143.37856548607312751538170047311.6702485226548511088284011782018-10-01 15:16:32
2434.719903131500707931022595684E+3147.079854697251061896533893526E+3143.80961195940413592076084272412.1750501842605951725718621582018-10-01 15:16:32
2513.341622835612528353592630685E+6293.341622835612528353592630685E+6294.30134446582968607869876923112.6784065728960961200549137892018-10-01 15:16:33
2626.683245671225056707185261370E+6293.341622835612528353592630685E+6294.45796012493645100811682422813.3911230620646779720618895792018-10-01 15:16:33
2736.683245671225056707185261370E+6291.002486850683758506077789206E+6304.22706706849519725133027999614.4975362454358034942992364392018-10-01 15:16:33
2816.699865905292268815365221375E+12596.699865905292268815365221375E+12594.47278066076339182371743610614.66684234187518294415503523102018-10-01 15:16:34
2921.339973181058453763073044275E+12606.699865905292268815365221375E+12594.38738429071790456710398785715.84678912512812579758546608102018-10-01 15:16:34
3031.339973181058453763073044275E+12602.009959771587680644609566412E+12604.11306154440989092204479520216.08824426908686380482178405102018-10-01 15:16:34
\n", + "
" + ], + "text/plain": [ + " mech_step s1 \\\n", + "0 0 2 \n", + "1 1 12 \n", + "2 2 24.8 \n", + "3 3 24.8 \n", + "4 1 13659.84 \n", + "5 2 27320.64298865549417547184177 \n", + "6 3 27320.64298865549417547184177 \n", + "7 1 1175751602.448815787831625727 \n", + "8 2 2351503205.897618211080153268 \n", + "9 3 2351503205.897618211080153268 \n", + "10 1 8294489196912759452.970615494 \n", + "11 2 16588978393825518906.94123099 \n", + "12 3 16588978393825518906.94123099 \n", + "13 1 4.127913063042348695585266519E+38 \n", + "14 2 8.255826126084697391170533038E+38 \n", + "15 3 8.255826126084697391170533038E+38 \n", + "16 1 1.022379975362139926212390600E+78 \n", + "17 2 2.044759950724279852424781200E+78 \n", + "18 3 2.044759950724279852424781200E+78 \n", + "19 1 6.271564884128939055277180913E+156 \n", + "20 2 1.254312976825787811055436183E+157 \n", + "21 3 1.254312976825787811055436183E+157 \n", + "22 1 2.359951565750353965511297842E+314 \n", + "23 2 4.719903131500707931022595684E+314 \n", + "24 3 4.719903131500707931022595684E+314 \n", + "25 1 3.341622835612528353592630685E+629 \n", + "26 2 6.683245671225056707185261370E+629 \n", + "27 3 6.683245671225056707185261370E+629 \n", + "28 1 6.699865905292268815365221375E+1259 \n", + "29 2 1.339973181058453763073044275E+1260 \n", + "30 3 1.339973181058453763073044275E+1260 \n", + "\n", + " s2 s3 \\\n", + "0 4 0 \n", + "1 15 0.9134790035783337813768412161 \n", + "2 15 2.248685730584553218869219712 \n", + "3 548.8 3.431275232953615539312717484 \n", + "4 14184.84 3.322814672054344544572535039 \n", + "5 14184.84 2.897641633315681179441300144 \n", + "6 43033.28298865549417547184177 3.109937351467413775751721194 \n", + "7 1175767316.088815787831625727 3.176228364900735157136598597 \n", + "8 1175767316.088815787831625727 3.669342085393265738584747393 \n", + "9 3527313580.269422654405954467 3.349759960987064464357988348 \n", + "10 8294489198088569828.342419937 3.291621062675780626360283198 \n", + "11 8294489198088569828.342419937 3.190260401352364227902370309 \n", + "12 24883467595441402812.55307358 3.121085581653047084982738199 \n", + "13 4.127913063042348695668211411E+38 3.451182382495768883556480363 \n", + "14 4.127913063042348695668211411E+38 3.741899406797318610377156551 \n", + "15 1.238373918912704608708757912E+39 3.502261092993842545620034035 \n", + "16 1.022379975362139926212390600E+78 3.469927066535463898981122193 \n", + "17 1.022379975362139926212390600E+78 3.389836636120093053817568517 \n", + "18 3.067139926086419778637171800E+78 3.691234576837118749676110598 \n", + "19 6.271564884128939055277180913E+156 3.626178019358236806863551566 \n", + "20 6.271564884128939055277180913E+156 3.220785150433332555990604134 \n", + "21 1.881469465238681716583154274E+157 3.109568780275700333829257981 \n", + "22 2.359951565750353965511297842E+314 3.094712150387259242879567261 \n", + "23 2.359951565750353965511297842E+314 3.378565486073127515381700473 \n", + "24 7.079854697251061896533893526E+314 3.809611959404135920760842724 \n", + "25 3.341622835612528353592630685E+629 4.301344465829686078698769231 \n", + "26 3.341622835612528353592630685E+629 4.457960124936451008116824228 \n", + "27 1.002486850683758506077789206E+630 4.227067068495197251330279996 \n", + "28 6.699865905292268815365221375E+1259 4.472780660763391823717436106 \n", + "29 6.699865905292268815365221375E+1259 4.387384290717904567103987857 \n", + "30 2.009959771587680644609566412E+1260 4.113061544409890922044795202 \n", + "\n", + " s4 time_step timestamp \n", + "0 0 0 2018-10-01 15:16:24 \n", + "1 2.502245379381494383430606376 1 2018-10-01 15:16:25 \n", + "2 5.512870077468841289396533774 1 2018-10-01 15:16:25 \n", + "3 9.152222843429326282106045717 1 2018-10-01 15:16:25 \n", + "4 7.708815382252544561603904880 2 2018-10-01 15:16:26 \n", + "5 7.871440379399112665270434205 2 2018-10-01 15:16:26 \n", + "6 8.630776907929052893315997214 2 2018-10-01 15:16:26 \n", + "7 9.476875554027664732983490933 3 2018-10-01 15:16:27 \n", + "8 9.078969322902328500177642109 3 2018-10-01 15:16:27 \n", + "9 11.17144391140400526366105626 3 2018-10-01 15:16:27 \n", + "10 11.79158573801193721089527021 4 2018-10-01 15:16:28 \n", + "11 10.83521005284223728823800392 4 2018-10-01 15:16:28 \n", + "12 11.90171862969807780698158412 4 2018-10-01 15:16:28 \n", + "13 10.56564601562031452828101181 5 2018-10-01 15:16:29 \n", + "14 11.51155602900725002724979131 5 2018-10-01 15:16:29 \n", + "15 10.05873509959087676986164634 5 2018-10-01 15:16:29 \n", + "16 10.85392093270310114268283059 6 2018-10-01 15:16:30 \n", + "17 10.22052760419210320393222941 6 2018-10-01 15:16:30 \n", + "18 11.37778574423056181482523150 6 2018-10-01 15:16:30 \n", + "19 12.22051263705128606140551412 7 2018-10-01 15:16:31 \n", + "20 12.76702364001153681852439011 7 2018-10-01 15:16:31 \n", + "21 12.84187980705835257162799234 7 2018-10-01 15:16:31 \n", + "22 14.23781301925247300696747254 8 2018-10-01 15:16:32 \n", + "23 11.67024852265485110882840117 8 2018-10-01 15:16:32 \n", + "24 12.17505018426059517257186215 8 2018-10-01 15:16:32 \n", + "25 12.67840657289609612005491378 9 2018-10-01 15:16:33 \n", + "26 13.39112306206467797206188957 9 2018-10-01 15:16:33 \n", + "27 14.49753624543580349429923643 9 2018-10-01 15:16:33 \n", + "28 14.66684234187518294415503523 10 2018-10-01 15:16:34 \n", + "29 15.84678912512812579758546608 10 2018-10-01 15:16:34 \n", + "30 16.08824426908686380482178405 10 2018-10-01 15:16:34 " + ] + }, + "execution_count": 75, + "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": 42, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "0\n", + "1\n", + "2\n", + "3\n", + "4\n" + ] + } + ], + "source": [ + "for x in list(range(5)):\n", + " print(x)" + ] + }, + { + "cell_type": "code", + "execution_count": 61, + "metadata": {}, + "outputs": [], + "source": [ + "def simulation(states_list, configs, env_processes, time_seq, runs):\n", + " pipeline_run = []\n", + " for run in range(runs):\n", + " if run == 0:\n", + " pipeline_run += pipeline(states_list, configs, env_processes, time_seq)\n", + "# pipeline_run += [run]\n", + " else:\n", + " pipeline_run += pipeline(pipeline_run[-1], configs, env_processes, time_seq)\n", + "# pipeline_run += [run]\n", + " return pipeline_run" + ] + }, + { + "cell_type": "code", + "execution_count": 79, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "999999999999999995000000000000000009999999999999999990000000000000000004999999999999999999" + "[0, 1]" ] }, - "execution_count": 11, + "execution_count": 79, "metadata": {}, "output_type": "execute_result" } ], + "source": [ + "list(range(2))" + ] + }, + { + "cell_type": "code", + "execution_count": 77, + "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", + "
mech_steps1s2s3s4time_steptimestamp
00240002018-10-01 15:16:24
1112150.96133742191122872888797701313.05262791623336182667003413412018-10-01 15:16:25
2224.8151.7878418867054752478439788316.14210807562603620769166584212018-10-01 15:16:25
3324.8463.82.6603514160051104294423873439.30572704359699394374669537612018-10-01 15:16:25
4111551.8411991.842.4646451853433646554407158469.33777728437343571731501191922018-10-01 15:16:26
5223104.6433083830337963148274211991.842.30463914826193806262431798010.2960246753892924374554966522018-10-01 15:16:26
6023104.6433083830337963148274236429.283308383033796314827421.74501435017167714302639392610.7983192271393526493051916502018-10-01 15:16:26
7111551.8411991.842.4646451853433646554407158469.33777728437343571731501191922018-10-01 15:16:26
8223104.6433083830337963148274211991.842.30463914826193806262431798010.2960246753892924374554966522018-10-01 15:16:26
9023104.6433083830337963148274236429.283308383033796314827421.74501435017167714302639392610.7983192271393526493051916502018-10-01 15:16:26
101841731806.1068385748529941713841745131.74683857485299417132.67443317714085638901916999613.0006236569486193745271504912018-10-01 15:16:27
1121683463613.213661318738279214841745131.74683857485299417133.62410141757133180976719867316.2064237531334924799690398512018-10-01 15:16:27
1231683463613.2136613187382792142525245934.2438082766250697005.62404596810520747959405439719.0605228567092632757599263112018-10-01 15:16:27
1314251159648082116507.1228759154251159648923898829.1530228735.99385581199740180262345385019.9848285645724548773428862922018-10-01 15:16:28
1428502319296164233015.2457518304251159648923898829.1530228735.89779674502673599164725994120.3451883001598149011174066822018-10-01 15:16:28
1538502319296164233015.24575183012753478947613377799.642582985.92907068676888572790928438921.1886549224812131716461903422018-10-01 15:16:28
\n", + "
" + ], + "text/plain": [ + " mech_step s1 s2 \\\n", + "0 0 2 4 \n", + "1 1 12 15 \n", + "2 2 24.8 15 \n", + "3 3 24.8 463.8 \n", + "4 1 11551.84 11991.84 \n", + "5 2 23104.64330838303379631482742 11991.84 \n", + "6 0 23104.64330838303379631482742 36429.28330838303379631482742 \n", + "7 1 11551.84 11991.84 \n", + "8 2 23104.64330838303379631482742 11991.84 \n", + "9 0 23104.64330838303379631482742 36429.28330838303379631482742 \n", + "10 1 841731806.1068385748529941713 841745131.7468385748529941713 \n", + "11 2 1683463613.213661318738279214 841745131.7468385748529941713 \n", + "12 3 1683463613.213661318738279214 2525245934.243808276625069700 \n", + "13 1 4251159648082116507.122875915 4251159648923898829.153022873 \n", + "14 2 8502319296164233015.245751830 4251159648923898829.153022873 \n", + "15 3 8502319296164233015.245751830 12753478947613377799.64258298 \n", + "\n", + " s3 s4 time_step \\\n", + "0 0 0 0 \n", + "1 0.9613374219112287288879770131 3.052627916233361826670034134 1 \n", + "2 1.787841886705475247843978831 6.142108075626036207691665842 1 \n", + "3 2.660351416005110429442387343 9.305727043596993943746695376 1 \n", + "4 2.464645185343364655440715846 9.337777284373435717315011919 2 \n", + "5 2.304639148261938062624317980 10.29602467538929243745549665 2 \n", + "6 1.745014350171677143026393926 10.79831922713935264930519165 0 \n", + "7 2.464645185343364655440715846 9.337777284373435717315011919 2 \n", + "8 2.304639148261938062624317980 10.29602467538929243745549665 2 \n", + "9 1.745014350171677143026393926 10.79831922713935264930519165 0 \n", + "10 2.674433177140856389019169996 13.00062365694861937452715049 1 \n", + "11 3.624101417571331809767198673 16.20642375313349247996903985 1 \n", + "12 5.624045968105207479594054397 19.06052285670926327575992631 1 \n", + "13 5.993855811997401802623453850 19.98482856457245487734288629 2 \n", + "14 5.897796745026735991647259941 20.34518830015981490111740668 2 \n", + "15 5.929070686768885727909284389 21.18865492248121317164619034 2 \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:26 \n", + "8 2018-10-01 15:16:26 \n", + "9 2018-10-01 15:16:26 \n", + "10 2018-10-01 15:16:27 \n", + "11 2018-10-01 15:16:27 \n", + "12 2018-10-01 15:16:27 \n", + "13 2018-10-01 15:16:28 \n", + "14 2018-10-01 15:16:28 \n", + "15 2018-10-01 15:16:28 " + ] + }, + "execution_count": 77, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "pd.DataFrame(flatten(simulation(states_list, configs, env_processes, range(2), 2)))" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "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", @@ -810,42 +1199,22 @@ }, { "cell_type": "code", - "execution_count": 12, + "execution_count": null, "metadata": { "scrolled": true }, - "outputs": [ - { - "data": { - "text/plain": [ - "1000000" - ] - }, - "execution_count": 12, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "1000 * 1000" ] }, { "cell_type": "code", - "execution_count": 13, + "execution_count": null, "metadata": { "scrolled": true }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "2018-10-02 12:37:06.309267\n", - "2018-10-02 12:38:06.309267\n" - ] - } - ], + "outputs": [], "source": [ "from datetime import datetime, timedelta\n", "# from datetime import timedelta \n", @@ -858,20 +1227,9 @@ }, { "cell_type": "code", - "execution_count": 14, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "datetime.datetime(2018, 10, 2, 12, 37, 6)" - ] - }, - "execution_count": 14, - "metadata": {}, - "output_type": "execute_result" - } - ], + "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", @@ -880,21 +1238,9 @@ }, { "cell_type": "code", - "execution_count": 15, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "ename": "TypeError", - "evalue": "Required argument 'timestamp' (pos 1) not found", - "output_type": "error", - "traceback": [ - "\u001b[0;31m--------------------------------------------------------------------------\u001b[0m", - "\u001b[0;31mTypeError\u001b[0m Traceback (most recent call last)", - "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m()\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mdatetime\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mfromtimestamp\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", - "\u001b[0;31mTypeError\u001b[0m: Required argument 'timestamp' (pos 1) not found" - ] - } - ], + "outputs": [], "source": [ "datetime.fromtimestamp()" ]