identity fix pt.2 (behaviors)
This commit is contained in:
parent
16fe59c106
commit
f2bf23cc37
|
|
@ -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):
|
||||
|
|
|
|||
|
|
@ -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 @@
|
|||
" <function __main__.behavior_identity.<locals>.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": [
|
||||
"<div>\n",
|
||||
"<style scoped>\n",
|
||||
" .dataframe tbody tr th:only-of-type {\n",
|
||||
" vertical-align: middle;\n",
|
||||
" }\n",
|
||||
"\n",
|
||||
" .dataframe tbody tr th {\n",
|
||||
" vertical-align: top;\n",
|
||||
" }\n",
|
||||
"\n",
|
||||
" .dataframe thead th {\n",
|
||||
" text-align: right;\n",
|
||||
" }\n",
|
||||
"</style>\n",
|
||||
"<table border=\"1\" class=\"dataframe\">\n",
|
||||
" <thead>\n",
|
||||
" <tr style=\"text-align: right;\">\n",
|
||||
" <th></th>\n",
|
||||
" <th>b1</th>\n",
|
||||
" <th>b2</th>\n",
|
||||
" <th>s1</th>\n",
|
||||
" <th>s2</th>\n",
|
||||
" <th>es0</th>\n",
|
||||
" <th>es1</th>\n",
|
||||
" <th>es2</th>\n",
|
||||
" <th>m</th>\n",
|
||||
" </tr>\n",
|
||||
" </thead>\n",
|
||||
" <tbody>\n",
|
||||
" <tr>\n",
|
||||
" <th>0</th>\n",
|
||||
" <td><function b1m1 at 0x10af42158></td>\n",
|
||||
" <td><function b2m1 at 0x10af42268></td>\n",
|
||||
" <td><function s1m1 at 0x10af42510></td>\n",
|
||||
" <td><function s2m1 at 0x10af42598></td>\n",
|
||||
" <td><function es3p1 at 0x10af42840></td>\n",
|
||||
" <td><function es4p2 at 0x10af428c8></td>\n",
|
||||
" <td><function es5p2 at 0x10af42950></td>\n",
|
||||
" <td>1</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>1</th>\n",
|
||||
" <td><function b1m2 at 0x10af422f0></td>\n",
|
||||
" <td><function b2m2 at 0x10af42400></td>\n",
|
||||
" <td><function s1m2 at 0x10af42620></td>\n",
|
||||
" <td><function state_identity.<locals>.identity at ...</td>\n",
|
||||
" <td><function es3p1 at 0x10af42840></td>\n",
|
||||
" <td><function es4p2 at 0x10af428c8></td>\n",
|
||||
" <td><function es5p2 at 0x10af42950></td>\n",
|
||||
" <td>2</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>2</th>\n",
|
||||
" <td><function behavior_identity.<locals>.identity ...</td>\n",
|
||||
" <td><function behavior_identity.<locals>.identity ...</td>\n",
|
||||
" <td><function s1m3 at 0x10af42730></td>\n",
|
||||
" <td><function state_identity.<locals>.identity at ...</td>\n",
|
||||
" <td><function es3p1 at 0x10af42840></td>\n",
|
||||
" <td><function es4p2 at 0x10af428c8></td>\n",
|
||||
" <td><function es5p2 at 0x10af42950></td>\n",
|
||||
" <td>3</td>\n",
|
||||
" </tr>\n",
|
||||
" </tbody>\n",
|
||||
"</table>\n",
|
||||
"</div>"
|
||||
],
|
||||
"text/plain": [
|
||||
" b1 \\\n",
|
||||
"0 <function b1m1 at 0x10af42158> \n",
|
||||
"1 <function b1m2 at 0x10af422f0> \n",
|
||||
"2 <function behavior_identity.<locals>.identity ... \n",
|
||||
"\n",
|
||||
" b2 \\\n",
|
||||
"0 <function b2m1 at 0x10af42268> \n",
|
||||
"1 <function b2m2 at 0x10af42400> \n",
|
||||
"2 <function behavior_identity.<locals>.identity ... \n",
|
||||
"\n",
|
||||
" s1 \\\n",
|
||||
"0 <function s1m1 at 0x10af42510> \n",
|
||||
"1 <function s1m2 at 0x10af42620> \n",
|
||||
"2 <function s1m3 at 0x10af42730> \n",
|
||||
"\n",
|
||||
" s2 \\\n",
|
||||
"0 <function s2m1 at 0x10af42598> \n",
|
||||
"1 <function state_identity.<locals>.identity at ... \n",
|
||||
"2 <function state_identity.<locals>.identity at ... \n",
|
||||
"\n",
|
||||
" es0 es1 \\\n",
|
||||
"0 <function es3p1 at 0x10af42840> <function es4p2 at 0x10af428c8> \n",
|
||||
"1 <function es3p1 at 0x10af42840> <function es4p2 at 0x10af428c8> \n",
|
||||
"2 <function es3p1 at 0x10af42840> <function es4p2 at 0x10af428c8> \n",
|
||||
"\n",
|
||||
" es2 m \n",
|
||||
"0 <function es5p2 at 0x10af42950> 1 \n",
|
||||
"1 <function es5p2 at 0x10af42950> 2 \n",
|
||||
"2 <function es5p2 at 0x10af42950> 3 "
|
||||
]
|
||||
},
|
||||
"execution_count": 4,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"# generate_config(mechanisms, ep)\n",
|
||||
"create_tensor_field(mechanisms)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 5,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
|
|
@ -214,35 +330,23 @@
|
|||
" [<function __main__.b1m1(step, sL, s)>,\n",
|
||||
" <function __main__.b2m1(step, sL, s)>]),\n",
|
||||
" ([<function __main__.s1m2(step, sL, s, _input)>,\n",
|
||||
" <function __main__.state_identity.<locals>.identity(step, sL, s, _input)>,\n",
|
||||
" <function __main__.es3p1(step, sL, s, _input)>,\n",
|
||||
" <function __main__.es4p2(step, sL, s, _input)>,\n",
|
||||
" <function __main__.es5p2(step, sL, s, _input)>],\n",
|
||||
" [<function __main__.b1m2(step, sL, s)>,\n",
|
||||
" <function __main__.b2m2(step, sL, s)>]),\n",
|
||||
" ([<function __main__.s1m3(step, sL, s, _input)>,\n",
|
||||
" <function __main__.state_identity.<locals>.identity(step, sL, s, _input)>,\n",
|
||||
" <function __main__.es3p1(step, sL, s, _input)>,\n",
|
||||
" <function __main__.es4p2(step, sL, s, _input)>,\n",
|
||||
" <function __main__.es5p2(step, sL, s, _input)>],\n",
|
||||
" [<function __main__.behavior_identity.<locals>.identity(step, sL, s)>,\n",
|
||||
" <function __main__.behavior_identity.<locals>.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",
|
||||
|
|
|
|||
15
ui/config.py
15
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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue