swarm-support
[Top][All Lists]
Advanced

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

easier way to monitor a sequence from ezgraph?


From: Paul E Johnson
Subject: easier way to monitor a sequence from ezgraph?
Date: Thu, 10 Jan 2002 14:22:10 -0600
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:0.9.5) Gecko/20011014

Dear Swarmish folk.

Today I decided I wanted a simulation to stop when an indicator in an EZGraph reached a certain value. And when the model stops, I want a pixmap of the EZGraph. (Hence I asked earlier about things at quit time).


SO I figured how to use probes! (Big Personal Breakthrough there, eh.) Anyway, I create a sequence and probe into it to get the averager object out of it, and then schedule so that when the value reaches 0, the sim stops. Here's how I did it:

id nchanges; //an averager object grabbed out of sequence

 {
    [opinionGraph createSequence: "Opinion = YES"
                      withFeedFrom:  [modelSwarm getInfluenceGrid]
                       andSelector: M(getPctTypeOne)];
                
    {
      id aseq = [opinionGraph createAverageSequence: "Opinion Changed"
                  withFeedFrom: [modelSwarm getCitizenList]
                  andSelector: M(getChanged)];
      id probe = [VarProbe createBegin: self];
      [probe setProbedClass: [aseq getClass]];
      [probe setProbedVariable: "averager"];
      probe = [probe createEnd];
      nchanges = (Averager *) [probe probeAsPointer: aseq];
    }
}

I've checked and getAverage calls to nchanges do get answers.

This seemed like a long way around the castle to find out the current value of a sequence object. Is there an easier way to do it in the current Swarm? If not, what would be the objections against me digging into the Swarm source and adding an IVAR to any sequence called "currentValue" or something and a method "getCurrent" to retrieve it?


Oh, one more thing. This is a numerical thing. I remember Ted Belding's caution about checking floating point numbers for equality. If you wanted a simulation to end when the average is 0, how likely with there be trouble if I compare a double against 0:

if ([nchanges getAverage] == 0)

Is it a one-in-ten problem or a one-in-one-million problem ?

--
Paul E. Johnson                       email: address@hidden
Dept. of Political Science            http://lark.cc.ukans.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]