cadCAD/documentation/param_sweep.md

1.3 KiB

System Model Parameter Sweep

Parametrization of a System Model configuration that produces multiple configurations.

Set Parameters
params = {
    'alpha': [1],
    'beta': [2, 5],
    'gamma': [3, 4],
    'omega': [7]
}

The parameters above produce 2 simulations.

  • Simulation 1:
    • alpha = 1
    • beta = 2
    • gamma = 3
    • omega = 7
  • Simulation 2:
    • alpha = 1
    • beta = 5
    • gamma = 4
    • omega = 7

All parameters can also be set to include a single parameter each, which will result in a single simulation.

Example State Updates

Previous State: y = 0

def state_update(_params, step, sL, s, _input):
    y = 'state'
    x = s['state'] + _params['alpha'] + _params['gamma']
    return y, x
  • Updated State:
    • Simulation 1: y = 4 = 0 + 1 + 3
    • Simulation 2: y = 5 = 0 + 1 + 4
Example Policy Updates
# Internal States per Mechanism
def policies(_g, step, sL, s):
    return {'beta': _g['beta'], 'gamma': _g['gamma']}
  • Simulation 1: {'beta': 2, 'gamma': 3]}
  • Simulation 2: {'beta': 5, 'gamma': 4}
Configure Simulation
from cadCAD.configuration.utils import config_sim

sim_config = config_sim(
    {
        "N": 2,
        "T": range(5),
        "M": g,
    }
)