torchdiffeq
torchdiffeq copied to clipboard
odeint as an iterator (progressive/on-demand solving of ODEs)
Hi, in situations where you'd be happy with a partial result but other considerations such as total time spent are more important, you'd want to be able to stop the iterations half way through.
Ideally, it would be nice to have odeint as a class supporting the iterator protocol, so that you can have full control over the iterations and get more on demand, instead of relinquishing control to odeint's own integration loop. Something like:
for (t, x) in odeint(myfunc, t=[0, 1]):
print(f"Intermediate solution at time {t}: {x}")
if x.norm() < 0.5: break # or any other custom logic