swarm-support
[Top][All Lists]
Advanced

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

Re: [Swarm-Support] simple scheduling question


From: Paul Johnson
Subject: Re: [Swarm-Support] simple scheduling question
Date: Mon, 09 May 2005 10:09:09 -0500
User-agent: Mozilla Thunderbird 1.0.2-1.3.2 (X11/20050324)

You can have more than one schedule. It seems it should not be necessary to set the repeat interval 5 and then add the action group 5 times. Just create an action group with trucks & cargo and set the repeat interval to 1 and add that action group.

For each of the separate types that repeat every 5 timesteps, create a separate schedule that repeat every 5 times, and then "layer them on" at the appropriate times. As long as you use "activateIn" properly, the actions from the various schedules will get layered on in the proper (barring you have not done something unusual to randomize concurrent actions).


There are some working examples on schedules, maybe you can see some patterns that will help. I have been pointing and clicking in here

http://www.ku.edu/~pauljohn/SwarmFaq/WorkingExampleCode/

It appears to me this one is almost exactly what you want:

http://www.ku.edu/~pauljohn/SwarmFaq/WorkingExampleCode/objc/ScheduleStartTimeXRepeat.txt

Other interesting ones

http://www.ku.edu/~pauljohn/SwarmFaq/WorkingExampleCode/objc/Schedule_SeparateTrials.txt

http://www.ku.edu/~pauljohn/SwarmFaq/WorkingExampleCode/objc/SchedulingPeriodicSwarms.txt

In that directory, there are many examples.

To be honest, I think the easiest thing to do is just create 2 schedules, one that repeats every time, and one every 5th time, and then write a separate method in the ModelSwarm for each class (markets, retailers,suppliers) like

- manageRetailers
{
        //whatever they have to do every time they act
}

and then throw that  on your long term schedule

 [schedule at: 4 createActionTo: self message: M(manageRetailers)];

I think this one is fun too!

http://www.ku.edu/~pauljohn/SwarmFaq/WorkingExampleCode/objc/ScheduleTimeOfDay.txt




Jurgen van der Pol wrote:
Hi,

I can't quite grasp/get the hang of the Swarm scheduling mechanism. What I want is the following (repeated) activity schedule in my supply chain model (fixed width font, tabbed, * == 'do your thing'):

time            t    t+1    t+2    t+3    t+4
-----------------------------------
trucks        *    *    *    *    *    // swarm objects representing trucks
cargo        *    *    *    *    *    // swarm objects representing cargo
market - * - - - // swarm object representing (the) market(s) retailer - - * - - // swarm object representing (a) retailer(s) manufacturer - - - * - // swarm object representing (a) manufacturer(s) supplier - - - - * // swarm object representing (a) supplier(s)


I've managed it (after various different approaches, including multiple schedules/actiongroups) via the following set-up (in Modelswarm.m):

//***********************
- buildActions
{
// put each group (trucks+cargo, market, retailer, manufacturer, supplier)
    // in separate ActionGroups + M(do-your-thing)
    modelActions = [ActionGroup create: self];
[modelActions createActionForEach: truckList message: M(goTrucks)]; [modelActions createActionForEach: cargoList message: M(checkState)]; marketActions = [ActionGroup create: self]; [marketActions createActionForEach: marketList message: M(goMarket)];

    retailerActions = [ActionGroup create: self];
[retailerActions createActionForEach: retailerList message: M(goRetailer)];

    manufacturerActions = [ActionGroup create: self];
[manufacturerActions createActionForEach: manufacturerList message: M(goManufacturer)];

      supplierActions = [ActionGroup create: self];
[supplierActions createActionForEach: supplierList message: M(goSupplier)];

    // next, combine all ActionGroups into ONE modelSchedule
    // and play around with setRepeatInterval and such
    modelSchedule = [Schedule createBegin: self];
      [modelSchedule setRepeatInterval: 5];
      modelSchedule = [modelSchedule createEnd];
[modelSchedule at: 0 createAction: modelActions]; // trucks & cargo at t [modelSchedule at: 1 createAction: modelActions]; // trucks & cargo at t+1 [modelSchedule at: 2 createAction: modelActions]; // trucks & cargo at t+2 [modelSchedule at: 3 createAction: modelActions]; // trucks & cargo at t+3 [modelSchedule at: 4 createAction: modelActions]; // trucks & cargo at t+4

    [modelSchedule at: 1 createAction: marketActions]; // market at t+1
[modelSchedule at: 2 createAction: retailerActions]; // retailer at t+2 [modelSchedule at: 3 createAction: manufacturerActions]; // manufacturer at t+3 [modelSchedule at: 4 createAction: supplierActions]; // supplier at t+4

    return self;
}

//***********************
- activateIn: swarmContext
{
    // only one schedule to activate
    [super activateIn: swarmContext];
    [modelSchedule activateIn: self];
    return [self getSwarmActivity];
}
//***********************


...But I feel that there must be a more elegant solutions? How do I elegantly tell agents to 'skip a beat', in a way, anyway?

Much obliged for any insights...

Cheers,
Jurgen van der Pol
Tilburg University


P.S. Looking forward to Turin!

_______________________________________________
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]