//Marcus Daniels June 18, 1999 swarm-support //MF> here is the part of my batchSwarm that is under //MF> question. Everything works fine (it writes data to file), except //MF> that in the .output file I got only 0s and 1s for the sequences,// //MF> whereas in the GUI mode they take their "reasonable" value that //MF> should fall between 0 and 1. // //Sorry, that code excerpt is not sufficient to reproduce the problem //you describe. // //Here is a complete test case extrapolated from your code excerpt. //Can you frob it to demonstrate the bad behavior you get? //If so, please report the change you make and facts about your system. #import #import #import #import #import #import #include #define PERSONCOUNT 100 @interface Native: SwarmObject - (double)getStrategyNF; - (double)getStrategyNN; @end @implementation Native - (double)getStrategyNF { return log (1.0 + getCurrentTime () * [uniformDblRand getDoubleWithMin: 1.0 withMax: 2.0]); } - (double)getStrategyNN { return log (1.0 + getCurrentTime () * [uniformDblRand getDoubleWithMin: 2.0 withMax: 3.0]); } @end @interface Foreigner: SwarmObject - (double)getStrategyFF; - (double)getStrategyFN; @end @implementation Foreigner - (double)getStrategyFF { return log (1.0 + getCurrentTime () * [uniformDblRand getDoubleWithMin: 4.0 withMax: 5.0]); } - (double)getStrategyFN { return log (1.0 + getCurrentTime () * [uniformDblRand getDoubleWithMin: 5.0 withMax: 6.0]); } @end @interface ModelSwarm: Swarm { id nativeList; id foreignerList; } + createBegin: aZone; - (id )getNativeList; - (id )getForeignerList; - (double)getXRatio; @end @implementation ModelSwarm + createBegin: aZone { ModelSwarm *obj = [super createBegin: aZone]; id l; unsigned i; l = [List create: aZone]; for (i = 0; i < PERSONCOUNT; i++) [l addLast: [Native create: aZone]]; obj->nativeList = l; l = [List create: aZone]; for (i = 0; i < PERSONCOUNT; i++) [l addLast: [Foreigner create: aZone]]; obj->foreignerList = l; return obj; } - (double)getXRatio { return [uniformDblRand getDoubleWithMin: 0.0 withMax: 1.0]; } - (id )getNativeList; { return nativeList; } - (id )getForeignerList { return foreignerList; } @end @interface DataCollectorSwarm: Swarm { id xGraph0; id modelSwarm; id schedule; id stopSchedule; } - buildObjects; - buildActions; - (void)stepGraph; - (id )activateIn: swarmContext; - (void)setupStopSchedule; - stop; @end @implementation DataCollectorSwarm - buildObjects { [super buildObjects]; modelSwarm = [ModelSwarm create: self]; xGraph0 = [EZGraph createBegin: self]; [xGraph0 setGraphics: swarmGUIMode]; [xGraph0 setFileOutput: !swarmGUIMode]; [xGraph0 setTitle: "My Graph"]; [xGraph0 setAxisLabelsX: "Time" Y: "Performance"]; xGraph0 = [xGraph0 createEnd]; [xGraph0 createSequence: "XRatio.output" withFeedFrom: modelSwarm andSelector:M(getXRatio)]; [xGraph0 createAverageSequence: "XAmongN.output" withFeedFrom: [modelSwarm getNativeList] andSelector:M(getStrategyNN)]; [xGraph0 createAverageSequence: "XNvsF.output" withFeedFrom: [modelSwarm getNativeList] andSelector:M(getStrategyNF)]; [xGraph0 createAverageSequence: "XFvsN.output" withFeedFrom: [modelSwarm getForeignerList] andSelector:M(getStrategyFN)]; [xGraph0 createAverageSequence: "XAmongF.output" withFeedFrom: [modelSwarm getForeignerList] andSelector:M(getStrategyFF)]; return self; } - buildActions { [super buildActions]; schedule = [Schedule createBegin: self]; [schedule setRepeatInterval: 1]; schedule = [schedule createEnd]; [schedule at: 0 createActionTo: self message: M(stepGraph)]; return self; } - (void)stepGraph { [xGraph0 step]; } - (id )activateIn: swarmContext { [super activateIn: swarmContext]; [schedule activateIn: self]; if (stopSchedule) [stopSchedule activateIn: self]; return [self getActivity]; } - (void)setupStopSchedule { stopSchedule = [Schedule create: self]; [stopSchedule at: 600 createActionTo: self message: M(stop)]; } - stop { [getTopLevelActivity () terminate]; return self; } @end @interface ObserverSwarm: GUISwarm { id displaySchedule; } - buildActions; - (id )activateIn: swarmContext; @end @implementation ObserverSwarm - buildActions { displaySchedule = [Schedule createBegin: self]; [displaySchedule setRepeatInterval: 1]; displaySchedule = [displaySchedule createEnd]; [displaySchedule createActionTo: actionCache message: M(doTkEvents)]; return self; } - (id )activateIn: swarmContext { [super activateIn: swarmContext]; [displaySchedule activateIn: self]; return [self getActivity]; } @end int main (int argc, const char **argv) { id dataCollectorSwarm, observerSwarm; initSwarm (argc, argv); dataCollectorSwarm = [DataCollectorSwarm create: globalZone]; [dataCollectorSwarm buildObjects]; [dataCollectorSwarm buildActions]; if (swarmGUIMode) { observerSwarm = [ObserverSwarm create: globalZone]; [observerSwarm buildObjects]; [observerSwarm buildActions]; [observerSwarm activateIn: nil]; [dataCollectorSwarm activateIn: observerSwarm]; [observerSwarm go]; } else { [dataCollectorSwarm setupStopSchedule]; [dataCollectorSwarm activateIn: nil]; [[dataCollectorSwarm getActivity] run]; } return 0; } /* Local Variables: compile-command: "/opt/gnu/bin/gcc -o ezgraph -g -Wno-import -L/opt/SUNWtcl/8.0/sun4/lib -R/opt/SUNWtcl/8.0/sun4/lib -L/opt/SDGblt/2.4g/lib -R/opt/SDGblt/2.4g/lib -L/opt/SDGlibffi/1.20/lib -R/opt/SDGlibffi/1.20/lib -L/opt/SDGswarm/1.4.1/lib -L/opt/SDGzlib/1.1.3/lib -L/usr/local/X11/lib -R/usr/local/X11/lib -L/usr/openwin/lib -R/usr/openwin/lib -L/opt/SDGhdf5/1.0.1/lib -I/opt/SDGswarm/1.4.1/include ezgraph.m -lanalysis -lsimtools -lsimtoolsgui -lactivity -ltkobjc -lrandom -lobjectbase -ldefobj -lcollections -lmisc -ltclobjc -ltk8.0 -ltcl8.0 -lBLT -lsocket -ldl -lnsl -L/usr/openwin/lib -lhdf5 -lpng -lz -lXpm -lX11 -lffi -lm -lobjc -lpthread -lposix4" End: */