swarm-support
[Top][All Lists]
Advanced

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

Re: Matters of taste or strategy?


From: Doug Donalson;
Subject: Re: Matters of taste or strategy?
Date: Fri, 5 Jun 1998 15:27:19 -0700 (PDT)

This message is supposed to go the the group, unlike one of my previous 
ones.

Point one:  I have used both create end and also used a message
I call firstEvent.  firstEvent is scheduled to each agent at
the start of the simulation.  It in turn does a lot of the
one time setup and then schedules all the initial asynchronous
events for the individual.  This gets me around the problem
of needing information for agents at creation that sometimes is not yet 
available.  For example, the case where an agent is created in
creatObjects but needs to know about a created in createActions.

Point 2:  I have a method I use that is slightly different, but I'm
not sure it's any better.  I chose a uniform random multiplied
by the [list getCount] and then use that to index into the list.

Then if you wanted to remove 1,000 you would just execute it 1000
times.  The nice thing is that it automatically adjusts for the
new list size.

Cheers (and apologies for the accidental SPAM of the list),

  D3

***************************************************************************
* Doug Donalson                          * Office: (805) 893-2962         *
* Ecology, Evolution, and Marine Biology * Home:   (805) 961-4447         *
* UC Santa Barbara                       * email address@hidden
* Santa Barbara Ca. 93106                *                                *
***************************************************************************
*                                                                         *
*   The most exciting phrase to hear in science, the one that             *
*   heralds new discoveries, is not "EUREKA" (I have found it) but        *
*   "That's funny ...?"                                                   *
*                                                                         *
*       Isaac Asimov                                                      *
*                                                                         *
***************************************************************************


On Fri, 5 Jun 1998 address@hidden wrote:

> 
> Two Swarm Modeling questions:
>  
>    
>   1. I've been comparing code in different programs and I wonder if you
> have ever considered this.  The CreateEnd code in an .m file can be
> used as a launching point for anything that has to be run only once in
> the life of the object.  So, instead of writing a setValue method
> in an object and then coding ModelSwarm at buildObjects time to execute
> the setValue method, the code that would have been inside the setValue
> can just be stuffed into createEnd instead.
> 
> It leads to some economical coding, but I wonder if it is "bad form" 
> in your eyes. 
> 
> For example, I want to create a random number generator to use inside
> an object.  I just put the code to create it in the createEnd method.
>   Example:
>  
> -createEnd {
>     worldXSize = [world getSizeX];
>     worldYSize = [world getSizeY];
>     aGenerator = [SWB1 create: [self getZone] setStateFromSeed: 23 ];
>     aNormalValue= [NormalDistribution create: [self getZone] 
>           setGenerator:  aGenerator
>           setMean: 0 setVariance: 1];   
>    return self;
> }
> 
> So, in this object, any methods can call values from aNormalValue.
> This saves me the trouble of writing another method for that object
> ("startRNG" and then going back to ModelSwarm and calling startRNG in
> the buildObjects phase).
> 
> I know in the sample swarm code projects that this use of createEnd is
> avoided, and I wonder why.  Is the problem that my approach is "not
> reusable" in other projects?
> 
>  2. Anybody create a nice way to randomly select members of a list? 
>   If I want to have some action committed on 1000 members out of a list
>   of 50000 objects, it seems there ought to be some easier way than
>   just cycling through the whole list of 50000, drawing a random
>   uniform for each one and picking that one if the random number is
>   less than 1/50.   
> 
>    Oh, well, just studying for fun!
> 
> -- 
> Paul E. Johnson                       email: address@hidden
> Dept. of Political Science            http://lark.cc.ukans.edu/~pauljohn
> University of Kansas                  Office: (913) 864-9086
> Lawrence, Kansas 66045                FAX: (913) 864-5700
> 
> 
>                   ==================================
>    Swarm-Support is for discussion of the technical details of the day
>    to day usage of Swarm.  For list administration needs (esp.
>    [un]subscribing), please send a message to <address@hidden>
>    with "help" in the body of the message.
>                   ==================================
> 

                  ==================================
   Swarm-Support is for discussion of the technical details of the day
   to day usage of Swarm.  For list administration needs (esp.
   [un]subscribing), please send a message to <address@hidden>
   with "help" in the body of the message.
                  ==================================


reply via email to

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