-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
42256bd
commit bec4c38
Showing
8 changed files
with
10 additions
and
2,385 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1 @@ | ||
**Robot and Marbles Tutorial Series** | ||
|
||
In this series, we introduce basic concepts of cadCAD and system modelling in general using a simple toy model. | ||
[Part 1](robot-marbles-part-1/robot-marbles-part-1.ipynb) - States and State Update Functions | ||
[Part 2](robot-marbles-part-2/robot-marbles-part-2.ipynb) - Actions and State Dependent Policies | ||
[Part 3](robot-marbles-part-3/robot-marbles-part-3.ipynb) - From Synchronous to Asynchronous Time | ||
[Part 4](robot-marbles-part-4/robot-marbles-part-4.ipynb) - Uncertainty and Stochastic Processes | ||
[Part 5](robot-marbles-part-5/robot-marbles-part-5.ipynb) - Using class objects as state variables | ||
|
||
Check out the [videos](videos) folder for detailed walkthroughs of each one of the tutorials. | ||
cadCAD is now open source! The tutorials have been moved to the [main repo](https://github.com/BlockScience/cadCAD) |
609 changes: 1 addition & 608 deletions
609
01 Tutorials/robot-marbles-part-1/robot-marbles-part-1.ipynb
Large diffs are not rendered by default.
Oops, something went wrong.
325 changes: 1 addition & 324 deletions
325
01 Tutorials/robot-marbles-part-2/robot-marbles-part-2.ipynb
Large diffs are not rendered by default.
Oops, something went wrong.
270 changes: 2 additions & 268 deletions
270
01 Tutorials/robot-marbles-part-3/robot-marbles-part-3.ipynb
Large diffs are not rendered by default.
Oops, something went wrong.
685 changes: 1 addition & 684 deletions
685
01 Tutorials/robot-marbles-part-4/robot-marbles-part-4.ipynb
Large diffs are not rendered by default.
Oops, something went wrong.
328 changes: 2 additions & 326 deletions
328
01 Tutorials/robot-marbles-part-5/robot-marbles-part-5.ipynb
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
cadCAD is now open source! The tutorials have been moved to the [main repo](https://github.com/BlockScience/cadCAD) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,165 +1 @@ | ||
cadCAD | ||
=== | ||
``` | ||
__________ ____ | ||
________ __ _____/ ____/ | / __ \ | ||
/ ___/ __` / __ / / / /| | / / / / | ||
/ /__/ /_/ / /_/ / /___/ ___ |/ /_/ / | ||
\___/\__,_/\__,_/\____/_/ |_/_____/ | ||
by BlockScience | ||
``` | ||
|
||
**Introduction:** | ||
|
||
cadCAD is a Python library that assists in the processes of designing, testing and validating complex systems through | ||
simulation. At its core, cadCAD is a differential games engine that supports parameter sweeping and Monte Carlo analyses | ||
and can be easily integrated with other scientific computing Python modules and data science workflows. | ||
|
||
**Description:** | ||
|
||
cadCAD (complex adaptive systems computer-aided design) is a python based, unified modeling framework for stochastic | ||
dynamical systems and differential games for research, validation, and Computer Aided Design of economic systems created | ||
by BlockScience. It is capable of modeling systems at all levels of abstraction from Agent Based Modeling (ABM) to | ||
System Dynamics (SD), and enabling smooth integration of computational social science simulations with empirical data | ||
science workflows. | ||
|
||
|
||
An economic system is treated as a state-based model and defined through a set of endogenous and exogenous state | ||
variables which are updated through mechanisms and environmental processes, respectively. Behavioral models, which may | ||
be deterministic or stochastic, provide the evolution of the system within the action space of the mechanisms. | ||
Mathematical formulations of these economic games treat agent utility as derived from the state rather than direct from | ||
an action, creating a rich, dynamic modeling framework. Simulations may be run with a range of initial conditions and | ||
parameters for states, behaviors, mechanisms, and environmental processes to understand and visualize network behavior | ||
under various conditions. Support for A/B testing policies, Monte Carlo analysis, and other common numerical methods is | ||
provided. | ||
|
||
|
||
In essence, cadCAD tool allows us to represent a company’s or community’s current business model along with a desired | ||
future state and helps make informed, rigorously tested decisions on how to get from today’s stage to the future state. | ||
It allows us to use code to solidify our conceptualized ideas and see if the outcome meets our expectations. We can | ||
iteratively refine our work until we have constructed a model that closely reflects reality at the start of the model, | ||
and see how it evolves. We can then use these results to inform business decisions. | ||
|
||
|
||
#### Documentation: | ||
* ##### [Tutorials](https://github.com/BlockScience/cadCAD-Tutorials/tree/master/01%20Tutorials) | ||
* ##### [System Model Configuration](https://github.com/BlockScience/cadCAD-Tutorials/blob/master/documentation/Simulation_Configuration.md) | ||
* ##### [System Simulation Execution](https://github.com/BlockScience/cadCAD-Tutorials/blob/master/documentation/Simulation_Execution.md) | ||
|
||
|
||
#### 0. Installation: | ||
|
||
cadCAD is in private beta. Access to a JupyterHUB instance (or tokens) are issued to participants. If you'd like to | ||
participate in the beta program, contact cadcad [at] block [dot] science. | ||
|
||
Replace `<TOKEN>` in the installation URL below. | ||
```bash | ||
pip3 install pandas pathos fn funcy tabulate | ||
pip3 install cadCAD --extra-index-url https://<TOKEN>@repo.fury.io/blockscience/ | ||
``` | ||
|
||
#### 1. [Configure System Model](https://github.com/BlockScience/cadCAD-Tutorials/blob/master/documentation/Simulation_Configuration.md) | ||
|
||
#### 2. [Execute Simulations:](https://github.com/BlockScience/cadCAD-Tutorials/blob/master/documentation/Simulation_Execution.md) | ||
|
||
##### Single Process Execution: | ||
Example System Model Configurations: | ||
* [System Model A](https://github.com/BlockScience/cadCAD-Tutorials/blob/master/documentation/examples/sys_model_A.py): | ||
`/documentation/examples/sys_model_A.py` | ||
* [System Model B](https://github.com/BlockScience/cadCAD-Tutorials/blob/master/documentation/examples/sys_model_B.py): | ||
`/documentation/examples/sys_model_B.py` | ||
|
||
Example Simulation Executions: | ||
* [System Model A](https://github.com/BlockScience/cadCAD-Tutorials/blob/master/documentation/examples/sys_model_A_exec.py): | ||
`/documentation/examples/sys_model_A_exec.py` | ||
* [System Model B](https://github.com/BlockScience/cadCAD-Tutorials/blob/master/documentation/examples/sys_model_B_exec.py): | ||
`/documentation/examples/sys_model_B_exec.py` | ||
|
||
```python | ||
import pandas as pd | ||
from tabulate import tabulate | ||
from cadCAD.engine import ExecutionMode, ExecutionContext, Executor | ||
from documentation.examples import sys_model_A | ||
from cadCAD import configs | ||
|
||
exec_mode = ExecutionMode() | ||
|
||
# Single Process Execution using a Single System Model Configuration: | ||
# sys_model_A | ||
sys_model_A = [configs[0]] # sys_model_A | ||
single_proc_ctx = ExecutionContext(context=exec_mode.single_proc) | ||
sys_model_A_simulation = Executor(exec_context=single_proc_ctx, configs=sys_model_A) | ||
|
||
sys_model_A_raw_result, sys_model_A_tensor_field = sys_model_A_simulation.execute() | ||
sys_model_A_result = pd.DataFrame(sys_model_A_raw_result) | ||
print() | ||
print("Tensor Field: sys_model_A") | ||
print(tabulate(sys_model_A_tensor_field, headers='keys', tablefmt='psql')) | ||
print("Result: System Events DataFrame") | ||
print(tabulate(sys_model_A_result, headers='keys', tablefmt='psql')) | ||
print() | ||
``` | ||
|
||
##### Multiple Simulations (Concurrent): | ||
###### Multiple Simulation Execution (Multi Process Execution) | ||
System Model Configurations: | ||
* [System Model A](https://github.com/BlockScience/cadCAD-Tutorials/blob/master/documentation/examples/sys_model_A.py): | ||
`/documentation/examples/sys_model_A.py` | ||
* [System Model B](https://github.com/BlockScience/cadCAD-Tutorials/blob/master/documentation/examples/sys_model_B.py): | ||
`/documentation/examples/sys_model_B.py` | ||
|
||
[Example Simulation Executions:](https://github.com/BlockScience/cadCAD-Tutorials/blob/master/documentation/examples/sys_model_AB_exec.py) | ||
`/documentation/examples/sys_model_AB_exec.py` | ||
|
||
```python | ||
import pandas as pd | ||
from tabulate import tabulate | ||
from cadCAD.engine import ExecutionMode, ExecutionContext, Executor | ||
from documentation.examples import sys_model_A, sys_model_B | ||
from cadCAD import configs | ||
|
||
exec_mode = ExecutionMode() | ||
|
||
# # Multiple Processes Execution using Multiple System Model Configurations: | ||
# # sys_model_A & sys_model_B | ||
multi_proc_ctx = ExecutionContext(context=exec_mode.multi_proc) | ||
sys_model_AB_simulation = Executor(exec_context=multi_proc_ctx, configs=configs) | ||
|
||
i = 0 | ||
config_names = ['sys_model_A', 'sys_model_B'] | ||
for sys_model_AB_raw_result, sys_model_AB_tensor_field in sys_model_AB_simulation.execute(): | ||
sys_model_AB_result = pd.DataFrame(sys_model_AB_raw_result) | ||
print() | ||
print(f"Tensor Field: {config_names[i]}") | ||
print(tabulate(sys_model_AB_tensor_field, headers='keys', tablefmt='psql')) | ||
print("Result: System Events DataFrame:") | ||
print(tabulate(sys_model_AB_result, headers='keys', tablefmt='psql')) | ||
print() | ||
i += 1 | ||
``` | ||
|
||
##### Parameter Sweep Simulation (Concurrent): | ||
[Example:](https://github.com/BlockScience/cadCAD-Tutorials/blob/master/documentation/examples/param_sweep.py) | ||
`/documentation/examples/param_sweep.py` | ||
|
||
```python | ||
import pandas as pd | ||
from tabulate import tabulate | ||
# The following imports NEED to be in the exact order | ||
from cadCAD.engine import ExecutionMode, ExecutionContext, Executor | ||
from documentation.examples import param_sweep | ||
from cadCAD import configs | ||
|
||
exec_mode = ExecutionMode() | ||
multi_proc_ctx = ExecutionContext(context=exec_mode.multi_proc) | ||
run = Executor(exec_context=multi_proc_ctx, configs=configs) | ||
|
||
for raw_result, tensor_field in run.execute(): | ||
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() | ||
``` | ||
cadCAD is now [open source](https://github.com/BlockScience/cadCAD) |