|
| 1 | +--- |
| 2 | +title: cadCAD Builder |
| 3 | +layout: page |
| 4 | +nav_order: 5 |
| 5 | +--- |
| 6 | + |
| 7 | +MSML provides interfaces for creating cadCAD style models that don't require end users poking around the actual code to use. The idea is that it provides a layer for data scientists to experiment just with toggling starting state and parameters and executing pre-packaged models. |
| 8 | + |
| 9 | +## Components |
| 10 | + |
| 11 | +### Inputs |
| 12 | + |
| 13 | +The following is required for building the cadCAD model: |
| 14 | + |
| 15 | +1. A math spec object with code bindings |
| 16 | +2. A list of blocks which should be executed for each timestep |
| 17 | +3. What state preparation and parameter preparation functions should be included to automatically run on experiment creation |
| 18 | + |
| 19 | + |
| 20 | +### Outputs |
| 21 | + |
| 22 | +The following is outputted by the creation function: |
| 23 | + |
| 24 | +1. State Space: The nested and typed dictionary of all types for the state in the simulation that the data scientist needs to define |
| 25 | +2. Parameter Space: The dictionary of parameters that the data scientist needs to define |
| 26 | +3. Model: The executable model that can spawn experiments to run given valid state space and parameter space passed |
| 27 | + |
| 28 | +## Creating a cadCAD Model in a Notebook |
| 29 | + |
| 30 | +The [template notebook on building cadCAD models](https://github.com/BlockScience/MSML-Template/blob/main/notebooks/Build%20cadCAD.ipynb) shows how to create a cadCAD model from an MSML model. |
| 31 | + |
| 32 | +## Using cadCAD Model Repositories |
| 33 | + |
| 34 | +A recommended design pattern is to have MSML developers create a batch of cadCAD models to be run within a cadCADModels folder [similar to the template](https://github.com/BlockScience/MSML-Template/tree/main/cadCADModels). |
| 35 | + |
| 36 | +The template also has an example of running the pre-built cadCAD models [here](https://github.com/BlockScience/MSML-Template/blob/main/notebooks/Pre-built%20cadCAD.ipynb). |
| 37 | + |
| 38 | + |
| 39 | +## Model Functionality |
| 40 | + |
| 41 | +### Experiment Creation |
| 42 | + |
| 43 | +- To create an experiment, one runs model.create_experiment(state, params) and passes in a valid state and parameter dictionary |
| 44 | +- The record_trajectory flag if set to true will record the state after each step of the simulation |
| 45 | +- The use_deepcopy flag if set to true will use deepcopy for the trajectory recording |
| 46 | + |
| 47 | + |
| 48 | +### Running Experiments |
| 49 | + |
| 50 | +- Using experiment.run(T) where T is the number of time steps will advance the simulations that many timesteps |
| 51 | +- If record_trajectory was set to true then the trajectories can be accessed from experiment.trajectories, if not you can always access the current state of the experiment by calling experiment.state |
| 52 | + |
| 53 | +### Batch Experiments |
| 54 | + |
| 55 | +- Batch experiments can be created and run through model.create_batch_experiments(...). An example of it is shown in the pre-built cadCAD notebook. |
0 commit comments