swarm-support
[Top][All Lists]
Advanced

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

Re: [Swarm-Support] Query regarding plotting a graph in Swarm.


From: Steve Railsback
Subject: Re: [Swarm-Support] Query regarding plotting a graph in Swarm.
Date: Wed, 22 Aug 2007 08:17:39 -0700
User-agent: Thunderbird 2.0.0.6 (Windows/20070728)

Kavita Gangal wrote:

hello,
i don't know how to plot a graph in Swarm.
I need to plot total population against time period and after every time period the graph should update itself.
Is any detailed documentation available abt the graphs and charts in Swarm?

Unfortunately, no, not beyond the reference guide. Example models like StupidModel are helpful.

I went through the Stupid Bug Model..

First of all the stupidModel15 is not working. It is asking for some external files.
Since no output is generated the code can't be tested.

There should be a file "Stupid_Cell.Data" packaged with the StupidModel15 code. I think it just needs to be in your working directory.

Also,
In the following "try" block from StupidObserverSwarm.java from StupidModel15 :
try {
            populationGraph.createCountSequence$withFeedFrom$andSelector
                ("Bug abundance", stupidModelSwarm.getBugList(),
new Selector (Class.forName ("stupidModel15.StupidBug"), "getMySize", false));
        } catch (NonUniqueMethodSignatureException e) {
            e.printStackTrace();
        } catch (SignatureNotFoundException e) {
            e.printStackTrace();
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }

1. a syntax error is produced with the third catch statement. How to remove that?

Does the class "stupidModel15.StupidBug" exist? (Is there still a class called "StupidBug" in a package named "stupidModel15"?)

If you are not working in Eclipse, you might not be required/allowed to include the package name "stupidModel15".

2.Can "CreateCountSequence$withFeedFrom$andSelector" method parameters be explained please?


Sure- (See the documentation for EZGraphImpl, in the swarm.analysis package in the JavaSwarm API http://www.swarm.org/swarmdocs-2.2/refbook-java/)

This method creates a new line on the EZGraph that:
 (1) is labeled "Bug abundance",
(2) "withFeedFrom" tells it the name of the collection of objects to get data from. Here, its data is from the collection "stupidModelSwarm.getBugList()". ("stupidModelSwarm.getBugList()" of course is a message to the model swarm to get its list of bug agents) (3) "andSelector" provides the selector to use to get the data from the agents in the collection. This selector provides the name of the method of the agents that returns the values you want plotted. However, here you are creating a "count" sequence, which only plots the number of agents in the collection. Therefore, you need to provide a selector for *some* method that the agents have, but it does not actually use the values returned by this method.
        If instead you wanted an "Average" sequence, this code:
             populationGraph.createAverageSequence$withFeedFrom$andSelector
                 ("Bug abundance", stupidModelSwarm.getBugList(),
                         new Selector (Class.forName
 ("stupidModel15.StupidBug"), "getMySize", false));

would create a line on the graph reporting the average size of the bugs in the model. ("getMySize" is a bug method that returns their size.)

Steve R.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]