Species metapopulation model
Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)
WHAT IS IT?
This is a model showing how a metapopulation system works. It shows how smaller habitat patches interact to allow a metapopulation to stay active.
HOW IT WORKS
When the 'setup' button is pressed, several yellow flowers will appear within the Netlogo 'World'. These represent habitat patches for the butterflies. You can alter the number of habitats and the total size of all the habitats combined using the toggle bars in the interface section.
The simulation is started when the 'continuous' button is pressed. This hatches a random number of butterflies, calculated using the equation (size of habitat)*(random no. between 1 and 10). The details to how the butterflies disperse are in the disperse function in the code tab.
The move function in the code tab shows how the butterflies move during one generation of a simulation. It 'asks' the butterflies to move to the left a certain number of times (a random number between 1 and 18), and then right in the same way (a random number between 1 and 10). The reason for the difference in numbers for left and right is so generally speaking the butterflies will go in a circular motion, and therefore more chance of hitting multiple other habitat patches. The move function, once the butterflies have moved left and right a certain number of times, will ask the butterflies to move one space forward. Once all of this has been done, still within the move function, the code as the butterflies whether they have come into contact with another habitat patch. If so, for clarity, the flower is changed from brown to yellow and the value relating to the occupancy is changed from 0 to 1.
The extinction function is very important, it tells the interface when to terminate the simulation. It basically asks the interface section if there are any habitats with occupancy equal to the value of 1. If not, then the simulation is terminated. There is an equation used to help determine whether or not all the habitats are unoccupied displayed in the code.
Finally, the continuous function is used to run the simulation. You will notice that other functions are present in this loop. This is so that the 'disperse' and 'extinction' functions are run during the simulation. The continuous loop is called when one presses the continuous button in the interface tab. The continuous loop also includes lines of code that export data to a CSV value, which can be very helpful for subsequent analysis of the data produced within a simulation.
It is worth noting that the higher the number of generations is before the simulation is terminated, the better the metapopulation is at preventing a species, such as butterflies, from going extinct.
HOW TO USE IT
The clear-all-plots button as suggested clears the plots from the previous simulation. This will need to be pressed if a new graph is wanted to be produced when a new simulation is run.
The setup button is used to set up the Netlogo world, and randomly spawn the desired number of selected habitats as explained below.
The disperse button, which isn't really needed, as suggested runs the disperse section of the code. This hatches a specific number of habitats and disperses them into the Netlogo world.
The extinction button, again like the disperse button is rarely used but runs the extinction section of the code. As stated in the 'How it works' section, asks the Netlogo world if there is at least 1 habitat occupied, if not then it terminates the simulation.
The continuous function starts the simulation, where butterflies are dispersed, habitats are asked if they are occupied, and terminates the simulation when there are no occupied habitats.
The 'Numberofhabitats' and 'Totalsizeofallhabitats' sliders are used as suggested to alter the total number of habitats and the total size of all the habitats created in the Netlogo world when the setup button is pressed.
THINGS TO NOTICE
Whether or not a habitat (or flower) changes from brown to yellow when a butterfly comes into contact with it. It is not certain that a habitats occupancy will change from 0 to 1 when a butterfly comes into contact as it is based on a probabilistic equation.
Note whether there is a correlation between the number of butterflies alive (or currently dispersing) and the number of habitats occupied.
Why the model runs faster over time. This is due to the decreasing number of butterflies dispersing. It will appear that the simulation is running quicker when there are fewer butterflies dispersing since it will be quicker for one generation to finish if there are indeed fewer butterflies being dispersed.
Is there a general pattern to the graph produced?
THINGS TO TRY
1) Try altering the number of habitats created, and try different values of the total size of all habitats. Sometimes the simulation will last hundreds of generations, and some less than 20. Why is this the case?
2) Explore different formations to a metapopulation. Why are some better? Why are some worse? Which formations are better and which are worse?
EXTENDING THE MODEL
1) One thing that was discussed intensively in the creation of this model is trying to overlay plots. Resetting the model so that a new formation of the metapopulation is visible in the Netlogo world, but making it so a new plot is created for the new simulation. This would help data collection as a new column of data will be created each time in the exported CSV file.
2) Importing a GIS shapefile was also talked about in how to extend this model. Importing a shapefile and converting these to habitats in Netlogo would make this model a very powerful tool in predicting how real-life metapopulation will develop and change over time.
NETLOGO FEATURES
Both the butterflies and the habitats (or flowers) are referred to as turtles in Netlogo, it is how you code them to interact with other 'turtles' is important in how to define them.
RELATED MODELS
N/a
CREDITS AND REFERENCES
Copyright 2020 Jon Bennie and Matthew Reynolds
College of Environmental sciences
University of Exeter
Comments and Questions
;; Metapopulation simulation v1.0 - Jon Bennie 03/08/2020 ;; any lines starting with semicolons are comments and are ignored by Netlogo ;; this "globals" command just defines any variables that are used throughout the whole code and are not specified in the graphical interface ;----------------------------------------------------------- globals [Generations ButterflyPopulation OccupiedHabitats HabitatsOccupied MyList CapacityTotal] ; MR: Added relevant things to here. ;; this section just defines the types of 'agent' or 'object' - called 'turtles' in Netlogo - that can interact in the model ;; here we just tell Netlogo that we have things called butterflies (singular butterfly) and habitats (singular habitats) breed [butterflies butterfly] breed [habitats habitat] ;; this defines characteristics of the agents - eg. each habitat has a capacity (size) and occupancy (occupied or not) ;; by default all 'turtles' already have some characteristics - eg. shape, colour, size etc... habitats-own [capacity occupancy] ;; this section (from 'to setup' up to 'end') is called every time you click the setup button on the interface ;; it clears the screen, creates 10 habitat [patches], and specifies the colour, shape, capacity and location in space of each one ;; the capacity of each patch is between 1 and 5 (random 4 creates a random number between 0 and 4, then it adds one) ;; initially all patches are coloured white and occupied ;; the location is set by x and y coordinates, which are randomised ;; it also resets the count of generations and refreshes the display to setup clear-turtles set MyList n-values Number_of_habitats [random 100000000000 + 1] ; MR: This is where I have changed the random number to that big number rather than 10, also creating a list. set CapacityTotal sum(mylist) create-habitats Number_of_habitats [ set capacity one-of MyList set mylist remove(capacity) MyList set shape "flower" set color yellow set size ((capacity) * (total_size_of_all_habitats / CapacityTotal)) setxy random-xcor random-ycor set occupancy 1 ] set Generations 0 display end ;---------------------------------------------------- ;; this section is called when you click the 'disperse button, or in continuous mode each generation ;; it update the number of generations, and 'asks' each habitat patch that is occupied to hatch new butterflies ;; the number of butterflies is the capacity (1-5) times 10 ;; turns out netlogo has an inbuilt defined shape called "butterfly", so I used that and coloured them blue ;; then it calls the "move" section (details below) 100 times before killing them off to disperse set Generations Generations + 1 ask habitats with [occupancy = 1] [ hatch-butterflies size * random 9 + 1 [set size 1.5 set shape "butterfly" set color blue ] ] repeat 100 [move] set OccupiedHabitats count habitats with [occupancy = 1] set HabitatsOccupied habitats with [occupancy = 1] ;set ButterflyPopulation ((sum [size] of HabitatsOccupied) + (count butterflies)) set ButterflyPopulation count butterflies ask butterflies [die] end ;; this section defines how butterflies move in each time step. ;; each butterfly turns right a random angle, then left a random angle ;; then moves forward one unit ;; then each butterfly 'asks' any habitat that it is on to become occupied (and turn white if it isn't already) to move ask butterflies [ rt random 18 lt random 10 fd 1 ask habitats-here [ set occupancy 1 set color yellow ] ] end ;; this section is triggered when you click "extinction" or in continuous mode ;; it 'asks' each occupied habitat patch to think of a random number between 0 and 100 ;; if this number is lower than (100 / capacity) then the habitat patch goes extinct (occupancy set to zero) and turns blue ;; so patch size 1 goes extinct 100% of the time (every time step) and patch size 5 goes extinct 20% of the time (on average every 5 timesteps) to extinction ask habitats with [occupancy = 1] [ if random 100 < 100 / size [ set occupancy 0 set color brown ] ] end ;; this section is triggered when you click the "continuous" button ;; it just checks to see if all habitat is empty - if so then it stops the simulation ;; otherwise it keeps repeating the dispersal and extinction procedure and updates the landscape forever... ;; it might be useful to put an on/off switch here somewhere if you can figure out how to do it! to continuous loop [ disperse extinction update-plots export-plot "Plot to show the population of butterflies over time" "plot.csv" ; MR: This is the part of the code that, as expected, exports the results of the plot. It overwrites the file 'plots.csv' each time. export-world "results.csv" ; MR: This is the section of code that if uncommented doesn't terminate the model once the population of the butterflies hits zero (I believe the line above to do the same). if all? habitats [occupancy = 0] [stop] ] reset-ticks end
There is only one version of this model, created almost 5 years ago by Matthew Reynolds.
Attached files
File | Type | Description | Last updated | |
---|---|---|---|---|
Species metapopulation model.png | preview | Preview for 'Species metapopulation model' | almost 5 years ago, by Matthew Reynolds | Download |
This model does not have any ancestors.
This model does not have any descendants.