renaming some user-facing terms
This commit is contained in:
parent
e2d68a0587
commit
00f5d53888
|
|
@ -10,17 +10,17 @@ from cadCAD.configuration.utils import exo_update_per_ts
|
||||||
|
|
||||||
class Configuration(object):
|
class Configuration(object):
|
||||||
def __init__(self, sim_config={}, initial_state={}, seeds={}, env_processes={},
|
def __init__(self, sim_config={}, initial_state={}, seeds={}, env_processes={},
|
||||||
exogenous_states={}, partial_state_updates={}, policy_ops=[foldr(dict_elemwise_sum())], **kwargs):
|
exogenous_states={}, partial_state_update_blocks={}, policy_ops=[foldr(dict_elemwise_sum())], **kwargs):
|
||||||
self.sim_config = sim_config
|
self.sim_config = sim_config
|
||||||
self.initial_state = initial_state
|
self.initial_state = initial_state
|
||||||
self.seeds = seeds
|
self.seeds = seeds
|
||||||
self.env_processes = env_processes
|
self.env_processes = env_processes
|
||||||
self.exogenous_states = exogenous_states
|
self.exogenous_states = exogenous_states
|
||||||
self.partial_state_updates = partial_state_updates
|
self.partial_state_updates = partial_state_update_blocks
|
||||||
self.policy_ops = policy_ops
|
self.policy_ops = policy_ops
|
||||||
|
|
||||||
|
|
||||||
def append_configs(sim_configs, initial_state, seeds, raw_exogenous_states, env_processes, partial_state_updates, _exo_update_per_ts=True):
|
def append_configs(sim_configs, initial_state, seeds, raw_exogenous_states, env_processes, partial_state_update_blocks, _exo_update_per_ts=True):
|
||||||
if _exo_update_per_ts is True:
|
if _exo_update_per_ts is True:
|
||||||
exogenous_states = exo_update_per_ts(raw_exogenous_states)
|
exogenous_states = exo_update_per_ts(raw_exogenous_states)
|
||||||
else:
|
else:
|
||||||
|
|
@ -35,7 +35,7 @@ def append_configs(sim_configs, initial_state, seeds, raw_exogenous_states, env_
|
||||||
seeds=seeds,
|
seeds=seeds,
|
||||||
exogenous_states=exogenous_states,
|
exogenous_states=exogenous_states,
|
||||||
env_processes=env_processes,
|
env_processes=env_processes,
|
||||||
partial_state_updates=partial_state_updates
|
partial_state_updates=partial_state_update_blocks
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
elif isinstance(sim_configs, dict):
|
elif isinstance(sim_configs, dict):
|
||||||
|
|
@ -46,7 +46,7 @@ def append_configs(sim_configs, initial_state, seeds, raw_exogenous_states, env_
|
||||||
seeds=seeds,
|
seeds=seeds,
|
||||||
exogenous_states=exogenous_states,
|
exogenous_states=exogenous_states,
|
||||||
env_processes=env_processes,
|
env_processes=env_processes,
|
||||||
partial_state_updates=partial_state_updates
|
partial_state_updates=partial_state_update_blocks
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -84,7 +84,7 @@ class Processor:
|
||||||
self.apply_identity_funcs = id.apply_identity_funcs
|
self.apply_identity_funcs = id.apply_identity_funcs
|
||||||
|
|
||||||
def create_matrix_field(self, partial_state_updates, key):
|
def create_matrix_field(self, partial_state_updates, key):
|
||||||
if key == 'states':
|
if key == 'variables':
|
||||||
identity = self.state_identity
|
identity = self.state_identity
|
||||||
elif key == 'policies':
|
elif key == 'policies':
|
||||||
identity = self.policy_identity
|
identity = self.policy_identity
|
||||||
|
|
@ -121,7 +121,7 @@ class Processor:
|
||||||
|
|
||||||
if len(partial_state_updates) != 0:
|
if len(partial_state_updates) != 0:
|
||||||
bdf = self.create_matrix_field(partial_state_updates, 'policies')
|
bdf = self.create_matrix_field(partial_state_updates, 'policies')
|
||||||
sdf = self.create_matrix_field(partial_state_updates, 'states')
|
sdf = self.create_matrix_field(partial_state_updates, 'variables')
|
||||||
sdf_values, bdf_values = no_update_handler(bdf, sdf)
|
sdf_values, bdf_values = no_update_handler(bdf, sdf)
|
||||||
zipped_list = list(zip(sdf_values, bdf_values))
|
zipped_list = list(zip(sdf_values, bdf_values))
|
||||||
else:
|
else:
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ class TensorFieldReport:
|
||||||
def __init__(self, config_proc):
|
def __init__(self, config_proc):
|
||||||
self.config_proc = config_proc
|
self.config_proc = config_proc
|
||||||
|
|
||||||
def create_tensor_field(self, partial_state_updates, exo_proc, keys=['policies', 'states']):
|
def create_tensor_field(self, partial_state_updates, exo_proc, keys=['policies', 'variables']):
|
||||||
dfs = [self.config_proc.create_matrix_field(partial_state_updates, k) for k in keys]
|
dfs = [self.config_proc.create_matrix_field(partial_state_updates, k) for k in keys]
|
||||||
df = pd.concat(dfs, axis=1)
|
df = pd.concat(dfs, axis=1)
|
||||||
for es, i in zip(exo_proc, range(len(exo_proc))):
|
for es, i in zip(exo_proc, range(len(exo_proc))):
|
||||||
|
|
@ -52,7 +52,7 @@ def time_step(dt_str, dt_format='%Y-%m-%d %H:%M:%S', _timedelta = tstep_delta):
|
||||||
|
|
||||||
ep_t_delta = timedelta(days=0, minutes=0, seconds=1)
|
ep_t_delta = timedelta(days=0, minutes=0, seconds=1)
|
||||||
def ep_time_step(s, dt_str, fromat_str='%Y-%m-%d %H:%M:%S', _timedelta = ep_t_delta):
|
def ep_time_step(s, dt_str, fromat_str='%Y-%m-%d %H:%M:%S', _timedelta = ep_t_delta):
|
||||||
if s['sub_step'] == 0:
|
if s['substep'] == 0:
|
||||||
return time_step(dt_str, fromat_str, _timedelta)
|
return time_step(dt_str, fromat_str, _timedelta)
|
||||||
else:
|
else:
|
||||||
return dt_str
|
return dt_str
|
||||||
|
|
@ -114,7 +114,7 @@ def sweep_states(state_type, states, in_config):
|
||||||
def exo_update_per_ts(ep):
|
def exo_update_per_ts(ep):
|
||||||
@curried
|
@curried
|
||||||
def ep_decorator(f, y, var_dict, sub_step, sL, s, _input):
|
def ep_decorator(f, y, var_dict, sub_step, sL, s, _input):
|
||||||
if s['sub_step'] + 1 == 1:
|
if s['substep'] + 1 == 1:
|
||||||
return f(var_dict, sub_step, sL, s, _input)
|
return f(var_dict, sub_step, sL, s, _input)
|
||||||
else:
|
else:
|
||||||
return y, s[y]
|
return y, s[y]
|
||||||
|
|
|
||||||
|
|
@ -51,7 +51,7 @@ class Executor:
|
||||||
|
|
||||||
self.apply_env_proc(env_processes, last_in_copy, last_in_copy['timestep']) # not time_step
|
self.apply_env_proc(env_processes, last_in_copy, last_in_copy['timestep']) # not time_step
|
||||||
|
|
||||||
last_in_copy["sub_step"], last_in_copy["time_step"], last_in_copy['run'] = sub_step, time_step, run
|
last_in_copy['substep'], last_in_copy['timestep'], last_in_copy['run'] = sub_step, time_step, run
|
||||||
sL.append(last_in_copy)
|
sL.append(last_in_copy)
|
||||||
del last_in_copy
|
del last_in_copy
|
||||||
|
|
||||||
|
|
@ -62,7 +62,7 @@ class Executor:
|
||||||
sub_step = 0
|
sub_step = 0
|
||||||
states_list_copy = deepcopy(states_list)
|
states_list_copy = deepcopy(states_list)
|
||||||
genesis_states = states_list_copy[-1]
|
genesis_states = states_list_copy[-1]
|
||||||
genesis_states['sub_step'], genesis_states['time_step'] = sub_step, time_step
|
genesis_states['substep'], genesis_states['timestep'] = sub_step, time_step
|
||||||
states_list = [genesis_states]
|
states_list = [genesis_states]
|
||||||
|
|
||||||
sub_step += 1
|
sub_step += 1
|
||||||
|
|
@ -93,7 +93,7 @@ class Executor:
|
||||||
states_list_copy = deepcopy(states_list)
|
states_list_copy = deepcopy(states_list)
|
||||||
head, *tail = self.run_pipeline(var_dict, states_list_copy, configs, env_processes, time_seq, run)
|
head, *tail = self.run_pipeline(var_dict, states_list_copy, configs, env_processes, time_seq, run)
|
||||||
genesis = head.pop()
|
genesis = head.pop()
|
||||||
genesis['sub_step'], genesis['time_step'], genesis['run'] = 0, 0, run
|
genesis['substep'], genesis['timestep'], genesis['run'] = 0, 0, run
|
||||||
first_timestep_per_run = [genesis] + tail.pop(0)
|
first_timestep_per_run = [genesis] + tail.pop(0)
|
||||||
pipe_run += [first_timestep_per_run] + tail
|
pipe_run += [first_timestep_per_run] + tail
|
||||||
del states_list_copy
|
del states_list_copy
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue