add tensor field to output

This commit is contained in:
Joshua E. Jodesty 2018-12-10 10:06:01 -05:00
parent 42e93f501e
commit 980bba081a
5 changed files with 13 additions and 10 deletions

View File

@ -44,12 +44,15 @@ from SimCAD import configs
exec_mode = ExecutionMode() exec_mode = ExecutionMode()
exec_mode = ExecutionMode()
print("Simulation Execution 1") print("Simulation Execution 1")
print() print()
first_config = [configs[0]] # from config1 first_config = [configs[0]] # from config1
single_proc_ctx = ExecutionContext(context=exec_mode.single_proc) single_proc_ctx = ExecutionContext(context=exec_mode.single_proc)
run1 = Executor(exec_context=single_proc_ctx, configs=first_config) 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 = pd.DataFrame(run1_raw_result)
# result.to_csv('~/Projects/DiffyQ-SimCAD/results/config4.csv', sep=',') # result.to_csv('~/Projects/DiffyQ-SimCAD/results/config4.csv', sep=',')
print() print()

View File

@ -1,5 +1,4 @@
from pathos.multiprocessing import ProcessingPool as Pool from pathos.multiprocessing import ProcessingPool as Pool
from tabulate import tabulate
from SimCAD.utils import flatten from SimCAD.utils import flatten
from SimCAD.configuration import Processor from SimCAD.configuration import Processor
@ -12,8 +11,8 @@ class ExecutionMode:
multi_proc = 'multi_proc' multi_proc = 'multi_proc'
# ToDo: switch / rename self.name & context ??
class ExecutionContext: class ExecutionContext:
def __init__(self, context=ExecutionMode.multi_proc): def __init__(self, context=ExecutionMode.multi_proc):
self.name = context self.name = context
self.method = None self.method = None
@ -37,7 +36,6 @@ class ExecutionContext:
class Executor: class Executor:
def __init__(self, exec_context, configs): def __init__(self, exec_context, configs):
self.SimExecutor = SimExecutor self.SimExecutor = SimExecutor
self.exec_method = exec_context.method self.exec_method = exec_context.method
@ -72,7 +70,7 @@ class Executor:
if self.exec_context == ExecutionMode.single_proc: if self.exec_context == ExecutionMode.single_proc:
tensor_field = create_tensor_field(mechanisms.pop(), eps.pop()) tensor_field = create_tensor_field(mechanisms.pop(), eps.pop())
result = self.exec_method(simulation_execs, states_lists, configs_structs, env_processes_list, Ts, Ns) 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: elif self.exec_context == ExecutionMode.multi_proc:
if len(self.configs) > 1: if len(self.configs) > 1:
simulations = self.exec_method(simulation_execs, states_lists, configs_structs, env_processes_list, Ts, Ns) simulations = self.exec_method(simulation_execs, states_lists, configs_structs, env_processes_list, Ts, Ns)

View File

@ -27,7 +27,7 @@ class Executor:
for state in state_dict.keys(): for state in state_dict.keys():
if state in list(env_processes.keys()): if state in list(env_processes.keys()):
env_state = env_processes[state] 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]) state_dict[state] = env_state(step)(state_dict[state])
else: else:
state_dict[state] = env_state(state_dict[state]) state_dict[state] = env_state(state_dict[state])

View File

@ -20,7 +20,7 @@ print()
first_config = [configs[0]] # from config1 first_config = [configs[0]] # from config1
single_proc_ctx = ExecutionContext(context=exec_mode.single_proc) single_proc_ctx = ExecutionContext(context=exec_mode.single_proc)
run1 = Executor(exec_context=single_proc_ctx, configs=first_config) 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 = pd.DataFrame(run1_raw_result)
# result.to_csv('~/Projects/DiffyQ-SimCAD/results/config4.csv', sep=',') # result.to_csv('~/Projects/DiffyQ-SimCAD/results/config4.csv', sep=',')
print() print()

View File

@ -84,7 +84,7 @@ def es5p2(step, sL, s, _input):
# Environment States # Environment States
def env_a(x): def env_a(x):
return 10 return 5
def env_b(x): def env_b(x):
return 10 return 10
# def what_ever(x): # 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 = { 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) "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 # need at least 1 behaviour and 1 state function for the 1st mech with behaviors
# mechanisms = {} # mechanisms = {}
mechanisms = { mechanisms = {
"m1": { "m1": {
"behaviors": { "behaviors": {