update readme
This commit is contained in:
parent
13d8d26ed4
commit
5fabb373e3
42
README.md
42
README.md
|
|
@ -7,8 +7,26 @@ pip install pipenv fn tabulate
|
||||||
|
|
||||||
**Project:**
|
**Project:**
|
||||||
|
|
||||||
Example Run File:
|
Example Runs:
|
||||||
`/DiffyQ-SimCAD/sandboxUX/`
|
`/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
|
```python
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
from tabulate import tabulate
|
from tabulate import tabulate
|
||||||
|
|
@ -36,28 +54,6 @@ for raw_result in run2_raw_results:
|
||||||
print()
|
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 .
|
Same can be run in Jupyter .
|
||||||
```bash
|
```bash
|
||||||
jupyter notebook
|
jupyter notebook
|
||||||
|
|
|
||||||
|
|
@ -6,8 +6,8 @@ from SimCAD.utils.ui import create_tensor_field
|
||||||
from SimCAD.utils.configProcessor import generate_config
|
from SimCAD.utils.configProcessor import generate_config
|
||||||
from SimCAD.engine.simulation import Executor as SimExecutor
|
from SimCAD.engine.simulation import Executor as SimExecutor
|
||||||
|
|
||||||
class ExecutionContext:
|
|
||||||
|
|
||||||
|
class ExecutionContext:
|
||||||
def parallelize_simulations(self, fs, states_list, configs, env_processes, Ts, Ns):
|
def parallelize_simulations(self, fs, states_list, configs, env_processes, Ts, Ns):
|
||||||
l = list(zip(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:
|
with Pool(len(configs)) as p:
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ class Executor(object):
|
||||||
|
|
||||||
return foldr(call, getColResults(step, sL, s, funcs))(ops)
|
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():
|
for state in state_dict.keys():
|
||||||
if state in list(env_processes.keys()):
|
if state in list(env_processes.keys()):
|
||||||
state_dict[state] = env_processes[state](step)(state_dict[state])
|
state_dict[state] = env_processes[state](step)(state_dict[state])
|
||||||
|
|
@ -50,10 +50,9 @@ class Executor(object):
|
||||||
del last_in_obj
|
del last_in_obj
|
||||||
|
|
||||||
# make env proc trigger field agnostic
|
# 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
|
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)
|
sL.append(last_in_copy)
|
||||||
del last_in_copy
|
del last_in_copy
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,26 +1,35 @@
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
from functools import reduce
|
from functools import reduce
|
||||||
|
|
||||||
|
|
||||||
def no_state_identity(step, sL, s, _input):
|
def no_state_identity(step, sL, s, _input):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
def state_identity(k):
|
def state_identity(k):
|
||||||
return lambda step, sL, s, _input: (k, s[k])
|
return lambda step, sL, s, _input: (k, s[k])
|
||||||
|
|
||||||
|
|
||||||
def b_identity(step, sL, s):
|
def b_identity(step, sL, s):
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
|
||||||
def behavior_identity(k):
|
def behavior_identity(k):
|
||||||
return b_identity
|
return b_identity
|
||||||
|
|
||||||
|
|
||||||
def key_filter(mechanisms, keyname):
|
def key_filter(mechanisms, keyname):
|
||||||
return [ v[keyname] for k, v in mechanisms.items() ]
|
return [ v[keyname] for k, v in mechanisms.items() ]
|
||||||
|
|
||||||
|
|
||||||
def fillna_with_id_func(identity, df, col):
|
def fillna_with_id_func(identity, df, col):
|
||||||
return df[[col]].fillna(value=identity(col))
|
return df[[col]].fillna(value=identity(col))
|
||||||
|
|
||||||
|
|
||||||
def apply_identity_funcs(identity, df, cols):
|
def apply_identity_funcs(identity, df, cols):
|
||||||
return list(map(lambda col: fillna_with_id_func(identity, df, col), cols))
|
return list(map(lambda col: fillna_with_id_func(identity, df, col), cols))
|
||||||
|
|
||||||
|
|
||||||
def create_matrix_field(mechanisms, key):
|
def create_matrix_field(mechanisms, key):
|
||||||
if key == 'states':
|
if key == 'states':
|
||||||
identity = state_identity
|
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
|
# Maybe Refactor to only use dictionary BUT I used dfs to fill NAs. Perhaps fill
|
||||||
def generate_config(state_dict, mechanisms, exo_proc):
|
def generate_config(state_dict, mechanisms, exo_proc):
|
||||||
|
|
||||||
|
# include False / False case
|
||||||
def no_update_handler(bdf, sdf):
|
def no_update_handler(bdf, sdf):
|
||||||
if (bdf.empty == False) and (sdf.empty == True):
|
if (bdf.empty == False) and (sdf.empty == True):
|
||||||
bdf_values = bdf.values.tolist()
|
bdf_values = bdf.values.tolist()
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
from SimCAD.utils.configProcessor import create_matrix_field
|
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']):
|
def create_tensor_field(mechanisms, exo_proc, keys=['behaviors', 'states']):
|
||||||
dfs = [create_matrix_field(mechanisms, k) for k in keys]
|
dfs = [create_matrix_field(mechanisms, k) for k in keys]
|
||||||
df = pd.concat(dfs, axis=1)
|
df = pd.concat(dfs, axis=1)
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,8 @@ 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
|
||||||
|
|
||||||
|
# pass ExecutionContext function instead of class
|
||||||
|
|
||||||
print("Simulation Run 1")
|
print("Simulation Run 1")
|
||||||
print()
|
print()
|
||||||
single_config = [config1]
|
single_config = [config1]
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue