From f2bf23cc3735deabef96edccb51ed40b8d4d050a Mon Sep 17 00:00:00 2001 From: "Joshua E. Jodesty" Date: Tue, 6 Nov 2018 08:22:40 -0500 Subject: [PATCH] identity fix pt.2 (behaviors) --- engine/configProcessor.py | 2 +- notebooks/config_padding.ipynb | 140 ++++++++++++++++++++++++++++----- ui/config.py | 15 ++-- 3 files changed, 131 insertions(+), 26 deletions(-) diff --git a/engine/configProcessor.py b/engine/configProcessor.py index 4123d46..3a99ae3 100644 --- a/engine/configProcessor.py +++ b/engine/configProcessor.py @@ -8,7 +8,7 @@ def state_identity(k): def behavior_identity(k): def identity(step, sL, s): - return s[k] + return 0 return identity def key_filter(mechanisms, keyname): diff --git a/notebooks/config_padding.ipynb b/notebooks/config_padding.ipynb index e322af5..e70f546 100644 --- a/notebooks/config_padding.ipynb +++ b/notebooks/config_padding.ipynb @@ -12,7 +12,7 @@ }, { "cell_type": "code", - "execution_count": 177, + "execution_count": 2, "metadata": {}, "outputs": [], "source": [ @@ -173,7 +173,7 @@ }, { "cell_type": "code", - "execution_count": 183, + "execution_count": 3, "metadata": {}, "outputs": [ { @@ -187,7 +187,7 @@ " .identity(step, sL, s)>]]" ] }, - "execution_count": 183, + "execution_count": 3, "metadata": {}, "output_type": "execute_result" } @@ -200,7 +200,123 @@ }, { "cell_type": "code", - "execution_count": 181, + "execution_count": 4, + "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", + "
b1b2s1s2es0es1es2m
0<function b1m1 at 0x10af42158><function b2m1 at 0x10af42268><function s1m1 at 0x10af42510><function s2m1 at 0x10af42598><function es3p1 at 0x10af42840><function es4p2 at 0x10af428c8><function es5p2 at 0x10af42950>1
1<function b1m2 at 0x10af422f0><function b2m2 at 0x10af42400><function s1m2 at 0x10af42620><function state_identity.<locals>.identity at ...<function es3p1 at 0x10af42840><function es4p2 at 0x10af428c8><function es5p2 at 0x10af42950>2
2<function behavior_identity.<locals>.identity ...<function behavior_identity.<locals>.identity ...<function s1m3 at 0x10af42730><function state_identity.<locals>.identity at ...<function es3p1 at 0x10af42840><function es4p2 at 0x10af428c8><function es5p2 at 0x10af42950>3
\n", + "
" + ], + "text/plain": [ + " b1 \\\n", + "0 \n", + "1 \n", + "2 .identity ... \n", + "\n", + " b2 \\\n", + "0 \n", + "1 \n", + "2 .identity ... \n", + "\n", + " s1 \\\n", + "0 \n", + "1 \n", + "2 \n", + "\n", + " s2 \\\n", + "0 \n", + "1 .identity at ... \n", + "2 .identity at ... \n", + "\n", + " es0 es1 \\\n", + "0 \n", + "1 \n", + "2 \n", + "\n", + " es2 m \n", + "0 1 \n", + "1 2 \n", + "2 3 " + ] + }, + "execution_count": 4, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "# generate_config(mechanisms, ep)\n", + "create_tensor_field(mechanisms)" + ] + }, + { + "cell_type": "code", + "execution_count": 5, "metadata": {}, "outputs": [ { @@ -214,35 +330,23 @@ " [,\n", " ]),\n", " ([,\n", - " .identity(step, sL, s, _input)>,\n", " ,\n", " ,\n", " ],\n", " [,\n", " ]),\n", " ([,\n", - " .identity(step, sL, s, _input)>,\n", " ,\n", " ,\n", " ],\n", - " [.identity(step, sL, s)>,\n", - " .identity(step, sL, s)>])]" + " [])]" ] }, - "execution_count": 181, + "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], - "source": [ - "generate_config(mechanisms, ep)" - ] - }, - { - "cell_type": "code", - "execution_count": 180, - "metadata": {}, - "outputs": [], "source": [ "# def generate_config(mechanisms, exogenous_states):\n", "# es_funcs = list(exogenous_states.values())\n", diff --git a/ui/config.py b/ui/config.py index 0406033..34754af 100644 --- a/ui/config.py +++ b/ui/config.py @@ -52,7 +52,7 @@ def s1m3(step, sL, s, _input): return (y, x) def s2m3(step, sL, s, _input): y = 's2' - x = s['s2'] + _input + x = s['s2'] + s['s3'] + _input return (y, x) # Exogenous States @@ -101,15 +101,16 @@ env_processes = { # test return vs. non-return functions as lambdas # test fully defined functions +# genesis Sites should always be there mechanisms = { "m1": { "behaviors": { "b1": b1m1, # lambda step, sL, s: s['s1'] + 1, "b2": b2m1 }, - "states": { + "states": { # exclude only. TypeError: reduce() of empty sequence with no initial value "s1": s1m1, - # "s2": s2m1, + "s2": s2m1 } }, "m2": { @@ -118,8 +119,8 @@ mechanisms = { "b2": b2m2 }, "states": { - # "s1": s1m2, - # "s2": s2m2, + "s1": s1m2, + "s2": s2m2 } }, "m3": { @@ -128,8 +129,8 @@ mechanisms = { "b2": b2m3 #toggle for error }, "states": { - # "s1": s1m3, - # "s2": s2m3, + "s1": s1m3, + "s2": s2m3 } } }