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

Support basic integration with a const IntegratorBase #22665

Open
RussTedrake opened this issue Feb 25, 2025 · 2 comments · May be fixed by #22720
Open

Support basic integration with a const IntegratorBase #22665

RussTedrake opened this issue Feb 25, 2025 · 2 comments · May be fixed by #22720
Assignees

Comments

@RussTedrake
Copy link
Contributor

Moving this discussion from slack.

#22601 is pushing on something that I've been meaning to push for some time: allowing a LeafSystem to use an IntegratorBase integrator, without that integrator holding undeclared state.

Currently even the simplest apis for integration are non-const -- the IntegratorBase uses member variables for state in at least a few different ways:

  1. it holds a reference to a mutable Context which it updates with the integration results,
  2. storage related to error control / variable step integration,
  3. book-keeping statistics (e.g. how many times the calc methods have been called),
  4. scratch memory to avoid allocation inside the main integration loops.

But if we want to use an integrator to implement integration inside a system or constraint, then this corresponds to hidden state.

After a quick experiment here, my proposal is to offer a new entry point: IntegratorBase<T>::IntegrateWithSingleFixedStepToTime(const T& t_target, Context<T>* context) const which:

  1. updates the mutable context argument,
  2. doesn't need error control / variable step integration,
  3. disable book-keeping,
  4. still writes to scratch memory -- but these will be marked mutable.

We could consider more sweeping support for const integration APIs (e.g. the multiple step variants), but this is already a good start.

@RussTedrake
Copy link
Contributor Author

@sherm1 -- do you prefer marking the book-keeping statistics mutable, or disabling book-keeping in the new const variants of the methods?

@sherm1
Copy link
Member

sherm1 commented Feb 25, 2025

My preference would be to make the stats always mutable and continue updating them in the const variants.

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

Successfully merging a pull request may close this issue.

2 participants