mountaindust / Planktos

ABM framework for dispersal modeling
https://planktos.readthedocs.io
GNU General Public License v3.0
5 stars 3 forks source link

Example for Poisson process state switching #64

Open mountaindust opened 1 month ago

mountaindust commented 1 month ago

There are many cases where an agent-based model includes attribute of state switches that occur as a Poisson process. An example is a locust model where locusts can be stationary, walking, or hopping. Another example is an intermittent search strategy where agents switch between ballistic motion and Brownian motion as they search for something. The typical thing to do in order to simulate such processes is to take dt small enough that one can assume a maximum of one state transition occurs during each time step (more than one transition is O(dt^2)). The time between transitions is then exponential and independent on each time step, and so it's easy to check if a transition occurs or not. If a transition does occur, the time of the transition can be used to split up the time step into two actions for that agent.

From the point of view of the Planktos framework, there is no reason that this cannot be done within the current capabilities of the code. Individual agent states can be stored in swarm.props, and a time history of that DataFrame (props_history) has been implemented in a branch. Growing lists of precise transition times could be stored on a per-agent basis in swarm.props, though it is worth noting that when a deep copy of the DataFrame is made to store in props_history, the process is not recursive. So the lists will be updated in the entire history each time it is updated in swarm.props. However, since the lists themselves are the history, this is more a feature than a bug because it saves memory. However, it should be pointed out in an example and/or documentation.

So, an example needs to be made demonstrating how one can implement some sort of basic, state-switching behavior using a Poisson process. I'm particularly thinking of an intermittent search strategy that could be used to simulate small organisms searching in flow.