Inherits From:
Declared In:

Class Description

BFParams is a class that holds parameter values that might be needed by several classes, principally, BFagent, BFCast, or BitVector. This class is currently designed so that, if one wants the values of the variables here to be individualized, then each agent can be created with its own instance of BFParams. A lot of the really complicated stuff that used to be in BFagent is now divided between this class and BitVector.

This particular version of BFParams has the forecast monitoring up to 16 bits of information. In the init method, the names of which 16 bits might be monitored are listed explicitly by name. Then the World object is asked for the bit number of each name, one-by-one. That sequential process fills up the array bitlist. As a result, it is a bit difficult to maintain this code and I wish there were an easy way out of this. But I didn't find it yet (2001-11-01)

It got to be tedious and boring to maintain getX methods, one for each instance variable, so if other classes want values out of this class, they can use either of 2 routes. Both are used in BFagent.m, just to keep up the variety. One way is the standard Objective-C method to obtain instance variable values, the -> operator. Look for usages like "privateParams->lambda". The other is a more Swarm oriented probe mechanism. Notice the functions at the top of the file BFParams.m, like getInt() and getDouble(). To get the lambda parameter, one can say getDouble(privateParams,"lambda"). Either of these works, and it frees us from the need to constantly add and edit get methods when we add or change instance variables in here.

Symbolic Constants



Macro Definitions



Instance Variables

int numfcasts;
int condwords;
int condbits;
int mincount;
int gafrequency;
int firstgatime;
int longtime;
int individual;
double tauv;
double lambda;
double maxbid;
double bitprob;
double subrange;
double a_min,a_max;
double b_min,b_max;
double c_min,c_max;
double a_range,b_range,c_range;
double newfcastvar;
double initvar;
double bitcost;
double maxdev;
double poolfrac;
double newfrac;
double pcrossover;
double plinear;
double prandom;
double pmutation;
double plong;
double pshort;
double nhood;
double genfrac;
double gaprob;
int npool;
int nnew;
int nnulls;
int *bitlist;
double *problist;
int npoolmax;
int nnewmax;
int ncondmax;

numfcastsnumber of forecasts maintained by this agent
condwordsnumber of words of memory required to hold bits
condbitsnumber of conditions bits are monitored
mincountminimum number of times forecast must be used to become active
gafrequencyhow often is genetic algorithm done?
firstgatimeafter how many time steps is the genetic algorithm done
longtimeunused time before Generalize() in genetic algorithm
individualNo description.
tauvNo description.
lambdaNo description.
maxbidNo description.
bitprobNo description.
subrangefraction of min-max range for initial random values
a_maxmin and max for p+d coef
b_maxmin and max for div coef
c_maxmin and max for constant term
c_rangeNo description.
newfcastvarvariance assigned to a new forecaster
initvarvariance of overall forecast for t<200
bitcostpenalty parameter for specificity
maxdevmax deviation of a forecast in variance estimation
poolfracfraction of rules in replacement pool
newfracfraction of rules replaced
pcrossoverprobability of running Crossover().
plinearlinear combination "crossover" prob.
prandomrandom from each parent crossover prob.
pmutationper bit mutation prob.
plonglong jump prob.
pshortshort (neighborhood) jump prob.
nhoodsize of neighborhood.
genfracfraction of 0/1 bits to generalize
gaprobderived: 1/gafrequency
npoolderived: replacement pool size
nnewderived: number of new rules
nnullsunnused bits
bitlistdynamic array, length condbits
problistdynamic array, length condbits
npoolmaxNo description.
nnewmaxNo description.
ncondmaxNo description.

Method Types

- init
- getBitListPtr
- copyBitList:Length:
- getProbListPtr
- copyProbList:Length:
- copy:

Instance Methods


- (BFParams *)copy:(id <Zone>)aZone

Create a copy of this BFParams instance. Note this copies EVERY instance variable, one by one


- (void)copyBitList:(int *)p Length:(int)size

if passed a pointer to an array of integers of length size, this frees the old bitlist and puts the new one in its place


- (void)copyProbList:(double *)p Length:(int)size

if passed a pointer to a double with a given size, this frees the old bitlist and puts the new one in its place


- (int*)getBitListPtr

No method description.


- (double *)getProbListPtr

No method description.


- init

Init does an awful lot of work for the BFParam object. It takes note of the number of condition bits that can be used and allocates space. It also uses a special function ReadBitname to access the World object to find out which bit in the World represents which piece of information.

Following ASM-2.0, this version of BFParams has condbits set equal to 16 bits. In the World, all possible bits are maintained, and one can ask for an attribute of the market history by a descriptive name like 'pr/d>1/4' and get back the integer value indicating which bit in the world keeps that information. The integer keys for the moitored bits then get translated into the forecast's instance variable bitlist, an an array of integers. Whenever the BFagent needs to make sure than a forecast is up to date, it takes that bitlist and checks the conditions against the state of the world for the monitored bits.

Again following ASM-2.0, we have here forecasts that only use a relatively small part of the world, 16 bits. These particular BFCasts monitor 10 bits which measure the size of price*interest/dividend, 4 more indicators of the change in moving averages of prices for various widths of the moving average, and two "dummy" bits fill out the array.

It is possible to revise this method to allow monitoring of more bits. To add more bits, it is necessary to change the condbits instance variable and then write out the names of some variables to be monitored inside this init method. As long as the number condbits is correct, then the init method should recalculate the amount of storage required. In future revisions of ASM, a cleanup and revision of this design should be a top priority.

Another issue to consider is the assumption that all forecasts used by an agent will use a subset of a given set of bits from the world. Probably it would be better to put a bitlist into each forecast, and completely de-couple the forecasts.

Version 1.1 Copyright ©2001. All Rights Reserved.