Sie sind auf Seite 1von 8

Agent-Based Modeling Assignment #2- Modifying ABM Models with NetLogo 1.

Explore the simulation with the default parameters. What is the percent-similar value? What makes a turtle unhappy? At what point does a simulation stop? Now explore different values for %-similarwanted? What do you observe? What is the maximum value of %-similar-wanted where no agents are unhappy? The percent similar value with default parameters is about 73% with 0% unhappy after around 13.8 runs. The turtles are "unhappy" if less than 30% of their neighbors (the eight adjacent patches) are similarly colored. Changing the %-similar-wanted higher than 30% (up to a threshold of 75%) will raise the percent of similar turtles as well as the number of ticks it takes for all turtles to be happy. Changing the variable lower than 30% will result in less ticks before stopping since its easier to satisfy the turtles. At 20% wanted the file will stop at 7.5 ticks with 0% unhappy and 57% similar. The maximum %-similar-wanted that results in no agents unhappy is 75% similar-wanted. This will result in 99.8% similar after around 146 ticks. At 76% similar-wanted the turtles will continue to move indefinitely with a percentage of turtles unhappy (varies with %-similar-wanted, for example at 80% similar the % unhappy fluctuates between 82 and 87%). 2. Now, suppose you add a third type of agent to the model. This will require you to make updates to the segregation model code and interface. Add yellow color turtles (agents) to the model. Add monitors to display to count the number of each color agent in your model. Now, what is the maximum value for %-similar where no agents unhappy?

Using the base case of 2000 total turtles and 30% similar wanted, the endstate is 72% similar turtles with 0% unhappy after 22.5 ticks.

Now the maximum percent similar wanted is 62% with zero unhappy after around 231 ticks. We can see from the snapshot that the groupings are more homogeneous compared to the lower %-similar-wanted (the "islands" of each group are bigger than before). 3. Now add sliders to control the number and each type of agent so you can have uneven distributions of agent types. Run experiments with different mixes and note any changes that result. Code I used for creating sliders:
;; create turtles on random patches using the "number-xxxx" slider ask n-of number-red patches [ sprout 1 [ set color red ] ] ask n-of number-green patches [ sprout 1 [ set color green find-new-spot ] ]

ask n-of number-yellow patches [ sprout 1 [ set color yellow

find-new-spot ] ]

With a "medium sized" mix of turtles (not nearing the max patches) with roughly equal parts green and yellow and less red, the threshold for reaching a stable outcome (all happy) seemed to be around 66% (at 67% the turtles would create groups but they would continuously shift and never stop)

4. Extend the Segregation model further. Lets suppose that the relationship pattern is more complex than originally described. Red turtles now want to be near yellow turtles and yellow turtles want to be near red turtles. However, their preferences towards green turtles are unchanged. Update your model to reflect the new preferences. What changes? Discuss the new behavior. The percentage of similar wanted goes up slightly to 62% and the percent similar are 99.4% before 0% of the turtles are unhappy. It takes longer for the turtles to reach a collective state of happiness than the initial model. This is most likely because it requires more time for the turtles to meet their happiness conditions. At the end, there is still a similar threshold for achieving happiness, it just requires more time. Code:
to update-turtles ask turtles [ if color = red [

set similar-nearby count (turtles-on neighbors) with [(color = [color] of myself) and (color = yellow)]

set other-nearby count (turtles-on neighbors) with [(color != [color] of myself) and (color = yellow)] ] if color = yellow [ set similar-nearby count (turtles-on neighbors)

with [(color = [color] of myself) and (color = red)] set other-nearby count (turtles-on neighbors) with [(color != [color] of myself) and (color = red)] ] if color = green [ set similar-nearby count (turtles-on neighbors)

with [(color = [color] of myself)] set other-nearby count (turtles-on neighbors) with [(color != [color] of myself)] ] set total-nearby similar-nearby + other-nearby set happy? similar-nearby >= ( %-similar-wanted * total-nearby / 100 )

5. Now suppose that the green turtles now want to be near red turtles. Update your model to reflect this fact. Which color turtles have the highest percentage of unhappiness? The green turtles have the highest percentage of unhappiness. At any percentage over 62% of %-similar wanted, there is no way to make all turtles happy. For any model under the 62% threshold, the green turtles always have the highest percentage of unhappy turtles Added monitor buttons to display numbers of unhappy turtles for each:
Example: Count turtles with [color = red]

Code:
to update-turtles ask turtles [ if color = red [

set similar-nearby count (turtles-on neighbors) with [(color = [color] of myself) and (color = yellow)]

set other-nearby count (turtles-on neighbors) with [(color != [color] of myself) and (color = yellow)] ] if color = yellow [ set similar-nearby count (turtles-on neighbors)

with [(color = [color] of myself) and (color = red)] set other-nearby count (turtles-on neighbors) with [(color != [color] of myself) and (color = red)] ] if color = green [ set similar-nearby count (turtles-on neighbors)

with [(color = [color] of myself)and (color = red)] set other-nearby count (turtles-on neighbors) with [(color != [color] of myself)and (color = red)] ] set total-nearby similar-nearby + other-nearby set happy? similar-nearby >= ( %-similar-wanted * total-nearby / 100 )

6. Choose any model from NetLogo or community models. What flavor of ABM is the model? Update the model code and interface to do something interesting. Describe your changes in detail. I chose the Rebellion model, which appears to be a free agent model that models cops and a population that wonders around randomly. If their "grievance level" is high and their perception (vision) of risks is low then they rebel. If the cops see some agent in its immediate vicinity rebelling, they arrest the agent for a random amount of ticks (up to threshold chose on the jail time slider). From the rebellion model "file info" page: "Each agent also calculates an individual risk of rebelling at the beginning of each turn. This ESTIMATEDARREST-PROBABILITY, is based on the number of cops and already rebelling agents within VISION patches, namely 1 - exp (- k * (C/A)v) where (C/A)v is the ratio of cops to active agents, and k is a constant set in startup to ensure a reasonable value when there is only one cop and one agent within a particular field of vision. Wilenskys implementation changes one aspect of Epsteins description. After dividing by C by A, it takes the floor of the result (that is, round downwards to an integer). Without this change, the model does not exhibit punctuated equilibrium. The effect of the change is that if there are

more rebels than cops in the neighbourhood, the probability of arrest is zero; otherwise it is very nearly 1.0."

We can see from the default settings that there are cycles with high numbers of open rebels, which affect the number of quiet agents, and is closely lagged by an increasing number of jailed agents (since the cops have more to arrest). I first got rid of the vision slider and set it as a constant = 1, and entered the following code in the to go section: if ticks = 80 [ set vision 10 ask patches [set neighborhood patches in-radius vision]] this will change the vision level to 10 after a certain number of ticks - 80 in this case.

With these settings, I observed that there was an almost immediate spike in active rebellers, followed by a high number of jailed agents. The levels of quiet, active and jailed stayed nearly constant until not long after 80 ticks, when the vision variable was changed to ten. At this point, the number of active went to zero and the number of quiet went up to almost 100% as the number of jailed plummeted. However, the number of jailed never went to zero. I also removed the "floor" from the ESTIMATED-ARREST-PROBABILITY formula described above. This removed the initial spike in rebellious agents (note there's no red lump in the graph below), but the final behavior ended the same - the number of active went to zero and the number of quiet went up to almost 100% as the number of jailed plummeted.

References: I worked with Burt Scearce and Mike Anderson both in class and during the week to develop the code and answer these questions.

Das könnte Ihnen auch gefallen