Skip to content

Commit

Permalink
Merge pull request #278 from cadCAD-org/pre_release
Browse files Browse the repository at this point in the history
Pre-Release: ver. 0.4.26
  • Loading branch information
JEJodesty authored Jul 6, 2021
2 parents 6bef7b6 + e286727 commit 4aba1be
Show file tree
Hide file tree
Showing 12 changed files with 169 additions and 37 deletions.
28 changes: 15 additions & 13 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
# Changelog:

### May 21, 2021

### New Features:
* **ver. ≥ `0.4.25`:**
### July 1, 2021
#### New Features:
* **ver. ≥ `0.4.26`:**
* ##### [Experiments](documentation#experiments)
* ##### [System Model Configurations]
* Configurations (`cadCAD.utils.Configuration`'s) as are no longer a part of the `cadCAD` module
Expand All @@ -18,17 +17,20 @@
* Users can no longer use the `config_list` method of `cadCAD.configuration.Experiment`
* **Backwards Compatibility:** The `append_model` method of `cadCAD.configuration.Experiment` can also be used as
the `append_configs` method.
* **Hot-Fixes:**
* [#257](https://github.com/cadCAD-org/cadCAD/issues/257)
* The `append_model` method of `cadCAD.configuration.Experiment` will no longer throw mis-leading error message
during simulation execution.
* ##### [Upgrade Guide:](documentation#cadCAD-v0.4.26-Model-Upgrade-Guide.md) specific to feature changes / additions
* **Fixes:**
* [#248](https://github.com/cadCAD-org/cadCAD/issues/248)
* The previous release was returning partial results. An A/B test for this has been included and will be for
future releases
* [#242](https://github.com/cadCAD-org/cadCAD/issues/242)
* Parallelized simulations re-enabled with the re-inclusion of `ProcessPool`.
* [#250](https://github.com/cadCAD-org/cadCAD/issues/250)
* First Partial State Update Block at first timestep no longer equals to 0 instead of the expected 1 in simulation
output.

* Parallelized simulations enabled with the re-inclusion of `ProcessPool`.
* [#257](https://github.com/cadCAD-org/cadCAD/issues/257)
* ValueError for runs accepted by the `cadCAD.configuration.Experiment().append_model` via the `sim_configs` no
longer gives mis-leading error message if catching a non-related ValueError
* [#252](https://github.com/cadCAD-org/cadCAD/issues/252)
* Jupyter lab and Jupyter notebook recognises cadCAD module


### September 22, 2020
##### [Multi - System Model Execution](https://github.com/cadCAD-org/cadCAD/blob/master/documentation/Simulation_Execution.md#multiple-simulation-execution)
* **ver. ≥ `0.4.23`:**
Expand Down
16 changes: 2 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
/ ___/ __` / __ / / / /| | / / / /
/ /__/ /_/ / /_/ / /___/ ___ |/ /_/ /
\___/\__,_/\__,_/\____/_/ |_/_____/
by cadCAD ver. 0.4.25
by cadCAD ver. 0.4.26
======================================
Complex Adaptive Dynamics
o i e
Expand All @@ -20,8 +20,7 @@ through simulation, with support for Monte Carlo methods, A/B testing and parame

# Getting Started


#### Change Log: [ver. 0.4.25](CHANGELOG.md)
#### Change Log: [ver. 0.4.26](CHANGELOG.md)

[Previous Stable Release (No Longer Supported)](https://github.com/cadCAD-org/cadCAD/tree/b9cc6b2e4af15d6361d60d6ec059246ab8fbf6da)

Expand Down Expand Up @@ -60,17 +59,6 @@ $ python3 setup.py sdist bdist_wheel
$ pip3 install dist/*.whl
```

**Option C: Using [Nix](https://nixos.org/nix/)**
1. Run `curl -L https://nixos.org/nix/install | sh` or install Nix via system package manager
2. Run `nix-shell` to enter into a development environment, `nix-build` to build project from source, and
`nix-env -if default.nix` to install

The above steps will enter you into a Nix development environment, with all package requirements for development of and
with cadCAD.

This works with just about all Unix systems as well as MacOS, for pure reproducible builds that don't
affect your local environment.

## 2. Documentation:
* [Simulation Configuration](documentation/README.md)
* [Simulation Execution](documentation/Simulation_Execution.md)
Expand Down
2 changes: 1 addition & 1 deletion cadCAD/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os, dill

name = "cadCAD"
version = "0.4.25"
version = "0.4.26"

if os.name == 'nt':
dill.settings['recurse'] = True
Expand Down
37 changes: 31 additions & 6 deletions cadCAD/utils/execution.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,41 @@
from pprint import pprint

from cadCAD import logo, version
from cadCAD.utils import flatten


def print_exec_info(exec_context, configs):
print(logo)
print(f'cadCAD Version: {version}')
print(f'Execution Mode: {exec_context}')
models = len(configs)
first_sim = configs[0].sim_config
n_t = len(first_sim['T'])
n_m = len(first_sim['M'])
n_n = first_sim['N']
n_s = len(configs[0].initial_state)
sim_strs, run_vals, timestep_vals, params, sub_states = [], [], [], [], set()
for i, config in enumerate(configs):
run_vals.append(config.sim_config['N'])
for timestep in [*config.sim_config['T']]:
timestep_vals.append(timestep)
if type(config.sim_config['M']) is dict:
params.append(len(config.sim_config['M']))
for state_key in list(config.initial_state.keys()):
sub_states.add(state_key)
sim = config.sim_config
n_t = len(sim['T'])
n_m = len(sim['M'])
n_n = sim['N']
n_s = len(config.initial_state)
sim_strs.append(f' Simulation {i}: (Timesteps, Params, Runs, Sub-States) = ({n_t}, {n_m}, {n_n}, {n_s})')

timesteps = len(timestep_vals)
if sum(params) != 0:
param_count = sum(params)
else:
param_count = 1
runs = sum(run_vals)
init_states = len(sub_states)

print("Simulation Dimensions:")
print(
f'Dimensions of the first simulation: (Models, Timesteps, Params, Runs, Vars) = ({models}, {n_t}, {n_m}, {n_n}, {n_s})'
f'Entire Simulation: (Models, Unique Timesteps, Params, Total Runs, Sub-States) = ({models}, {timesteps}, {param_count}, {runs}, {init_states})'
)
for sim_str in sim_strs:
print(sim_str)
Binary file removed dist/cadCAD-0.4.25.tar.gz
Binary file not shown.
Binary file not shown.
Binary file added dist/cadCAD-0.4.26.tar.gz
Binary file not shown.
4 changes: 2 additions & 2 deletions documentation/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ in the simulation. In other words, for how long do they want to simulate the sys

cadCAD facilitates running multiple simulations of the same system sequentially, reporting the results of all those
runs in a single dataset. This is especially helpful for running
[Monte Carlo Simulations](../tutorials/robot-marbles-part-4/robot-marbles-part-4.ipynb).
[Monte Carlo Simulations](https://github.com/cadCAD-org/demos/blob/master/tutorials/robots_and_marbles/robot-marbles-part-4/robot-marbles-part-4.ipynb).

### M - Parameters of the System

Expand Down Expand Up @@ -149,7 +149,7 @@ cadCAD relies on in order to run the simulation according to the specifications.
### Policy Functions
A Policy Function computes one or more signals to be passed to [State Update Functions](#State-Update-Functions)
(via the _\_input_ parameter). Read
[this article](../tutorials/robot-marbles-part-2/robot-marbles-part-2.ipynb)
[this article](https://github.com/cadCAD-org/demos/blob/master/tutorials/robots_and_marbles/robot-marbles-part-2/robot-marbles-part-2.ipynb)
for details on why and when to use policy functions.

<!-- We would then expand the tutorials with these kind of concepts
Expand Down
91 changes: 91 additions & 0 deletions documentation/cadCAD-v0.4.26-Model-Upgrade-Guide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
<table>
<tr>
<th>
Feature
</th>
<th>
ver. 0.4.26
</th>
<th>
ver. 0.4.23
</th>
</tr>
<tr>
<td>
<h5>
Experiments & System Model Configurations
</h5>
</td>
<td>
<pre lang="python">
from cadCAD.configuration import Experiment

exp = Experiment()
exp.append_model(
model_id = 'sys_model_1', # System Model
initial_state = ..., # System Model
partial_state_update_blocks = ..., # System Model
policy_ops = ..., # System Model
sim_configs = ..., # Simulation Properties
)
exp.append_model(
model_id = 'sys_model_2', # System Model
...
)

configs = exp.configs
</pre>
</td>
<td>
<pre lang="python">
from cadCAD import configs
from cadCAD.configuration import Experiment
exp = Experiment()
exp.append_configs(...)
</pre>
</td>
</tr>
<tr>
<td>
<h5>
cadCAD Post-Processing Modifications
</h5>
</td>
<td>
<pre lang="python">
import pandas as pd
from tabulate import tabulate
from cadCAD.engine import ExecutionMode, ExecutionContext, Executor
from simulations.regression_tests.experiments import multi_exp
from simulations.regression_tests.models import config_multi_1, config_multi_2

exec_mode = ExecutionMode()

local_proc_ctx = ExecutionContext(context=exec_mode.local_mode)
run = Executor(exec_context=local_proc_ctx, configs=multi_exp.configs)

raw_result, tensor_fields, _ = run.execute()
result = pd.DataFrame(raw_result)
print(tabulate(tensor_fields[0], headers='keys', tablefmt='psql'))
print(tabulate(result, headers='keys', tablefmt='psql'))
</pre>
</td>
<td>
<pre lang="python">
import pandas as pd
from tabulate import tabulate
from cadCAD.engine import ExecutionMode, ExecutionContext, Executor
import system_model_A, system_model_B

from cadCAD import configs
exec_mode = ExecutionMode()

local_ctx = ExecutionContext(context=exec_mode.local_mode)
simulation = Executor(exec_context=local_ctx, configs=configs)
raw_result, sys_model, _ = simulation.execute()
result = pd.DataFrame(raw_result)
print(tabulate(result, headers='keys', tablefmt='psql'))
</pre>
</td>
</tr>
</table>
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"""

name = "cadCAD"
version = "0.4.25"
version = "0.4.26"

setup(name=name,
version=version,
Expand Down
18 changes: 18 additions & 0 deletions simulations/regression_tests/execs/multi_config_test2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
from tabulate import tabulate
from pprint import pprint
import pandas as pd

from cadCAD.engine import ExecutionMode, ExecutionContext, Executor
from simulations.regression_tests.experiments import multi_exp
from simulations.regression_tests.models import config_multi_1, sweep_config

exec_mode = ExecutionMode()

local_proc_ctx = ExecutionContext(context=exec_mode.local_mode)
run = Executor(exec_context=local_proc_ctx, configs=multi_exp.configs)

raw_result, tensor_fields, sessions = run.execute()
result = pd.DataFrame(raw_result)
print(tabulate(tensor_fields[0], headers='keys', tablefmt='psql'))
# pprint(sessions)
print(tabulate(result, headers='keys', tablefmt='psql'))
8 changes: 8 additions & 0 deletions simulations/regression_tests/models/sweep_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
# from cadCAD.configuration import append_configs
from cadCAD.configuration import Experiment
from cadCAD.configuration.utils import env_trigger, var_substep_trigger, config_sim, psub_list
from simulations.regression_tests.experiments import multi_exp


def some_function(x):
Expand Down Expand Up @@ -91,3 +92,10 @@ def sweeped(_g, step, sL, s, _input, **kwargs):
env_processes=env_process,
partial_state_update_blocks=partial_state_update_blocks
)
multi_exp.append_model(
model_id='sys_model_2',
sim_configs=sim_config,
initial_state=genesis_states,
env_processes=env_process,
partial_state_update_blocks=partial_state_update_blocks
)

0 comments on commit 4aba1be

Please sign in to comment.