140 likes | 330 Views
peer-to-peer and agent-based computing. “Implementation” of Auctions. A word on “implementation”. It’s not really Java It’s pseudo-code Algorithms Some elements of “realism” Purpose: Flesh out details of what happens before/after messages are sent/received
E N D
peer-to-peer and agent-based computing “Implementation” of Auctions
A word on “implementation”... • It’s not really Java • It’s pseudo-code • Algorithms • Some elements of “realism” • Purpose: • Flesh out details of what happens before/after messages are sent/received • Detail the information of each message • NOT to define “business logic” to use programs in eBay (thus maximising profit...) peer-to-peer and agent-based computing – wamberto vasconcelos
English Auction • “Official” standard from FIPA (www.fipa.org) peer-to-peer and agent-based computing – wamberto vasconcelos
Auctioneer pseudocode (1) input: Agent id, good to sell g and its reserve price p,bidders B = {b0,…,bn} output: winnerB and price fpp or false (if no winner) auctioneer(id, B, p) 1. ac← fresh auction id // e.g., time or a random number 2. winner← nil; fp← p // initialise winner and fp 3. for all b Bdo send(id, b, inform-start-of-auction, g, ac) 4. for all b Bdo send(id, b, cfp, g, fp, ac) 5. Msgs← receiveMsgs(ac) // receive msgs 6. Losers, hb, hp ← processMsgs(fp, ac, Msgs) // get highest bid & losers 7. ifhb = nil then // no “good” bids now 8. ifwinner = nil then return false // no previous winner 9. else // we had a previous winner 10. send(id, winner, request, g, fp, ac) // request payment 11. B’ ←B \ {winner } // get “other” bidders’ ids 12. for all b Bdo send(id, b, inform, g, fp, winner, ac) // inform who won 13. returnfp,winner, ac // return winner 14. else 15. winner← hb; fp← hp // update winner and current price 16. send(id, winner, accept-proposal, g, fp, ac) // accept highest bid 17. for all b, p Losersdo send(id, b, reject-proposal, g, p, ac) 18. go to 4 peer-to-peer and agent-based computing – wamberto vasconcelos
Auctioneer pseudocode (2) input: Auction id ac output: set of received messages Msgs receiveMsgs(ac) 1. Msgs ← 2. patienceLimit ← 10 3. whilepatienceLimit > 0 do 4. receive(m) // non-blocking receive; m = nil, if no msg 5. ifm = nil then 6. patienceLimit ← patienceLimit 1 7. sleep 5ms 8. else 9. Msgs ←Msgs {m } 10. remove from Msgs messages with different ac 11. returnMsgs peer-to-peer and agent-based computing – wamberto vasconcelos
Auctioneer pseudocode (3) input: Current higher price fp,auction id ac, messages Msgs= {m0,…,mn} output: Losers,hb,hp (Losers failed bids, hb/hp successful bidder/price) processMsgs(fp, ac, Msgs) 1. Losers ← 2. for all m Msgsdo 3. ifm = b, a, not-understood, ac then Msgs ← Msgs– {m } // filter 4. if Msgs = then return ,nil,nil 5. for all m Msgsdo 6. ifm = b, a, propose, g, p, ac then 7. ifp < fpthen// less than current highest offer? 8. Losers ← Losers {b, p} // add to set of losers 9. Msgs ← Msgs– {m } // remove from msgs 10. pick m Msgssuch that m = b, a, propose, g, p, ac 11. hb ← b ; hp ← p 12. for all m Msgsdo 13. if m = b, a, propose, g, p, ac then 14. ifp > hpthen// higher bid? 15. Losers ← Losers {hb, hp} // previous highest is loser 16. hb ← b; hp ← p // update highest bidder and bid 17. else // equal bid? 18. Losers ← Losers {b, p} // add to losers 17. returnLosers,hb,hp peer-to-peer and agent-based computing – wamberto vasconcelos
Bidder pseudocode (1) input: Ag. id, good g, highest price hp,increase % in bid inc output: price paid pphp or nil (if unsuccessful in auction) bidder(id, g, hp, inc) 1. Bid ← nil; pp ← nil 2. Msgs ← receiveMsgs // receive msgs 3. As← {m Msgs | m = a, id, inform-start-of-auction, g, ac } // auctions of g 4. choose auction m As, m = a, id, inform-start-of-auction, g, ac 5. Msgs ← receiveMsgs // receive msgs 6. CFPs← {m Msgs | m = a, id, cfp, g, p, ac and p hp } // get cfps 7. ifCFPs = then go to 1 // nothing of interest so far… peer-to-peer and agent-based computing – wamberto vasconcelos
Bidder pseudocode (2) input: Agent id, good to buy g, highest price hp,increase % in bid inc output: price paid pphp or nil(if unsuccessful in auction) bidder(id, g, hp, inc) … 8. get from CFPs the lowest offer, m = a, id, cfp, g, p, ac 9. offer← (p + (pinc /100)) 10. ifBid = nil andoffer hpthen // no pending bids & offer OK 11. send(id, a, propose, g, offer, ac) 12. go to 5 13. if a, id, accept-proposal, g, p, ac Msgsthen // offer accepted 14. Bid ← a, p, ac 15. go to 5 16. if a, id, reject-proposal, g, offer, ac Msgsthen // offer rejected 17. go to 1 18. if a, id, inform, g, p, winner, ac Msgsthen // someone won... 19. if id = winnerthen // it was me! 20. pp ← offer 21. // ... wait for payment request; perform payment; etc. ... 22. returnpp 23. else // someone else won... 24. return nil peer-to-peer and agent-based computing – wamberto vasconcelos
Bidder pseudocode (3) input: Agent id, good to buy g, highest price hp,increase % in bid inc output: price paid pphp or nil(if unsuccessful in auction) bidder(id, g, hp, inc) 1. Bid ← nil; pp ← nil 2. Msgs← receiveMsgs // receive msgs 3. As← { m Msgs | m = a, id, inform-start-of-auction, g, ac } // get all auctions of good g 4. choose one of the auctions m As, m = a, id, inform-start-of-auction, g, ac 5. Msgs← receiveMsgs // receive msgs 6. CFPs← { m Msgs | m = a, id, cfp, g, p, ac and p hp } // get “affordable” cfps 7. if CFPs = then go to 1 // nothing of interest so far… 8. get from CFPs the lowest offer, m = a, id, cfp, g, p, ac 9. offer← (p + (pinc /100)) 10. ifBid = nil andoffer hpthen // no pending bids & offer OK 11. send(id, a, propose, g, offer, ac) 12. go to 5 13. if a, id, accept-proposal, g, p, ac Msgsthen // offer accepted 14. Bid ← a, p, ac 15. go to 5 16. if a, id, reject-proposal, g, offer, ac Msgsthen // offer rejected 17. go to 1 18. if a, id, inform, g, p, winner, ac Msgsthen // someone won... 19. if id = winnerthen // it was me! 20. pp ← offer 21. // ... wait for payment request; perform payment; etc. ... 22. returnpp 23. else // someone else won... 24. return nil peer-to-peer and agent-based computing – wamberto vasconcelos
Issues • The auction id is essential as there might be many auctions going on at the same time • Cases: • No bidders • “normal” bidders • Bidders with the wrong auction/good id • No need to record “round” of algorithm – why? • Algorithm deals with messages “out of order” • E.g.: the current highest bid is N and a “late” bidder has just sent a bid for the previous offer of N – 10 peer-to-peer and agent-based computing – wamberto vasconcelos
Issues (2) • Could you extend auctioneer to cope with many goods with simultaneous auctions? • Each good would be associated with a different auction • Bids would not be confused as they are associated with an auction id • Could you extend bidder to cope with many goods and a budget to buy them all? • Each item the bidder buys should reflect on the budget for the remaining items • Bidder should “leave” the auction (i.e., stop running) when budget is spent peer-to-peer and agent-based computing – wamberto vasconcelos
Issues (3) • Can you adapt the auctioneer and bidders so that they enact the Dutch auction? peer-to-peer and agent-based computing – wamberto vasconcelos
Issues (4) • Bidders may be outpriced • They could join efforts: • Buying in bulk and splitting costs/goods • How would bidders change to allow the formation of “co-operatives” • Overall purchase power is the sum of individual highest price • Bidders could use up part of their budget • One of the bidders would be the organiser • In the English auction, the cooperative could be disbanded and reformed • When the price exceeds the limit of the cooperative then the cooperative is dissolved and another one re-formed peer-to-peer and agent-based computing – wamberto vasconcelos