|
| 1 | +<!DOCTYPE html> |
| 2 | +<html lang="en"> |
| 3 | +<head> |
| 4 | +<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> |
| 5 | +<title>NCSU GIS 714: Geospatial Computation and Simulations</title> |
| 6 | + |
| 7 | +<link rel="shortcut icon" href=".././img/favicon.ico" /> |
| 8 | + |
| 9 | +<link href="../layout.css" rel="stylesheet" type="text/css" media="screen"> |
| 10 | +<link href="../style.css" rel="stylesheet" type="text/css" media="screen"> |
| 11 | + |
| 12 | +</head> |
| 13 | + |
| 14 | +<body> |
| 15 | + |
| 16 | +<div id="outercontainer"> |
| 17 | +<div id="container"> |
| 18 | + |
| 19 | +<header> |
| 20 | +<div id="header-image"> |
| 21 | + <h1>NCSU GIS 714:<br>Geospatial Computing and Simulations</h1> |
| 22 | +</div> |
| 23 | + |
| 24 | +<nav> |
| 25 | +<ul class="nav"> |
| 26 | +<li><a href="../index.html">Syllabus</a></li> |
| 27 | +<li><a href="../schedule.html">Schedule</a></li> |
| 28 | +<li><a href="../logistics.html">Course logistics</a></li> |
| 29 | +<li><a href="../topics/index.html">Topics</a></li> |
| 30 | +<li><a href="../projects.html">Projects</a></li> |
| 31 | +</ul> |
| 32 | +</nav> |
| 33 | + |
| 34 | +</header> |
| 35 | + |
| 36 | +<main> |
| 37 | +<!-- This is a generated file. Do not edit. --> |
| 38 | +<h2>Agent Based Modeling</h2> |
| 39 | + |
| 40 | +<p> |
| 41 | +Resources: |
| 42 | +<ul> |
| 43 | + <li><a href="http://grass.osgeo.org/grass-stable/manuals/"> |
| 44 | +GRASS GIS overview and manual</a> |
| 45 | + <li><a href="http://www.grassbook.org/">GRASS book</a> |
| 46 | + <li><a href="https://grass.osgeo.org/grass-stable/manuals/addons/r.landscape.evol.html">r.landscape.evol</a> |
| 47 | + <li><a href="https://github.com/projectmesa/mesa/">MESA: agent based modeling in Python</a> |
| 48 | +</ul> |
| 49 | + |
| 50 | +<h3>Agent Based Modeling in Python using Mesa</h3> |
| 51 | +We will install ABM framework <a href="https://mesa.readthedocs.io/en/master/">MESA</a>, |
| 52 | + run some example models, and then modify and expand the fire model to reuse it as a tree disease spread model. |
| 53 | + |
| 54 | +<h4>Installation</h4> |
| 55 | +Use pip to install Mesa, note that Mesa requires Python 3: |
| 56 | + |
| 57 | +<pre><code>pip install mesa |
| 58 | +</code></pre> |
| 59 | + |
| 60 | +Test if successfull: |
| 61 | +<pre><code>mesa --help |
| 62 | +# alternatively ~/.local/bin/mesa --help |
| 63 | +</code></pre> |
| 64 | + |
| 65 | +Download <a href="https://github.com/projectmesa/mesa/archive/v0.8.5.zip">Mesa v0.8.5</a>, unzip and in command line go to examples folder, |
| 66 | +pick an example folder (for example <code>Schelling</code>) and install dependencies: |
| 67 | +<pre><code>pip install -r requirements.txt |
| 68 | +</code></pre> |
| 69 | + |
| 70 | +<pre><code>mesa runserver |
| 71 | +</code></pre> |
| 72 | +Inspect the code in <code>model.py</code> defining the agent rules. |
| 73 | + |
| 74 | +<h4>From fire to disease spread ABM</h4> |
| 75 | +Copy folder <code>forest_fire</code> and rename it to <code>disease_spread</code>. |
| 76 | +Now run the model in the same way and observe the behavior. |
| 77 | +Inspect the code in <code>model.py</code>, <code>agent.py</code> and <code>server.py</code>. |
| 78 | +<p> |
| 79 | +Now the task is to change and expand the forest fire model to represent a tree disease spread simulation. |
| 80 | +Start by renaming the categories: "On Fire" to "Infected", "Burned Out" to "Dead". |
| 81 | + |
| 82 | +Then independently work on these possible tasks, or come up with your own rules and behaviors: |
| 83 | +<ul> |
| 84 | + <li>Change mortality to have trees die after a specified number of steps </li> |
| 85 | + <li>Add stochastic behavior, for example, infect neighbor only with certain probability</li> |
| 86 | + <li>Increase distance how far the disease can spread |
| 87 | + (use <a href="https://mesa.readthedocs.io/en/master/apis/space.html#space.Grid.iter_neighbors"><code>model.grid.iter_neighbors</code></a>)</li> |
| 88 | + <li>Implement prevailing spread direction, can be stochastic</li> |
| 89 | + <li>Add another agent (use <a href="https://mesa.readthedocs.io/en/master/apis/space.html#space.MultiGrid"><code>MultiGrid</code></a>) |
| 90 | + who is doing random walk and spreading disease</li> |
| 91 | + <li>Add slider/dropdown box to the web interface to interactively explore the effects</li> |
| 92 | +</ul> |
| 93 | + |
| 94 | +Solution can be found <a href="https://github.com/ncsu-geoforall-lab/mesa-teaching-example">here</a>. |
| 95 | + |
| 96 | + |
| 97 | + |
| 98 | +<h3>Modeling coupled human and natural systems using MedlanD </h3> |
| 99 | +Things to download: |
| 100 | +<ul> |
| 101 | + <li><a href="../resources/r.landscape.evol2.py">r.landscape.evol2</a></li> |
| 102 | + <li><a href="../resources/r.agropast.adaptive2.py">r.agropast.adaptive2</a></li> |
| 103 | + <li><a href="https://drive.google.com/a/ncsu.edu/file/d/1aHTMkhhe52oXhEp1_qdunGwFSQBjZ7m_/view?usp=sharing">GRASS Location</a></li> |
| 104 | + <li><a href="https://drive.google.com/a/ncsu.edu/file/d/1dv7A7n6NC4_rHKnqRaSffJBEE6D6yyi9/view?usp=sharing">GRASS reclassification rules</a></li> |
| 105 | +</ul> |
| 106 | +Start GRASS in the provided Location and create new mapset. |
| 107 | + |
| 108 | +Unzip the reclassification rules to a directory and place there the scripts r.agropast.adaptive2.py and r.landscape.evol2.py. |
| 109 | +Change to the directory where the rule files and the scripts are and run the simulation for 3 iterations: |
| 110 | + |
| 111 | +<pre><code>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 |
| 112 | +</code></pre> |
| 113 | + |
| 114 | + |
| 115 | +<!-- If you want to set up your own geographic locale for this, you'll also need r.catchment --> |
| 116 | +<!-- "https://github.com/comses/medland/blob/master/Scripts/r.catchment.py" --> |
| 117 | + |
| 118 | +<!-- there is also a spreadsheet with default values for agropastoral economy - get the numbers into the assignment webpage --> |
| 119 | + |
| 120 | + |
| 121 | +</main> |
| 122 | + |
| 123 | +<footer> |
| 124 | + |
| 125 | +<nav> |
| 126 | +<ul> |
| 127 | + <li><a class="term-changes" href="https://moodle-courses2527.wolfware.ncsu.edu/course/view.php?id=5978">Moodle site</a></li> |
| 128 | + <li><a href="https://help.ncsu.edu/">Computing Help</a></li> |
| 129 | + <li><a href="https://geospatial.ncsu.edu/">GIST Home</a></li> |
| 130 | + <li><a href="https://www.ncsu.edu/policies/prr-disclaimer.php">Disclaimer</a></li> |
| 131 | + <li><a href="https://oit.ncsu.edu/itaccess">Accessibility</a></li> |
| 132 | +<li> |
| 133 | + <a href="https://github.com/ncsu-geoforall-lab/geospatial-simulations-course" title="Source code for web pages on GitHub"> |
| 134 | + <img src="../img/github_logo.png" alt="GitHub Octocat logo"> |
| 135 | + </a> |
| 136 | +</li> |
| 137 | +<li title="Copyright and license (not applicable to linked materials)"> |
| 138 | + © 2023 |
| 139 | + <a href="https://creativecommons.org/licenses/by-sa/4.0/">CC BY-SA</a> |
| 140 | + <a href="https://geospatial.ncsu.edu/geoforall/">NCSU GeoForAll Lab</a> |
| 141 | +</li> |
| 142 | +</ul> |
| 143 | +</nav> |
| 144 | + |
| 145 | +</footer> |
| 146 | + |
| 147 | +</div> |
| 148 | +</div> |
| 149 | + |
| 150 | +</body> |
| 151 | +</html> |
0 commit comments