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

VectorContinuousCallback with duplicate events causes infinite loop #889

Open
pepijndevos opened this issue Mar 9, 2023 · 0 comments
Open

Comments

@pepijndevos
Copy link
Contributor

MWE:

using OrdinaryDiffEq

f = function (u, p, t)
    -u + sin(-t)
end

prob = ODEProblem(f, 1.0, (0.0, -10.0))

condition(out, u, t, integrator) = out[:] = [-t - 2.95, -t - 2.95]

function affect!(integrator, idx)
    @show integrator, idx
    integrator.u = integrator.u + 2
end

callback = VectorContinuousCallback(condition, affect!, 2)

sol = solve(prob, Tsit5(), callback = callback)

Of course for trivial cases the answer is "don't do that" but when different components or computations end up with the same event, this causes problems.

I've been looking into it a little bit and it seems that find_callback_time gets a vector of all the callbacks that changed sign, so I imagine it should check if after the rootfinding it can "check off" multiple events and move on, but I don't fully understand the code yet, and maybe it's a lot more complicated than that, judging by all the comment about floating point details.

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

No branches or pull requests

1 participant