Conversation
|
hell yeah baby!!!! |
|
Sorry, test fail because of me. I've tried to improve the printing of the model for no space but failed to adjust the tests. Can you do it quickly (I don't have Agents deved atm)? |
|
Yes, and yes - i'll fix both in a bit. |
|
Perhaps we should also update the comparison table in this PR? |
|
Yep. I need to update ABM_framework_comparison et al as well. About to go to get the second vaccine, so will get back to this later. (Wanted to get this out before resubmit) |
Codecov Report
@@ Coverage Diff @@
## master #541 +/- ##
==========================================
+ Coverage 94.35% 94.38% +0.03%
==========================================
Files 24 24
Lines 1453 1461 +8
==========================================
+ Hits 1371 1379 +8
Misses 82 82
Continue to review full report at Codecov.
|
|
just to clarify: I shouldn't merge this, right? |
|
Correct. It's not ready yet. Will let you know. |
|
The cutoff looks like it scales pretty well for everything: GraphSpace g = complete_digraph(500)
model = ABM(Agent5, GraphSpace(g))
for _ in 1:500
add_agent_single!(model, rand(model.rng))
end
kill_agent!(random_agent(model), model)
run_test(model)
499
Current: 0.023975974358974358 ms, Proposed: 0.010073555555555554 ms
0.998For 5000 julia> run_test(model)
4999
Current: 0.046383 ms, Proposed: 0.40435699999999997 ms
4998
Current: 0.052060999999999996 ms, Proposed: 0.143565 ms
4997
Current: 0.048937999999999995 ms, Proposed: 0.15190599999999999 ms
4996
Current: 0.07264799999999999 ms, Proposed: 0.052907249999999996 ms
0.9992For 50 julia> run_test(model)
49
Current: 0.037711253583241455 ms, Proposed: 0.0005155497326203208 ms
0.983D GridSpace @agent Agent3D GridAgent{3} begin end
model = ABM(Agent3D, GridSpace((10,10,10)))
for _ in 1:prod(size(model.space.s))
add_agent_single!(model)
end
kill_agent!(random_agent(model), model)
julia> run_test(model)
999
Current: 0.007721111111111111 ms, Proposed: 0.05982014285714285 ms
998
Current: 0.01596222222222222 ms, Proposed: 0.034263166666666664 ms
997
Current: 0.007904777777777776 ms, Proposed: 0.017391666666666666 ms
996
Current: 0.007268999999999999 ms, Proposed: 0.010618924242424242 ms
995
Current: 0.015423999999999998 ms, Proposed: 0.011567 ms
0.995For 50^3 julia> run_test(model)
124999
Current: 1.212627 ms, Proposed: 35.20457 ms
124998
Current: 1.047918 ms, Proposed: 21.559383 ms
124997
Current: 1.0224309999999999 ms, Proposed: 12.160535 ms
...
124954
Current: 1.023584 ms, Proposed: 1.061899 ms
124953
Current: 1.080368 ms, Proposed: 1.014422 ms
0.999624Of course you can micromanage this value but we have a good default at I'll run the benchmarks and update the docs soon. |
|
While |
|
Good point. These tests assume that the number of agents are always less than the available spaces in the grid. The logic should be clamped to 1 (values above 1 should not be allowed). I'll fix that. |
random_emptyand kin require a full filter of the board each time they're called regardless of how sparse the agents are populating it. This PR provides us quite a noticeable performance enhancement using guesses, that we stop using once we start failing too much.The core concept is a loop that gives us a
random_positionand returns it, otherwise tries again.Benchmarking on the maximum time of our current and this proposed solution, we can find the place where we guarantee chance will win out to filtering/collecting.
The changeover point is close to 0.999 (!) on this model, and as we go lower, as performance matters less, 0.998.. So we set our cutoff there and we can compare our standard Schelling benchmark (which needs random_empty):
Current (my machine): 13.783 ms
This PR (my machine): 2.771 ms
Speedup: 4.98x
Comparisons against other frameworks for Schelling (est, need to bump some changes here):
Mesa: 31.5x -> 156.9x
Netlogo: 8x -> 39.8x
MASON: 14.3x -> 71.1x