Recently I’ve been playing with agent based models, which are computer simulations of the interactions of autonomous agents. For example, this simple model of cars in traffic can be used to illustrate why traffic jams seem to happen for no apparent reason:
The software is called NetLogo, and the way it works is essentially this:
Step 1: Code the internal logic of an individual agent (in this case, a single car)
Accelerate if the space ahead is clear, or
Brake if the space ahead has a car in it
Step 2: Set up the simulation by randomly placing the agents on the road
Step 3: Press “go” and see what happens
The emergent phenomena that follows step 3 is a phantom traffic jam where the congestion isn’t caused by some accident or roadworks but by the behaviour of individual drivers. If you want to try it for yourself, here’s the link to the web version of this model. You can also download NetLogo to run it locally.
HIV Spread
The traffic simulation is part of NetLogo’s Models Library which has loads of pre-existing models you can tinker with.
Another model in the library I found interesting looked at the spread of HIV among a population where each individual wanders around the world, and every time they encounter another person there is a probability p that they will start a sexual relationship; p is a slider that you the scientist can control (average-coupling-tendency). The other sliders you can control are the average duration of their monogamy, the probability that they’ll use a condom, and the number of times a year they get tested. It explores the effects of monogamy, condom use, and regular testing in the spread of HIV.
The colours represent HIV status: red means HIV positive, blue means HIV positive but not practicing safe sex because their status is unknown, and green means HIV negative. Halfway through the video, I reset the simulation and slide average-condom-use and average-test-frequency down and you can see how the rate of infection climbs much quicker.
If you want to try it for yourself, I can’t seem to find it on the web version so you might have to download NetLogo on your computer and go to File > Models Library and search for ‘HIV - Social Science’.
Two-Step Flow Communication
Finally, the last model I wanted to talk about is one I coded myself as part of a Coursera course I took on Computational Social Science. It looks at the way people form opinions: do we generally form opinions based on information we get directly from the media, or are we more influenced by social interactions we have with community members and activists?
In this model, there are two media sources represented in red and blue (no intended connection to any real life political parties). People wander around the screen randomly and when they step on a red or blue square, they consume a message that informs their opinion. Here’s the video and I’ll explain everything below.
The sliders you can control are the population size, the size difference between the blue patch and red patch, and finally the degree of activism behind blue messages.
If you set the activism slider to zero, then people won’t talk to each other will rely solely on the media for information, and the majority opinion will converge in favour of whichever media outlet is larger.
If you set the activism slider to one, then people who run into each other will have a conversation and possibly influence each other’s opinion. This interaction goes like this:
If the other person has more blue messages than I have red messages, then I was wrong to believe red, and I’ll discard all my red messages.
Vice versa: If the other person has more red messages than I have blue messages, then I was wrong to believe blue and I’ll discard all my blue messages.
Importantly, red and blue messages have the same weight in these interactions only when activism = 1.
If you the activism slider to a number greater than one, it will have the effect of making the blue messages stronger.
E.g. if activism = 3, then 5 blue messages have the same weight as 15 (5*3) red messages, so if person A had 5 blue messages and person B has 14 red messages, the result would be that person B resets all their red messages to 0 because the blue activism was just that convincing.
I know this isn’t totally realistic; when was the last time that you completely abandoned an opinion you had after a single conversation? The truth is that we’re all much more irrational in real life. The big idea is to see that grassroots activism for blue messages acts as a pushback against the size of the larger red media empire.
To see the code and for more info on the model, you can go to this link! I’ve added it to my personal website which is a whole other project in and of itself, let me know if you have any feedback or questions. See you next time!