edu.cuny.cat.market.accepting
Class StandingAverageBeatingAcceptingPolicy

java.lang.Object
  extended by edu.cuny.cat.market.AuctioneerPolicy
      extended by edu.cuny.cat.market.accepting.ShoutAcceptingPolicy
          extended by edu.cuny.cat.market.accepting.OnlyNewShoutDecidingAcceptingPolicy
              extended by edu.cuny.cat.market.accepting.StandingAverageBeatingAcceptingPolicy
All Implemented Interfaces:
AuctionEventListener, edu.cuny.config.param.Parameterizable, edu.cuny.obj.Resetable

public class StandingAverageBeatingAcceptingPolicy
extends OnlyNewShoutDecidingAcceptingPolicy

This accepting policy compares a shout with the average price of the existing shouts on the same side and allows the shout to place only if it is no less competitive than the average. It also uses a parameter, ratio, to loose or tighten the restriction by adding the product of ratio and the variance to the average. When ratio is positive, it looses the restriction, while when it is negative, it tightens the restriction. This policy should be distinguished from SlidingMatchedAverageBeatingAcceptingPolicy. SlidingMatchedAverageBeatingAcceptingPolicy averages prices of matched shouts, while this policy averages prices of standing shouts.

Parameters

base.ratio
double (0 by default)
(a factor to adjust the restriction threshold by how many variances)

Version:
$Revision: 1.5 $
Author:
Jinzhong Niu

Nested Class Summary
protected  class StandingAverageBeatingAcceptingPolicy.ShoutAverageTracker
          tracks the average price of shouts on one side of the market.
 
Field Summary
protected  StandingAverageBeatingAcceptingPolicy.ShoutAverageTracker askAverageTracker
           
protected  StandingAverageBeatingAcceptingPolicy.ShoutAverageTracker bidAverageTracker
           
static java.lang.String P_RATIO
           
protected  double ratio
           
 
Fields inherited from class edu.cuny.cat.market.accepting.ShoutAcceptingPolicy
P_DEF_BASE
 
Fields inherited from class edu.cuny.cat.market.AuctioneerPolicy
auctioneer
 
Constructor Summary
StandingAverageBeatingAcceptingPolicy()
           
 
Method Summary
 void check(Shout shout)
          accepts all shouts that are no less competitive than the average of standing shouts from the same side, or IllegalShoutException is thrown otherwise.
 void eventOccurred(AuctionEvent event)
           
 double getRatio()
           
 StandingAverageBeatingAcceptingPolicy.ShoutAverageTracker getShoutAverage(boolean isAsk)
           
 void reset()
          resets the state to be the same as the policy is created and initialized.
 void setRatio(double ratio)
           
 void setup(edu.cuny.config.param.ParameterDatabase parameters, edu.cuny.config.param.Parameter base)
           
 java.lang.String toString()
           
 
Methods inherited from class edu.cuny.cat.market.accepting.OnlyNewShoutDecidingAcceptingPolicy
check
 
Methods inherited from class edu.cuny.cat.market.AuctioneerPolicy
getAuctioneer, initialize, setAuctioneer
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

P_RATIO

public static final java.lang.String P_RATIO
See Also:
Constant Field Values

askAverageTracker

protected StandingAverageBeatingAcceptingPolicy.ShoutAverageTracker askAverageTracker

bidAverageTracker

protected StandingAverageBeatingAcceptingPolicy.ShoutAverageTracker bidAverageTracker

ratio

protected double ratio
Constructor Detail

StandingAverageBeatingAcceptingPolicy

public StandingAverageBeatingAcceptingPolicy()
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
Overrides:
setup in class AuctioneerPolicy

reset

public void reset()
Description copied from class: AuctioneerPolicy
resets the state to be the same as the policy is created and initialized.

Specified by:
reset in interface edu.cuny.obj.Resetable
Overrides:
reset in class AuctioneerPolicy

getRatio

public double getRatio()
Returns:
ratio

setRatio

public void setRatio(double ratio)
Parameters:
ratio -

getShoutAverage

public StandingAverageBeatingAcceptingPolicy.ShoutAverageTracker getShoutAverage(boolean isAsk)
Parameters:
isAsk -
Returns:
the shout average tracker requested

check

public void check(Shout shout)
           throws IllegalShoutException
accepts all shouts that are no less competitive than the average of standing shouts from the same side, or IllegalShoutException is thrown otherwise.

Specified by:
check in class OnlyNewShoutDecidingAcceptingPolicy
Parameters:
shout - the shout being checked.
Throws:
IllegalShoutException
See Also:
OnlyNewShoutDecidingAcceptingPolicy.check(edu.cuny.cat.core.Shout)

eventOccurred

public void eventOccurred(AuctionEvent event)
Specified by:
eventOccurred in interface AuctionEventListener
Overrides:
eventOccurred in class AuctioneerPolicy

toString

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