swarm-support
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

a technique for managing lots of configurable parameters


From: Nelson Minar
Subject: a technique for managing lots of configurable parameters
Date: Wed, 9 Jul 1997 01:22:40 +0200

Inspired by a nice dinner with Benedikt at Fészek Müvész Klub Étterem,
an artist's club near Blaha Ljusa Ter, I set about to improve my life
demoing Sugarscape models.

The way I'm implementing Sugarscape I have a whole bunch of different
simulations in one program. Versions with old age, versions with sex,
versions with culture, etc. Anytime you want to reproduce an
experiment in their book you have to go in and set about 10 different
parameters to make the model go right. This is error prone and a real pain.

Borrowing a technique from the BatchSwarm examples, I rigged my
GUISwarm interactive system to also read parameters from a file. It
works like this: you start Swarm, up pop the friendly probe windows.
The ObserverSwarm now has a new variable, "parameterFile", which is
set to (null) by default. If the user types in a filename then an
ObjectLoader is invoked to set simulation parameters. 

The neat thing is that the ObjectLoader only overwrites the parameters
actually specified in the file. Ie: I can set some things visually,
then press "go" and it will load in the rest from a file. The
interface is still a bit funky (it'd be better if the file were read
when the program started, but then you don't have a place to change
the filename), but overall it's quite nice.

It's simple to do. The key idea is to put this code in your
ObserverSwarm startup:

  // Set our state to stopped - this code also waits until the user
  // clicks "go" so he has a chance to change parameters.
  [controlPanel setStateStopped];

  // Great - now we've read the parameters from the user, we can override them
  if (parameterFile) {
    char name[256];
    sprintf(name, "parameters/%s.model", parameterFile);
    [ObjectLoader load: modelSwarm fromFileNamed: name];
    sprintf(name, "parameters/%s.obs", parameterFile);
    [ObjectLoader load: self fromFileNamed: name];
  }
  
  // Now build the model swarm
  [modelSwarm buildObjects];

(some extra lines included for context). If the parameterFile variable
is set, then we use that to read in two files - one for the model
swarm, one for the observer. Ie, if the user types "foo" as a
parameter file, then my program reads "parameters/foo.model" and
"parameters/foo.obs".)

It works pretty well.


PS: Confidential to Dr. Langton. You should have sent me to Budapest
when I worked for you, I've gotten more done here with Swarm in a week
than I did a month at a time in Santa Fe :-)

                  ==================================
   Swarm-Support is for discussion of the technical details of the day
   to day usage of Swarm.  For list administration needs (esp.
   [un]subscribing), please send a message to <address@hidden>
   with "help" in the body of the message.
                  ==================================


reply via email to

[Prev in Thread] Current Thread [Next in Thread]