-
Notifications
You must be signed in to change notification settings - Fork 125
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 in periodic continuous spaces due to... floating point error? #853
Comments
I guess this is a very fringe case if it never came up but I have a set of fairly large simulations that simply cannot be run due to this approximation error. |
Good catch. What about changing
in
does this have any unwanted side effect? edit: yes, |
But changing also
to
it seems to work fine.
|
Actually it is not breaking since the grid is an internal field only used to improve efficiency of neighbors searches. So, is this fine? |
I tried to implement your approach but it breaks a bunch of things, throwing errors of the form BoundsError: attempt to access 20×20 Matrix{Vector{Int64}} at index [0, 0] |
I guess the problem is because 0 is a valid position in ContinuousSpace. So instead of bumping it up to index 1, |
In principle it could be solved by always having a call like |
you are right, then I guess we should just handle the special case with a branch which checks if the value is 0 and makes it 1, hopefully branch prediction should anyway make the code efficient. Otherwise we could clamp it before doing the ceiling |
an even simpler way is to use max between 1 and the ceiling |
move_agent!
andwalk!
throwposition is outside of space extent
error, apparently due to floating point approximationMinimal Working Example
This particular MWE is on main, but I originally encountered the error on a code running 5.14.0.
What happens is the following (let
agent = model[1]
):the direction of motion is evaluated as
then the "raw" target position would be
which, when passed to
normalize_position
, becomeswhich errors since 1.0 is not a valid position
The text was updated successfully, but these errors were encountered: