AMICI-dev / AMICI

Advanced Multilanguage Interface to CVODES and IDAS
https://amici.readthedocs.io/
Other
108 stars 31 forks source link

Handling (non-negativity) constraints #2327

Closed dweindl closed 8 months ago

dweindl commented 8 months ago

In many applications, our models are subject to physical constraint, such that the model state has to be non-negative. Due to numerical issues, this is however not always ensured in practice. Currently, this is optionally handled via Model.{setStateIsNonNegative|allStatesNonNegative}, which boils down to taking max(0, state).

As of v6.2.0[1], SUNDIALS supports handling such constraints via projection functions. This would be the preferable mechanism for handling non-negativity- or more general constraints.

This will, however, first require upgrading SUNDIALS (#1565).

[1] Note: relevant memory leaks fixed in v6.4.0

dweindl commented 8 months ago

Oh, for the handling of plain (non)negativity/positivity constraints we don't need to upgrade sundials. We have CVodeSetConstraints already available. Only for the more general constraint handling (#2329) we'll have to upgrade.

dweindl commented 8 months ago

Okay, after a brief test, this won't help with cases where the Jacobian cannot be evaluated (produces NaN) for negative x.

dweindl commented 8 months ago

Note:

CVODES in function cvInitialSetup : Constraints can not be enforced while forward sensitivity is used with simultaneous method