MASON-INTEREST-L Archives

June 2005

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:
"glen e. p. ropella" <[log in to unmask]>
Reply To:
MASON Multiagent Simulation Toolkit <[log in to unmask]>
Date:
Thu, 9 Jun 2005 13:22:32 -0700
Content-Type:
text/plain
Parts/Attachments:
text/plain (40 lines)
Sean Luke wrote:
>> public Bag agents;  // filled with parents and children
>> public void step() {
>>    agents.shuffle(this.random);
>>    for (int agentNdx=0 ; agentNdx<agents.numObjs ; agentNdx++ ) {
>>       schedule.scheduleOnce(agents.objs[agentNdx]);
>>    }
>> }
>
>
> FWIW, there's a tool which does this already: RandomSequence.

Does RandomSequence work for dynamic data structures?  It appears from
the code:

-------------------
     public Steppable[] steps;
[...]
         for(int x=steps.length-1; x>0 ; x--)
             {
             int i = (shouldSynchronize ?
                nextInt(state,x+1) : state.random.nextInt(x+1));
             temp = steps[i];
             steps[i] = steps[x];
             steps[x] = temp;
             }
         super.step(state);
--------------------

that we're using a fixed size array.  And if that's the case, I'd have
to recreate the RandomSequence at each cycle, thereby defeating the
purpose.  But, perhaps I'm just not looking deep enough.  To resize an
array, you'd have to replace the old Sequence instance variable with a
new array (with the new size), right?

--
glen e. p. ropella              =><=                Hail Eris!
H: 503-630-4505                       http://ropella.net/~gepr
M: 503-971-3846                        http://tempusdictum.com

ATOM RSS1 RSS2