merge heaven: working
This commit is contained in:
parent
8d56cf2939
commit
ed2f31cffc
|
|
@ -16,4 +16,5 @@ def config_sim(d):
|
|||
for M in process_variables(d["M"])
|
||||
]
|
||||
else:
|
||||
d["M"] = [{}]
|
||||
return d
|
||||
|
|
|
|||
|
|
@ -55,7 +55,6 @@ class Executor:
|
|||
Ts.append(x.sim_config['T'])
|
||||
Ns.append(x.sim_config['N'])
|
||||
var_dict_list.append(x.sim_config['M'])
|
||||
|
||||
states_lists.append([x.state_dict])
|
||||
eps.append(list(x.exogenous_states.values()))
|
||||
configs_structs.append(config_proc.generate_config(x.state_dict, x.mechanisms, eps[config_idx]))
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ import pandas as pd
|
|||
from tabulate import tabulate
|
||||
# The following imports NEED to be in the exact order
|
||||
from SimCAD.engine import ExecutionMode, ExecutionContext, Executor
|
||||
from simulations.validation import sweep_config
|
||||
from simulations.validation import config1, config2 # sweep_config
|
||||
from SimCAD import configs
|
||||
|
||||
exec_mode = ExecutionMode()
|
||||
|
|
|
|||
|
|
@ -2,10 +2,9 @@ from decimal import Decimal
|
|||
import numpy as np
|
||||
from datetime import timedelta
|
||||
|
||||
from SimCAD import configs
|
||||
from SimCAD.configuration import Configuration
|
||||
from SimCAD.configuration.utils import exo_update_per_ts, proc_trigger, bound_norm_random, \
|
||||
ep_time_step
|
||||
from SimCAD.configuration import append_configs
|
||||
from SimCAD.configuration.utils import proc_trigger, bound_norm_random, ep_time_step
|
||||
from SimCAD.configuration.utils.parameterSweep import config_sim
|
||||
|
||||
|
||||
seed = {
|
||||
|
|
@ -17,46 +16,46 @@ seed = {
|
|||
|
||||
|
||||
# Behaviors per Mechanism
|
||||
def b1m1(step, sL, s):
|
||||
def b1m1(_g, step, sL, s):
|
||||
return {'param1': 1}
|
||||
def b2m1(step, sL, s):
|
||||
def b2m1(_g, step, sL, s):
|
||||
return {'param2': 4}
|
||||
|
||||
def b1m2(step, sL, s):
|
||||
def b1m2(_g, step, sL, s):
|
||||
return {'param1': 'a', 'param2': 2}
|
||||
def b2m2(step, sL, s):
|
||||
def b2m2(_g, step, sL, s):
|
||||
return {'param1': 'b', 'param2': 4}
|
||||
|
||||
def b1m3(step, sL, s):
|
||||
def b1m3(_g, step, sL, s):
|
||||
return {'param1': ['c'], 'param2': np.array([10, 100])}
|
||||
def b2m3(step, sL, s):
|
||||
def b2m3(_g, step, sL, s):
|
||||
return {'param1': ['d'], 'param2': np.array([20, 200])}
|
||||
|
||||
|
||||
# Internal States per Mechanism
|
||||
def s1m1(step, sL, s, _input):
|
||||
def s1m1(_g, step, sL, s, _input):
|
||||
y = 's1'
|
||||
x = _input['param1']
|
||||
return (y, x)
|
||||
def s2m1(step, sL, s, _input):
|
||||
def s2m1(_g, step, sL, s, _input):
|
||||
y = 's2'
|
||||
x = _input['param2']
|
||||
return (y, x)
|
||||
|
||||
def s1m2(step, sL, s, _input):
|
||||
def s1m2(_g, step, sL, s, _input):
|
||||
y = 's1'
|
||||
x = _input['param1']
|
||||
return (y, x)
|
||||
def s2m2(step, sL, s, _input):
|
||||
def s2m2(_g, step, sL, s, _input):
|
||||
y = 's2'
|
||||
x = _input['param2']
|
||||
return (y, x)
|
||||
|
||||
def s1m3(step, sL, s, _input):
|
||||
def s1m3(_g, step, sL, s, _input):
|
||||
y = 's1'
|
||||
x = _input['param1']
|
||||
return (y, x)
|
||||
def s2m3(step, sL, s, _input):
|
||||
def s2m3(_g, step, sL, s, _input):
|
||||
y = 's2'
|
||||
x = _input['param2']
|
||||
return (y, x)
|
||||
|
|
@ -66,19 +65,19 @@ def s2m3(step, sL, s, _input):
|
|||
proc_one_coef_A = 0.7
|
||||
proc_one_coef_B = 1.3
|
||||
|
||||
def es3p1(step, sL, s, _input):
|
||||
def es3p1(_g, step, sL, s, _input):
|
||||
y = 's3'
|
||||
x = s['s3'] * bound_norm_random(seed['a'], proc_one_coef_A, proc_one_coef_B)
|
||||
return (y, x)
|
||||
|
||||
def es4p2(step, sL, s, _input):
|
||||
def es4p2(_g, step, sL, s, _input):
|
||||
y = 's4'
|
||||
x = s['s4'] * bound_norm_random(seed['b'], proc_one_coef_A, proc_one_coef_B)
|
||||
return (y, x)
|
||||
|
||||
ts_format = '%Y-%m-%d %H:%M:%S'
|
||||
t_delta = timedelta(days=0, minutes=0, seconds=1)
|
||||
def es5p2(step, sL, s, _input):
|
||||
def es5p2(_g, step, sL, s, _input):
|
||||
y = 'timestamp'
|
||||
x = ep_time_step(s, dt_str=s['timestamp'], fromat_str=ts_format, _timedelta=t_delta)
|
||||
return (y, x)
|
||||
|
|
@ -103,14 +102,11 @@ genesis_states = {
|
|||
}
|
||||
|
||||
|
||||
# remove `exo_update_per_ts` to update every ts
|
||||
exogenous_states = exo_update_per_ts(
|
||||
{
|
||||
raw_exogenous_states = {
|
||||
"s3": es3p1,
|
||||
"s4": es4p2,
|
||||
"timestamp": es5p2
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
env_processes = {
|
||||
|
|
@ -153,19 +149,19 @@ mechanisms = {
|
|||
}
|
||||
|
||||
|
||||
sim_config = {
|
||||
"N": 2,
|
||||
"T": range(5)
|
||||
}
|
||||
|
||||
|
||||
configs.append(
|
||||
Configuration(
|
||||
sim_config=sim_config,
|
||||
state_dict=genesis_states,
|
||||
seed=seed,
|
||||
exogenous_states=exogenous_states,
|
||||
env_processes=env_processes,
|
||||
mechanisms=mechanisms
|
||||
)
|
||||
sim_config = config_sim(
|
||||
{
|
||||
"N": 2,
|
||||
"T": range(5),
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
append_configs(
|
||||
sim_configs=sim_config,
|
||||
state_dict=genesis_states,
|
||||
seed=seed,
|
||||
raw_exogenous_states=raw_exogenous_states,
|
||||
env_processes=env_processes,
|
||||
mechanisms=mechanisms
|
||||
)
|
||||
|
|
|
|||
|
|
@ -2,11 +2,9 @@ from decimal import Decimal
|
|||
import numpy as np
|
||||
from datetime import timedelta
|
||||
|
||||
from SimCAD import configs
|
||||
from SimCAD.configuration import Configuration
|
||||
from SimCAD.configuration.utils import exo_update_per_ts, proc_trigger, bound_norm_random, \
|
||||
ep_time_step
|
||||
|
||||
from SimCAD.configuration import append_configs
|
||||
from SimCAD.configuration.utils import proc_trigger, bound_norm_random, ep_time_step
|
||||
from SimCAD.configuration.utils.parameterSweep import config_sim
|
||||
|
||||
seed = {
|
||||
'z': np.random.RandomState(1),
|
||||
|
|
@ -17,46 +15,46 @@ seed = {
|
|||
|
||||
|
||||
# Behaviors per Mechanism
|
||||
def b1m1(step, sL, s):
|
||||
def b1m1(_g, step, sL, s):
|
||||
return {'param1': 1}
|
||||
def b2m1(step, sL, s):
|
||||
def b2m1(_g, step, sL, s):
|
||||
return {'param2': 4}
|
||||
|
||||
def b1m2(step, sL, s):
|
||||
def b1m2(_g, step, sL, s):
|
||||
return {'param1': 'a', 'param2': 2}
|
||||
def b2m2(step, sL, s):
|
||||
def b2m2(_g, step, sL, s):
|
||||
return {'param1': 'b', 'param2': 4}
|
||||
|
||||
def b1m3(step, sL, s):
|
||||
def b1m3(_g, step, sL, s):
|
||||
return {'param1': ['c'], 'param2': np.array([10, 100])}
|
||||
def b2m3(step, sL, s):
|
||||
def b2m3(_g, step, sL, s):
|
||||
return {'param1': ['d'], 'param2': np.array([20, 200])}
|
||||
|
||||
|
||||
# Internal States per Mechanism
|
||||
def s1m1(step, sL, s, _input):
|
||||
def s1m1(_g, step, sL, s, _input):
|
||||
y = 's1'
|
||||
x = _input['param1']
|
||||
return (y, x)
|
||||
def s2m1(step, sL, s, _input):
|
||||
def s2m1(_g, step, sL, s, _input):
|
||||
y = 's2'
|
||||
x = _input['param2']
|
||||
return (y, x)
|
||||
|
||||
def s1m2(step, sL, s, _input):
|
||||
def s1m2(_g, step, sL, s, _input):
|
||||
y = 's1'
|
||||
x = _input['param1']
|
||||
return (y, x)
|
||||
def s2m2(step, sL, s, _input):
|
||||
def s2m2(_g, step, sL, s, _input):
|
||||
y = 's2'
|
||||
x = _input['param2']
|
||||
return (y, x)
|
||||
|
||||
def s1m3(step, sL, s, _input):
|
||||
def s1m3(_g, step, sL, s, _input):
|
||||
y = 's1'
|
||||
x = _input['param1']
|
||||
return (y, x)
|
||||
def s2m3(step, sL, s, _input):
|
||||
def s2m3(_g, step, sL, s, _input):
|
||||
y = 's2'
|
||||
x = _input['param2']
|
||||
return (y, x)
|
||||
|
|
@ -66,19 +64,19 @@ def s2m3(step, sL, s, _input):
|
|||
proc_one_coef_A = 0.7
|
||||
proc_one_coef_B = 1.3
|
||||
|
||||
def es3p1(step, sL, s, _input):
|
||||
def es3p1(_g, step, sL, s, _input):
|
||||
y = 's3'
|
||||
x = s['s3'] * bound_norm_random(seed['a'], proc_one_coef_A, proc_one_coef_B)
|
||||
return (y, x)
|
||||
|
||||
def es4p2(step, sL, s, _input):
|
||||
def es4p2(_g, step, sL, s, _input):
|
||||
y = 's4'
|
||||
x = s['s4'] * bound_norm_random(seed['b'], proc_one_coef_A, proc_one_coef_B)
|
||||
return (y, x)
|
||||
|
||||
ts_format = '%Y-%m-%d %H:%M:%S'
|
||||
t_delta = timedelta(days=0, minutes=0, seconds=1)
|
||||
def es5p2(step, sL, s, _input):
|
||||
def es5p2(_g, step, sL, s, _input):
|
||||
y = 'timestamp'
|
||||
x = ep_time_step(s, dt_str=s['timestamp'], fromat_str=ts_format, _timedelta=t_delta)
|
||||
return (y, x)
|
||||
|
|
@ -103,14 +101,11 @@ genesis_states = {
|
|||
}
|
||||
|
||||
|
||||
# remove `exo_update_per_ts` to update every ts
|
||||
exogenous_states = exo_update_per_ts(
|
||||
{
|
||||
raw_exogenous_states = {
|
||||
"s3": es3p1,
|
||||
"s4": es4p2,
|
||||
"timestamp": es5p2
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
env_processes = {
|
||||
|
|
@ -153,19 +148,19 @@ mechanisms = {
|
|||
}
|
||||
|
||||
|
||||
sim_config = {
|
||||
"N": 2,
|
||||
"T": range(5)
|
||||
}
|
||||
|
||||
|
||||
configs.append(
|
||||
Configuration(
|
||||
sim_config=sim_config,
|
||||
state_dict=genesis_states,
|
||||
seed=seed,
|
||||
exogenous_states=exogenous_states,
|
||||
env_processes=env_processes,
|
||||
mechanisms=mechanisms
|
||||
)
|
||||
sim_config = config_sim(
|
||||
{
|
||||
"N": 2,
|
||||
"T": range(5),
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
append_configs(
|
||||
sim_configs=sim_config,
|
||||
state_dict=genesis_states,
|
||||
seed=seed,
|
||||
raw_exogenous_states=raw_exogenous_states,
|
||||
env_processes=env_processes,
|
||||
mechanisms=mechanisms
|
||||
)
|
||||
|
|
|
|||
Loading…
Reference in New Issue