Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handling (non-negativity) constraints #2327

Closed
dweindl opened this issue Feb 28, 2024 · 3 comments
Closed

Handling (non-negativity) constraints #2327

dweindl opened this issue Feb 28, 2024 · 3 comments
Assignees

Comments

@dweindl
Copy link
Member

dweindl commented Feb 28, 2024

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
Copy link
Member Author

dweindl commented Feb 28, 2024

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 dweindl self-assigned this Feb 28, 2024
@dweindl
Copy link
Member Author

dweindl commented Feb 29, 2024

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

dweindl added a commit to dweindl/AMICI that referenced this issue Mar 4, 2024
In addition to the current `Model.setStateIsNonNegative`, this adds the option to set additional
(non)negativity/positivity constraints to be enforced by the solver.

See [CVodeSetConstraints](https://sundials.readthedocs.io/en/latest/cvode/Usage/index.html#c.CVodeSetConstraints) for details.

Related to AMICI-dev#2327.
dweindl added a commit that referenced this issue Mar 7, 2024
In addition to the current `Model.setStateIsNonNegative`, this adds the option to set additional
(non)negativity/positivity constraints to be enforced by the solver.

See [CVodeSetConstraints](https://sundials.readthedocs.io/en/latest/cvode/Usage/index.html#c.CVodeSetConstraints) for details.

Related to #2327.
@dweindl
Copy link
Member Author

dweindl commented Mar 7, 2024

Note:

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

@dweindl dweindl closed this as completed Mar 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant