Agent


Inherits From:
SwarmObject
Declared In:
Agent.h


Class Description

This is the abstract superclass of all agent classes; all agent classes must be direct or indirect descendants of this one.


Instance Variables

double demand;
double profit;
double wealth;
double position;
double cash;
double initialcash;
double minholding;
double mincash;
double intrate;
double intratep1;
double price;
double dividend;
int myID;

demandbid or -offer
profitexp-weighted moving average
wealthtotal agent wealth
positiontotal shares of stock
cashtotal agent cash position
initialcashNo description.
minholdingNo description.
mincashNo description.
intrateNo description.
intratep1No description.
priceNo description.
dividendNo description.
myIDNo description.


Method Types

+ setWorld:
- setID:
- setPosition:
- setintrate:
- setminHolding:minCash:
- setInitialCash:
- setInitialHoldings
- getPriceFromWorld
- getDividendFromWorld
- creditEarningsAndPayTaxes
- constrainDemand::
- getAgentPosition
- getWealth
- getCash
- prepareForTrading
- getDemandAndSlope:forPrice:
- updatePerformance


Class Methods

setWorld:

+ setWorld:(World *)aWorld

Sets a world for an agent. It is a class method as it is used in both class and instance methods in BFagent.


Instance Methods

constrainDemand::

- (double)constrainDemand:(double *)slope :(double)trialprice

Method used by agents to constrain their demand according to the mincash and minholding constraints.

It checks "demand" against the mincash and minholding constraints and clips it if necessary, then also setting *slope. For use within subclass implementations of getDemandAndSlope: forPrice:. Used only by agents that work with the Slope Specialist.


creditEarningsAndPayTaxes

- creditEarningsAndPayTaxes

No method description.


getAgentPosition

- (double)getAgentPosition

Return the agent's current position


getCash

- (double)getCash

Return the agent's current cash level


getDemandAndSlope:forPrice:

- (double)getDemandAndSlope:(double *)slope forPrice:(double)trialprce

This message is sent to each agent during bidding to ask for its bid (demand > 0) or offer (demand < 0) at price p. The agent may also return a value for d(demand)/d(price) through "slope", but this is not required; *slope may be left unchanged. This method may be called one or more times in each period, depending on the specialist method. The last such call is at the final trading price. The -prepareForTrading message is sent to each agent before the first such call in each period. Note that agents without demand functions return zero slope, but the Slope specialist is never used with these agents.

There is no default for this method in the Agent class; the agent subclasses MUST provide it.


getDividendFromWorld

- getDividendFromWorld

Sets an instance variable of agent, dividend, to the current dividend. That information is retrieved from the object known as "world".


getPriceFromWorld

- getPriceFromWorld

Sets an instance variable of agent, price, to the current price which is controlled by the object known as "world". Please note this assumes world is already set.


getWealth

- (double)getWealth

Return the agent's current wealth


prepareForTrading

- prepareForTrading

Sent to each enabled agent at the start of each trading period, before the first -getDemandAndSlope:forPrice: message for that agent. The class method +prepareForTrading: is sent to each type before any of these messages. This probably should have some subclassMustImplement code here, because the default code does nothing. It must be overridden


setID:

- setID:(int)iD

Gives an integer name to an agent during creation. Sometimes it helps with debugging to have a unique id for each agent


setInitialCash:

- setInitialCash:(double)initcash

Sets the initial cash holdings of each agent.


setInitialHoldings

- setInitialHoldings

Sets the initial stock holdings of each agent. It is the designated initializer. Most agent classes will have additional initialization, but should do [super setInitialHoldings] to run this first. It will initialize instance variables common to all agents, setting profit,wealth, and position equal to 0, and it sets the variable cash equal to initialcash


setPosition:

- setPosition:(double)aDouble

Sets the agent's position (holding) to "aDouble".


setintrate:

- setintrate:(double)rate

Sets the IVAR intrate and uses that to calculate intratep1 (intrate + 1).


setminHolding:minCash:

- setminHolding:(double)holding minCash:(double)minimumcash

Sets the borrowing and short selling constraints, i.e., the values can be negative. It sets values of the IVARS minholding and mincash


updatePerformance

- updatePerformance

Sent to each enabled agent at the end of each period to tell it to update its performance meaures, forecasts, etc. The default code does nothing, this method must be specified by each agent type. Probably needs a subclass responsibility statement


Version 1.1 Copyright ©2001. All Rights Reserved.