Print

Print


It looks like it should be okay for the moment, but doesn't

protected abstract double getNextTime(SimState state, double currentTime);

force the user to make use of Mason's random number generator, which
if I recall only supports uniform and Gaussian distributions? Granted,
you can use those to generate random variates of other types, but I'm
not sure what the performance impact might be.

I might be wrong on that assumption though.




On Fri, Jul 20, 2012 at 7:58 PM, Eric 'Siggy' Scott <[log in to unmask]> wrote:
> I find this acceptable.
>
> It's true, however, that the need for this behavior is quite common -- so
> eventually it would be nice to have a more unified/integrated solution, IMO.
> That may require rolling out own distributions library, though.
>
> Siggy
>
> On Fri, Jul 20, 2012 at 6:58 PM, Sean Luke <[log in to unmask]> wrote:
>>
>> 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
>>
>>
>
>
>
> --
> Ph.D. Student in Computer Science
> Volgenau School of Engineering
> George Mason University
>