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

User exposing init and step for customization. #466

Conversation

manuelgloeckler
Copy link
Contributor

@manuelgloeckler manuelgloeckler commented Oct 24, 2024

User exposing init and step

Currently, the only user API to solve a cell ODE is jx.integrate. For various applications, it is useful to have access to an init function, which initializes the state, and a step function, which executes a single ode step. Some examples are:

  • Nonuniform step sizes
  • Integration with Kalman or Particle filtering frameworks
  • Stochastic Models (i.e. add noise after each step) ...

Also see #350 .

Proposal

init_fn, step_fn = build_init_and_step_fn(cell, **maybe_some_other)

# All the reformating
states, params = init_fn(params, all_states, **kwargs)
next_state = step_fn(states, params, externals, dt=0.025, **kwargs)

Copy link
Contributor

@michaeldeistler michaeldeistler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Beautiful, I love it!

Could you write a test (which we can later reuse as a tutorial :) ) which compares jx.integrate() to a minimal version of iteratively calling step()?

@manuelgloeckler manuelgloeckler self-assigned this Oct 24, 2024
@manuelgloeckler
Copy link
Contributor Author

Alright, I added an API equivalence test of integrate vs. manual for-loop.

Copy link
Contributor

@michaeldeistler michaeldeistler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amazing, thanks!

@michaeldeistler michaeldeistler merged commit 3bf221c into main Oct 25, 2024
1 check passed
@michaeldeistler michaeldeistler deleted the 350-expose-step-such-that-users-have-fine-grained-control-over-solve branch October 25, 2024 09:32
michaeldeistler pushed a commit that referenced this pull request Nov 13, 2024
* Working init and step

* Refactored integrate

* Adding API equivalence test

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

Successfully merging this pull request may close these issues.

Expose step such that users have fine-grained control over solve
2 participants