Reafactor Pt. 5: Improved Runtime Env / ux Pt.3
This commit is contained in:
parent
cee90b564c
commit
7ecd4e6c86
|
|
@ -28,7 +28,7 @@ class Executor(object):
|
||||||
def execute():
|
def execute():
|
||||||
ec = ExecutionContext()
|
ec = ExecutionContext()
|
||||||
print(configs)
|
print(configs)
|
||||||
states_lists, Ts, Ns, eps, configs_struct, env_processes, mechanisms, simulation_execs = \
|
states_lists, Ts, Ns, eps, configs_structs, env_processes_list, mechanisms, simulation_execs = \
|
||||||
[], [], [], [], [], [], [], []
|
[], [], [], [], [], [], [], []
|
||||||
config_idx = 0
|
config_idx = 0
|
||||||
for x in configs:
|
for x in configs:
|
||||||
|
|
@ -36,8 +36,8 @@ class Executor(object):
|
||||||
Ts.append(x.sim_config['T'])
|
Ts.append(x.sim_config['T'])
|
||||||
Ns.append(x.sim_config['N'])
|
Ns.append(x.sim_config['N'])
|
||||||
eps.append(list(x.exogenous_states.values()))
|
eps.append(list(x.exogenous_states.values()))
|
||||||
configs_struct.append(generate_config(x.state_dict, x.mechanisms, eps[config_idx]))
|
configs_structs.append(generate_config(x.state_dict, x.mechanisms, eps[config_idx]))
|
||||||
env_processes.append(x.env_processes)
|
env_processes_list.append(x.env_processes)
|
||||||
mechanisms.append(x.mechanisms)
|
mechanisms.append(x.mechanisms)
|
||||||
simulation_execs.append(Executor(x.behavior_ops).simulation)
|
simulation_execs.append(Executor(x.behavior_ops).simulation)
|
||||||
|
|
||||||
|
|
@ -46,20 +46,18 @@ class Executor(object):
|
||||||
# Dimensions: N x r x mechs
|
# Dimensions: N x r x mechs
|
||||||
|
|
||||||
if len(configs) > 1:
|
if len(configs) > 1:
|
||||||
simulations = ec.parallelize_simulations(simulation_execs, states_lists, configs_struct, env_processes, Ts, Ns)
|
simulations = ec.parallelize_simulations(simulation_execs, states_lists, configs_structs, env_processes_list, Ts, Ns)
|
||||||
|
results = []
|
||||||
for result, mechanism, ep in list(zip(simulations, mechanisms, eps)):
|
for result, mechanism, ep in list(zip(simulations, mechanisms, eps)):
|
||||||
print(tabulate(create_tensor_field(mechanism, ep), headers='keys', tablefmt='psql'))
|
print(tabulate(create_tensor_field(mechanism, ep), headers='keys', tablefmt='psql'))
|
||||||
print(tabulate(pd.DataFrame(flatten(result)), headers='keys', tablefmt='psql'))
|
results.append(flatten(result))
|
||||||
|
return results
|
||||||
else:
|
else:
|
||||||
print('single note')
|
simulation, states_list, config = simulation_execs.pop(), states_lists.pop(), configs_structs.pop()
|
||||||
simulation, states_list, config = simulation_execs.pop(), states_lists.pop(), configs_struct.pop()
|
env_processes, T, N = env_processes_list.pop(), Ts.pop(), Ns.pop()
|
||||||
env_process = env_processes.pop()
|
result = simulation(states_list, config, env_processes, T, N)
|
||||||
# simulations = [simulation(states_list, config, env_processes, T, N)]
|
# print(flatten(result))
|
||||||
|
return flatten(result)
|
||||||
# behavior_ops, states_list, configs, env_processes, time_seq, runs
|
|
||||||
# result = simulation(states_list1, config1, conf1.env_processes, T, N)
|
|
||||||
# return pd.DataFrame(flatten(result))
|
|
||||||
|
|
||||||
self.ExecutionContext = ExecutionContext
|
self.ExecutionContext = ExecutionContext
|
||||||
self.main = execute
|
self.main = execute
|
||||||
|
|
@ -1,7 +1,26 @@
|
||||||
|
import pandas as pd
|
||||||
|
from tabulate import tabulate
|
||||||
|
|
||||||
from SimCAD.engine import ExecutionContext, Executor
|
from SimCAD.engine import ExecutionContext, Executor
|
||||||
from sandboxUX import config1, config2
|
from sandboxUX import config1, config2
|
||||||
|
|
||||||
|
print("Simulation Run 1")
|
||||||
|
print()
|
||||||
|
single_config = [config1]
|
||||||
|
run1 = Executor(ExecutionContext, single_config)
|
||||||
|
run1_raw_result = run1.main()
|
||||||
|
result = pd.DataFrame(run1_raw_result)
|
||||||
|
print(tabulate(result, headers='keys', tablefmt='psql'))
|
||||||
|
print()
|
||||||
|
|
||||||
|
print("Simulation Run 2: Pairwise Execution")
|
||||||
|
print()
|
||||||
configs = [config1, config2]
|
configs = [config1, config2]
|
||||||
run = Executor(ExecutionContext, configs)
|
run2 = Executor(ExecutionContext, configs)
|
||||||
result = run.main()
|
run2_raw_results = run2.main()
|
||||||
|
for result in run2_raw_results:
|
||||||
|
print(tabulate(result, headers='keys', tablefmt='psql'))
|
||||||
|
print()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue