Data Structure for Spatial Agent Based Modeling [closed]
Asked Answered
C

2

6

What are some good data structures for keeping track of agents in a two-dimensional, spatial simulation?

I've seen some references to quadtrees (which I understand) and kd-trees (which I don't understand very well).

I'm looking for something through which an agent can efficiently say, "I know my location, and I would like to know which agents are near me (within a certain radius of myself)."

Examples (pseudo-code is fine) would be greatly appreciated.

I'm working in Java.

Chlores answered 18/10, 2011 at 16:57 Comment(0)
C
2

I have found something called a Bucket PR Quadtree.

Chlores answered 24/10, 2011 at 18:30 Comment(1)
Update: I decided to go with a simple grid implementation.Chlores
S
2

Well, I'm not sure exactly how it is implemented, but the MASON toolkit uses a discretization algorithm that places agents that are close to one another in the same "bucket" of a hash table. It makes for very fast lookups, as only a few of these buckets have to be checked for each query.

The best thing for you is probably to take a look at the source code here: http://code.google.com/p/mason/source/browse/trunk/mason/sim/field/continuous/Continuous2D.java?r=529

Stunk answered 18/10, 2011 at 18:34 Comment(0)
C
2

I have found something called a Bucket PR Quadtree.

Chlores answered 24/10, 2011 at 18:30 Comment(1)
Update: I decided to go with a simple grid implementation.Chlores

© 2022 - 2024 — McMap. All rights reserved.