Showing posts with label Java. Show all posts
Showing posts with label Java. Show all posts

Wednesday, June 10, 2009

Game of Life on a globe

Always interested in ways to visualize models, I just seen Richard Milton's version of John Conway's Game of Life on a globe model. Richard has has written a short tutorial on how it was done (click here). The the Java applet allows you to explore how different configurations of automata evolve around the globe.


To view the applet click here. Another similar model (shown below) was created by Ventrella to celebrate Earth Day. Click here to see more details about the model.

Monday, February 9, 2009

N-Person Prisoner's Dilemma: A Spatial Application

In the current issue of JASSS there is an article by Conrad Power entitled "A Spatial Agent-Based Model of N-Person Prisoner's Dilemma Cooperation in a Socio-Geographic Community" where he presents a spatial agent-based model on the N-person prisoner's dilemma (NPPD). The NPPD is a social dilemma game which is focused on the simulation of the collective actions and behaviours within social groups.

The purpose of the model is to present a spatial agent-based approach for modelling the processes of communication and cooperation within a socio-geographic community. The model itself is written in Java and utilizes RepastJ, OpenMap and JTS to simulate agent interactions, movements, and the NPPD game play to the town of Catalina, Newfoundland and Labrador, Canada.

The full article can be found on the JASSS site.

Thursday, October 30, 2008

Work Update

Readers of the blog might have been wondering why I been interested in Second Life (click here to see blog posts on Second Life), and why I been exploring fine scale modelling of the London housing market and what this has to do with GIS and ABM. As part of the CASA seminar series, I was asked to give a talk about some of my work from the last year. The talk was entitled "Modelling Cities: An Approach using Agent-Based Models and GIS' which pulled together these topics. The abstract or the talk is below:

The Agent-based modelling (ABM) paradigm is becoming an increasingly used technique to study cities. It allows us to grow social structures in artificial worlds specifically how a set of micro-specifications are sufficient to generate the macro-phenomena of interest. Until recently many applications of agent-based models exploring urban phenomena have used a regular partition of space (cells) to represent space. While these models have provided valuable insights into urban phenomena especially as they can capture geographic detail, they miss geometric detail. This area is critical to good applications but is barely touched upon in the literature. Geometry (points, lines and polygons), forms the skeleton of cities from streets and buildings, through to parks, rivers, etc. The ability to represent the urban environment as a series of points, lines, and polygons allows for different size features such as houses and roads to be directly incorporated into the modelling process onto which other physical and social attributes can be added. Additionally the inclusion of geometry allows us to make agent-based models more realistic compared to representing the urban environment as a series of discrete regular cells. This presentation introduces ABM, explore how agent-based models coupled loosely with geographic information systems (GIS) can be created through illustrated examples focusing on residential location. These applications directly consider geometry when building these artificial worlds and running the simulations. Furthermore, these models highlight how the inclusion of geometry impacts on simulation results. Problems and challenges with this approach and ABM in general will be identified. To conclude we will argue the need for fine scale and extensive datasets of the built and socio-economic environments to ground such models, along with the need to communicate and visualise agent-based models. To this extent we introduce our detailed housing and built environment database for London, which will be used as a building block for agent-based models associated with London. We then explore how such models might be communicated and shared with others using advances in technology, specifically Web 2.0 and Second Life.

Some people have asked for the slides of the talk, so I have made them available, they can be downloaded from here (28MB). Accompanying these I have also made a movie of the talk which give a sense of dynamics from such models.




Any thoughts or comments most welcome.

Wednesday, April 16, 2008

New Working Paper: ABM of Residential Segregation

We just finished a new working paper entitled “Constructing and Implementing an Agent-Based Model of Residential Segregation through Vector GIS”

The abstract is as follows:

In this paper, we present a geographically explicit agent-based model, loosely coupled with vector GIS, which explicitly captures and uses geometrical data and socio economic attributes in the simulation process. The ability to represent the urban environment as a series of points, line and polygons not only allows one to represent a range of different sized features such as houses or larger areas portrayed as the urban environment but is a move away from many agent-based models utilising GIS which are rooted in grid-based structures. We apply this model to the study of residential segregation, specifically creating a Schelling (1971, 1978) type of model within a hypothetical cityscape, thus demonstrating how this approach can be used for linking vector-based GIS and agent-based modelling. A selection of simulation experiments are presented, highlighting the inner workings of the model and how aggregate patterns of segregation can emerge from the mild tastes and preferences of individual agents interacting locally over time. Furthermore, the paper suggests how this model could be extended and demonstrates the importance of explicit geographical space in the modelling process.

Keywords: Agent-Based Modelling, GIS, Residential Segregation, Repast

The full reference is:

Crooks, A. T. (2008), Constructing and Implementing an Agent-Based Model of Residential Segregation through Vector GIS, Centre for Advanced Spatial Analysis (University College London), Working Paper 133, London.

The paper can be downloaded from here. As always, any thoughts or comments about the paper are more than welcome.


Wednesday, April 18, 2007

Creating Slider bars in Repast

Slider bars (as in the image above) are a easy way to change model parameters of a simulation. Someone asked how to create a Slider Bar within a Repast model, so I thought I would share it. To create one is relatively straight forward. All you need to do is place this piece of code in the setup method:

//creates a slider which has to be an int.
RangePropertyDescriptor pdMovement = new RangePropertyDescriptor("Movement", 0, 1000, 200);

descriptors.put("Movement", pdMovement);

Where “Movement” relates to the “Movement” parameter in the getInitParam method. For example:

String [] initparams = {"PerAgents", "Movement",
};
return initparams;
}

Further information on PropertyDescriptors can be found on the Repast Website under "How to Create PropertyDescriptors"


Thursday, March 29, 2007

PropertyWindow class

There was this message on the Repast mailing list the other day:

Dear list,
I want to probe some variables of my agents of the OpenMap Layer. I did this by making the following method:

public String[] gisPropertyList() {

String []gisPropertyList = {"Lat/Lon","getLatLonPointString","nativeCountry","getNativeCountry",

"residence","getResidence","age","getAge","gender","getGender" };


return gisPropertyList;

It works, however when I probe one of my agents I get the screen below. It seems like something is on top of the last fields. How can I fix this? Thanks!

I had exactly the same problem as this is to do with the PropertyWindow class which only permits 4 items to be displayed in the anl.repast.gis.display package. Click here to see my modification that works around this problem. I hope this helps.



Thursday, May 11, 2006

Trove4J

I have just discovered a java library called Trove, which allows you to plug in their versions (eg THashMap) of certain containers (java.util.HashMap, java.util.HashSet, java.util.LinkedList), and use them just like you would with the standard versions gaining performance. For example the THashMap class is a faster than java.util.HashMap. Trove also comes when you download Repast.

Thursday, March 2, 2006

OpenJUMP

A friend of mine has just switched from using OpenMap to OpenJUMP (Java Unified Mapping Platform) and what he showed me was very impressive. Especially as he is integrating it with Repast. OpenJUMP is an open source GIS software written in Java. It is based on JUMP GIS by Vivid Solutions. It is developed and maintained by a group of volunteers (quite impressive). OpenJUMP is a Vector GIS but can read rasters as well.

Basic GIS functions include: built in drawing and geometry editing tools, attribute query, a set of selection tools, image export in Scalable Vector Graphics (SVG) format, a tool to zoom to a user defined map scale, it can show multiple layers dependent on the current map scale. It also has the ability to read and write shapefiles. Sounds like a good Open Source GIS.