question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Lots of code reuse between solvers, and between adjoint SDEs

See original GitHub issue

To be clear, not raising this because I feel like being nitpicky - read on!

Other than very minor differences (e.g. order), the code for each Euler–Maruyama/Milstein/SRK method is essentially the same across noise types. Instead one can have e.g. a single Euler that accepts order as an argument, and four different wrappers that set that argument.

Similarly, the adjoint SDE definitions have lots of code reuse; it’d easier to write down a single adjoint SDE for the general noise case. (And any unnecessary computation can be masked out with if statements checking the noise type.)

I think the latter in particular offers an easy opportunity to unify Ito and Stratonovich: it’d just be another if statement checking if the correction term should be applied.

As for why I’m raising this - I’m interested in:

  • Defining custom SDE solvers.
  • Solving the adjoint SDE with general noise. (And I’m happy to do so with Euler–Maruyama, knowing the strong order is 0.5. It should still work, right?)
  • Solving Stratonovich SDEs.

The first is aided by tidying up the existing code for solvers (I don’t want to define MyCustomSolverAdditive, MyCustomSolverGeneral,…), the second is made possible by improving the adjoint SDE, and the third is a stretch goal that’ll probably be easier if it can just be implemented with if sde_type= corrections in the right places.

Tidying up the solvers at least is probably something I can offer a PR on, but I wanted to check if this fit your general vision, or if you think there’s anything that might go wrong, as it pretty much involves removing the whole methods directory structure.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
patrick-kidgercommented, Aug 15, 2020

@mtsokol Hello there. So I’m not completely sure that I’m the one you should be asking - this is really @lxuechen’s repository, not mine!

That said - we’re currently in the process of rewriting large portions of the internals - see the dev branch. In particular we should now have support for Stratonovich SDEs via the midpoint method, so you could look at formatting your work on Heun’s method in the same manner, and then submit a PR there?

Glancing at what you’ve already done so far - I see you’ve done a diagonal-only version of Heun’s method. I think this should be applicable to any noise type, so you could also look at generalising that (again, c.f. how midpoint is implemented).

0reactions
mtsokolcommented, Aug 15, 2020

@patrick-kidger Hi! I’ve recently started learning this repository and while implementing Heun’s method in #4 I’ve also noticed some parts where logic can be unified to avoid some duplication, especially right now in the process of introducing support for Stratonovich. I’d love to continue contributing, I’ve tried to follow up with your discussion in #15 regarding this general refactor - If you have spare task that I could try please let me know.

Read more comments on GitHub >

github_iconTop Results From Across the Web

FDOT: A F ast, memory-efficient and automated approach for ...
First, as mentioned earlier, the adjoint code must be initiated using the fully converged solution from the primal solver. Second, the iterative ...
Read more >
arXiv:1912.07696v2 [cs.MS] 26 Oct 2021
Abstract. We present a new software system PETSc TSAdjoint for first-order and second- order adjoint sensitivity analysis of time-dependent ...
Read more >
User Documentation for cvodes, An ODE Solver with ...
system solvers comprise a layer of code modules that is separated from the integration algorithm, allowing for easy modification and expansion of the...
Read more >
High weak order solvers and adjoint sensitivity analysis for ...
The high weak order solvers will allow for massive performance advantages for fitting expectations of equations. Instead of automatic ...
Read more >
Hybrid Approaches to Adjoint Code Generation with dco/c++
With growing computational power and further developments, the transition from pure simulation to optimization emerged as highly desirable and most notably ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found