ODESpec

models.ODESpec(
    derivatives,
    initial,
    state_cost,
    state_effect,
    event_rates=None,
    event_cost=None,
    event_effect=None,
)

One intervention’s dynamics and rewards for a single parameter set.

Returned by the engine’s dynamics_and_rewards function. Arrays are plain numpy arrays over the engine’s compartment (state) order.

Parameters

Name Type Description Default
derivatives Derivatives The right-hand side of the system, fn(t, y) -> dy/dt, where t is time in years and y is the compartment vector, shape (n_states,). Returns the instantaneous rate of change of each compartment, same shape. required
initial NDArray[np.float64] Initial compartment sizes at t = 0, shape (n_states,). Their sum is the population scale; costs and effects come out in the same units, so an incremental cost-effectiveness ratio is unaffected by it. required
state_cost NDArray[np.float64] Per-year cost of each unit of occupancy in each compartment, shape (n_states,). The occupancy integral of this vector is the discounted cost that accrues while individuals sit in a compartment. required
state_effect NDArray[np.float64] Per-year effect (quality-adjusted life-years) of each unit of occupancy in each compartment, shape (n_states,). required
event_rates EventRates | None Optional fn(t, y) -> rates returning the per-year rate of each tracked flow event, shape (n_events,). A flow event is a movement between compartments carrying a one-time amount, such as a vaccination or a new infection. None when the model has no flow-based rewards. None
event_cost NDArray[np.float64] | None One-time cost charged per unit of each flow event, shape (n_events,). Required when event_rates is given. None
event_effect NDArray[np.float64] | None One-time effect charged per unit of each flow event, shape (n_events,). Required when event_rates is given; pass zeros when the events carry cost only. None