|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.util.Observable
uk.ac.liv.auction.core.AuctionImpl
uk.ac.liv.auction.core.RoundRobinAuction
A class representing an auction in which RoundRobinTraders can trade by placing shouts in a synchronous round-robin shedule.
TraderAgents are notified that it is their turn to bid by invokation of the requestShout() method on each agent.
This class implements Runnable so auctions can be run as threads, e.g.:
Thread t = new Thread(auction);
t.start();
However, this class is not necessarily itself thread-safe.
This class is designed for high-performance lightweight simulation of auctions. Developers wishing to provide asynchronous auction functionality through, e.g. a web servlet, should either extend AuctionImpl or implement the Auction directly directly using the existing Auctioneer classes to provide the "bidding logic".
Parameters
| base.maximumrounds int >= 0 |
(the number of auction rounds) |
| base.maximumdays int >= 0 |
(the number of days in the auction) |
| base.lengthofday int >= 0 |
(the maximum number of rounds in a trading day) |
| base.auctioneer class, inherits uk.ac.liv.auction.core.Auctioneer |
(the auction protocol to use) |
| base.logger class, inherits uk.ac.liv.auction.stats.MarketDataLogger |
(the MarketDataLogger to use) |
| base.stats class, inherits uk.ac.liv.auction.stats.MarketStats |
(the MarketStats to use) |
| base.name string |
(the name of this auction) |
| base.agenttype.n int |
(the number of different agent types) |
| base.agenttype.i classname, inherits uk.ac.liv.auction.agent.RoundRobinTrader |
(the class for agent type #i) |
TradingAgent,
Serialized Form| Field Summary | |
protected java.util.HashSet |
acceptedShouts
The set of shouts that have been matched in the current round. |
protected java.util.LinkedList |
activeTraders
The collection of TraderAgents currently taking part in this auction. |
protected int |
age
|
protected int |
day
The current trading day (period) |
protected java.util.LinkedList |
defunctTraders
The collection of idle TraderAgents |
static java.lang.String |
ERROR_SHOUTSVISIBLE
|
protected AuctionConsoleFrame |
guiConsole
Optional graphical console |
protected int |
lengthOfDay
The maximum length in rounds of a trading day |
protected int |
maximumDays
The maximum number of trading days before the auction closes |
protected int |
maximumRounds
The maximum number of rounds in the auction. |
static java.lang.String |
P_AGENT_TYPE
|
static java.lang.String |
P_AUCTIONEER
|
static java.lang.String |
P_CONSOLE
|
static java.lang.String |
P_EVENTHANDLER
|
static java.lang.String |
P_LENGTH_OF_DAY
|
static java.lang.String |
P_MAXIMUM_DAYS
|
static java.lang.String |
P_MAXIMUM_ROUNDS
|
static java.lang.String |
P_NAME
|
static java.lang.String |
P_NUM_AGENT_TYPES
|
static java.lang.String |
P_NUM_AGENTS
|
static java.lang.String |
P_REPORT
|
static java.lang.String |
P_STATS
|
protected java.util.LinkedList |
registeredTraders
The collection of all TraderAgents registered in the auction. |
protected int |
round
The current round. |
protected boolean |
shoutsProcessed
Were any shouts processed (received & accepted) in the last round of trading? |
| Fields inherited from class uk.ac.liv.auction.core.AuctionImpl |
auctioneer, closed, eventListeners, id, lastAsk, lastBid, lastShout, name, report |
| Constructor Summary | |
RoundRobinAuction()
|
|
RoundRobinAuction(java.lang.String name)
Construct a new auction in the stopped state, with no traders, no shouts, and no auctioneer. |
|
| Method Summary | |
protected void |
activate(TradingAgent agent)
|
void |
activateGUIConsole()
Activate a graphical console for monitoring and controlling the progress of the auction. |
void |
begin()
|
void |
changeShout(Shout shout)
|
protected void |
checkEndOfDay()
Terminate the current trading day (period) if the auction is quiescent or the maximum time allowed for a period has expired. |
void |
clear(Shout ask,
Shout bid,
double trPrice)
Handle a single clearing operation between two traders |
void |
deactivateGUIConsole()
Deactivate the graphical console. |
void |
end()
|
protected void |
endDay()
Terminate the current trading period (day) |
void |
generateReport()
Generate a report. |
java.util.Iterator |
getActiveTraderIterator()
|
int |
getAge()
|
AuctionConsoleFrame |
getConsole()
|
int |
getDay()
|
Shout |
getLastAsk()
Get the last ask placed in the auction. |
Shout |
getLastBid()
Get the last bid placed in the auction. |
int |
getLengthOfDay()
|
int |
getMaximumDays()
|
int |
getMaximumRounds()
Return the maximum number of rounds for this auction. |
int |
getNumberOfRegisteredTraders()
Return the total number of traders registered in the auction. |
int |
getNumberOfTraders()
Return the number of traders currently active in the auction. |
int |
getRemainingTime()
Get the remaining time in the current trading day (period). |
int |
getRound()
Get the current round number |
java.util.Iterator |
getTraderIterator()
Return an iterator iterating over all traders registered (as opposed to actively trading) in the auction. |
void |
informRoundClosed()
|
protected void |
initialise()
|
boolean |
isQuiescent()
Returns true if no bidding activity occured in the latest auction round. |
void |
newShout(Shout shout)
Handle a new shout in the auction. |
void |
register(TradingAgent trader)
Register a new trader in the auction. |
void |
remove(TradingAgent trader)
Remove a trader from the auction. |
void |
requestShout(TradingAgent trader)
|
void |
requestShouts()
Invokes the requestShout() method on each trader in the auction, giving each trader the opportunity to bid in the auction. |
void |
reset()
Restore the auction to its original state, ready for another run. |
void |
run()
Runs the auction. |
void |
runSingleRound()
|
void |
setConsole(AuctionConsoleFrame console)
|
void |
setLengthOfDay(int lengthOfDay)
|
void |
setMaximumDays(int maximumDays)
|
void |
setMaximumRounds(int maximumRounds)
Set the maximum number of rounds for this auction. |
void |
setup(ec.util.ParameterDatabase parameters,
ec.util.Parameter base)
Initialise this object from a parameter database. |
boolean |
shoutAccepted(Shout shout)
Determines whether or not the given shout was matched in the current round of trading. |
void |
step()
|
protected void |
sweepDefunctTraders()
Remove defunct traders. |
boolean |
transactionsOccured()
Determines whether or not any transactions have occured in the current round of trading. |
| Methods inherited from class uk.ac.liv.auction.core.AuctionImpl |
addAuctionEventListener, addAuctionEventListener, addListener, addReport, close, closed, fireEvent, getAuctioneer, getLastShout, getName, getQuote, getReport, getReport, getResults, informAuctionClosed, informAuctionOpen, informEndOfDay, printState, recordShout, removeAuctionEventListener, removeAuctionEventListener, removeShout, setAuctioneer, setName, setReport, 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 |
protected java.util.LinkedList activeTraders
protected java.util.LinkedList defunctTraders
protected java.util.LinkedList registeredTraders
protected int round
protected int age
protected int maximumRounds
protected boolean shoutsProcessed
protected AuctionConsoleFrame guiConsole
protected int lengthOfDay
protected int day
protected int maximumDays
protected java.util.HashSet acceptedShouts
public static final java.lang.String P_MAXIMUM_ROUNDS
public static final java.lang.String P_MAXIMUM_DAYS
public static final java.lang.String P_REPORT
public static final java.lang.String P_AUCTIONEER
public static final java.lang.String P_NAME
public static final java.lang.String P_STATS
public static final java.lang.String P_LENGTH_OF_DAY
public static final java.lang.String P_NUM_AGENT_TYPES
public static final java.lang.String P_NUM_AGENTS
public static final java.lang.String P_AGENT_TYPE
public static final java.lang.String P_CONSOLE
public static final java.lang.String P_EVENTHANDLER
public static final java.lang.String ERROR_SHOUTSVISIBLE
| Constructor Detail |
public RoundRobinAuction(java.lang.String name)
name - The name of this auction.public RoundRobinAuction()
| Method Detail |
public void setup(ec.util.ParameterDatabase parameters,
ec.util.Parameter base)
Parameterizable
setup in interface Parameterizable
public void clear(Shout ask,
Shout bid,
double trPrice)
Auction
clear in interface Auction
public boolean shoutAccepted(Shout shout)
throws ShoutsNotVisibleException
shoutAccepted in interface AuctionShoutsNotVisibleException
public boolean transactionsOccured()
throws ShoutsNotVisibleException
transactionsOccured in interface AuctionShoutsNotVisibleExceptionpublic void register(TradingAgent trader)
public void remove(TradingAgent trader)
public void requestShouts()
public void requestShout(TradingAgent trader)
public void setMaximumRounds(int maximumRounds)
maximumRounds - The maximum number of roudns for this auction.public int getMaximumRounds()
public int getLengthOfDay()
public int getMaximumDays()
public int getNumberOfTraders()
getNumberOfTraders in interface Auctionpublic int getNumberOfRegisteredTraders()
public int getRound()
getRound in interface Auctionpublic int getAge()
public int getDay()
getDay in interface Auctionpublic int getRemainingTime()
Auction
getRemainingTime in interface Auction
public Shout getLastBid()
throws ShoutsNotVisibleException
ShoutsNotVisibleException
public Shout getLastAsk()
throws ShoutsNotVisibleException
ShoutsNotVisibleExceptionpublic void run()
run in interface java.lang.Runnablepublic void begin()
public void end()
public void step()
throws AuctionClosedException
AuctionClosedException
public void runSingleRound()
throws AuctionClosedException
AuctionClosedExceptionpublic void informRoundClosed()
public void newShout(Shout shout)
throws AuctionException
AuctionImpl
newShout in interface AuctionnewShout in class AuctionImplshout - The new shout in the auction.
AuctionException
public void changeShout(Shout shout)
throws AuctionException
AuctionExceptionpublic java.util.Iterator getTraderIterator()
public java.util.Iterator getActiveTraderIterator()
public boolean isQuiescent()
public void reset()
reset in interface Resetablereset in class AuctionImplpublic void generateReport()
public void activateGUIConsole()
public void deactivateGUIConsole()
public void setConsole(AuctionConsoleFrame console)
public AuctionConsoleFrame getConsole()
public void setLengthOfDay(int lengthOfDay)
public void setMaximumDays(int maximumDays)
protected void sweepDefunctTraders()
protected void initialise()
initialise in class AuctionImplprotected void activate(TradingAgent agent)
protected void checkEndOfDay()
protected void endDay()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||