NCSU GIS 714:
Geospatial Computing and Simulations

Agent Based Modeling

Resources:

Agent Based Modeling in Python using Mesa

We will install ABM framework MESA, run some example models, and then modify and expand the fire model to reuse it as a tree disease spread model.

Installation

Use pip to install Mesa, note that Mesa requires Python 3:
pip install mesa
Test if successfull:
mesa --help
# alternatively ~/.local/bin/mesa --help
Download Mesa v0.8.5, unzip and in command line go to examples folder, pick an example folder (for example Schelling) and install dependencies:
pip install -r requirements.txt
mesa runserver
Inspect the code in model.py defining the agent rules.

From fire to disease spread ABM

Copy folder forest_fire and rename it to disease_spread. Now run the model in the same way and observe the behavior. Inspect the code in model.py, agent.py and server.py.

Now the task is to change and expand the forest fire model to represent a tree disease spread simulation. Start by renaming the categories: "On Fire" to "Infected", "Burned Out" to "Dead". Then independently work on these possible tasks, or come up with your own rules and behaviors:

  • Change mortality to have trees die after a specified number of steps
  • Add stochastic behavior, for example, infect neighbor only with certain probability
  • Increase distance how far the disease can spread (use model.grid.iter_neighbors)
  • Implement prevailing spread direction, can be stochastic
  • Add another agent (use MultiGrid) who is doing random walk and spreading disease
  • Add slider/dropdown box to the web interface to interactively explore the effects
Solution can be found here.

Modeling coupled human and natural systems using MedlanD

Things to download: Start GRASS in the provided Location and create new mapset. Unzip the reclassification rules to a directory and place there the scripts r.agropast.adaptive2.py and r.landscape.evol2.py. Change to the directory where the rule files and the scripts are and run the simulation for 3 iterations:
python3 r.agropast.adaptive2.py -1 numpeople=30 years=3 prefx=sim costsurf=farm_catch_10yr_30ppl_cost_surface agcatch=farm_catch_10yr_30ppl grazecatch=graze_catch fodder_rules=fodder_rules.txt inlcov=init_veg infert=init_fert lc_rules=luse_reclass_rules.txt cfact_rules=cfactor_recode_rules.txt elev=DEM initbdrk=init_bdrk