Banking

Modeling cellular automaton with StarLogo

When Justin James learned that StarLogo TNG 1.0 was released, it brought back fond memories of a project in college. He recounts how he used StarLogo software to model a scientific theory.

 

One of the most interesting projects I have ever worked on was in college. I was taking a fascinating course called "The Philosophy of Science" in which we learned a lot about evolutionary game theory and other scientific/mathematic techniques of testing theories. (You can check out the current syllabus on the Rutgers Web site.)

My project was to use software to model a scientific theory in order to test it. I ended up using a package called StarLogo. StarLogo's latest incarnation, StarLogo TNG 1.0, was just released, so I thought I would share my experiences with the older version.

The assignment: Test Gordon's theory

I was assigned to read Ants at Work: How an Insect Society is Organized by Deborah Gordon. Then, I had to model the central hypothesis of the book as precisely as possible in software, and see if implementing the theory as described in software would result in a close approximation to what was being studied.

Gordon theorizes there is no centralized management of ant colonies and that ants release pheromones indicating what task they are performing. When an idle ant detects a "work pheromone," they follow the chemical trail and try to perform the same type of work. It is an elegant theory that neatly fit the observed behavior.

As a result, the model that I followed was a cellular automaton system. In such a model, there is no "master program" that controls things, but a number of independent agents that all run the same code (or agents grouped by "species"). Each agent is essentially its own program, and you study the interactions of the agent with other agents and the environment.

StarLogo provided a framework for this project. It established the idea of a "world" composed of "patches" (think of pixels in a bitmap) that could be assigned properties. The "agents" were called "turtles" (due to its roots in Logo) and were given code to execute. It also provided UI elements, including sliders to adjust environmental factors, a pause/play button, output windows, and visual display of the patches. When running, it operated in iterations; the main routine of each turtle was run once per iteration, and any actions that were taken were executed simultaneous, so each turtle made their decisions in an identical environment.

The result: A flaw in the theory

Using StarLogo, I discovered that Gordon's theory had a critical flaw. It was essentially a perpetual motion machine, but nothing was providing the initial energy. In other words, if all ants do what other ants are doing, they all remain idle unless one ant starts doing something for some reason external to the model. By modifying my code to simulate an artificial stimulus (having a random number of ants at start up automatically be assigned a task), I resolved the problem, and the model worked precisely as expected.

StarLogo was a great tool for this kind of work. It freed me from having to worry about any of the programming other than modeling the relationship between the ants and their world (the turtles and patches). It was also a snap to hook the UI elements to the model. Overall, the documentation was good enough to get me going.

Check out StarLogo TNG

I haven't looked at StarLogo much since then, but I stayed on the mailing list. So, when I saw that version 1.0 of StarLogo TNG was released, it sparked this flood of good memories.

If you have a need for a modeling tool like this, go ahead and give StarLogo TNG a look.

J.Ja

Disclosure of Justin's industry affiliations: Justin James has a working arrangement with Microsoft to write an article for MSDN Magazine. He also has a contract with Spiceworks to write product buying guides.

---------------------------------------------------------------------------------------

Get weekly development tips in your inbox Keep your developer skills sharp by signing up for TechRepublic's free Web Developer newsletter, delivered each Tuesday. Automatically subscribe today!

About

Justin James is the Lead Architect for Conigent.

6 comments
myrdhrin
myrdhrin

Logo was my second programming language I learned at age 12... right after GWBasic. Brings a lot of good memories... and mostly brings back to mind the reason why I got into computer science in the first place (a mathematics manual with an example of a program that would learn)

bcarpent1228
bcarpent1228

i do some modeling for a group that attempts to predict behavioral patterns in specific groups -using a code model from CodeProject (VStudio - cellular automata). Biggest problems are instability and flexibility (i am constantly revising the program). Maybe this program will remove these problems and reduce my (as yet unpaid for) work.

Justin James
Justin James

Have you ever had to do any simulations or modeling in code? What did you use to do it? J.Ja

Justin James
Justin James

I know a number of people who got their first taste of computers with Logo, and attribute their career path directly to it. I encountered Logo briefly, in 6th grade (Apple ]['s connected to Lego's with Logo), but I had already had my taste before that. :) J.Ja

myrdhrin
myrdhrin

The closest I came from doing real simulation was through a homegrown Rule Engine to assist data entry operators when working on some mainframes. Altough the whole simulation and AI part of the field got me in computer science I kept a bit away from it playing mostly in finance and business processes and documents. That being said, I strongly believe in programming simple behaviors that once added up together provides for very rich systems. I did that on a few very complex project I was involved with and the end result is that very little code is "changed", behaviors are either removed or added. The best part is that the system ends up covering situations where you did not think of any "specific" rules but still behaves correctly :-) (very interesting when modeling business processes)

Justin James
Justin James

I would say that the majority of the people I know who went into IT for more than just a career were motivated by similar experiences. Yet none of us get to do this stuff on the job. A lot of us do it at home for fun. Weird how that works, isn't it? A bit sad, too. J.Ja

Editor's Picks