Print

Print


Trent Gordon wrote:

> Hey, I'm new to Mason, and agent simulation as a whole.  I have constructed
> a program that moves agents around relative to their distance to their
> closest neighbor bla bla bla.  The point is, these agents are continuously
> re-setting their edges to other, closer, neighbors.  I am trying to, in the
> long run, graph this on a histogram (to see how long certain agents link
> with others etc...) but am having extreme difficulty getting the inspectors
> to work as I'd like.  I extended the Edge class to my own so that I could
> use a setTo() method to alter the edge without re-initilizing it (otherwise
> I could NEVER follow it with an inspector because the agents change
> neighbors so rapidly).  This way, I am able to watch an edge for the entire
> program (every agent has only one edge leading away from them (though
> multiple, or none, coming to them).  

Thinking about your problem, I first have a question: are you just 
changing the to-value in the edge?  Or are you removing the edge from 
the network and then resubmitting it to the Network?

The Network class a hash table which contains, for each node, the edges 
going out of that node (plus some other information).  This is what 
MASON queries when it does dynamic updates.  Just changing the to and 
from values in the edge is not sufficient (and actually breaks the 
network).  Edge doesn't let you change its to and from values that way 
on purpose.

But your need is definitely without merit (assuming this is the issue). 
  I just tweaked Network and Edge to add a new updateEdge(...) method to 
Network which lets you change the to/from/info values in a safe manner 
and still reuse the edge.  I'm attaching the classes.  I can't promise 
they work (I'm in Graz Austria attending RoboCup right now so I can't do 
any testing).  Throw away your custom Edge class and use the updateEdge 
method instead and let us know if it does the job.



> *How do I get the histogram option on the inspector to un-gray itself?

Histograms only appear for the following things which can represent 
lists of numbers:

     <li>Any array of numerical values (byte[], int[], double[], etc.)
     <li>Any array of sim.util.Valuable
     <li>Any array of Numbers (Double[], Integer[], etc.)
     <li>Any sim.util.IntBag
     <li>Any sim.util.DoubleBag

Try doing a histogram on bugXPos in HeatBugs for example.  That's an 
array of ints.

Sean