diff --git a/Simulation.md b/Simulation.md index cd314df..a6e1347 100644 --- a/Simulation.md +++ b/Simulation.md @@ -4,7 +4,7 @@ A blockchain is a distributed ledger with economic agents transacting in a network. The state of the network evolves with every new transaction, which can be a result of user behaviors, protocol-defined system mechanisms, or external processes. -It is not uncommon today for blockchain projects to announce a set of rules for their network and make claims about their system level behvaior. However, the validity of those claims is hardly validated. Furthermore, it is difficult to know the potential system-level impact when the network is considering an upgrade to their system rules and prameters. +It is not uncommon today for blockchain projects to announce a set of rules for their network and make claims about their system level behavior. However, the validity of those claims is hardly validated. Furthermore, it is difficult to know the potential system-level impact when the network is considering an upgrade to their system rules and parameters. To rigorously and reliably analyze, design, and improve cryptoeconomic networks, we are introducing this Computer Aided Design Engine where we define a cryptoeconomic network with its state and exogneous variables, model transactions as a result of agent behaviors, state mechanisms, and environmental processes. We can then run simulations with different initial states, mechanisms, environmental processes to understand and visualize network behavior under different conditions. diff --git a/simulations/example_run.py b/simulations/example_run.py index e80c2de..d41d8da 100644 --- a/simulations/example_run.py +++ b/simulations/example_run.py @@ -8,28 +8,28 @@ from SimCAD import configs 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() -# result = pd.DataFrame(run1_raw_result) -# print() -# print("Tensor Field:") -# print(tabulate(tensor_field, headers='keys', tablefmt='psql')) -# print("Output:") -# print(tabulate(result, headers='keys', tablefmt='psql')) -# print() +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() +result = pd.DataFrame(run1_raw_result) +print() +print("Tensor Field:") +print(tabulate(tensor_field, headers='keys', tablefmt='psql')) +print("Output:") +print(tabulate(result, headers='keys', tablefmt='psql')) +print() -print("Simulation Execution 2: Pairwise Execution") -multi_proc_ctx = ExecutionContext(context=exec_mode.multi_proc) -run2 = Executor(exec_context=multi_proc_ctx, configs=configs) -for raw_result, tensor_field in run2.main(): - result = pd.DataFrame(raw_result) - print() - print("Tensor Field:") - print(tabulate(tensor_field, headers='keys', tablefmt='psql')) - print("Output:") - print(tabulate(result, headers='keys', tablefmt='psql')) - print() +# print("Simulation Execution 2: Pairwise Execution") +# multi_proc_ctx = ExecutionContext(context=exec_mode.multi_proc) +# run2 = Executor(exec_context=multi_proc_ctx, configs=configs) +# for raw_result, tensor_field in run2.main(): +# result = pd.DataFrame(raw_result) +# print() +# print("Tensor Field:") +# print(tabulate(tensor_field, headers='keys', tablefmt='psql')) +# print("Output:") +# print(tabulate(result, headers='keys', tablefmt='psql')) +# print() diff --git a/simulations/validation/config1.py b/simulations/validation/config1.py index ef5ef55..14084fb 100644 --- a/simulations/validation/config1.py +++ b/simulations/validation/config1.py @@ -26,29 +26,29 @@ seed = { # Behaviors per Mechanism # @curried -def b1m1(param, step, sL, s): +def b1m1(step, sL, s): return {'param1': 1} # @curried -def b2m1(param, step, sL, s): +def b2m1(step, sL, s): return {'param2': 4} # @curried def b1m2(param, step, sL, s): return {'param1': 'a', 'param2': param} # @curried -def b2m2(param, step, sL, s): +def b2m2(step, sL, s): return {'param1': 'b', 'param2': 0} # @curried -def b1m3(param, step, sL, s): +def b1m3(step, sL, s): return {'param1': np.array([10, 100])} # @curried -def b2m3(param, step, sL, s): +def b2m3(step, sL, s): return {'param1': np.array([20, 200])} # Internal States per Mechanism # @curried -def s1m1(param, step, sL, s, _input): +def s1m1(step, sL, s, _input): y = 's1' x = 0 return (y, x) @@ -59,22 +59,22 @@ def s2m1(param, step, sL, s, _input): x = param return (y, x) # @curried -def s1m2(param, step, sL, s, _input): +def s1m2(step, sL, s, _input): y = 's1' x = _input['param2'] return (y, x) # @curried -def s2m2(param, step, sL, s, _input): +def s2m2(step, sL, s, _input): y = 's2' x = _input['param2'] return (y, x) # @curried -def s1m3(param, step, sL, s, _input): +def s1m3(step, sL, s, _input): y = 's1' x = 0 return (y, x) # @curried -def s2m3(param, step, sL, s, _input): +def s2m3(step, sL, s, _input): y = 's2' x = 0 return (y, x) @@ -98,7 +98,7 @@ def es4p2(param, step, sL, s, _input): ts_format = '%Y-%m-%d %H:%M:%S' t_delta = timedelta(days=0, minutes=0, seconds=1) # @curried -def es5p2(param, step, sL, s, _input): +def es5p2(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)