swarm-support
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Swarm-Support] shuffling a list


From: Corinne A. Coen
Subject: Re: [Swarm-Support] shuffling a list
Date: Tue, 25 Feb 2003 16:12:44 -0500 (EST)

Thanks for the example!
Corinne

On Tue, 25 Feb 2003, Paul E Johnson wrote:

> Date: Tue, 25 Feb 2003 13:48:34 -0600
> From: Paul E Johnson <address@hidden>
> Reply-To: address@hidden
> To: address@hidden
> Subject: Re: [Swarm-Support] shuffling a list
> 
> Swarm now has the List Shuffler class in it, so use that.
> 
> I used the shuffler to mix up a list in this model, look in ModelSwarm.m:
> 
> http://lark.cc.ku.edu/~pauljohn/Swarm/MySwarmCode/schelling-2.1.140.tar.gz
> 
> The usage is like this in my example model
> 
> - stepThroughList
> {
>    id shuffler = [ListShuffler create: self];
>    id <Index> index;
>    id anObject;
> 
> 
>    if (randomize == YES)
>      {
>        [shuffler shuffleWholeList: agentList];
>      }
> 
>    index = [agentList begin: self];
> 
>    for (anObject = [index next]; [index getLoc]==Member; anObject = 
> [index next])
>      {
>        [anObject step];
>      }
>    [shuffler drop];
>    [index drop];
>    return self;
> }
> 
> 
> 
> Corinne A. Coen wrote:
> > I have been unable to get any form of list shuffler to work.
> > 
> > I've downloaded Ted Belding's shuffler.tar.gz and included Shuffler.h and 
> > Shuffler.m into my model.  I've included this new object in my Makefile, 
> > created it in ModelSwarm.m
> > 
> > Since Ted's Shuffler involves a Shuffle.h and Shuffle.m file, I treated 
> > them like an additional object in my model.  I created Shuffle in 
> > ModelSwarm.m
> > 
> >   [Shuffler setModel: self];
> >   shuffler = [Shuffler create: globalZone];
> > 
> > In Shuffle.m, I set the model.. (of course, identifying the method in 
> > Shuffler.h)
> > 
> >   id model;
> > 
> >   @implementation Shuffler
> > 
> >   +(void) setModel: (id) m { model = m; }
> > 
> > I can compile the model, but when I run it, I get the following error 
> > message:
> > 
> > error: Shuffler (class)
> > Shuffler does not recognize setModel:
> > Aborted
> > 
> > So then I removed all of the "setModel" methods, and get the following 
> > complaint.
> > 
> > *** event raised for error: InvalidCombination
> > shuffler was created without a random
> > number generator.
> > *** execution terminating due to error
> > /home/pauljohn/LinuxDownloads/redhat/BUILD/swarm-2.1.107.20010925/src/defobj/Symbol.m:173
> >  
> > -[Error(c) _raiseEvent:]
> > Aborted
> > 
> > 
> > Finally, as an alternate approach, I tried using ListShuffler in 
> > collections.h.  Unfortunately, when I call  the list shuffler, it does not 
> > recognize the method described in the swarm documentation  (e.g., 
> > [ListShuffler shuffleWholeList: myList]). 
> > 
> > error: ListShuffler_c.Creating (class)
> > ListShuffler_c.Creating does not recognize shuffleWholeList:
> > Aborted 
> > 
> > Any ideas for me?
> > Corinne Coen
> > 
> > 
> > 
> > 
> > _______________________________________________
> > Support mailing list
> > address@hidden
> > http://www.swarm.org/mailman/listinfo/support
> 
> 
> 
> 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]