|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectedu.cuny.cat.market.AuctioneerPolicy
edu.cuny.cat.market.matching.ShoutEngine
edu.cuny.cat.market.matching.FourHeapShoutEngine
public class 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 status is maintained in memory resident data structures and no crash recovery is provided.
| Field Summary | |
|---|---|
protected org.apache.commons.collections15.buffer.PriorityBuffer<Shout> |
bIn
Matched bids in ascending order |
protected org.apache.commons.collections15.buffer.PriorityBuffer<Shout> |
bOut
Unmatched bids in descending order |
protected org.apache.commons.collections15.buffer.PriorityBuffer<Shout> |
sIn
Matched asks in descending order |
protected org.apache.commons.collections15.buffer.PriorityBuffer<Shout> |
sOut
Unmatched asks in ascending order |
| Fields inherited from class edu.cuny.cat.market.matching.ShoutEngine |
|---|
AscendingOrder, DescendingOrder |
| Fields inherited from class edu.cuny.cat.market.AuctioneerPolicy |
|---|
auctioneer |
| Constructor Summary | |
|---|---|
FourHeapShoutEngine()
|
|
| Method Summary | |
|---|---|
java.util.Iterator<Shout> |
ascendingAskIterator()
|
java.util.Iterator<Shout> |
askIterator()
|
java.util.Iterator<Shout> |
bidIterator()
|
java.util.Iterator<Shout> |
descendingBidIterator()
|
int |
displaceHighestMatchedAsk(Shout ask)
|
int |
displaceLowestMatchedBid(Shout bid)
|
protected int |
displaceShout(Shout shout,
org.apache.commons.collections15.buffer.PriorityBuffer<Shout> from,
org.apache.commons.collections15.buffer.PriorityBuffer<Shout> 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. |
org.apache.commons.collections15.buffer.PriorityBuffer<Shout> |
getMatchedAsks()
|
org.apache.commons.collections15.buffer.PriorityBuffer<Shout> |
getMatchedBids()
|
int |
getMatchedVolume()
|
int |
getNumOfMatchedAsks()
|
int |
getNumOfMatchedBids()
|
int |
getNumOfUnmatchedAsks()
|
int |
getNumOfUnmatchedBids()
|
org.apache.commons.collections15.buffer.PriorityBuffer<Shout> |
getUnmatchedAsks()
|
org.apache.commons.collections15.buffer.PriorityBuffer<Shout> |
getUnmatchedBids()
|
int |
getUnmatchedDemand()
|
int |
getUnmatchedSupply()
|
void |
insertUnmatchedAsk(Shout ask)
Insert an unmatched ask into the approriate heap. |
void |
insertUnmatchedBid(Shout bid)
Insert an unmatched bid into the approriate heap. |
java.util.Iterator<Shout> |
matchedAskIterator()
|
java.util.Iterator<Shout> |
matchedBidIterator()
|
java.util.List<Shout> |
matchShouts()
Return a list of matched bids and asks. |
protected void |
newAsk(Shout ask)
|
protected void |
newBid(Shout bid)
|
void |
newShout(Shout shout)
|
protected void |
postRemovalProcessing()
Sub-classes should override this method if they wish to check auction status integrity after shout removal. |
protected void |
preRemovalProcessing()
Sub-classes should override this method if they wish to check auction status integrity before shout removal. |
void |
prettyPrint(java.lang.String title,
org.apache.commons.collections15.buffer.PriorityBuffer<Shout> shouts)
|
void |
printState()
Log the current status of the auction. |
int |
promoteHighestUnmatchedBid(Shout ask)
|
int |
promoteLowestUnmatchedAsk(Shout bid)
|
int |
promoteShout(Shout shout,
org.apache.commons.collections15.buffer.PriorityBuffer<Shout> from,
org.apache.commons.collections15.buffer.PriorityBuffer<Shout> to,
org.apache.commons.collections15.buffer.PriorityBuffer<Shout> matched)
|
protected void |
reinsert(org.apache.commons.collections15.buffer.PriorityBuffer<Shout> 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()
resets the state to be the same as the policy is created and initialized. |
java.lang.String |
toString()
|
protected static Shout |
unifyShout(Shout shout,
org.apache.commons.collections15.buffer.PriorityBuffer<Shout> 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 edu.cuny.cat.market.matching.ShoutEngine |
|---|
getMatchedShouts |
| Methods inherited from class edu.cuny.cat.market.AuctioneerPolicy |
|---|
eventOccurred, getAuctioneer, initialize, setAuctioneer, setup |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected org.apache.commons.collections15.buffer.PriorityBuffer<Shout> bIn
protected org.apache.commons.collections15.buffer.PriorityBuffer<Shout> bOut
protected org.apache.commons.collections15.buffer.PriorityBuffer<Shout> sIn
protected org.apache.commons.collections15.buffer.PriorityBuffer<Shout> sOut
| Constructor Detail |
|---|
public FourHeapShoutEngine()
| Method Detail |
|---|
public void reset()
AuctioneerPolicy
reset in interface edu.cuny.obj.Resetablereset in class AuctioneerPolicypublic void removeShout(Shout shout)
removeShout in class ShoutEngineprotected void removeAsk(Shout shout)
protected void removeBid(Shout shout)
public java.lang.String toString()
toString in class AuctioneerPolicypublic void printState()
printState in class ShoutEngine
public void prettyPrint(java.lang.String title,
org.apache.commons.collections15.buffer.PriorityBuffer<Shout> shouts)
public void insertUnmatchedAsk(Shout ask)
throws DuplicateShoutException
DuplicateShoutException
public void insertUnmatchedBid(Shout bid)
throws DuplicateShoutException
DuplicateShoutExceptionpublic Shout getHighestUnmatchedBid()
getHighestUnmatchedBid in class ShoutEnginepublic Shout getLowestMatchedBid()
getLowestMatchedBid in class ShoutEnginepublic Shout getLowestUnmatchedAsk()
getLowestUnmatchedAsk in class ShoutEnginepublic Shout getHighestMatchedAsk()
getHighestMatchedAsk in class ShoutEngine
protected static Shout unifyShout(Shout shout,
org.apache.commons.collections15.buffer.PriorityBuffer<Shout> heap)
shout - The shout.heap - The heap.
protected int displaceShout(Shout shout,
org.apache.commons.collections15.buffer.PriorityBuffer<Shout> from,
org.apache.commons.collections15.buffer.PriorityBuffer<Shout> to)
throws DuplicateShoutException
DuplicateShoutException
public int promoteShout(Shout shout,
org.apache.commons.collections15.buffer.PriorityBuffer<Shout> from,
org.apache.commons.collections15.buffer.PriorityBuffer<Shout> to,
org.apache.commons.collections15.buffer.PriorityBuffer<Shout> 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 newShout(Shout shout)
throws DuplicateShoutException
newShout in class ShoutEngineDuplicateShoutException
protected void newBid(Shout bid)
throws DuplicateShoutException
DuplicateShoutException
protected void newAsk(Shout ask)
throws DuplicateShoutException
DuplicateShoutExceptionpublic java.util.Iterator<Shout> askIterator()
askIterator in class ShoutEnginepublic java.util.Iterator<Shout> ascendingAskIterator()
ascendingAskIterator in class ShoutEnginepublic java.util.Iterator<Shout> bidIterator()
bidIterator in class ShoutEnginepublic java.util.Iterator<Shout> descendingBidIterator()
descendingBidIterator in class ShoutEnginepublic java.util.Iterator<Shout> matchedAskIterator()
matchedAskIterator in class ShoutEnginepublic java.util.Iterator<Shout> matchedBidIterator()
matchedBidIterator in class ShoutEnginepublic java.util.List<Shout> matchShouts()
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.
matchShouts in class ShoutEngineprotected void preRemovalProcessing()
protected void postRemovalProcessing()
protected void reinsert(org.apache.commons.collections15.buffer.PriorityBuffer<Shout> heap,
int quantity)
heap - The heap to remove shouts from.quantity - The total quantity to remove.public int getMatchedVolume()
getMatchedVolume in class ShoutEnginepublic int getUnmatchedSupply()
getUnmatchedSupply in class ShoutEnginepublic int getUnmatchedDemand()
getUnmatchedDemand in class ShoutEnginepublic int getNumOfUnmatchedBids()
getNumOfUnmatchedBids in class ShoutEnginepublic int getNumOfMatchedBids()
getNumOfMatchedBids in class ShoutEnginepublic int getNumOfUnmatchedAsks()
getNumOfUnmatchedAsks in class ShoutEnginepublic int getNumOfMatchedAsks()
getNumOfMatchedAsks in class ShoutEnginepublic org.apache.commons.collections15.buffer.PriorityBuffer<Shout> getMatchedBids()
getMatchedBids in class ShoutEnginepublic org.apache.commons.collections15.buffer.PriorityBuffer<Shout> getUnmatchedBids()
getUnmatchedBids in class ShoutEnginepublic org.apache.commons.collections15.buffer.PriorityBuffer<Shout> getMatchedAsks()
getMatchedAsks in class ShoutEnginepublic org.apache.commons.collections15.buffer.PriorityBuffer<Shout> getUnmatchedAsks()
getUnmatchedAsks in class ShoutEngine
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||