NetLogo banner

 Home
 Download
 Help
 Resources
 Extensions
 FAQ
 References
 Contact Us
 Donate

 Models:
 Library
 Community
 Modeling Commons

 User Manuals:
 Web
 Printable
 Chinese
 Czech
 Japanese

  Donate

NetLogo User Community Models

(back to the NetLogo User Community Models)

EditedCode-CarCruise

by Abha Trivedi (Submitted: 05/09/2016)

[screen shot]

Download EditedCode-CarCruise
If clicking does not initiate a download, try right clicking or control clicking and choosing "Save" or "Download".(The run link is disabled because this model uses external files.)

## WHAT IS IT?

This is a proof of concept for including GIS into NetLogo for a dynamic Car Cruising model within the Santa Fe downtown area.

A project was defined for two summer interns, Simran McKenna and Dayoung Jung by Santa Fe Economic Development Inc, under the guidance of Stephen Guerin of the RedfishGroup in collaboration with Santa Fe's Community Development Division and the city police. I helped out evaluating NetLogo's capabilities for importing a GIS image and executing a model with sufficient performance

The background map of the model is the result of converting GIS data for downtown Santa Fe NM into an image, initally 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. Note that 9.9999 was converted to/from 9 as a space saving stunt for performance gains. See http://backspaces.net/hacks/23/netlogo-cruising-model for a blog entry on the topic.

Finally, the model itself simply manages many 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. It chooses its next location by seeing if it should turn as just described, or by choosing a forward direction in a set of increasing angles of forward cones. NOTE: See mail lists for newer way to do this via a reporter returning agent-sets within a cone of given degree. It will have considerably better performance.

That said, the fact we get such reasonable performance pushing NetLogo to its limits is quite a testimonal for NetLogo!

## HOW IT WORKS

The agents are initialized to be on a street at a random location. They then use a simple move-forward proceedure to choose a reasonable next location.

## HOW TO USE IT

Choose a number of cars. Then click setup then go.

## THINGS TO NOTICE

That it works at all is quite surprising, at least to me! This suggests we can start pushing NetLogo into GIS oriented models using simple patch level heuristics.

## THINGS TO TRY

Not much .. its pretty limited.

## EXTENDING THE MODEL

Good homework would be to figure out how to have cars handle one way streets, crowding, street repair and so on. Also, different speeds might be interesting.

## NETLOGO FEATURES

Tiny patches => Maps.

## RELATED MODELS

(models in the NetLogo Models Library and elsewhere which are of related interest)

## CREDITS AND REFERENCES

Edited few old style code syntax which are as follows
1) Changed the variable name "ticks"
2) use of foreach statement
3) concatanation of strings
4) changed declaration of local variables
5) changed one-of instead of random-one-of to select a random agent from an agentset.
6) Use of reporter max-pxcor instead of screen-edge-x for maximum x-coordinate

MIT License Copyright (C) 2004, Owen Densmore, Stephen Guerin and RedfishGroup

(back to the NetLogo User Community Models)