MASON-INTEREST-L Archives

July 2012

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:
Sean Luke <[log in to unmask]>
Reply To:
MASON Multiagent Simulation Toolkit <[log in to unmask]>
Date:
Fri, 20 Jul 2012 18:58:22 -0400
Content-Type:
multipart/mixed
Parts/Attachments:
text/plain (394 bytes) , Schedule.java (37 kB) , Repeat.java (37 kB) , RandomRepeat.java (37 kB) , text/plain (37 kB)
Okay, here's a first cut at an approach to allow repeats drawn from a distribution.  If there are certain very common distribution needs, we could make those built into the class, but for now you have to roll you own.

The revised code (which is NOT out on SVN) is attached.  The modified files are Schedule.java, Repeat.java, RandomRepeat.java, all of which should be placed into sim/engine/




Let's say you want to schedule something which repeatedly reschedules itself using the absolute value of a standard normal distribution, plus 1.0. You could say this: Steppable step = ... double initialTime = 5.0; int initialOrdering = 0; RandomRepeat repeat = new RandomRepeat(step, initialOrdering, false) // use 'true' if multithreaded { protected double getNextTime(SimState state, double currentTime) { return currentTime + Math.abs(state.random.nextGaussian()) + 1.0; } }; state.schedule.scheduleOnce(initialTIme, initialOrdering, repeat); This code was written at 12:50 at night and has not been tested or even tried. But there is a slight chance it might work right. Anyway, it's a first draft which uses an abstract superclass and anonymous subclass to get around the issue of a multitude of distribution APIs in sim.util.distribution. Opinions? Sean

ATOM RSS1 RSS2