MASON-INTEREST-L Archives

June 2015

MASON-INTEREST-L@LISTSERV.GMU.EDU

Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
Sadat Chowdhury <[log in to unmask]>
Reply To:
MASON Multiagent Simulation Toolkit <[log in to unmask]>
Date:
Mon, 15 Jun 2015 13:02:47 -0400
Content-Type:
text/plain
Parts/Attachments:
text/plain (45 lines)
I still have a lot of files to change, and have not actually run/tested with this new method — maybe it would throw the  ConcurrentModificationException, I don’t know yet.

I am going to look into MutableDouble — it makes more sense as far as accuracy goes. Thanks!


> On Jun 15, 2015, at 12:58 PM, Ernesto Carrella <[log in to unmask]> wrote:
> 
> You could try populating your SparseGrid2D with either an AtomicDouble or a MutableDouble from commons-lang. 
> That way you can modify them without pulling them out of the grid and putting them back in.
> 
> I am quite surprised it doesn't throw a ConcurrentModification exception since you are effectively looping through a list of objects that you are also modifying (with remove() and setLocation()). I suppose MASON passes a safe copy in that bag.
> 
> On Mon, Jun 15, 2015 at 5:23 PM Sadat Chowdhury <[log in to unmask]> wrote:
> Hi All,
> 
> When I increased the 2D world size of my system, there was a significant slowdown of the simulation. After I investigated using a profiler, it turned out to be due to methods that scan through 2D grids that in my system are defined as DoubleGrid2D.
> 
> I have started converting those DoubleGrid2D into SparseGrid2D — because it fits the description perfectly: the world can be potentially unbounded and most times there will be fewer actual objects in the world.
> 
> While it was relatively easy to convert all the parts that was setting and accessing objects in the grid — I am at a point where I have a lot of DoubleGrid2D’s that used full-scanning functions like .lowerBound() and .multiply(). Supposing I have a SparseGrid2D that has only one Double object per coordinate, what would be the most efficient (fast) way to implement a function similar to multiply() ?
> 
> This is what I have so far, but I am just wondering if it can be done more efficiently (faster)?
> 
>         final public void SparseGrid2DMultiply(SparseGrid2D theGrid,
>                         double multiplier) {
>                 /*
>                  * theGrid is assumed to contain one and only one Double in a given
>                  * coordinate
>                  */
>                 Bag objects = theGrid.getAllObjects();
>                 for (Object object : objects) {
>                         double val = (Double) object;
>                         if (val != 0.0) {
>                                 val = val * multiplier;
>                                 Int2D location = theGrid.getObjectLocation(object);
>                                 theGrid.remove(object);
>                                 theGrid.setObjectLocation(val, location);
>                         }
>                 }
> 
>         }
> 
> Any thoughts/comments is greatly appreciated,
> Sadat.

ATOM RSS1 RSS2