update readme

This commit is contained in:
Joshua E. Jodesty 2018-11-18 14:28:28 -05:00
parent 13d8d26ed4
commit 5fabb373e3
6 changed files with 41 additions and 32 deletions

View File

@ -7,8 +7,26 @@ pip install pipenv fn tabulate
**Project:**
Example Run File:
Example Runs:
`/DiffyQ-SimCAD/sandboxUX/`
**User Interface: Simulation Configuration**
Configurations:
```bash
/DiffyQ-SimCAD/ui/config.py
```
**Build Tool & Package Import:**
Step 1. Build & Install Package locally:
```bash
pip install .
pip install -e .
```
* [Package Creation Tutorial](https://python-packaging.readthedocs.io/en/latest/minimal.html)
Step 2. Import Package & Run:
```python
import pandas as pd
from tabulate import tabulate
@ -36,28 +54,6 @@ for raw_result in run2_raw_results:
print()
```
**User Interface: Simulation Configuration**
Configurations:
```bash
/DiffyQ-SimCAD/ui/config.py
```
**Build Tool & Package Import:**
Step 1. Build & Install Package locally:
```bash
pip install .
pip install -e .
```
* [Package Creation Tutorial](https://python-packaging.readthedocs.io/en/latest/minimal.html)
Step 2. Import Package & Run:
```python
from engine import run
run.main()
```
Same can be run in Jupyter .
```bash
jupyter notebook

View File

@ -6,8 +6,8 @@ from SimCAD.utils.ui import create_tensor_field
from SimCAD.utils.configProcessor import generate_config
from SimCAD.engine.simulation import Executor as SimExecutor
class ExecutionContext:
class ExecutionContext:
def parallelize_simulations(self, fs, states_list, configs, env_processes, Ts, Ns):
l = list(zip(fs, states_list, configs, env_processes, Ts, Ns))
with Pool(len(configs)) as p:

View File

@ -19,7 +19,7 @@ class Executor(object):
return foldr(call, getColResults(step, sL, s, funcs))(ops)
def apply_env_proc(env_processes, state_dict, step):
def apply_env_proc(self, env_processes, state_dict, step):
for state in state_dict.keys():
if state in list(env_processes.keys()):
state_dict[state] = env_processes[state](step)(state_dict[state])
@ -50,10 +50,9 @@ class Executor(object):
del last_in_obj
# make env proc trigger field agnostic
Executor.apply_env_proc(env_processes, last_in_copy, last_in_copy['timestamp']) # mutating last_in_copy
self.apply_env_proc(env_processes, last_in_copy, last_in_copy['timestamp']) # mutating last_in_copy
last_in_copy["mech_step"], last_in_copy["time_step"], last_in_copy['run'] = m_step, t_step, run
# print(last_in_copy)
sL.append(last_in_copy)
del last_in_copy

View File

@ -1,26 +1,35 @@
import pandas as pd
from functools import reduce
def no_state_identity(step, sL, s, _input):
return None
def state_identity(k):
return lambda step, sL, s, _input: (k, s[k])
def b_identity(step, sL, s):
return 0
def behavior_identity(k):
return b_identity
def key_filter(mechanisms, keyname):
return [ v[keyname] for k, v in mechanisms.items() ]
def fillna_with_id_func(identity, df, col):
return df[[col]].fillna(value=identity(col))
def apply_identity_funcs(identity, df, cols):
return list(map(lambda col: fillna_with_id_func(identity, df, col), cols))
def create_matrix_field(mechanisms, key):
if key == 'states':
identity = state_identity
@ -37,6 +46,7 @@ def create_matrix_field(mechanisms, key):
# Maybe Refactor to only use dictionary BUT I used dfs to fill NAs. Perhaps fill
def generate_config(state_dict, mechanisms, exo_proc):
# include False / False case
def no_update_handler(bdf, sdf):
if (bdf.empty == False) and (sdf.empty == True):
bdf_values = bdf.values.tolist()

View File

@ -1,6 +1,8 @@
import pandas as pd
from SimCAD.utils.configProcessor import create_matrix_field
# dont for-loop to apply exo_procs, use exo_proc struct
def create_tensor_field(mechanisms, exo_proc, keys=['behaviors', 'states']):
dfs = [create_matrix_field(mechanisms, k) for k in keys]
df = pd.concat(dfs, axis=1)

View File

@ -4,6 +4,8 @@ from tabulate import tabulate
from SimCAD.engine import ExecutionContext, Executor
from sandboxUX import config1, config2
# pass ExecutionContext function instead of class
print("Simulation Run 1")
print()
single_config = [config1]