swarm-support
[Top][All Lists]
Advanced

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

customized probe setting actions


From: Rick Riolo
Subject: customized probe setting actions
Date: Wed, 28 May 1997 12:19:54 -0400 (EDT)

One nice feature of swarm is that one can 'play' with a model
to rapidly gain intuitions about its dynamics by running a swarm 
model in GUI mode, occassionally pausing (STOPping on the GUI) using 
probes to change instance variables (eg model parameters, object IVs)
and then running the model some more.

This feature would be even nicer, I think, if one could have
a record of all the changes one made during the run, so that
one could at the least know what one had done, or even better
be able to automatically re-run a 
particular history that was especially interesting.

I have hacked a way to do this, which may or may not be
a good, swarm-OO solution, but which works.
Basically I put a hook in VarProbe so that if the application
stores the SEL of a custom method in the VarProbe, that message
is sent to the object being probed whenever the VarProbe is used
to change the probed IV in that object. 
In particular, I changed VarProbe just a bit, giving it an IV
  SEL setMethod;
and a method:
  -setSetMethod: (SEL) aMethod;
which I can use to assign a method to a VarProbe.
I changed (in VarProbe.m) the 
  -(int) setData: (id) anObject ToString: (const char *) s;
method so that after it stores a value into the probed IV,
if there is a non-nil setMethod, the VarProbe sends that message to the
object containing the IV being probed:
  if ( setMethod ) 
     [anObject perform: setMethod with: self with: s];
The method assigned to setMethod writes the model time,
the IV and the new value to a report file.
That much gives me a record of the changes done during the run.
Finally, I have some codes to read in a report file when
the model is started, find all those lines in the report which 
record changes made to IV's during the run via probes, 
and then schedule those changes to IVs at the record times.

So....my question is:
Is there a better way to do this?
If so, how?
In either case, could a way to do this be incorporated
into the next version of swarm so that we can achieve my
original goal, i.e, be able to record changes made via probes
during the course of a run.

One other way I thought of doing this:
Just change the 
  -(int) setData: (id) anObject ToString: (const char *) s;
method so that it asks the object being probed if it
has a method setMyVar: ie a method to set the IV called myVar.
If so, rather than finding the offset and writing directly
to it (as setData:ToString: does now), it calls the method
provided by the user.
(In fact, I thought I read somewhere once that in fact swarm
did something like that, which is why swarm encouraged the
standarization of setMyVar method names.)

thanks for any advice, comments, etc.

 - r

Rick Riolo                       address@hidden
Program for Study of Complex Systems (PSCS)
1061 Randall Lab     University of Michigan
Ann Arbor MI 48109-1120
http://pscs.physics.lsa.umich.edu/PEOPLE/rlr-home.html


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