Showing posts with label Agent Based Modelling. Show all posts
Showing posts with label Agent Based Modelling. Show all posts

Friday, 11 May 2012

Social Forces Model with Human participants on the BBC

The BBC's science series 'Bang goes the Theory' recently had an episode on crowd behaviour. It shows a fascinating way of getting plenty of research out there into the public eye, using very short clips of research taking place based on certain themes. Anders Johansson, who still works with CASA, ran an experiment based on the 'social forces' model.

To give a heads up, the social forces model is an agent based model that simulates the microscopic movements of pedestrians. The motion of these pedestrians are described by subjecting them to 'social forces'. These forces are exerted by the pedestrians personal environment, as well as the interactions with other pedestrians in this context.

The movement of these pedestrians governed by these social forces are defined by the equation below:



If you'd like more details on the paper, it can be found here

An example of a social forces simulation model can be seen running in this video below:




Now, with this BBC episode, you can check out this model in a real world example with the help of an experiment with human participants, where you can see the effect of jams during an evacuation in a potential real world situation, and how a very simple solution of placing an obstacle at the exit can actually improve the flow of people through a door when evacuating a building. Although, your intuition I'm sure would say that it would not make sense. Actually, as this obstacle separates the flow of people, it prevents a jam occuring at the door, and therefore, creates a smoother flow through the door. Have a look, it's available for another 10days, and the experiment runs from around the 24 min mark, UK users only I'm afraid:

BBC Bang goes the Theory S6 Ep 4

Enjoy!

Tuesday, 19 May 2009

Netlogo to 3D Max: Code

Based on the pseudocode for the Netlogo to 3DMax implementation, I have now decided to post a short tutorial on exporting the Netlogo traffic simulation to 3DMax. This tutorial will mainly cover the output of the turtles and visualising it in 3DMax.

Netlogo (traffic grid simulation):

For the turtles, I output during runtime, therefore, open the file at the first tick, keep writing, and close the file at the last tick, depending on how many ticks you would want to output, in my case 500.

if ticks = 0 [file-open "myfile.txt"]
ask turtles [
file-write xcor file-type " " file-show ycor
]
if ticks >= 500 [file-close]

This will output in the form:

-12 (turtle: 2) 11
-17 (turtle: 0) 5
-4 (turtle: 1) -8

I didn't find a simple way just to output only the turtle id number, so I manually delete the brackets and text using find and replace, giving me an output as seen below:

-12 2 11
-17 0 5
-4 1 -8

Now our next step is to import it into 3DMax. Once the output file has been stored, the script below can be run, and on clicking the 'Make' button, locate the output file, and it will create the animation.

The code works by importing the Netlogo output file into an array. It can be found here.

I have commented the code in order to explain what is happening at each step.

Running this script will result in the animation shown in my previous post. To get the road patches, and traffic lights in 3DMax, the code can be extended further to store the patches and traffic light states in arrays for each frame, once imported from the Netlogo output.

Update: As pointed out by a reader, there is actually a simple way to output only the turtle id number using the command:

ask turtles [print who]

Therefore, the Netlogo output above can be obtained by using the following command

ask turtles 
[
file-type word xcor " " file-type word who " " file-print ycor
]

ShareThis