|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectuk.ac.liv.auction.core.FourHeapShoutEngine
This class provides auction shout management services using the 4-Heap algorithm. See:
"Flexible Double Auctions for Electronic Commerce: Theory and Implementation" by Wurman, Walsh and Wellman 1998.
All state is maintained in memory resident data structures and no crash recovery is provided.
| Field Summary | |
protected org.apache.commons.collections.buffer.PriorityBuffer |
bIn
Matched bids in ascending order |
protected org.apache.commons.collections.buffer.PriorityBuffer |
bOut
Unmatched bids in descending order |
protected static AscendingShoutComparator |
greaterThan
|
protected static DescendingShoutComparator |
lessThan
|
protected org.apache.commons.collections.buffer.PriorityBuffer |
sIn
Matched asks in descending order |
protected org.apache.commons.collections.buffer.PriorityBuffer |
sOut
Unmatched asks in ascending order |
| Constructor Summary | |
FourHeapShoutEngine()
|
|
| Method Summary | |
java.util.Iterator |
askIterator()
Return an iterator that non-destructively iterates over every ask in the auction (both matched and unmatched). |
java.util.Iterator |
bidIterator()
Return an iterator that non-destructively iterates over every bid in the auction (both matched and unmatched). |
int |
displaceHighestMatchedAsk(Shout ask)
|
int |
displaceLowestMatchedBid(Shout bid)
|
protected int |
displaceShout(Shout shout,
org.apache.commons.collections.buffer.PriorityBuffer from,
org.apache.commons.collections.buffer.PriorityBuffer to)
|
Shout |
getHighestMatchedAsk()
Get the highest matched ask. |
Shout |
getHighestUnmatchedBid()
Get the highest unmatched bid. |
Shout |
getLowestMatchedBid()
Get the lowest matched bid |
Shout |
getLowestUnmatchedAsk()
Get the lowest unmatched ask. |
java.util.List |
getMatchedShouts()
Return a list of matched bids and asks. |
protected void |
initialise()
|
void |
insertUnmatchedAsk(Shout ask)
Insert an unmatched ask into the approriate heap. |
void |
insertUnmatchedBid(Shout bid)
Insert an unmatched bid into the approriate heap. |
void |
newAsk(Shout ask)
|
void |
newBid(Shout bid)
|
protected void |
postRemovalProcessing()
Sub-classes should override this method if they wish to check auction state integrity after shout removal. |
protected void |
preRemovalProcessing()
Sub-classes should override this method if they wish to check auction state integrity before shout removal. |
void |
prettyPrint(java.lang.String title,
org.apache.commons.collections.buffer.PriorityBuffer shouts)
|
void |
printState()
Log the current state of the auction. |
int |
promoteHighestUnmatchedBid(Shout ask)
|
int |
promoteLowestUnmatchedAsk(Shout bid)
|
int |
promoteShout(Shout shout,
org.apache.commons.collections.buffer.PriorityBuffer from,
org.apache.commons.collections.buffer.PriorityBuffer to,
org.apache.commons.collections.buffer.PriorityBuffer matched)
|
protected void |
reinsert(org.apache.commons.collections.buffer.PriorityBuffer heap,
int quantity)
Remove, possibly several, shouts from heap such that quantity(heap) is reduced by the supplied quantity and reinsert the shouts using the standard insertion logic. |
protected void |
removeAsk(Shout shout)
|
protected void |
removeBid(Shout shout)
|
void |
removeShout(Shout shout)
|
void |
reset()
Reinitialise our state to the original settings. |
java.lang.String |
toString()
|
protected static Shout |
unifyShout(Shout shout,
org.apache.commons.collections.buffer.PriorityBuffer heap)
Unify the shout at the top of the heap with the supplied shout, so that quantity(shout) = quantity(top(heap)). |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
protected org.apache.commons.collections.buffer.PriorityBuffer bIn
protected org.apache.commons.collections.buffer.PriorityBuffer bOut
protected org.apache.commons.collections.buffer.PriorityBuffer sIn
protected org.apache.commons.collections.buffer.PriorityBuffer sOut
protected static AscendingShoutComparator greaterThan
protected static DescendingShoutComparator lessThan
| Constructor Detail |
public FourHeapShoutEngine()
| Method Detail |
public void removeShout(Shout shout)
removeShout in interface ShoutEngineprotected void removeAsk(Shout shout)
protected void removeBid(Shout shout)
public java.lang.String toString()
public void printState()
printState in interface ShoutEngine
public void prettyPrint(java.lang.String title,
org.apache.commons.collections.buffer.PriorityBuffer shouts)
public void insertUnmatchedAsk(Shout ask)
throws DuplicateShoutException
DuplicateShoutException
public void insertUnmatchedBid(Shout bid)
throws DuplicateShoutException
DuplicateShoutExceptionpublic Shout getHighestUnmatchedBid()
getHighestUnmatchedBid in interface ShoutEnginepublic Shout getLowestMatchedBid()
getLowestMatchedBid in interface ShoutEnginepublic Shout getLowestUnmatchedAsk()
getLowestUnmatchedAsk in interface ShoutEnginepublic Shout getHighestMatchedAsk()
getHighestMatchedAsk in interface ShoutEngine
protected static Shout unifyShout(Shout shout,
org.apache.commons.collections.buffer.PriorityBuffer heap)
shout - The shout.heap - The heap.
protected int displaceShout(Shout shout,
org.apache.commons.collections.buffer.PriorityBuffer from,
org.apache.commons.collections.buffer.PriorityBuffer to)
throws DuplicateShoutException
DuplicateShoutException
public int promoteShout(Shout shout,
org.apache.commons.collections.buffer.PriorityBuffer from,
org.apache.commons.collections.buffer.PriorityBuffer to,
org.apache.commons.collections.buffer.PriorityBuffer matched)
throws DuplicateShoutException
DuplicateShoutException
public int displaceHighestMatchedAsk(Shout ask)
throws DuplicateShoutException
DuplicateShoutException
public int displaceLowestMatchedBid(Shout bid)
throws DuplicateShoutException
DuplicateShoutException
public int promoteHighestUnmatchedBid(Shout ask)
throws DuplicateShoutException
DuplicateShoutException
public int promoteLowestUnmatchedAsk(Shout bid)
throws DuplicateShoutException
DuplicateShoutException
public void newBid(Shout bid)
throws DuplicateShoutException
newBid in interface ShoutEngineDuplicateShoutException
public void newAsk(Shout ask)
throws DuplicateShoutException
newAsk in interface ShoutEngineDuplicateShoutExceptionpublic java.util.Iterator askIterator()
ShoutEngine
askIterator in interface ShoutEnginepublic java.util.Iterator bidIterator()
ShoutEngine
bidIterator in interface ShoutEnginepublic java.util.List getMatchedShouts()
Return a list of matched bids and asks. The list is of the form
where bi is the ith bid and a0 is the ith ask. A typical auctioneer would clear by matching bi with ai for all i at some price.
getMatchedShouts in interface ShoutEngineprotected void initialise()
public void reset()
Resetable
reset in interface Resetableprotected void preRemovalProcessing()
protected void postRemovalProcessing()
protected void reinsert(org.apache.commons.collections.buffer.PriorityBuffer heap,
int quantity)
heap - The heap to remove shouts from.quantity - The total quantity to remove.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||