LISTSERV mailing list manager LISTSERV 16.0

Help for MASON-INTEREST-L Archives


MASON-INTEREST-L Archives

MASON-INTEREST-L Archives


MASON-INTEREST-L@LISTSERV.GMU.EDU


View:

Message:

[

First

|

Previous

|

Next

|

Last

]

By Topic:

[

First

|

Previous

|

Next

|

Last

]

By Author:

[

First

|

Previous

|

Next

|

Last

]

Font:

Proportional Font

LISTSERV Archives

LISTSERV Archives

MASON-INTEREST-L Home

MASON-INTEREST-L Home

MASON-INTEREST-L  September 2016

MASON-INTEREST-L September 2016

Subject:

Re: "Interesting" behavior on simulation start.

From:

Sean Luke <[log in to unmask]>

Reply-To:

MASON Multiagent Simulation Toolkit <[log in to unmask]>

Date:

Mon, 5 Sep 2016 19:11:46 -0400

Content-Type:

text/plain

Parts/Attachments:

Parts/Attachments

text/plain (23 lines)

Allow me to jump in on this conversation very late, and without having read very well.  :-)

It sounds like your original concern was that the agents seem to be behaving strangely in the first step, and then work fine from then on.  But the conversation seems to have morphed into a discussion of proper use of random number generators.  I won't be able to look into your code regarding the original concern for a few days probably.  But let me weigh in on the random number generation discussion.

The rule of thumb with random number generators is as follows: unless you know exactly what you are doing, you should:

1. Seed a single random number generator

2. Only use that random number generator throughout your run

3. If you have multiple threads active, and ONLY if this is the case (because it is somewhat slow), then code in each thread should lock on SOMETHING before accesing the random number generator.  In MASON, that something is by convention the random number generator itself, that is,         synchronized (state.random) { return state.random.nextInt(n); }  etc.

And that's it.  Your agents are welcome to have pointers to the SimState RNG, but they should NOT have their own independent RNGs.  This is not because it's not possible to write perfectly cromulent code with agents having their own independent RNGs.  It's because with a high probability you will not write it correctly, and because there's absolutely no reason to do this in the first place.

Problem 1: seeding.  You have to seed each generator separately.  How are you going to do this?  You can't do it based on wall-clock time: they'll likely be synchronized.  You could seed them based on increasing steps beyond wall-clock time and that will PROBABLY work okay, but it's a major potential source of hard-to-debug errors.  For example, I'm guessing that you probably didn't pulse each of the Mersenne Twister RNGs about 1500 times to get rid of initial bad randomness in your seeding.  No one thinks of stuff like this.  You could also (as Joey said) seed them based on a random number generation from a master RNG.  This is called "forking" an RNG. Note that Mersenne Twister is NOT DESIGNED FOR FORKING.  It's not going to have statistically guarantees.  

Problem 2: memory.  Each of your agents now is holding onto an object that contains about 3K of RAM for no good reason.  If you have 1000 agents, that's 3 megs just for unneccessary RNGs.

This stuff has to be done delicately and in ways you probably didn't think of.  For example, the GUI has its own separate RNG to assign random colors etc. for GUI purposes so as not to pollute the underlying model RNG.

So here's what you should do.  Each of your agents should be given a pointer to the SimState (state), or to state.random, and just call SimState's RNG directly if they're all in the same thread.  And that's it.  You'll save memory, it'll be just as fast, and you'll dramatically reduce the chances that you've introduced RNG bugs.

Sean

Top of Message | Previous Page | Permalink

Advanced Options


Options

Log In

Log In

Get Password

Get Password


Search Archives

Search Archives


Subscribe or Unsubscribe

Subscribe or Unsubscribe


Archives

December 2017
November 2017
September 2017
June 2017
May 2017
March 2017
February 2017
January 2017
December 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
December 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
December 2013
November 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
December 2010
November 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
February 2010
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
December 2008
November 2008
October 2008
September 2008
August 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
April 2005
March 2005
February 2005
January 2005
December 2004
November 2004
October 2004
September 2004
July 2004
May 2004
April 2004
March 2004

ATOM RSS1 RSS2



LISTSERV.GMU.EDU

CataList Email List Search Powered by the LISTSERV Email List Manager