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

Question: Help setting inequality constraints where the right hand side is different than 0 #71

Closed
AaronHKim opened this issue Aug 9, 2021 · 2 comments
Labels

Comments

@AaronHKim
Copy link

AaronHKim commented Aug 9, 2021

I am interested in using CVode to integrate with inequality constraints where the right-hand side is different than zero, e.g., y_1 < 5. What is the intended method for doing this? Should I be modifying my states so that the inequality constraint changes, i.e., change y_1 = y_1 - 5 so that the new inequality constraint is y_1 <0, or is there a different method that I can use instead? I would like to avoid modifying my states if possible.

Additionally is there some intended method of implementing a 2-sided band constraint, where a<=y<=b?

@balos1
Copy link
Member

balos1 commented Aug 11, 2021

This was answered on the SUNDIALS mailing list.

Hello Kim Aaron,

Yes, to solve that problem with CVODE will have to
make a change of variables from y_i to y_i - bound
in order to enforce a bound y_i < bound.

-Alan H

@balos1 balos1 closed this as completed Aug 11, 2021
@AaronHKim
Copy link
Author

AaronHKim commented Aug 11, 2021

Thank you for the reply!

Do you happen to know of any additional information on the second question regarding how to implement a 2-banded constraint where a<=y<=b?

Edit (answered by mailing list):

As with the upper bound question, CVODE has no built-in
constraint option of that type. Here is how you can do it:
In addition to changing variables from y to y-b and requiring this variable to be <= 0, add to the system another dependent variable z which is equal to y-a,
have z satisfy the same ODE that y does (with the shift accounted for in its right-hand side function), and require the constraint z >= 0. The two resulting numerical solutions for y will agree within specified tolerances.

In any case, please be aware that if the true solution of the ODE system takes y outside of that band, CVODE cannot resolve that conflict, and will grind to a halt. If the true solution does indeed stay in the band, any actual numerical violations of the bounds (detected internally), will be temporary and will be corrected by CVODE.

-Alan H

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants