Jan 28: Converting CSV to Netlogo Lists
Whenever I want to import data into Netlogo, I usually write a script to convert the file's formatting to be something that is Netlogo friendly before importing it. But so much data comes in CSV (comma separated value) format that it there should be an automatic file-read command for that. There isn't. In lieu of that I have the following two procedures that take care of this. Also note that this includes a Replace-All function for strings in Netlogo, which again it needs but mysteriously lacks.
Aug 16: Voronoi Countries in Netlogo
Another student in my ICPSR ABM workshop wanted to generate countries and have them interact via trade, conflict, assimilation, and splitting. He was new to Netlogo and only had enough time to build the behavior part of the model and couldn’t visualize the behaviors so I created this foundation for him. It provides basic functionality for those capabilities as well as a few others. It occurs to me that many people might need some basic country setup to get their IR model going. You can download my Voronoi Countries code example and use that to freely steal my code for your own use.
A student in my ICPSR ABM workshop was having trouble creating a networked interaction structure with particular properties and asked for my help. The problem was actually quite sophisticated. She needed a tree graph wherein she could specify both the total number of nodes and the number of terminal nodes for graphs of different depths (layers) but she wanted the overall structure to be as random as possible within those constraints. The problem was non-trivial, but I did manage to write a procedure to create precisely the graphs she needed…and now I'm sharing the method with the world. In addition to the examples and explanations below you can download my personal parameterized tree graph code example and use that to freely steal my code for your own use.
Aug 01: Showing the Underlying Grid
During my ICPSR 2009 ABM Workshop a student asked me if there is a way to reveal the underlying grid structure in Netlogo. My response was, "Yes, but it's not built in." The point is that in certain models the patches don't do anything, but to check movement and interaction rules are working properly it would sometimes be helpful so be able to measure distances by sight. Of course this might also be helpful even if the patches are displaying values. So in this post I provide two code snippets that allow one to see the gridspace made up of patches.
Typically when we explore the outputs of agent-based models we do a parameter sweep: change the values of the parameters according to some pre-defined scheme and take measurements of the outcome from each of those parameter sets. Typically our models are stochastic so we do multiple trials of each set of parameters. Similar approaches are used for many other modeling techniques (including deterministic ones) to measure sensitivities and generate comparative statics. This post focuses on an alternative to the standard parameter sweep that intelligently searches through the parameter space to find the regions where the outcome is most variable, i.e. the interesting parts.
Jun 13: Transparency in Netlogo 4.1
The newest version of Netlogo includes and much asked for (at least by me) feature: transparency! It applies to turtles (and it also applies to links and pens) and only for 2D models, but it's a great addition to the program. That said, there are some eccentricities in how one must use Netlogo's transparency features and I've worked out some these so you don't have to. What follows is some procedures you can include in your code to use transparency in the way that you should be able to use transparency...just like another turtle variable such as size or color. In addition to the examples and explanations below you can download my personal transparency code example and use that to freely steal my code for your own use.
There are several approaches to the genetic algorithm (GA) technique (e.g. variations in parameters, birth-death timing, encodings) and these differences typically affect the performance and outcome of the technique. There are some cases where the appropriateness of one variation is clearly better than others, but many more cases of a technique being chosen merely by convention or because something still must be done when there are no differentiating reasons. Part of the problem is that the differences generated by the variations in GA approach are things which are very difficult to measure with existing metrics: dynamical properties relating to the number and location of attractors, their relative basin sizes, the speed of convergence, etc. These are precisely the sorts of properties that I developed the tipping point methodology to be able to measure and so bringing it to bear on a few GA variations of a common problem may yield some valuable insights.
Aug 02: Markov Diagrams in Mathematica 6
In my upcoming paper on how to measure tipping points, robustness, and path dependence I plan to provide examples in the form of illustrations. Since the technique uses Markov modeling to measures these properties of system dynamics my illustrations are (not surprisingly) going to be Markov diagrams that provide examples of the definitions and applications of the algorithms. Eventually I will create software in Java to run these analyses and these will produce a visual output; so one option is to build that software now and use screenshot for my diagrams. The problem is that it is quite hard to get java to output exactly what I want and have it look the way I want it. My answer came in the form of Mathematica 6.
Nov 29: Hex in NetLogo
Early in my agent-based modeling training I fell in love with the idea of hexagonal-tiled discrete spaces (rather than square-tiled). One of my first projects (done with Ken as a matter of fact) was to implement the famous AntPheromones model on a hex grid. For some bizarre reason (perhaps problems in implementation) hex is not commonly used despite its expansive list of known benefits. Support for hex in Repast was/is bad, very bad, and we had to rewrite and correct several buggy methods for that project. Support for hex in NetLogo is worse (see code samples). This post aims to fill this niche in NetLogo by providing a framework for hex-based (cellular automata or free-roaming agent-based) models.
Bioengineering has begun a kind of revolution. DNA sequencing and synthesis has developed to the point where researches can build short strands of specifically designed DNA with very low error rates. The ability to utilize abstraction hierarchies can now be used to fabricate biological systems in a manner akin to early electronic systems engineering. There are two points to make here: 1) this is not a real revolution because this is just applying standard linear techniques to biosystems and is not rethinking anything; biofab does not harness the power of biology to the degree that evolving systems will (whenever Ken gets around to it). 2) Insofar as abstraction hierarchy fabrication will allow engineers to specialize on system design and hence more quickly invent and mass produce useful devices it constitutes a major leap in the applicability of the technology. Realizing the benefits of (2) I see no reason why we shouldn't implement the same technique for agent-based models.