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 12:22:14 -0400
Content-Type:
text/plain
Parts/Attachments:
text/plain (32 lines)
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