# Wiki

# D2D Software / Integration tolerances and modification possibilities

In the following, integrator tolerances, their effect and trade-off behaviour is outlined. Also, automatic calibration of tolerances to cover scalings in observation functions is described.

Integrations in the d2d-framework are performed via the CVODEs package. Therefore, relative and absolute tolerances, RTOL and ATOL, are set. The default values for both are 1e-6. The integration steps are chosen in a way that the Newton iteration of the implicit backward differentiation formula within CVODEs satisfies the error tolerance given by:

RTOL * |x_i| + ATOL , with internal state x_i.

Changing tolerance values can help improve the speed or convergence of the optimiser by setting looser or tighter tolerances, respectively. Hence, there is a trade-off between fast integration and better chi2 estimates and sensitivities which can improve the optimisation.
On the other hand, a tight tolerance (e.g. 1e-12) can lead to large integration times or even failures in the integration, since the tolerances can't be met with the lowest step size available.
The sensitivities of the ODE system, integrated simultaneous with the internal states, get the same relative tolerance whereas the absolute tolerance is set to `ATOL/|p_i|`

for a sensitivity with parameter i.

The crucial values for the model optimisation, chi2 and its sensitivities, are computed on the observations given in the model. Thus, a high scaling factor in the observation function can lead to loose tolerances of the optimisation.
To adjust these in order to reach a desired accuracy for the observations, the absolute tolerances can be scaled by `1/max( sum_i( sum_j( dy_i/dx_j )))`

with observation i and internal state j.

In the d2d-framework, adjustment of ATOL can be set on for internal states with

ar.config.atolV = 1;

for internal states and

ar.config.atolV_sens = 1;

for sensitivities. The range of the rescaled tolerances are hereby bounded to `[1.e-4, 1.e-12]`

to preserve a good integration feasibility.

Updated