swarm-support
[Top][All Lists]
Advanced

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

Re: not reading variables


From: Paul Johnson
Subject: Re: not reading variables
Date: Tue, 14 May 2002 08:09:22 -0500
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:0.9.9) Gecko/20020501

Stacy Oerder wrote:
Hi

I'm experiencing a problem reading in global variables(integers) into my
swarm from my .scm file.
I'm afraid some of the expert C programmers will see you say "global variables" and go berserk because global variables are bad. But I don't think you mean global in the C sense, you mean parameters in your grid.

> Once I've compiled my program and run it, it is
apparent that my variables set in the .scm file are read correctly into
my ModelSwarm file but they do not read in correctly in my bug and
foodspace files.
That seems odd to me, because when I have a mistake in the scm file, it is generally causing a segmentation fault.

I suspect the problem might be this. If you are working from a standard application like heatbugs, then that code has the command to read in the modelswarm parameters from the file. But when you create the foodspace, you need to read that in as well. But I bet you don't have a line which instructs that object to be loaded from a file. I mean something such as:

id archiver = [LispArchiver create: [self getZone] setPath: "my-lisp-file"];
 foodspace = [archiver getObject: "foodspace"];
 [archiver drop];

(fill in my-lisp-file with the name of your file).
Notice I'm not relying on any global objects to take care of my archiving because I don't know what all might be available. It is easy enough to create an archiver, have it load your foodspace, and kill it off.

Every object you want loaded has to be explicitly loaded in this way. Your Observer loads the modelswarm, the model probably has to load the others.

Now, if you run your model and put in commands to save the objects, such as, you will see what you need. This one creates the file name on the fly, but you can just put in some string and cut that. (It also talks to my parameters object, but you don't need that). If you put something like this in your model swarm and then cause it to run at some point, it will create the *scm file and let you see what is in there.

This one here does a shallow save on the model (shallow means save only ints, doubles, and other variables that are actually inside the model) but it does a deep save on my agent list (citizenList). Deep save will try to save objects within objects within objects. It can get really complicated, but it does work as long as all objects in side there have lispOutDeep: methods that make it work.

- lispArchive: (char *)inputName
{
  char dataArchiveName[100];
  if (!inputName)
snprintf(dataArchiveName,100,"%s%d-%s.scm","run",[parameters getRunArg],"blah");
  else
snprintf(dataArchiveName,100,"%s%d-%s.scm","run",[parameters getRunArg],inputName); id dataArchiver = [LispArchiver create: [self getZone] setPath: dataArchiveName];

  [dataArchiver putShallow: "model" object: self];
  [dataArchiver putDeep: "citizenList" object: citizenList];

  [dataArchiver putShallow: "parameters" object: parameters];

  [dataArchiver sync];
  [dataArchiver drop];

  return self;
}

I'm only bringin this up because saving a foodspace will generate a pretty massive file. It will save not only the original value of the food you were talking about last week, it will also try to save the entire lattice of current food values. I doubt your current *.scm file will have all that in there already. So I suggest having your program write an scm file so you can see what is supposed to be in there.



Oddly enough the one variable does read into the
foodspace, namely the amount of original food, but the world size does
not read in correctly. And again at my bug file the world size reads in
correctly but the value for the original food does not get read in. I
constantly get the value 0 for all other variables, that is the food to
be added as well as the world size for the two different files. Does
anyone have an idea why this seems to be happening? I am a newbie with
SWARM and am still coming to terms with the code.

Thanks in advance.
Stacy Oerder

                  ==================================
   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.



--
Paul E. Johnson                       email: address@hidden
Dept. of Political Science            http://lark.cc.ku.edu/~pauljohn
University of Kansas                  Office: (785) 864-9086
Lawrence, Kansas 66045                FAX: (785) 864-5700


                 ==================================
  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]