DiffEqML / torchdyn

A PyTorch library entirely dedicated to neural differential equations, implicit models and related numerical methods
https://torchdyn.org
Apache License 2.0
1.4k stars 130 forks source link

Multiple shooting solvers missing coarse/fine solver attributes #186

Closed jcallaham closed 1 year ago

jcallaham commented 1 year ago

Describe the bug

The multiple shooting solvers are expecting to have coarse_method and fine_method attributes, but the initialization is commented out here. Maybe this is related to the circular import issue noted here?

If I uncomment those lines and import str_to_solver within MultipleShootingDiffeqSolver.__init__ then there's an additional issue of handling the default value of save_at. This is currently replaced by t_span and cast to a tensor in odeint, but that step doesn't happen in odeint_mshooting.

I'd propose fixing this by importing str_to_solver inside the initialization and moving the save_at handling to within _fixed_odeint.

Steps to Reproduce

x0 = torch.randn(8, 3) + 15
t_span = torch.linspace(0, 3, 10)
sys = Lorenz()

odeint_mshooting(sys, x0, t_span, solver=solver, fine_steps=2, maxiter=4)

This also pops up running the quickstart notebook.