edu.cuny.cat.trader.marketselection
Class AbstractMarketSelectionStrategy

java.lang.Object
  extended by java.util.Observable
      extended by edu.cuny.cat.trader.marketselection.AbstractMarketSelectionStrategy
All Implemented Interfaces:
edu.cuny.config.param.Parameterizable, edu.cuny.obj.Resetable
Direct Known Subclasses:
AdaptiveMarketSelectionStrategy, RandomMarketSelectionStrategy, StaticMarketSelectionStrategy

public abstract class AbstractMarketSelectionStrategy
extends java.util.Observable
implements edu.cuny.config.param.Parameterizable, edu.cuny.obj.Resetable

An abstract market selection strategy, the super class of all the implementations of market selection strategy.

Version:
$Revision: 1.25 $
Author:
Kai Cai

Field Summary
protected  java.util.SortedSet<java.lang.Integer> activeMarkets
          active specialists' indices in markets from which this strategy will choose one daily
protected  AbstractTradingAgent agent
          the trading agent that plays this strategy
protected  int currentMarketIndex
          the index of selected specialist in markets.
protected  java.util.Map<Specialist,java.lang.Integer> marketIndices
          mapping from specialists to their indices in markets
protected  Specialist[] markets
          the complete list of specialists including active and inactive ones
 
Constructor Summary
AbstractMarketSelectionStrategy()
           
 
Method Summary
protected  void addActiveSpecialist(Specialist specialist)
           
 void eventOccurred(AuctionEvent event)
           
 Specialist getCurrenMarket()
           
 boolean hasValidCurrentMarket()
           
 void initialize()
           
 void registerMarket()
          requests to register with the specialist returned from getCurrenMarket().
 void reset()
           
abstract  void selectMarket()
          selects a specialist from the list of active ones in the game, which is stored in activeMarkets.
 void setAgent(AbstractTradingAgent agent)
          sets up the trading agent that plays this strategy.
 void setup(edu.cuny.config.param.ParameterDatabase parameters, edu.cuny.config.param.Parameter base)
           
protected  void setupMarkets(java.util.Collection<Specialist> marketColl)
          initiates specialists traders may register with in the game.
 java.lang.String toString()
           
 
Methods inherited from class java.util.Observable
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChanged
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

agent

protected AbstractTradingAgent agent
the trading agent that plays this strategy


markets

protected Specialist[] markets
the complete list of specialists including active and inactive ones


activeMarkets

protected java.util.SortedSet<java.lang.Integer> activeMarkets
active specialists' indices in markets from which this strategy will choose one daily


marketIndices

protected java.util.Map<Specialist,java.lang.Integer> marketIndices
mapping from specialists to their indices in markets


currentMarketIndex

protected int currentMarketIndex
the index of selected specialist in markets.

Constructor Detail

AbstractMarketSelectionStrategy

public AbstractMarketSelectionStrategy()
Method Detail

setup

public void setup(edu.cuny.config.param.ParameterDatabase parameters,
                  edu.cuny.config.param.Parameter base)
Specified by:
setup in interface edu.cuny.config.param.Parameterizable

initialize

public void initialize()

reset

public void reset()
Specified by:
reset in interface edu.cuny.obj.Resetable

eventOccurred

public void eventOccurred(AuctionEvent event)

addActiveSpecialist

protected void addActiveSpecialist(Specialist specialist)

setupMarkets

protected void setupMarkets(java.util.Collection<Specialist> marketColl)
initiates specialists traders may register with in the game.

Parameters:
marketColl - the collection of specialists participating in the game

selectMarket

public abstract void selectMarket()
selects a specialist from the list of active ones in the game, which is stored in activeMarkets.


registerMarket

public void registerMarket()
requests to register with the specialist returned from getCurrenMarket().


getCurrenMarket

public Specialist getCurrenMarket()
Returns:
the specialist selected to register for the current day if one is chosen; or null if none selected.

hasValidCurrentMarket

public boolean hasValidCurrentMarket()
Returns:
true if a specialist is chosen to register with or false otherwise.

setAgent

public void setAgent(AbstractTradingAgent agent)
sets up the trading agent that plays this strategy.

Parameters:
agent -

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object