diff --git a/README.md b/README.md index 0630e5f..f447d54 100644 --- a/README.md +++ b/README.md @@ -44,12 +44,15 @@ from SimCAD import configs exec_mode = ExecutionMode() +exec_mode = ExecutionMode() + + print("Simulation Execution 1") print() first_config = [configs[0]] # from config1 single_proc_ctx = ExecutionContext(context=exec_mode.single_proc) run1 = Executor(exec_context=single_proc_ctx, configs=first_config) -run1_raw_result, tensor_field = run1.main() +run1_raw_result, tensor_field = run1.main() result = pd.DataFrame(run1_raw_result) # result.to_csv('~/Projects/DiffyQ-SimCAD/results/config4.csv', sep=',') print() diff --git a/SimCAD/engine/__init__.py b/SimCAD/engine/__init__.py index f5d93bc..9f87879 100644 --- a/SimCAD/engine/__init__.py +++ b/SimCAD/engine/__init__.py @@ -1,5 +1,4 @@ from pathos.multiprocessing import ProcessingPool as Pool -from tabulate import tabulate from SimCAD.utils import flatten from SimCAD.configuration import Processor @@ -12,8 +11,8 @@ class ExecutionMode: multi_proc = 'multi_proc' +# ToDo: switch / rename self.name & context ?? class ExecutionContext: - def __init__(self, context=ExecutionMode.multi_proc): self.name = context self.method = None @@ -37,7 +36,6 @@ class ExecutionContext: class Executor: - def __init__(self, exec_context, configs): self.SimExecutor = SimExecutor self.exec_method = exec_context.method @@ -72,7 +70,7 @@ class Executor: if self.exec_context == ExecutionMode.single_proc: tensor_field = create_tensor_field(mechanisms.pop(), eps.pop()) result = self.exec_method(simulation_execs, states_lists, configs_structs, env_processes_list, Ts, Ns) - return (result, tensor_field) + return result, tensor_field elif self.exec_context == ExecutionMode.multi_proc: if len(self.configs) > 1: simulations = self.exec_method(simulation_execs, states_lists, configs_structs, env_processes_list, Ts, Ns) diff --git a/SimCAD/engine/simulation.py b/SimCAD/engine/simulation.py index f6e3b9c..a0c5d61 100644 --- a/SimCAD/engine/simulation.py +++ b/SimCAD/engine/simulation.py @@ -27,7 +27,7 @@ class Executor: for state in state_dict.keys(): if state in list(env_processes.keys()): env_state = env_processes[state] - if env_state.__name__ == '_curried': # might want to change + if (env_state.__name__ == '_curried') or (env_state.__name__ == 'proc_trigger'): # might want to change state_dict[state] = env_state(step)(state_dict[state]) else: state_dict[state] = env_state(state_dict[state]) diff --git a/simulations/sim_test.py b/simulations/sim_test.py index 7002687..1bbfcdc 100644 --- a/simulations/sim_test.py +++ b/simulations/sim_test.py @@ -20,7 +20,7 @@ print() first_config = [configs[0]] # from config1 single_proc_ctx = ExecutionContext(context=exec_mode.single_proc) run1 = Executor(exec_context=single_proc_ctx, configs=first_config) -run1_raw_result, tensor_field = run1.main() +run1_raw_result, tensor_field = run1.main() result = pd.DataFrame(run1_raw_result) # result.to_csv('~/Projects/DiffyQ-SimCAD/results/config4.csv', sep=',') print() diff --git a/simulations/validation/config1.py b/simulations/validation/config1.py index 6d1581d..7bdd5ac 100644 --- a/simulations/validation/config1.py +++ b/simulations/validation/config1.py @@ -84,7 +84,7 @@ def es5p2(step, sL, s, _input): # Environment States def env_a(x): - return 10 + return 5 def env_b(x): return 10 # def what_ever(x): @@ -108,9 +108,10 @@ exogenous_states = exo_update_per_ts( } ) -# make env proc trigger field agnostic +# ToDo: make env proc trigger field agnostic +# ToDo: input json into function renaming __name__ env_processes = { - "s3": proc_trigger('2018-10-01 15:16:25', env_a), + "s3": env_a, "s4": proc_trigger('2018-10-01 15:16:25', env_b) } @@ -126,6 +127,7 @@ env_processes = { # need at least 1 behaviour and 1 state function for the 1st mech with behaviors # mechanisms = {} + mechanisms = { "m1": { "behaviors": {