# IntegratorRunner#

class brainpy.IntegratorRunner(target, inits=None, dt=None, monitors=None, dyn_vars=None, jit=True, numpy_mon_after_run=True, progress_bar=True, args=None, dyn_args=None, fun_monitors=None)[source]#

Structural runner for numerical integrators in brainpy.

Examples

Example to run an ODE integrator,

```>>> import brainpy as bp
>>> import brainpy.math as bm
>>> a=0.7; b=0.8; tau=12.5
>>> dV = lambda V, t, w, I: V - V * V * V / 3 - w + I
>>> dw = lambda w, t, V, a, b: (V + a - b * w) / tau
>>> integral = bp.odeint(bp.JointEq([dV, dw]), method='exp_auto')
>>>
>>> runner = bp.IntegratorRunner(
>>>          integral,  # the simulation target
>>>          monitors=['V', 'w'],  # the variables to monitor
>>>          inits={'V': bm.random.rand(10),
>>>                 'w': bm.random.normal(size=10)},  # the initial values
>>> )
>>> runner.run(100.,
>>>            args={'a': 1., 'b': 1.},  # update arguments
>>>            dyn_args={'I': bp.inputs.ramp_input(0, 4, 100)},  # each time each current input
>>> )
>>> bp.visualize.line_plot(runner.mon.ts, runner.mon.V, plot_ids=[0, 1, 4], show=True)
```

Example to run an SDE intragetor,

```>>> import brainpy as bp
>>> import brainpy.math as bm
>>> # stochastic Lorenz system
>>> sigma=10; beta=8 / 3; rho=28
>>> g = lambda x, y, z, t, p: (p * x, p * y, p * z)
>>> f = lambda x, y, z, t, p: [sigma * (y - x), x * (rho - z) - y, x * y - beta * z]
>>> lorenz = bp.sdeint(f, g, method='milstein2')
>>>
>>> runner = bp.IntegratorRunner(
>>>   lorenz,
>>>   monitors=['x', 'y', 'z'],
>>>   inits=[1., 1., 1.], # initialize all variable to 1.
>>>   dt=0.01
>>> )
>>> runner.run(100., args={'p': 0.1},)
>>>
>>> import matplotlib.pyplot as plt
>>> fig = plt.figure()
>>> ax = fig.gca(projection='3d')
>>> plt.plot(runner.mon.x.squeeze(), runner.mon.y.squeeze(), runner.mon.z.squeeze())
>>> ax.set_xlabel('x')
>>> ax.set_xlabel('y')
>>> ax.set_xlabel('z')
>>> plt.show()
```
run(duration, start_t=None, eval_time=False, args=None, dyn_args=None)[source]#

The running function.

Parameters:
• duration (float, int, tuple, list) – The running duration.

• start_t (float, optional) – The start time to simulate.

• eval_time (bool) – Evaluate the running time or not?

• args (dict) – The equation arguments to update. .. versionadded:: 2.3.1

• dyn_args (dict) –

The dynamically changed arguments over time. The size of first dimension should be equal to the running `duration`.

New in version 2.3.1.