Only in ASM: .libs diff -ub ASM-Brandon/ASMBatchSwarm.h ASM/ASMBatchSwarm.h --- ASM-Brandon/ASMBatchSwarm.h Mon Apr 24 20:25:06 2000 +++ ASM/ASMBatchSwarm.h Sun May 7 12:43:34 2000 @@ -2,11 +2,8 @@ #import #import #import -#import -#import #import "ASMModelSwarm.h" - @interface ASMBatchSwarm: Swarm { int loggingFrequency; @@ -20,12 +17,12 @@ id output; } -+createBegin: (id)aZone; --buildObjects; --buildActions; --activateIn: (id)swarmContext; --go; --stopRunning; ++ createBegin: aZone; +- buildObjects; +- buildActions; +- activateIn: swarmContext; +- go; +- stopRunning; @end diff -ub ASM-Brandon/ASMModelSwarm.m ASM/ASMModelSwarm.m --- ASM-Brandon/ASMModelSwarm.m Mon Apr 24 20:25:06 2000 +++ ASM/ASMModelSwarm.m Sun May 7 12:43:34 2000 @@ -1,7 +1,8 @@ #import "ASMModelSwarm.h" #import #import "Output.h" -#import "random.h" +//#import "random.h" +#import #include @@ -39,7 +40,7 @@ obj->reb = 2.0; obj->randomSeed = 0; - //The BFagent sets these internally. + //BFagent lambda and initvar set internally obj->tauv = 50.0; obj->lambda = 0.3; obj->maxbid = 10.0; @@ -210,10 +211,16 @@ int i; /* Initialise random number stream (0 means set randomly) */ - randomSeed = randset(randomSeed); // returns actual seed if 0 + //pj + //randomSeed = randset(randomSeed); // returns actual seed if 0 + + if(randomSeed != 0) [randomGenerator setStateFromSeed: randomSeed]; + //pj: note I'm making this like other swarm apps. Same each time, new seeds only if precautions taken. + /* Initialize the dividend, specialist, and world (order is crucial) */ dividendProcess = [Dividend createBegin: [self getZone]]; + [dividendProcess initNormal]; [dividendProcess setBaseline: baseline]; [dividendProcess setmindividend: mindividend]; [dividendProcess setmaxdividend: maxdividend]; @@ -393,7 +400,6 @@ while ([[warmupSwarm getSwarmActivity] run] != Completed); } - void initPeriod (id initPeriodSchedule) { diff -ub ASM-Brandon/ASMObserverSwarm.h ASM/ASMObserverSwarm.h --- ASM-Brandon/ASMObserverSwarm.h Mon Apr 24 20:25:06 2000 +++ ASM/ASMObserverSwarm.h Sun May 7 12:43:34 2000 @@ -28,7 +28,7 @@ id volumeGrapher; id positionHisto; - //Histo *cashHisto; //A hisogram for agent cash holdings. + //Histo *cashHisto; //A histogram for agent cash holdings. id relativeWealthHisto; //This is for comparing different agents. But since there is diff -ub ASM-Brandon/BFagent.m ASM/BFagent.m --- ASM-Brandon/BFagent.m Mon Apr 24 20:25:06 2000 +++ ASM/BFagent.m Sun May 7 12:43:34 2000 @@ -64,12 +64,19 @@ // #import "BFagent.h" -#import "random.h" +#import #import "World.h" #include extern World *worldForAgent; +//pj: +//convenience macros to replace stuff from ASM random with Swarm random stuff + +#define drand() [uniformDblRand getDoubleWithMin: 0 withMax: 1] +#define urand() [uniformDblRand getDoubleWithMin: -1 withMax: 1] +#define irand(x) [uniformIntRand getIntegerWithMin: 0 withMax: x-1] + //Macros for bittables #define WORD(bit) (bit>>4) #define MAXCONDBITS 80 Common subdirectories: ASM-Brandon/CVS and ASM/CVS diff -ub ASM-Brandon/Dividend.h ASM/Dividend.h --- ASM-Brandon/Dividend.h Mon Apr 24 20:25:07 2000 +++ ASM/Dividend.h Sun May 7 12:43:34 2000 @@ -15,9 +15,13 @@ double gauss; double dvdnd; + + id normal; } -//These member functions just take parameters set in the ASMModelSwarm. +-initNormal; + + //These member functions just take parameters set in the -setBaseline: (double)theBaseline; -setmindividend: (double)minimumDividend; -setmaxdividend: (double)maximumDividend; @@ -25,7 +29,6 @@ -(int)setPeriod: (int)thePeriod; -setDerivedParams; -//The main member function. Sets the dividend. -(double)dividend; @end diff -ub ASM-Brandon/Dividend.m ASM/Dividend.m --- ASM-Brandon/Dividend.m Mon Apr 24 20:25:07 2000 +++ ASM/Dividend.m Sun May 7 12:43:34 2000 @@ -38,8 +38,8 @@ #import "Dividend.h" -#import "random.h" - +//#import "random.h" +#import //swarm library to get NormalDist #include #include @@ -49,7 +49,15 @@ @implementation Dividend -//All set members take parameters from the ASMModelSwarm upon creation. +//pj: new method +- initNormal +{ + + normal=[NormalDist create: [self getZone] setGenerator: randomGenerator setMean: 0 setVariance: 1]; + + return self; +} + -setBaseline: (double)theBaseline { baseline = theBaseline; @@ -104,8 +112,9 @@ rho = exp(-1.0/((double)period)); rho = 0.0001*rint(10000.0*rho); gauss = deviation*sqrt(1.0-rho*rho); - dvdnd = baseline + gauss*normal(); - + //pj: + //dvdnd = baseline + gauss*normal(); + dvdnd = baseline + gauss*[normal getDoubleSample]; return self; } @@ -118,8 +127,9 @@ * introduced to maintain phase when certain parameters are changed. */ { - dvdnd = baseline + rho*(dvdnd - baseline) + gauss*normal(); - + //pj: + // dvdnd = baseline + rho*(dvdnd - baseline) + gauss*normal(); + dvdnd = baseline + rho*(dvdnd - baseline) + gauss*[normal getDoubleSample]; if (dvdnd < mindividend) dvdnd = mindividend; if (dvdnd > maxdividend) diff -ub ASM-Brandon/Makefile ASM/Makefile --- ASM-Brandon/Makefile Mon Apr 24 20:25:07 2000 +++ ASM/Makefile Sun May 7 12:53:57 2000 @@ -1,9 +1,11 @@ ifeq ($(SWARMHOME),) -SWARMHOME=../swarm-1998-08-20 +SWARMHOME=/usr endif +APPVERSION=2.1 +BUGADDRESS=weber2@ssc.upenn.edu APPLICATION = asm OBJECTS = Agent.o BFagent.o Dividend.o World.o \ - random.o Specialist.o Output.o ASMModelSwarm.o \ + Specialist.o Output.o ASMModelSwarm.o \ ASMObserverSwarm.o ASMBatchSwarm.o main.o OTHERCLEAN = param.data_* output.data* DATAFILES = batch.setup param.data @@ -11,7 +13,7 @@ include $(SWARMHOME)/etc/swarm/Makefile.appl main.o: main.m ASMObserverSwarm.h Agent.h BFagent.h Dividend.h World.h \ - random.h Specialist.h Output.h ASMBatchSwarm.h + Specialist.h Output.h ASMBatchSwarm.h Agent.o: Agent.h Agent.m BFAgent.o: BFagent.h BFagent.m Dividend.o: Dividend.h Dividend.m @@ -19,7 +21,6 @@ ASMModelSwarm.o: ASMModelSwarm.h ASMModelSwarm.m Specialist.o: Specialist.h Specialist.m World.o: World.h World.m -random.o: random.h random.m ASMModelSwarm.o: ASMModelSwarm.h ASMModelSwarm.m ASMObserverSwarm.o: ASMObserverSwarm.h ASMObserverSwarm.m ASMBatchSwarm.o: ASMBatchSwarm.h ASMBatchSwarm.m diff -ub ASM-Brandon/Output.h ASM/Output.h --- ASM-Brandon/Output.h Mon Apr 24 20:25:07 2000 +++ ASM/Output.h Sun May 7 12:43:35 2000 @@ -1,5 +1,4 @@ // Artificial Stock Market Swarm Version Output File Interface -// This could use some help. #import #import diff -ub ASM-Brandon/World.h ASM/World.h --- ASM-Brandon/World.h Mon Apr 24 20:25:07 2000 +++ ASM/World.h Sun May 7 12:43:35 2000 @@ -40,7 +40,6 @@ +(const char *)nameOfBit: (int)n; +(int)bitNumberOf: (const char *)name; -//Set member functions take parameters from ASMModelSwarm. -setintrate: (double)rate; -setExponentialMAs: (BOOL)aBool; -(int)getNumWorldBits; diff -ub ASM-Brandon/World.m ASM/World.m --- ASM-Brandon/World.m Mon Apr 24 20:25:07 2000 +++ ASM/World.m Sun May 7 12:48:40 2000 @@ -105,7 +105,7 @@ #import "World.h" -#import "random.h" +#import #include #include @@ -115,6 +115,13 @@ // 1. Their computation in -makebitvector in this file. // 2. The PUPDOWBITNUM value. // 3. The NAMES documentation file -- do "market -n > NAMES". + +//pj: +//convenience macros to replace stuff from ASM random with Swarm random stuff + +#define drand() [uniformDblRand getDoubleSample] +#define urand() [uniformDblRand getDoubleWithMin: -1 withMax: 1] +#define irand(x) [uniformIntRand getIntegerWithMin: 0 withMax: x-1] static struct bitnamestruct {