Ferramentas do usuário

Ferramentas do site


geopro:pedro:netlogo

Netlogo

NetLogo’s design is based on our experience with our earlier environment, StarLogoT. We redesigned both the language and the user interface. NetLogo includes almost all of StarLogoT’s features and many new ones.

leg.ufpr.br_pedro_figures_netlogo.jpg


Homepage http://ccl.northwestern.edu/netlogo/
Origin Center for Connected Learning (CCL)
Year 1999
Version 4.0beta1
License freeware
Language Lisp
Discussion http://groups.yahoo.com/group/netlogo-users/


The original StarLogo was developed at the MIT Media Lab in 1989-1990 […]. A few years later (1994), a simulated parallel version was developed for the Macintosh computer. That version eventually became MacStarLogo. StarLogoT (1997), developed at the Center for Connected Learning and Computer-Based Modeling (CCL), is essentially an extended version of MacStarLogo with many additional features and capabilities. Since then two multi-platform Java-based multi-agent Logos have been developed: NetLogo (from the CCL) and a Java-based version of StarLogo (from MIT). The NetLogo language and environment differ in many respects from MIT StarLogo's. Both languages were inspired by the original StarLogo, but were redesigned in different ways. NetLogo's design was driven by the need to revise and expand the language so it is easier to use and more powerful, and by the need to support the HubNet architecture. NetLogo incorporates almost all of the extended functionality of our earlier StarLogoT, as well as a great many newer features.

To cite this program, use Wilensky, U. (1999). NetLogo. http://ccl.northwestern.edu/netlogo. Center for Connected Learning and Computer-Based Modeling. Northwestern University, Evanston, IL.

Some characteristics:

  • mobile agents (turtles) move over a grid of stationary agents (patches)
  • create links between turtles to make networks
  • view your model in either 2D and 3D
  • agent monitors for inspecting and controlling agents
  • BehaviorSpace tool used to collect data from multiple runs of a model

GIS

http://ccl.northwestern.edu/netlogo/docs/gis.html

load vector GIS data (points, lines, and polygons), and raster GIS data (grids) into NetLogo. The extension supports vector data in the form of ESRI shapefiles. The shapefile (.shp) format is the most common format for storing and exchanging vector GIS data. The extension supports raster data in the form of ESRI ascii Grid files. The ascii grid file (.asc or .grd) is not as common as the shapefile, but is supported as an interchange format by most GIS platforms.

Models

Wolf Sheep Model

leg.ufpr.br_pedro_figures_netlogo-wolf-sheep.jpg

Wolf sheep is a predator-prey model of interaction among wolfes, sheeps and grass. Wolfes and sheeps are turtles, and the grass is represented by patches. The source code can be seen here. The whole model is available together with the program, and there is a java applet in the Starlogo page.

There are two functions for moving a turtle. The first put a turtle in a given (x,y)

setxy random-xcor random-ycor

The second function moves it from the actual spatial position. Turtles move according to a direction where they are pointing to. The function for moving is called fd (forward), and the exemple shows a function of random movement to one of four neighbours.

to move  ;; turtle procedure
  rt random 50
  lt random 50
  fd 1
end

The next function stops a turtle and removes it from the model. Note that the definition of this function (as well as “move” above) does not especifies that it is related to agents, breaking the oo concept.

to death  ;; turtle procedure
  ;; when energy dips below zero, die
  if energy < 0 [ die ]
end

One wolf catches sheeps that stand in the same cell that it is. Note the predicate “ask”, the way that agents can communicate:

to catch-sheep  ;; wolf procedure
  let prey one-of sheep-here                    ;; grab a random sheep
  if prey != nobody                             ;; did we get one?  if so,
    [ ask prey [ die ]                          ;; kill it
      set energy energy + wolf-gain-from-food ] ;; get energy from eating
end

It is interesting the idea of an “ask,” because it means that the agent is sending an information to another, but in terms of implementation it is executing the code using another agent.

ask turtles [set sex (random 2)]

TerraME: this function could be implemented using

ForEachAgent(cellularSpace, function(agent)
  agent.sex = math.random(2)
end)

(or something like agent.setSex(…)). Question: can an agent get the result of an ask? (I didn't find any example.) Is that useful?

Agents are not free to reason. The main function “to go” dictates all the agenda of each class of agents.

to go
  if not any? turtles [ stop ]
  ask sheep [
    move
    if grass? [
      set energy energy - 1  ;; deduct energy for sheep only if grass? switch is on
      eat-grass
    ]
    reproduce-sheep
    death
  ]

  ; [...] wolves

  if grass? [ ask patches [ grow-grass ] ]
  tick
  update-plot
  display-labels
end

Seggregation

to find-new-spot
  rt random-float 360
  fd random-float 10
  if any? other turtles-here
    [ find-new-spot ]          ;; keep going until we find an unoccupied patch
  move-to patch-here  ;; move to center of patch
end

TerraME: Wouldn't be interesting if we could have a “capacity of cells”, in order to control empty, non-empty, full and non-full cells? Each cell may have its own capacity, implemented by some internal control. Cells could activate events each time someone arrives or leaves it, and the programmer could implement the functions to be activated.

Communication

leg.ufpr.br_pedro_figures_netlogo-cooperation.jpg

to interact  ;; turtle procedure
  ;; interact with Von Neumann neighborhood
  ask turtles-on neighbors4 [
    ;; the commands inside the ASK are written from the point of view
    ;; of the agent being interacted with.  To refer back to the agent
    ;; that initiated the interaction, we use the MYSELF primitive.
    set meet meet + 1
    ;; do one thing if the individual interacting is the same color as me
    if color = [color] of myself [
      ;; record the fact the agent met someone of the own color
      set meetown meetown + 1
      ;; if I cooperate then I reduce my PTR and increase my neighbors
      if [cooperate-with-same?] of myself [
        set coopown coopown + 1
        set [PTR] of myself [PTR] of myself - cost-of-giving
        set PTR PTR + gain-of-receiving
      ]
    ]
  ;; [...]
  ]

Much effort for little results. If the implementation followed the idea of reading data from the neighbours and write only in itself, instead of one agent sends a message to its neighbours to increment the value of “meet”, it could increment its value “for each neighbour”. But note that when we have a stochastic decision of the neighbour, this simplification does not work, and perhaps it would be necessary to have a third agent, a “controller”.

Car Cruising model: A GIS Example

leg.ufpr.br_pedro_figures_netlogo-gis-cars.jpg

Presented here.

A good example of where GIS can be introduced into a model, is for dynamic car cruising within the Santa Fe downtown area.

The background map of the model is the result of converting GIS data into an image, initially a jpeg file. It was then converted into a text format image file: PPM (portable pix map) consisting of three RGB values for each pixel. These were converted into NetLogo color values using the import-ppm procedure. The data was cleaned up a bit within Netlogo itself with the cleanup-map procedure, then written to an external data file via the export-dat procedure. Finally, for this version of the model, the data written out in the preceeding step was cut & paste into the model as an array of integer values.

The model itself simply manages automobiles driving on the map staying on the “streets” by using the patch colors as guide. The cars randomly choose side streets as they see them, choosing to turn roughly 1/3 of the time in the move-forward procedure.

TerraME: It could import raster data as well as vectorial data to cellular spaces, to support this kind of application.

Papers

Modeling Nature’s Emergent Patterns with Multi-agent Languages

U. Wilensky, 2001 Proceedings of EuroLogopdf 23 citations in Scholar

leg.ufpr.br_pedro_figures_netlogo-gas.jpg

In the minds of many, […] complex systems theory is not a new branch of science, but rather a new framework, a new perspective that allows us to see old scientific content in new ways. This new perspective and the methods it brings to bear have been adopted across a wide array of natural and social sciences. An understanding of complex systems is becoming an essential part of every scientist’s knowledge and skills. The time has come for these ideas and methods to become a central part of every student’s learning.

The paper describes two models. The first is the model of predator/pray using wolf/sheep/grass agents (the one cited above, and the same example used in a paper that describes repast). The second model studies the trajectory of gas particles in a box, as shown in the figure. The yellow zig-zag line traces the movement of a single particle.

NetLogo: A Simple Environment for Modeling Complexity

S. Tisue and U. Wilensky, 2004 International Conference on Complex Systems pdf13 citations in Scholar


leg.ufpr.br_pedro_figures_netlogo-graph.jpg

NetLogo is a multi-agent programming language and modeling environment for simulating complex phenomena. It is designed for both research and education […]. In this paper we focus on NetLogo as a tool for research and for teaching […]. We outline the principles behind our design and describe recent and planned enhancements.

No firm distinction is made between using a model and editing it—you can move, modify, or create interface elements at any time. Agents can be inspected and altered and the code for the model can be changed without restarting the simulation.

Finished models can be published on the web as Java applets.

NetLogo includes a still evolving tool called BehaviorSpace that allows “parameter sweeping,” that is, systematically testing the behavior of a model across a range of parameter settings.

The space is not fixed to a grid, one can use the turtles to represent nodes and edges in a network, as shown in the graph on the right. Networks can be read from external text files.

There are many language elements for talking about space and spatial relations: towards, distance, neighbors, forward and back, left and right, size, heading, patch-ahead, diffuse, and so on. Some of these come from Logo—others are new.

An important NetLogo language feature, not found in its predecessors, is “agentsets,” or collections of agents. For example, the set of all turtles and the set of all patches are agentsets. You can also make custom agentsets on the fly […]. Agentsets are responsible for much of NetLogo’s expressive power.

There is a model where particles move randomly in the space. The model starts with a central pixel colored with green. When a particle founds a green pixel, it dies and paint green the pixel where it is.

if any? neighbours with [pcolor = green]
  [ stamp green
    die ]

This model generates a branching aggregate, as we can see in the top figure of this page.

NetLogo: Where We Are, Where We’re Going

P. Blikstein, D. Abrahamson, and U. Wilensky, 2005 Proceedings of Interaction Design & Childrenpdf 5 citations in Scholar


leg.ufpr.br_pedro_figures_netlogo-classroom.jpg

NetLogo, a multi-agent cross-platform modeling-and-simulation environment, has been enhanced with new capabilities. We explain selected simulations from our Models Library and describe recent enhancements (e.g., 3D) and demonstrate extensions (e.g., music). We focus on HubNet, a technological infrastructure for facilitating participatory simulations, run these activities with participants, and discuss learning experiences afforded by these activities.

geopro/pedro/netlogo.txt · Última modificação: 2011/08/18 20:25 por pedro