-
Notifications
You must be signed in to change notification settings - Fork 10
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
Bug with timed event when no other events scheduled #54
Comments
It seems that the issue is at: DiscreteEvents.jl/src/clock.jl Lines 291 to 295 in 4a9fab4
In the example above, Proposed change is to first check if while any(i-> !iszero(i) && (c.time ≤ i < c.end_time), (c.tn, c.tev))
_step!(c) == 0 || break
if c.state == Halted()
return c.end_time
end
end However, this won't work if a simulation starts at a negative time point (instead of 0)... @pbayer, I can create a PR for this if you think this is a good fix or we can discuss something more robust. Perhaps, setting |
In a local branch, I substituted the while condition while any(i->(c.time ≤ i < c.end_time), (c.tn, c.tev)) with the following while c.time ≤ c.tev < c.end_time || (c.time <= c.tn < c.end_time && c.tn != 0) ||
(c.time <= c.tn < c.end_time && _sampling(c)) It's pretty verbose but I think it works and at least it passes all tests. If you like I can make PR from my branch. I also added a couple of related tests. |
A PR would be great. Thanks. |
The following should not execute the scheduled event until t=10, but it gets executed when @run! is called:
However, if other events are scheduled before t=10, the event doesn't trigger when running up to t=1.
The text was updated successfully, but these errors were encountered: