[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: My Proposed EZGraph patch
From: |
Marcus G. Daniels |
Subject: |
Re: My Proposed EZGraph patch |
Date: |
17 Jan 2001 20:08:42 -0800 |
User-agent: |
Gnus/5.070084 (Pterodactyl Gnus v0.84) Emacs/20.4 |
>>>>> "PJ" == Paul E Johnson <address@hidden> writes:
PJ> I do not yet know what is necessary to make this change show up on
PJ> the Java side. Perhaps Marcus will give me a pointer if some work
PJ> is necessary.
All that is required is a rebuild. I've made a patch like yours
to get -setUnsignedArg: in EZSequence & EZAverageSequence. It's in
today's snapshot and today's DLLs.
Here's a test case/demo:
import swarm.Globals;
import swarm.simtoolsgui.GUISwarmImpl;
import swarm.defobj.Zone;
import swarm.activity.Activity;
import swarm.objectbase.Swarm;
import swarm.activity.Schedule;
import swarm.activity.ScheduleImpl;
import swarm.analysis.EZGraphImpl;
import swarm.analysis.EZGraph;
import swarm.analysis.EZSequence;
import swarm.Selector;
import java.util.LinkedList;
import java.util.List;
public class TestEZGraph extends GUISwarmImpl {
EZSequence sequence, averagingSequence;
class Agent {
double value;
Agent (double value) {
this.value = value;
}
void newValue () {
value = Globals.env.uniformDblRand.getDoubleWithMin$withMax (.1, 1);
}
public double getAgentValue (int scale) {
return value * scale;
}
}
List list;
Schedule schedule;
EZGraph ezgraph;
Agent standaloneAgent;
TestEZGraph (Zone aZone) {
super (aZone);
}
void addValueToList () {
double v = Globals.env.uniformDblRand.getDoubleWithMin$withMax (.1, 1);
list.add (new Agent (v));
}
public Object step () {
standaloneAgent.newValue ();
addValueToList ();
sequence.setUnsignedArg (Globals.env.getCurrentTime ());
averagingSequence.setUnsignedArg (Globals.env.getCurrentTime () - 20);
ezgraph.step ();
getActionCache ().doTkEvents ();
return this;
}
public Object buildObjects () {
super.buildObjects ();
list = new LinkedList ();
addValueToList ();
standaloneAgent = new Agent (1.0);
ezgraph = new EZGraphImpl (getZone (), "setUnsignedArg Demo",
"t", "prob.",
"ezgraph");
try {
Selector sel = new Selector (Agent.class,
"getAgentValue",
false);
sequence =
ezgraph.createSequence$withFeedFrom$andSelector ("standalone",
standaloneAgent,
sel);
averagingSequence =
ezgraph.createAverageSequence$withFeedFrom$andSelector ("av(list)",
list,
sel);
} catch (Exception e) {
e.printStackTrace (System.err);
System.exit (1);
}
return this;
}
public Object buildActions () {
super.buildActions ();
schedule = new ScheduleImpl (getZone (), 1);
try {
Selector sel = new Selector (getClass (), "step", false);
schedule.at$createActionTo$message (0, this, sel);
} catch (Exception e) {
e.printStackTrace (System.err);
System.exit (1);
}
return this;
}
public Activity activateIn (Swarm swarmContext) {
super.activateIn (swarmContext);
schedule.activateIn (this);
return getActivity ();
}
static void main (String []args) {
Globals.env.initSwarm ("TestEZGraph", "0.0", "address@hidden", args);
TestEZGraph ezgraphTest = new TestEZGraph (Globals.env.globalZone);
ezgraphTest.buildObjects ();
ezgraphTest.buildActions ();
ezgraphTest.activateIn (null);
ezgraphTest.go ();
}
}
==================================
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.