[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Initializing Averager in Java?
From: |
Marcus G. Daniels |
Subject: |
Re: Initializing Averager in Java? |
Date: |
26 Jul 2001 16:25:58 -0600 |
User-agent: |
Gnus/5.070084 (Pterodactyl Gnus v0.84) Emacs/20.7 |
>>>>> "TW" == Tom Wainwright <address@hidden> writes:
TW> I can't figure out how to set the collection for an Averager in Java.
Usually an Averager is created via an EZGraph, but it can be used
directly, as well. An Averager is just a special kind of MessageProbe.
The main thing is it requires the more-complicated phase switching idioms.
import swarm.analysis.Averager;
import swarm.analysis.AveragerC;
import swarm.analysis.AveragerCImpl;
import swarm.analysis.AveragerImpl;
import swarm.defobj.Zone;
import swarm.Globals;
import swarm.Selector;
import java.util.List;
import java.util.LinkedList;
class Agent {
public double value;
Agent (double value) {
this.value = value;
}
public double getAgentValue () {
return value;
}
}
public class TestAverager {
TestAverager (Zone aZone) {
List l = new LinkedList ();
l.add (new Agent (1.0));
l.add (new Agent (2.0));
l.add (new Agent (3.0));
l.add (new Agent (4.0));
AveragerC averagerC = new AveragerCImpl (new AveragerImpl ());
averagerC.createBegin (aZone);
try {
Selector sel = new Selector (Agent.class, "getAgentValue", false);
averagerC.setProbedSelector (sel);
} catch (Exception e) {
e.printStackTrace (System.err);
System.exit (1);
}
averagerC.setCollection (l);
Averager averager = (Averager) averagerC.createEnd ();
averager.update ();
System.out.println (averager.getAverage ());
}
static void main (String args[]) {
Globals.env.initSwarm ("TestAverager", "0.0", "address@hidden",
args);
new TestAverager (Globals.env.globalZone);
}
}
==================================
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.
- Re: Instantiating multiple ModelSwarms, (continued)
- Re: Instantiating multiple ModelSwarms, Paul E Johnson, 2001/07/18
- Re: Instantiating multiple ModelSwarms, Marcus G. Daniels, 2001/07/18
- RE: Instantiating multiple ModelSwarms, Fred Wan, 2001/07/24
- Re: Instantiating multiple ModelSwarms, Marcus G. Daniels, 2001/07/24
- Re: Instantiating multiple ModelSwarms, Paul E Johnson, 2001/07/24
- Re: Instantiating multiple ModelSwarms, Marcus G. Daniels, 2001/07/24
- Re: Instantiating multiple ModelSwarms, Paul E Johnson, 2001/07/24
- Re: Instantiating multiple ModelSwarms, Marcus G. Daniels, 2001/07/24
- RE: Instantiating multiple ModelSwarms, Fred Wan, 2001/07/25
- Initializing Averager in Java?, Tom Wainwright, 2001/07/26
- Re: Initializing Averager in Java?,
Marcus G. Daniels <=
- Re: Initializing Averager in Java?, Tom Wainwright, 2001/07/26
- Forte for java as java IDE, William T. Stockhausen, 2001/07/27
- Re: Forte for java as java IDE, Marcus G. Daniels, 2001/07/27
- Forte for java as java IDE--Yes!, William T. Stockhausen, 2001/07/27
- Re: Forte for java as java IDE--Yes!, James, 2001/07/27
- NetBeans free Forte works (was Re: Forte for java as java IDE--Yes!, pauljohn, 2001/07/27
- Re: NetBeans free Forte works (was Re: Forte for java as java IDE--Yes!, Marcus G. Daniels, 2001/07/27
- Re: NetBeans free Forte works (was Re: Forte for java as java IDE--Yes!, pauljohn, 2001/07/27
- Re: NetBeans free Forte works (was Re: Forte for java as java IDE--Yes!, Marcus G. Daniels, 2001/07/27
- Re: Initializing Averager in Java?, Paul E Johnson, 2001/07/27