-
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
Create abmtime function for StandardABM #941
Comments
yes i've been thinking about this as well, to add a timer in standardABM as well. Now run! and co should start from the model timer which itself starts at 0 but is never reset (unless re-creating the model of course). |
and so I guess also step! with a function should change:
(the docstring is even not very clear in my opinion) I would remove the |
Okay, but it has to be breaking. It is bad for performance to check if a user gave in a function expecting 1 or 2 arguments. Type unstable. (I know from DynamicalSystems.jl) |
actually it seems not bad with this trick: julia> h(x) = x
h (generic function with 1 method)
julia> h(x, y) = x + y
h (generic function with 2 methods)
julia> t(f) = try; f(1); return true; catch; f(1,2); return false; end;
julia> using BenchmarkTools
julia> @btime t($h)
1.182 ns (0 allocations: 0 bytes)
true (same when h(x) is not defined) |
this is a missleading benchmark because you are passing constant literals to |
it is well known (stated in the manual in performance tips) that one should not use |
good observation, but I guess we are still in a similar situation since I think |
notice also that we would call it outside the for loop inside step!, at the start of the function, just a warning there is enough |
julia> f(x) = x
f (generic function with 1 method)
julia> t(f, x, y) = applicable(f, x, y) ? true : false
t (generic function with 1 method)
julia> using BenchmarkTools
julia> @btime t($f, $1, $1)
93.312 ns (0 allocations: 0 bytes)
false (the try catch trick takes microseconds when the catch block is executed instead...otherwise it is very fast though, so it could become a good reason for the user to update the code :D) |
or, we could simply break nothing. Make it so that the API is: Or, Since the model time is a new concept, either choice is non-breaking, given that we didn't explain this well enough originally. (What is breaking or not is defined by what the docs say) |
In this case:
On the other hand, leaving
so in the end I think that keeping |
Sure, but it keeps the API the same, so it is non breaking in this case.
I don't think this is a breaking change. This is what I am trying to say: whether something is "breaking" or not is defined by the docs. No by what the actual code does. If something was ambiguous in the docs and could be interpreted either way, it does not count as a breaking change to enforce one of the ways it could be interpreted.
I disagree! And that's the reason time was given as an argument in the first place. I would never use this functionality without an |
Yes, I'm more on the side to keep the current way since if you want to call twice step! with a function, it should be easier to implement a condition related to the number of steps if the time is relative to step! On the breaking change part I don't agree but the subject is controversial :D : https://dev.to/turnerj/should-behavioural-changes-be-considered-breaking-changes-under-semver-2d5n |
So what is your opinion @Datseris on all this? I'm for keeping the time relative when a function is passed for the advantage I stated in the previous comment. p.s. I can't help on Agents.jl for a while (some weeks) since I'm really short on time with uni work D: |
My opinion is the same. Keep the API as is and time is relative to model initial time. No worries about the lack of time. I'll try to finish the event queue but also no promises. |
just a clarification since I'm not really sure that we are on the same
bandwidth: by relative to the model time, do you mean that it starts from 0
each time you call the step! function just like it is already currently?
because I think this is already the best between alternatives since if you call step!
multiple times I think it is better this way
Il Mar 5 Dic 2023, 10:29 George Datseris ***@***.***> ha
scritto:
… My opinion is the same. Keep the API as is and time is relative to model
initial time.
No worries about the lack of time. I'll try to finish the event queue but
also no promises.
—
Reply to this email directly, view it on GitHub
<#941 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AQH6VXZEO4KYEWVMOR6GYXTYH3SPNAVCNFSM6AAAAABAD5P36KVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQNBQGM3TAOBUHE>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Yes, I mean that the counter inside |
This is practically costless, and actually somewhat needed: run! and offline_run! restart from 0 in the step column each time they are called. Apart from that, this is a function some people would implement by themselves anyway to track the time of the ABM, and implementing it would make StandardABM more homogeneous with the new EventQueueABM which has one.
This means that this is a breaking change though if we change those two functions to instead use the time of the model
cc @Datseris
The text was updated successfully, but these errors were encountered: