So now my model is nearing completion (sort of), I have one main dilemma.
Following a presentation of my work to fellow biologist/ecologists, it seemed that what people wanted to see what a motivation for why individuals move around, rather than simply hard-coding them to move around x% of the time. This meant a shift away from the least-cost model to something more intuitive - food.
At first glance, this seems a relatively straight-forward shift to make. Now, instead of individuals choosing a location based on some negative cost value (and opting for the least-cost move) now they would move around according to their food requirements. In principle, the landscape-effect is similar. Forest is still good whilst agricultural areas/urban areas etc are not so good. However, the shift to 'emergent' behaviour, i.e. individuals moving around to meet some food requirement involves quite a lot of behind the scenes work within the code itself. To put in brief, the two flowcharts outline the decisions made by individuals within each given scenario, 1. moving to find enough food and 2. moving according to least-cost principles. Circles in red are decisions, those in thick red are standard default decisions.
Pros and Cons
1. Food
Now it becomes clear, whilst moving for food may be more intuitive and more 'realistic', it is a lot more complicated, involving a large number of additional parameters, is more likely to cause some un-conceieved bias in the results, and hence is far more sensitive to initial conditions and far less robust that a simpler movement process. There is also no explicit recognition of mortality risk, protection, mating opportunities, physiological costs etc that are encompassed with the single cost value used in the least-cost model. In short, the only factor affecting where a jaguar moves is the availability of food.
In addition, mortality risk is modelled separate to movement choice. Individuals are not 'aware' of the mortality risk of any particular location and are unable to choose a location according to this risk. Of course, this could be added as another factor, but this would increase the complexness of the model, add further parameters and make it even more sensitive.
Some additional parameters include:
1. Amount of food required by an individual (per step or as an average per day still to be decided)
2. Reduction in food per time step - should this be different depending on if the individual physically moves compared to staying in the same cell? should there be a reduction per time step and another depending on how the individual moves? Should this be a set amount or a proportion of the total food resource/food required per step/day?
3. Increase in food availability in cells that have been visited by a jaguar - should this be proportional, an incremental increase or a logistic increase? - i.e. type I, type II or type III response to predation?
4. Should the food be homogenous or clumped/variable in distribution?
5. Should the food change in spatial representation over time?
2. Cost
But then again, cost doesn't necessarily make the best option either. Here, whilst the model decision making is simple and straight-forward there is now no motivation for individuals to move. Movement is not 'emergent' but hard-coded. Males move x% of the time, females y% of the time. However, there is much less risk of the model being sensitive to initial conditions as there are only two parameters to be concerned about: relative differences in cost between habitats and movement rates for males and females.
In addition to this, movement decisions are now based on a range of factors, implicitly outlined by the cost of any particular habitat. Not only does food get represented in the cost, but also mortality risk, cover, mating opportunities, physiological costs of moving through the terrain.
My PhD research on spatially explicit modelling of habitat permeability for mammalian wildlife
11.1.12
Repast Development and Batch Runs
So its back to the grindstone following a not-long-enough christmas and new year break. This month its all about finalising my model and getting it to a state where I can send off a batch run of the model to Southampton University's super computer. Not only will this mean I get my model to work much more efficiently but that I also won't have to sit around for ages watching the GUI display and waiting... and waiting.... and waiting... whilst tediously repeating... repeating... and repeating runs whilst manually changing parameters.
Excellent.
Only problem is, Repast, once again, seems to be letting me down on documentation! This has to be THE major disadvantage of using this software over others such as MASON (whom several people have suggested I use, but I'm loathe to, considering the time and effort I've spent in learning Repast and the fact that MASON seems to be heavily social simulation focused).
However, there are some other kind people out there who, also noticing the severe lack of Repast documentation, have been amazingly generous by recording and allowing public access to their findings. Pamela Toman, I am very grateful to you for this post about doing batch runs in Repast. Some other useful pages exist including one of Repast Simphony's own online pages found here that outlines the format of how to amend the batch_params.xml file, even if it doesn't go into detail about how to get this to work, or what the file should look like once its been constructed.
Basically, its all a bit more complicated that it needs to be. Repast has an option of a Batch run from the run menu in Eclipse. This requires you to show it where it can find the batch parameters run file (batch_params.xml located in the batch folder within the model architecture in eclipse). I've yet to get to the point of trying this out but it seems that if you just want to run a batch run within eclipse, this MAY be all you need to do.
Exporting the model to run in batch via an external source (i.e. a super-computer) seems much more complicated and there are several files that need amending in order for this to work. So far, I've done the amending, but not been able to test if the export works. Thats next on my list of jobs to do.
Pamela Tomans post outlines all of this, but in brief:
1. The main amendments involved the start_model.bat or start_model.command files (.bat in Windows, .command in Mac/Linux). The model needs to know explicitly where to look for all necessary files, which need to be manually added (running in GUI doesn't require this step). The repast.simphony.repast.RepastMain command also needs to be changed to repast.simphony.batch.BatchMain so it knows to run in batch mode (see Pamela Tomans post for more details on how to amend this file).
2. Actually, what you need to do is create a new start_model.command/bat file. You can call it whatever you want, but if you want the model to be able to run in both GUI and batch, you can't amend the original start_model.command file. If you do, it will no longer run in GUI mode.
3. Now you have added a new file for batch, you need to add this to two other files, so the model knows to look at this file. Here you need the find the installation_coordinator.xml and installation_components.xml files (both within the installer folder of the model architecture in eclipse). Again, more info on Pamela Tomans post.
I have a slight issue with this step however. My installation_coordinator.xml file has a slightly different format to that suggested by Pamela (and others when I googled online). Im still trying to work out where to add the necessary information..... The install_components.xml file was straightforward to amend.
4. Ok, now you should be ready to update the batch_params.xml file. Again, Pamela has a good example on her page. Im currently working through this to get ready to test with a simple one-parameter change and only 5 runs. I'll update once I know more and post my final .xml file.
5. Now comes the tricky bit as far as I can tell. If the batch is to run within repast then you should just be able to choose the batch model run and show it the batch_params.xml file. Again I should be testing this soon.... if the batch is to export and go to a super-computer, then the batch file itself needs to be amended. Not sure where to find this or how to run the batch file outside of repast. Should have some answers here within the month. Fingers crossed.
Useful webpages
Pamela Toman - http://www.pamelatoman.net/blog/tag/batch-runs/
Repast Simphony batch runs - http://repast.sourceforge.net/docs/reference/SIM/Batch%20Runs.html
Repast Simphony batch parameters - http://repast.sourceforge.net/docs/reference/SIM/Batch%20Parameters.html
Repast Parameter Sweeps Getting Started - http://repast.sourceforge.net/docs/RepastParameterSweepsGettingStarted.pdf
Excellent.
Only problem is, Repast, once again, seems to be letting me down on documentation! This has to be THE major disadvantage of using this software over others such as MASON (whom several people have suggested I use, but I'm loathe to, considering the time and effort I've spent in learning Repast and the fact that MASON seems to be heavily social simulation focused).
However, there are some other kind people out there who, also noticing the severe lack of Repast documentation, have been amazingly generous by recording and allowing public access to their findings. Pamela Toman, I am very grateful to you for this post about doing batch runs in Repast. Some other useful pages exist including one of Repast Simphony's own online pages found here that outlines the format of how to amend the batch_params.xml file, even if it doesn't go into detail about how to get this to work, or what the file should look like once its been constructed.
Basically, its all a bit more complicated that it needs to be. Repast has an option of a Batch run from the run menu in Eclipse. This requires you to show it where it can find the batch parameters run file (batch_params.xml located in the batch folder within the model architecture in eclipse). I've yet to get to the point of trying this out but it seems that if you just want to run a batch run within eclipse, this MAY be all you need to do.
Exporting the model to run in batch via an external source (i.e. a super-computer) seems much more complicated and there are several files that need amending in order for this to work. So far, I've done the amending, but not been able to test if the export works. Thats next on my list of jobs to do.
Pamela Tomans post outlines all of this, but in brief:
1. The main amendments involved the start_model.bat or start_model.command files (.bat in Windows, .command in Mac/Linux). The model needs to know explicitly where to look for all necessary files, which need to be manually added (running in GUI doesn't require this step). The repast.simphony.repast.RepastMain command also needs to be changed to repast.simphony.batch.BatchMain so it knows to run in batch mode (see Pamela Tomans post for more details on how to amend this file).
2. Actually, what you need to do is create a new start_model.command/bat file. You can call it whatever you want, but if you want the model to be able to run in both GUI and batch, you can't amend the original start_model.command file. If you do, it will no longer run in GUI mode.
3. Now you have added a new file for batch, you need to add this to two other files, so the model knows to look at this file. Here you need the find the installation_coordinator.xml and installation_components.xml files (both within the installer folder of the model architecture in eclipse). Again, more info on Pamela Tomans post.
I have a slight issue with this step however. My installation_coordinator.xml file has a slightly different format to that suggested by Pamela (and others when I googled online). Im still trying to work out where to add the necessary information..... The install_components.xml file was straightforward to amend.
4. Ok, now you should be ready to update the batch_params.xml file. Again, Pamela has a good example on her page. Im currently working through this to get ready to test with a simple one-parameter change and only 5 runs. I'll update once I know more and post my final .xml file.
5. Now comes the tricky bit as far as I can tell. If the batch is to run within repast then you should just be able to choose the batch model run and show it the batch_params.xml file. Again I should be testing this soon.... if the batch is to export and go to a super-computer, then the batch file itself needs to be amended. Not sure where to find this or how to run the batch file outside of repast. Should have some answers here within the month. Fingers crossed.
Useful webpages
Pamela Toman - http://www.pamelatoman.net/blog/tag/batch-runs/
Repast Simphony batch runs - http://repast.sourceforge.net/docs/reference/SIM/Batch%20Runs.html
Repast Simphony batch parameters - http://repast.sourceforge.net/docs/reference/SIM/Batch%20Parameters.html
Repast Parameter Sweeps Getting Started - http://repast.sourceforge.net/docs/RepastParameterSweepsGettingStarted.pdf
1.12.11
Some GIS analysis
Ok, so I'm fed up of doing something in GIS, forgetting to write it down and then having to repeat the process due to an update of GIS data, or a change in my model needs etc that I am now trying to make a note of the main GIS analysis to get the data into some format that I can then use in my models, so here goes.
Data I need at the moment:
Habitat Map in raster format, cells of size 100m x 100m
Roads and trails, in raster format, cells of size 100x100
Cockscomb, raster - a simple map of where the protected forest is
CameraTraps - a shape file of the location of all 47 camera traps (in suitable projection to match the raster data
Sample area - a raster dataset of a buffer around the camera traps that represents the sampling area of the traps
Rivers, in raster formation, cells of size 100x100
Model Area, a shape file created to represent the area to be used in the model
Each of these datasets also needs to be of the same area (an annoying problem in some cases)
So, all data was provided in shape file format which meant it all had to be converted or processed and then converted to raster.
All information is relevant to ArcGIS version 9.3. (ArcMap unless otherwise stated).
HabitatMap
1. A simple conversion from 'feature to raster', using Ecosystem field as the field of interest and stating a cell size of 100.
2. This raster then covered the entire area of Belize, so it needed to be clipped to meet the model area of interest. (I'll discuss how to create a shape file of the required area next), but otherwise use the 'clip' command. Some commands from the various toolboxes only work on specific types of dataset, such as the clip command within the Analysis Tools toolbox only works with feature/shapefile data and NOT with rasters. For Rasters, use the following, putting the shape file to use as the 'clipping' feature in the 'output extent' box and selecting the 'use input features for clipping geometry box', otherwise you can designate your own coordinates to create a rectangle to use to clip...
3. Now we should have a raster of cell size 100x100, but only having data for the required region/area of Belize. This now needs to be converted to an ASCII file for me to use and import into RePast.
Data I need at the moment:
Habitat Map in raster format, cells of size 100m x 100m
Roads and trails, in raster format, cells of size 100x100
Cockscomb, raster - a simple map of where the protected forest is
CameraTraps - a shape file of the location of all 47 camera traps (in suitable projection to match the raster data
Sample area - a raster dataset of a buffer around the camera traps that represents the sampling area of the traps
Rivers, in raster formation, cells of size 100x100
Model Area, a shape file created to represent the area to be used in the model
Each of these datasets also needs to be of the same area (an annoying problem in some cases)
So, all data was provided in shape file format which meant it all had to be converted or processed and then converted to raster.
All information is relevant to ArcGIS version 9.3. (ArcMap unless otherwise stated).
HabitatMap
1. A simple conversion from 'feature to raster', using Ecosystem field as the field of interest and stating a cell size of 100.
[Conversion Tools - To Raster - Feature To Raster]
2. This raster then covered the entire area of Belize, so it needed to be clipped to meet the model area of interest. (I'll discuss how to create a shape file of the required area next), but otherwise use the 'clip' command. Some commands from the various toolboxes only work on specific types of dataset, such as the clip command within the Analysis Tools toolbox only works with feature/shapefile data and NOT with rasters. For Rasters, use the following, putting the shape file to use as the 'clipping' feature in the 'output extent' box and selecting the 'use input features for clipping geometry box', otherwise you can designate your own coordinates to create a rectangle to use to clip...
[Data Management Tools - Raster - Raster Processing - Clip]
3. Now we should have a raster of cell size 100x100, but only having data for the required region/area of Belize. This now needs to be converted to an ASCII file for me to use and import into RePast.
[Conversion Tools - From Raster - Raster to ASCII]
Model Area
For this we need to create a new shape file and then amend it to create a new polygon for the area we want to use as our model area.
1. Open Arc Catalog, locate the folder you want the file to be created in.
2. Right click in the main box (showing contents of the folder you are looking at), go to New, and shape file. Then give it an appropriate name.
3. Ok, now go back into ArcMap and add the new shape file to the display.
4. Now you need to edit the shape file
[View (from the top bar) - Toolbars - Editor - Editor - Start Editing]
5. At this point, you may need to select the fold or database which you would like to edit. Select the folder which houses the newly created and added shape file, click OK.
6. Make sure the correct shape file is displayed in the Target box on the Editor Toolbar
7. Now you need to create a polygon of the area you want to be the model area
[Editor -More Editing Tools - Advanced Editing]
8. A new toolbox should have popped up called Advanced Editing. Select the rectangle icon (last but one on the right) and now you should be able to draw a rectangle within the correct shape file layer. You can have other layers open so you can see where to draw the rectangle. If the rectangle is selected it can also be deleted so it doesn't matter if it isn't correct first time. Once you have the area you are happy with, go back to the editor toolbar
[Editor - Save Edits- Stop Editing]
9. There should now be a shape file with a single polygon representing the outline of the model area you want to use. This shape file can now be used to 'clip' any dataset required (as in step 2 above).
Cockscomb
1. Ok, so I was given a dataset with all the protected areas outlined on it, as well as a single dataset with the outline of Cockscomb Basin Wildlife Sanctuary. This simply needed to be clipped to the model area (my model area only covers a portion of the sanctuary) and then converted to a raster and then ask ASCII.
So first, clip the polygon of Cockscomb, and use the newly created ModelArea file (above) as the 'clip features'
[Analysis Tools - Extract - Clip]
2. Now convert it to raster (you could also convert it to a raster first and then use the raster clip function (outlined above) to clip the raster).
[Conversion Tools - To Raster - Feature To Raster]
3. Now convert the raster to an ASCII file
[Conversion Tools - From Raster - Raster To ASCII]
Roads/Trails and Rivers
1. These are both done in the same manner so can be dealt with together. They came in polyline format (shape file) so they need processing and then converting to a raster. Firstly, they needed transforming form they current WGS-1984 projection to the required NAD1927-16N projection (all GPS and camera data information is in the latter format). This is relatively simple. If you have other data open when you add the roads/rivers data it will tell you it is in a different coordinate system and you can change it from that pop-up box, otherwise do the following:
[View (top bar) - Data Frame Properties - Coordinate System]
2. You should now see what coordinate system your current data is in, if it needs to be change:
[Transformations - Select the correct coordinate system in the 'Convert from' box and make sure the correct new coordinate system is in the 'Into' box, now select a transformation technique from the 'Using' box, (they should all do the same job), then press OK - Apply - OK]
Data should now match.
3. Now the data is in the correct coordinate system, it needs to be processed. I had several different files that needed merging together to create a single file of the entire road/river network. This can be done several ways, but the easiest (and most effective) way I found was via the editor toolbox. I also needed to create some additional trails from point data supplied.
4. Creating new trails, need to create a new shape file layer in Arc Catalog (as above for the Model Area). Add the new empty layer into ArcMap. Display the data of points that represents the information you need.
[View - Toolbars - Edtor - Editor - Start Editing]
5. Now all you need to do is draw over the points to create a line. The trick is to make lots of joins to make sure the line follows the points. Selecting the pencil icon on the editor toolbar allows you to draw onto the empty shape file layer. A single click make a join and a double click ends the current line. You can connect separate lines together at the end, so I zoomed in and make several lines that I then joined up at the end to create the entire trail network. Once all the lines have been drawn, you can then merge them.
[Click on the arrow head on the editor toolbar - draw a large square around your newly created lines to select them all - Editor - Merge]
6. Now all the lines should be joined up but still selected. Selection(from top bar) - Clear Selected Features, will clear a selection at any time. Now you need to join the newly created trails with the several existing datasets. A similar process can work successfully, or you can do it via the Data Management Tools
[Data Management Tools - General - Merge]
7. Now you should have one layer with all the relevant roads or rivers in. Now this needs to be clipped using the Model Area shape file.
[Analysis Tools - Extract - Clip]
8. Again now convert it to a raster and then to an ASCII file.
9. Some problem I encountered - the original roads data was given to me, not of the whole of Belize, but of a small area within the area I was using as my model area. Therefore the dataset was SMALLER than the model area I needed. Problem!
10. Much investigation didn't come up with a good process for extending the display of the dataset (it only needed additional NoData information to make up the entire area). You can extend the display of the layers
[right-click on the layer - Properties - Extent - choose any layer in the 'set the extent to' drop down box]
11. Whilst this seemed to work when I converted the layer to a raster it lost this additional extent. So do this instead, you need to convert the ModelArea shape file to a raster and then add the two raster layers together:
[ModelArea = Conversion Tools - To Raster - Feature to Raster]
[View(top tool bar) - Toolbars - Spatial Analyst - Options - Extent - Union of Inputs] then
[Spatial Analyst - Raster Calculator - select the new raster of the modelArea then select the + and then select the roads raster file]
12. This should create a raster layer of the roads that same size as the modelArea. The raster layer of the ModelArea needs to have a non-negative, non-zero value (mine went to 1 automatically) so that this value is added to the value of the roads (I have 6 classes of roads all with a value from 1 to 6 representing the class). The values of my new raster went from 2 to 7 so I used the reclass function to put them back to 1 - 6, with the NoData values sticking at -9999. I had some problems converting these values to anything else in the reclass function so I left them at the default value.
[Spatial Analyst Tools - Reclass - Reclassify - choose the new roads raster and enter in the new values in the NewValues column in the box in the centre]
Camera Traps
1. These were fairly straightforward. I had the data as x and y coordinates in an excel spreadsheet. So add the spreadsheet to the ArcMap display:
[right click on the spreadsheet - Display XY Data - and choose the correct columns that represent the x and y data - choose the correct coordinate system, via - Edit - Select - Projected Coordinate Systems - UTM - NAD 1927 - NAD 1927 UTM Zone 16N.prj - Add]
2. You might then need to make the layer permanent, to do this you need to export it as a shape file:
[right-click on the new 'events' - Data - Export Data - then choose All Features in the 'Export' box and the folder you want in the 'Output shape file or feature class' box and give it a name you want - OK]
Sample Area
1. So this is the effective sampling area of my dataset - basically just a circle around each camera Trap of a specified radius - calculated from the average home range of a jaguar - 1784m in this case (half of the full estimated diameter of 3568m - taken from thesis if Rebecca Foster (currently working for Panthera in Belize and collaborating on this work)). So to do this you use the buffer function:
[Analysis Tools - Proximity - Buffer - new cameraTrap file as the 'Input Features', choose an appropriate name and location for the output file, put the radius in the 'Linear Unit' box and make sure the next box is in the correct units]
2. This now needs to be converted to a raster and made the same size as the modelArea, then converted to an ASCII.
All these files need to be converted to .pgm files (apart from the cameraTraps) for importing into RePast. I'll cover this in a later post.
Book
An interesting new book but Alison Heppenstall, Andrew Crooks, Linda See and Mike Batty
"Agent-Based Model of Geographical Systems"
as stated on Andrew Crooks' blog 'GIS and agent-based modelling':
"Agent-Based Model of Geographical Systems"
as stated on Andrew Crooks' blog 'GIS and agent-based modelling':
[the book] brings together a comprehensive set of papers on the background, theory, technical issues and applications of agent-based modelling (ABM) within geographical systems. This collection of papers (see below) is an invaluable reference point for the experienced agent-based modeller as well those new to the area. Specific geographical issues such as handling scale and space are dealt with as well as practical advice from leading experts about designing and creating ABMs, handling complexity, visualising and validating model outputs. With contributions from many of the world’s leading research institutions (see map below), the latest applied research (micro and macro applications) from around the globe exemplify what can be achieved in geographical context.
This book is relevant to researchers, postgraduate and advanced undergraduate students, and professionals in the areas of quantitative geography, spatial analysis, spatial modelling, social simulation modelling and geographical information sciences.
Book Contents:
Part 1: Computational Modelling: Techniques for Simulating Geographical Systems
Part 1: Computational Modelling: Techniques for Simulating Geographical Systems
- Perspectives on Agent-Based Models and Geographical Systems.
- A Generic Framework for Computational Spatial Modelling.
- A Review of Microsimulation and Hybrid Agent Based Approach.
- Cellular Automata in Urban Spatial Modelling.
- Introduction to Agent-Based Modelling.
- Agent-Based Models - Because they're Worth it?
- Agent-Based Modelling and Complexity.
- Designing and Building an Agent-Based Model.
- Modelling Human Behaviour in Agent-Based Models.
- Calibration and Validation of Agent-Based Models of Land Cover Change.
- Networks in Agent-Based Social Simulation.
- The Integration of Agent-Based Modelling and Geographical Information for Geospatial Simulation.
- Space in Agent-Based Models.-
- Large Scale Agent-Based Modelling: A Review and Guidelines for Model Scaling.
- Uncertainty and Error.-
- Agent-Based Extensions to a Spatial Microsimulation Model of Demographic Change.
- Designing, Formulating, and Communicating Agent-Based Models.-
- Agent Tools Techniques and Methods for Macro and Microscopic Simulation.
Part 4: Fine-Scale, Micro Applications of Agent-Based Models:
- Using Agent-Based Models to Simulate Crime.
- Urban Geosimulation.
- Applied Pedestrian Modelling.
- Business Applications and Research Questions using Spatial Agent-Based Models.
- Using Agent-Based Models for Education Planning. Is the UK Education System Agent Based?
- Simulating Spatial Health Inequalities.
- ABM of Residential Mobility, Housing Choice and Regeneration.-
- Do Land Markets Matter? A Modelling Ontology and Experimental Design to Test the Effects of Land Markets for an Agent-Based Model of Ex-urban Residential Land-Use Change.
- Exploring Coupled Housing and Land Market Interactions Through an Economic Agent-Based Model (CHALMS).
- Exploring Urban Dynamics in Latin American Cities using an Agent-Based Simulation Approach.
- An Agent-Based/Network Approach to Spatial Epidemics.
- An Agent-Based Modelling Application of Shifting Cultivation.
- Towards New Metrics for Urban Road Networks. Some Preliminary Evidence from Agent-Based Simulations.
- A Logistic Based Cellular Automata Model for Continuous Urban Growth Simulation: A Case Study of the Gold Coast City, Australia.
- Exploring Demographic and Lot Effects in an ABM/LUCC of Agriculture in the Brazilian Amazon.
- Beyond Zipf: An Agent Based Understanding of City Size Distributions.
- The Relationship of Dynamic Entropy Maximising and Agent Based Approaches in Urban Modelling.
- Multi-Agent System Modelling for Urban Systems: The Series of SIMPOP Models.
- Reflections and Conclusions: Geographical Models to Address Grand Challenges
Looks particularly interesting but I'll be waiting to hear a few more reviews before I take the plunge and buy it on impulse. Very interesting though....
Subscribe to:
Posts (Atom)


