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: Paul E Johnson
Subject: Re: [Swarm-Support] shuffling a list
Date: Tue, 25 Feb 2003 13:48:34 -0600
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.0.1) Gecko/20020918

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



--
Paul E. Johnson                       email: address@hidden
Dept. of Political Science            http://lark.cc.ku.edu/~pauljohn
1541 Lilac Lane, Rm 504
University of Kansas                  Office: (785) 864-9086
Lawrence, Kansas 66044-3177           FAX: (785) 864-5700



reply via email to

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