OR/16/022 Software trialled: Difference between revisions

From MediaWiki
Jump to navigation Jump to search
Ajhil (talk | contribs)
 
Dbk (talk | contribs)
m 1 revision imported
 
(No difference)

Latest revision as of 12:02, 18 October 2016

Beriro, D, Cave, M, Wragg, J and Hughes, A. 2016. Agent Based Modelling: Initial assessment for use on soil bioaccessibility. British Geological Survey Internal Report, OR/16/022.

Repast-simphony

Repast-Simphony is an open source agent-based modelling tool kit, originally developed (North et al., 2013[1]) in 2001. It operates using a modified Java IDE (Eclipse Luna) to implement agent-based modelling. Launched from Eclipse, Repast-Simphony is a separate visualisation module that is also capable of a range of user modifications e.g. access to Google Earth maps for GIS agent-based modelling. Repast Simphony is a cross platform Java-based modelling system that runs under Microsoft Windows, Apple Mac OS X, and Linux. It supports the development of extremely flexible models of interacting agents for use on workstations and computing clusters (using Logo-style C++ computer language). Repast Simphony models can be developed in several different forms including the ReLogo dialect of Logo, point-and-click statecharts, Groovy or Java all of which can be interleaved.

More information on Repast Simphony including documentation and downloads can be found at: http://repast.sourceforge.net/repast_simphony.php. The use of the software in the literature suggests it has a moderate level of uptake (Scopus search ‘repast AND ‘agent based’’: 168 hits since 2013).

Familiarisation with Repast Simphony was achieved two ways: 1) implementation of a demonstration model (FlowZombies) using Groovy and Java based programming; and 2) implementation and customisation of a second demonstration model (Geography). The Zombie flow model was implemented directly from the following user guides downloaded with the software or in the documentation section on the website.

The FlowZombies example is simple agent-based model involving zombies chasing humans and humans running away from zombies. When Human energy levels are low they stop moving and the Zombie infects the Human and turn them into a Zombie. The Humans and Zombie are both agents.

The Groovy FlowZombie example was initiated using a user guide led implementation of flow chart programming where each item in the flow chart was assigned attributes. These Flow charts were initiated by Repast Simphony in its own Java-like language.

The Java FlowZombie example was initiated using a user guide led implementation of a Java programme which utilised a Repast Simphony API (a collection of function based libraries).

The output of both FlowZombie models is a gridded display of Zombie chasing and infecting humans (Figure 1).

Figure 1    Example of the flow zombie tutorial.

The secondary demonstration model, Geography has been developed. The Context Builder for this model describes it as:

‘…mobile GisAgents move around the Geography with a random motion and are represented by point locations. ZoneAgents are polygons that represent certain geographic areas. WaterLine agents represent water supply lines from Lake Michigan that supply the Chicago area. When a ZoneAgent intersects a WaterLine, the ZoneAgent will have access to fresh drinking water. GisAgents that are within a certain distance from the ZoneAgent boundary will also have access to water. Agents that are not in proximity to a Zone with a water supply will not have access to water (they will be thirsty). BufferZoneAgents are for visualization to illustrate the extend of the boundary around a ZoneAgent.’

This example was modified to represent a more realistic example of As uptake. Mobile agents (stars in Figure 2) were moved by a random walk from the bottom left to the top right of the agent domain. Two shapefiles were added to the example as ZoneAgents: one to represent buildings and the other representing a ‘patch’ of contamination. The agents are moved by the random walk method and then ‘bounced’ off the walls of the buildings before crossing the contaminated ground collecting exposure. Whilst the example was relatively crude, it demonstrated the capability of repast-simphony.

Figure 2    Screenshot of the modified geography example.

Repast-simphony lessons learnt

A summary of the lessons learnt are presented in the SWOT diagram in Table 2.

Table 2    SWOT analysis for repast-simphony
Strengths

Agent-based models can be programmed from scratch in universal programming languages.

Library of models to test and extract useful code.

Can be used for to create GIS models.

Can bring in shapefile and display (in geographical context).

Different geographical contexts: grid, space and geographical.

Rules on where agents can move achieved by using logic.

Weaknesses

Dearth of user community despite apparent popularity.

Advanced Java programming skills required Visualisation module unstable.

Reliance of open source coding and visualisation software.

Opportunities

Universal programming language so easily conveyed to programming community and ABM specialists.

Applicable to other research lines in and outside BGS.

Upskill team in Java programming.

Specialised modelling not common to all organisations.

Use pre-programmed models as code resource to build on.

Threats

Time required to upskill BGS staff.

The level of Java programming is highly advanced and that team will find it difficult to meet demand within resources allocated.

Time resources need to programme a good model will exceed resources available to team.

NetLogo is an agent-based programming language and integrated modelling environment.

NetLogo was designed, in the spirit of the Logo programming language, to be ‘low threshold and no ceiling’[2]. Logo is an educational programming language, designed in 1967 by Daniel G. Bobrow, Wally Feurzeig, Seymour Papert and Cynthia Solomon. The language was originally conceived to teach concepts of programming related to the computer language Lisp and only later to enable what Papert called ‘body-syntonic reasoning’ where students could understand (and predict and reason about) a turtle's motion by imagining what they would do if they were a turtle.

NetLogo teaches programming concepts using agents in the form of turtles, patches, links and the observer. NetLogo was designed for multiple audiences in mind, in particular: teaching children in the education community and for domain experts without a programming background to model related phenomena. Many scientific articles have been published using NetLogo (web of science search on NetLogo on 30/3/2016 gives 320 results).

The NetLogo environment enables exploration of emergent phenomena. It comes with an extensive models library including models in a variety of domains, such as economics, biology, physics, chemistry, psychology, system dynamics. NetLogo allows exploration by modifying switches, sliders, choosers, inputs, and other interface elements. Beyond exploration, NetLogo allows authoring of new models and modification of existing models.

NetLogo is freely available from the NetLogo website. It is in use in a wide variety of educational contexts from elementary school to graduate school. Many teachers make use of NetLogo in their curricula.

NetLogo was designed and authored by Uri Wilensky, director of Northwestern University's Center for Connected Learning and Computer-Based Modelling.

User group and support

NetLogo has a number of user groups and discussion lists. The program itself is written in Java and ther is a ‘NetLogo-devel’ for developing the actual program (www.groups.google.com/forum/#!forum/netlogo-devel). There is a group for asking programming questions on the NetLogo language on the ‘Stack Overflow’ site (www.stackoverflow.com/questions/tagged/netlogo). NetLogo also has a twitter feed (@NetLogo) for release announcements and NetLogo-related news.

There are also extensive libraries of NetLogo models. The program comes with a wide variety of example models covering the fields of art, biology, chemistry and physics, computer science, earth science, games, mathematics, networks, social science, system dynamics. Users are encouraged to upload their completed and tested models to the site. There is also a site called ‘NetLogo Modelling Commons’ which NetLogo user can sign up to share models (www.modelingcommons.org/account/login). It currently contains over 1000 models.

Program environment

The program consists of a programming window and an associated graphical user interface (GUI) (Figure 3). The GUI which contains a pictorial view of the application being modelled (movement of agents and the state of the patches the agents are moving within and around). As well as this, there are buttons which control specific subroutines of the underlying program and sliders which can be used to change the value of inputs to the program as well plots and data reporting boxes to monitor the progress of the model.

Figure 3    Example screen shot of a NetLogo model.

Preliminary assessment of NetLogo for Human Health Risk assessment

The initial aim was to look at the feasibility of both generally using ABM within BGS and the NetLogo language specifically as a tool for human health risk assessment with respect to contaminated land.

A simple scenario was tested. The town of Northampton has soils developed from the underlying ironstone formations which have elevated As concentrations. The soils were the subject of a study in which the bioaccessibility of the As in the soils was modelled from bioaccessibility measurements, soil properties and total As concentrations (Cave et al 2013[3]). The idea was to take the spatial distribution of As bioaccessibility from the study, read this into NetLogo, then to have a set of human agents moving over different sections of the sample space (Northampton As bioaccessibility map) whilst being exposed to the variable concentrations of As and building up an exposure over time.

Reading in the spatial data

NetLogo has a built in function for importing spatial data either as a raster or shapefiles. In this case a raster file of the As bioaccessibility was read into the NetLogo environment (Figure 4) with white representing high bioaccessible As and black representing low bioaccessible As.

Figure 4    Northampton As bioaccessibility imported into NetLogo.

Agent movement and exposure

Four separate populations of human subjects containing 8 humans were set up in different locations in Northampton, shown as the different coloured figures in Figure 4. The program is set up so that each population moves in a random walk but no more than a set distance from the starting point. Each human agent starts out with a zero exposure to As and each time it move onto a new square their exposure is increased by a given fraction of the As bioaccessibility of the square they are occupying. The programming script for the model shown is in Appendix 1 - NetLogo associated scripts.

Operation of the model

Figure 5 shows the model in operation for each population with the agents moving in their designated areas at no more than 3 units away from their starting locations.

Figure 5    Northampton As exposure model in operation.

Monitoring of the model outputs

Whilst the NetLogo model allows the exposure received by each human agent in each area to be plotted in graphs there in as additional feature of NetLogo which gives additional functionality to controlling inputs and collecting and analysing data. There is a package written in the R programming language called ‘RNetLogo’ which allows an R program to run a NetLogo model to modify the input parameters and collect the outputs for further statistical analysis.

As an example an R program was written to run the Northampton NetLogo model setting 100 agents at each of the 4 locations and collecting the data from 100 time steps. The R script for this is shown in Appendix 2 - Repast-simphony associated scripts.

Figure 6    Cumulative As exposure for each of the human agents in each of the four groups (coloured lines) and the mean cumulative exposure for each group (dashed black line).

Figure 6 shows the cumulative exposure for each of the 100 human agents in each of the 4 locations.

Figure 7    Box and whisker plot of the exposure for each of the 4 groups after 100 time steps.

Figure 7 summarises the final exposure in each of the four groups in terms of a boxplot and Figure 8 shows the same data but in the form of a probability density function.

Figure 8    Probability density function plot of the exposure for each of the 4 groups after 100 time steps.

Conclusions

The NetLogo language appears to be a well-established tool in the field of ABM with a strong user base and a good record of peer reviewed work in the literature. Within the context of this scoping study the NetLogo environment has worked well on the small demonstration project and shows promise to be a very useful tool for human health risk assessment from contaminated soils.

Table 3    SWOT analysis for NetLogo
Strengths

Agent-based models can be programmed from scratch in universal programming languages.

Library of models to test and extract useful code.

Can be used for to create GIS models.

Can bring in shapefile and display (in geographical context).

Different geographical contexts: grid, space and geographical.

Strong user community.

Significant published literature using NetLogo.

Weaknesses

R programming skills required

Opportunities

Universal programming language so easily conveyed to programming community and ABM specialists.

Applicable to other research lines in and outside BGS.

Specialised modelling not common to all organisations.

Use pre-programmed models as code resource to build on.

Threats

Time required to upskill BGS staff. Relies on open source products.

Insight-maker

Insight-maker: insightmaker.com is a web-based model building tool which has an ABM capability. Aimed at making modelling more accessibile to a wider range of users, the user needs to have an account which can be used to build and run models. To understand the capabiulities of the software the ABM Tutorial was undertaken: insightmaker.com/node/3790. This tutorial was impleneted which can be accessed at: www.insightmaker.com/insight/49684/ABM-Tutorial.

A relatively simple interface is designed to allow the user to set up a model using a flow chart- based approach (Figure 9). This shows the creation of a simple example using primitives (activities used to build a model) and links (which join up the actions). Once the model has been run the output can be displayed in a number of different ways: time series plots and the distribution of the agents (Figure 10).

Figure 9    Example model created using ‘primitives’ and ‘links’.
Figure 10    Examples of model output.

Whilst Insight-maker offers a simple and effective way of producing models, it does have a number of limitations. It is web-based which limits the processing power, it requires models to be stored on a server and is aimed at ‘quick and dirty’ solutions. Whilst it does what it sets out to do, namely lower the barrier to entry for modelling, this is achieved at the expense of scalability to increasingly complex problems.

Table 4    SWOT analysis for Insight-maker
Strengths

Agent-based models can be quickly and easily programmed from scratch in universal programming languages.

Library of models to test and extract useful code.

Relatively strong user community.

Weaknesses

Lack of scalability to more complex problems.

Opportunities

Universal programming language so easily conveyed to programming community and ABM specialists.

Applicable to other problems inside and outside BGS.

Threats

Code resides in web-based repository Website may be no longer supported.

References

  1. North, M J, Collier, N T, Ozik, J, Tatara, E R, Macal, C M, Bragen, M, and Sydelko, P. 2013. Complex adaptive systems modeling with Repast Simphony. Complex adaptive systems modeling, 1(1), 1.
  2. Low threshold and no ceiling concept means that programmers with limited skills can start using the language, but that it is flexible enough for much more complex problems to be tackled.
  3. Cave, M R, Wragg, J, and Harrison, H. 2013. Measurement modelling and mapping of arsenic bioaccessibility in Northampton, UK. Journal of Environmental Science & Health Part A, 48, 629–640.