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