-
-
Notifications
You must be signed in to change notification settings - Fork 266
LazyAgentSet
LazyAgentSet is a lazy implementation of NetLogo's AgentSet. It keeps track of others and withs called on it, and lazily filters them out when needed. It would potentially replace the current system of essentially hard-coding specific optimizations for compounded filter cases (e.g. otherwith, countotherwith, etc) as well as cover other cases currently not accounted for (e.g. withwith).
- agents only accessed after force
- agents only modified by side-effects of filters within force
- agents that pass filters are immediately included in the resulting AgentSet
- filters don't change between calls to hasNext
- once a lazy agent set is forced, it will never need to be forced again.
- LazyAgentSet's underlying data structure for storing agents is an ArrayAgentSet (as opposed to holding an array like ArrayAgentSet)
- LazyAgentSet stores other and withs to be lazily forced later
- assume other is always a single agent or null
- use java.util.ArrayList to store other and withs
- Add getArray to AgentSet so LazyAgentSet has access to its underlying ArrayAgentSet's array of agents
- Pass RNG to random methods
- Random functions and toLogoList force
- Count, iterator, and shufflerator do not force
- force at Statement boundaries for semantics
As evident from numerous benchmarks, LazyAgentSet performs significantly worse for some benchmark models. Part of this is due to the necessary overhead of repeatedly generating and managing an extra layer of lazy abstraction. For a simple baseline comparison between the two, a simple Benchmark was run on both branches:
globals [result]
to setup
clear-all
crt 10000
end
to go
ask turtles with [heading < 90] with [heading > 270] []
end
to benchmark
random-seed 1
reset-timer
setup
repeat 100 [ go ]
set result timer
end
LazyAgentSet was marginally faster with 0.087 compared to hexy's 0.089.
| primitive name | can / should return lazy agentset | can / should accept lazy agentset |
|---|---|---|
| any? | N/A | yes |
| count | N/A | yes |
| oneof | N/A | yes |
| with | yes | yes |
| other | yes | yes |
| n-of | no | yes |
| member | N/A | yes |
| with-max | no | can (no speedup) |
| with-min | no | can (no speedup) |
| all? | N/A | can (no speedup) |
| in-cone | can (maybe shouldn't?) | can (maybe shouldn't?) |
| in-radius | can (maybe shouldn't?) | can (maybe shouldn't?) |
| at-points | can (maybe shouldn't?) | can (maybe shouldn't?) |
| max-one-of | N/A | can (no speedup) |
| max-n-of | no | can (no speedup) |
| min-one-of | N/A | can (no speedup) |
| min-n-of | no | can (no speedup) |
| sortby | N/A | can (no speedup) |
| sorton | N/A | can (no speedup) |
| turtlesat | no | N/A |
| mylinks | no | N/A |
| inlinkneighbors | no | N/A |
| links | no | N/A |
| nolinks | no | N/A |
| outlinkneighbors | no | N/A |
| noturtles | no | N/A |
| neighbors4 | no | N/A |
| myoutlinks | no | N/A |
| turtleson | no | N/A |
| turtles | no | N/A |
| turtleshere | no | N/A |
| nopatches | no | N/A |
| linkneighbors | no | N/A |
| linkset | no | N/A |
| turtleset | no | N/A |
| myinlinks | no | N/A |
| patchset | no | N/A |
| neighbors | no | N/A |
| patches | no | N/A |
| bothends | no | N/A |
| word | no | N/A |
| askconcurrent | N/A | no |
| of | N/A | no |
| createlinksto | N/A | no |
| sort | N/A | no |
| layouttutte | N/A | no |
| layoutradial | N/A | no |
| createlinksfrom | N/A | no |
| layoutspring | N/A | no |
| setdefaultshape | N/A | no |
| list | N/A | no |
| run | N/A | no |
| runresult | no | no |
| layoutcircle | N/A | no |
| sentence | N/A | no |
| createlinkswith | N/A | no |
| ask | N/A | no |
To best help further LazyAgentSet's development, next steps might include setting up a Netlogo LazyAgentSet Extension as well as making code optimizations to improve performance to its full potential.
- Extensions
- NetLogo Libraries
- Controlling API
- Extensions API
- 6.0 Extension and Controlling API Transition-Guide
- Optimizing NetLogo Runs
- Setting English as the Default Language when Running NetLogo
- Unofficial Features
- Advanced Installation
- Optimization List
- Java System Properties and how to use them
- NetLogo on ARM Devices
- Multiple Views via HubNet
- Branches
- Building
- Tests
- Windows Setup
- Continuous Integration
- Draft: How to Help
- NetLogo Project Ideas
- Syntax Highlighting
- Building with IntelliJ
- Code Formatting
- Localization
- XML File Format
- Pre‐7.0.0 File Format (.nlogo) and Widget Format
- Benchmarking
- Releasing/Publishing
- Preparing the Models Library for Release
- Documentation
- NetLogo Bundled Java Versions
- JOGL
- Plugins API
- Architecture
- LazyAgentset
- Model Runs and Review Tab
- Model Runs: To Do and Code Overview
- Notes on in Radius
- Archived Branches
- Touch API Proposal
- Why isn't NetLogo "Parallel"?
- Potential Speedups
- Tortoise
- SimServer, WebStart, and NetLogo in Classrooms
