def runAndPrint(filename): print("Loading data from file %s..." % filename) count = 0 slots = [] # slot object array bids = [] # bid object array with open(filename) as infile: for line in infile: line = line.strip() count += 1 # read auction term if count == 1: term = line # read click through rate if count == 2: parts = line.split(' ') for ctr in parts: slot = Slot(ctr) slots.append(slot) # read bids information if count > 2: bid = Bid(line) bids.append(bid) print("\nAuction for \"%s\" with %d slots and %d bidders:" % (term, len(slots), len(bids))) for slot in slots: print("slot: %6.2f %8.2f %8.2f %s" % (float(slot.clickThruRate), float(slot.price), float( slot.profit), slot.bidder)) print(" <-- click through rates") print(" ") auction = Auction(term, bids) # print bid information print "Bids sorted from high to low:" for b in auction.bids: # print ("%s\t%s" % (b.value, b.name)) print("bid:%6.2f %s" % (float(b.value), b.name)) auction.executeVCG(slots) print(" ") print("%12s %8s %8s %8s\n" % ("clicks", "price", "profit", "bidder")) # print slots for slot in slots: print("slot: %6.2f %8.2f %8.2f %s" % (float(slot.clickThruRate), float(slot.price), float( slot.profit), slot.bidder)) # print sums cls = 0 rev = 0 val = 0 for s in slots: cls += float(s.clickThruRate) rev += float(s.price) val += float(s.profit) print("sums: %6.2f %8.2f %8.2f\n" % (cls, rev, val))
def simulation(numbid, numitem, valueGenFunc, truthOrRandom, repeatTimes): auction = Auction(numbid, numitem, valueGenFunc, truthOrRandom) for i in range(repeatTimes): auction.executeGSP() auctionRGSP = auction.revenueSum bidderRGSP = [] for i in range(int(numbid)): bidderRGSP.insert(i, auction.bidders[i].revenueSum()) return auctionRGSP, bidderRGSP
def runAndPrint(filename): print ("Loading data from file %s..." % filename) count = 0 slots = [] # slot object array bids = [] # bid object array with open(filename) as infile: for line in infile: line = line.strip() count += 1 # read auction term if count == 1: term = line # read click through rate if count == 2: parts = line.split(' ') for ctr in parts: slot = Slot(ctr) slots.append(slot) # read bids information if count > 2: bid = Bid(line) bids.append(bid) print ("\nAuction for \"%s\" with %d slots and %d bidders:" % (term, len(slots), len(bids))) for slot in slots: print("slot: %6.2f %8.2f %8.2f %s" % (float(slot.clickThruRate), float(slot.price), float(slot.profit), slot.bidder)) print (" <-- click through rates") print(" ") auction = Auction(term, bids) # print bid information print "Bids sorted from high to low:" for b in auction.bids: # print ("%s\t%s" % (b.value, b.name)) print ("bid:%6.2f %s" % (float(b.value), b.name)) auction.executeVCG(slots) print(" ") print("%12s %8s %8s %8s\n" % ("clicks", "price", "profit", "bidder")) # print slots for slot in slots: print("slot: %6.2f %8.2f %8.2f %s" % (float(slot.clickThruRate), float(slot.price), float(slot.profit), slot.bidder)) # print sums cls = 0; rev = 0; val = 0; for s in slots: cls += float(s.clickThruRate); rev += float(s.price); val += float(s.profit); print ("sums: %6.2f %8.2f %8.2f\n" % (cls, rev, val))
def runAndPrint(filename): print("loading Auction from file %s" % filename) count = 0 slots = [] bids = [] with open(filename) as infile: for line in infile: line = line.strip() count += 1 if count == 1: term = line if count == 2: parts = line.split(' ') for ctr in parts: slot = Slot(ctr) slots.append(slot) if count > 2: bid = Bid(line) bids.append(bid) print("Auction for \"%s\" with %d slots and %d bidders" % (term, len(slots), len(bids))) for slot in slots: print("slot: %6.2f %8.2f %8.2f %s" % (float(slot.clickThruRate), float(slot.price), float( slot.profit), slot.bidder)) print(" <-- click through rates") print(" ") auction = Auction(term, bids) for b in auction.bids: # print ("%s\t%s"%(b.value,b.name)) print("bid:%6.2f %s" % (float(b.value), b.name)) auction.executeVCG(slots) print(" ") print("%12s %8s %8s %8s\n" % ("clicks", "price", "profit", "bidder")) for slot in slots: print("slot: %6.2f %8.3f %8.3f %s" % (float(slot.clickThruRate), float(slot.price), float( slot.profit), slot.bidder)) cls = 0 rev = 0 val = 0 for s in slots: cls += float(s.clickThruRate) rev += float(s.price) val += float(s.profit) print("sums: %6.2f %8.3f %8.3f\n" % (cls, rev, val))
def runAndPrint(filename): print("loading Auction from file %s" % filename) count = 0 slots = [] bids = [] with open(filename) as infile: for line in infile: line = line.strip() count += 1 if count == 1: term = line if count == 2: parts = line.split(' ') for ctr in parts: slot = Slot(ctr) slots.append(slot) if count > 2: bid = Bid(line) bids.append(bid) print("Auction for \"%s\" with %d slots and %d bidders" % (term, len(slots), len(bids))) # for slot in slots: # print("slot: %6.2f %8.2f %8.2f %s" % ( # float(slot.clickThruRate), float(slot.price), float(slot.profit), slot.bidder)) # print(" <-- click through rates") # print(" ") auction = Auction(term, bids) for b in auction.bids: # print ("%s\t%s"%(b.value,b.name)) print("bid:%6.2f %s" % (float(b.value), b.name)) auction.executeVCG(slots) print(" ") print("%12s %6s %6s %6s %6s\n" % ("clicks", "win_bid", "price", "profit", "bidder")) for slot in slots: print("slot: %6.3f %6.3f %6.3f %6.3f %s" % ( float(slot.clickThruRate), float(slot.win_bid), float(slot.price), float(slot.profit), slot.bidder)) cls = 0; bid = 0; rev = 0; val = 0; for s in slots: cls += float(s.clickThruRate); bid += float(s.win_bid) rev += float(s.price); val += float(s.profit); print("sums: %6.3f %6.3f %6.3f %6.3f\n" % (cls, bid, rev, val))
def validatePage(self, question=True): lots = self.get_lots() if len(lots) < 1: QtGui.QMessageBox.critical(None, ERROR, LOTS_FULL_AUCTION) return False for i, lot in enumerate(lots): if 5 > len(lot.title) > 0: self.slider.goto(i) QtGui.QMessageBox.critical(None, ERROR, LOTS_TITLE_INCORRECT) return False try: float(lot.start_price) except ValueError: self.slider.goto(i) QtGui.QMessageBox.critical(None, ERROR, ) return False if len(lot.members) < 1: self.slider.goto(i) QtGui.QMessageBox.critical(None, ERROR, LOTS_MEMBERS_EMPTY) return False app.set_auction(Auction(lots)) if question: reply = QtGui.QMessageBox.question(self, START_AUCTION_QUESTION, START_AUCTION_QUESTION, QtGui.QMessageBox.Yes, QtGui.QMessageBox.No) return reply == QtGui.QMessageBox.Yes else: return True
def _create(self) -> Auction: self.actualMessage.delete() auction = Auction(self.name, self.description, self.priceRaise, self.offerMaxNumber, self.time, self.buyout, self.minimumPrice, self.app) Database.storeAuction(auction) auctions.append(auction) return auction
def load_file(): dialog = QtGui.QFileDialog() filename = dialog.getOpenFileName()[0] if ".auc" not in filename: filename += ".auc" try: return Auction(pickle.load(open(filename, "r"))['lots']) except: QtGui.QMessageBox.critical(None, ERROR, FILE_CANNOT_OPEN) return False
def runAndPrint(numbid, numitem, valueGenFunc, truthOrRandom, repeatTimes): auction = Auction(numbid, numitem, valueGenFunc, truthOrRandom) SWVCGseq, RVCGseq, SWGSPseq, RGSPseq = [], [], [], [] for i in range(repeatTimes): # auction = Auction(numbid, numitem, truthOrRandom) auction.clearData() #auction.executeVCG() #swVCG = auction.SocialWelfare #rVCG = auction.revenue #SWVCGseq = np.append(SWVCGseq, swVCG) #RVCGseq = np.append(RVCGseq, rVCG) auction.executeGSP() #swGSP = auction.SocialWelfare rGSP = auction.revenue #SWGSPseq = np.append(SWGSPseq, swGSP) RGSPseq = np.append(RGSPseq, rGSP) #SWVCG = np.mean(SWVCGseq) #RVCG = np.mean(RVCGseq) #SWGSP = np.mean(SWGSPseq) SWVCG, RVCG, SWGSP = 0, 0, 0 RGSP = np.mean(RGSPseq) #print("seq: RVCG[0] = " + str(RVCGseq[0]) + ", RVCG[n-1] = " + str(RVCGseq[repeatTimes-1])) #print("seq: RGSP[0] = " + str(RGSPseq[0]) + ", RGSP[n-1] = " + str(RGSPseq[repeatTimes-1])) return [SWVCG, RVCG, SWGSP, RGSP]
def main(): deco_head() url = 'https://mckenzieauction.hibid.com/' auctions_page = url + 'auctions' # start the soup headers = {'User-Agent': new_agent()} soup = load_html(auctions_page, with_cookies=True, headers=headers) auction_links = find_auction_links(soup) auction_list = [] for taggroup in auction_links: link = taggroup.find("a") name = link.text link = url + link['href'] current_auction = Auction(name, len(auction_list) + 1, link) auction_list.append(current_auction) print(auction_list)
def loadEveryAuction(app: Client): with open("auctions.txt", "r") as file: auctionList = yaml.load(file, Loader=yaml.FullLoader) if auctionList is not None: for auction in auctionList: regex = ( 'Name: (?P<_0>.+)\nDesc: (?P<_1>.+)\nOfferN: (?P<_2>\d+)\nTime: (?P<_3>\d+)\nBuyout: (?P<_4>\d+)\nPriceRaise: (?P<_5>\d+)\nMinimumPrice: (?P<_6>\d+)' ) match = re.match(regex, auction).groupdict() auctions.append( Auction(name=match["_0"], description=match["_1"], offerMaxNumber=int(match["_2"]), time=int(match["_3"]), buyout=int(match["_4"]), priceRaise=int(match["_5"]), minimumPrice=int(match["_6"]), app=app))
def runAndPrint(filename): print ("loading Auction from file %s" % filename) print(" ") count = 0 # CTR + price + profit + bidder slots = [] # value + name bids = [] with open(filename) as infile: for line in infile: line = line.strip() count += 1 '''print count 1-6 ''' # row1 dataset's name if count == 1: term = line # row2 CTR if count == 2: parts = line.split(' ') for ctr in parts: slot = Slot(ctr) slots.append(slot) # the rest row bid and advertisers' name if count > 2: bid = Bid(line) bids.append(bid) print ("Auction for \"%s\" with %d slots and %d bidders" % (term, len(slots), len(bids))) '''Slot.py 里面抓出来的''' for slot in slots: print("slot: %6.2f %8.2f %8.2f %s" % ( float(slot.clickThruRate), float(slot.price), float(slot.profit), slot.bidder)) #print (" <-- click through rates") print(" ") '''0123在 Auction 初始化的时候打印出来 应该是看有没有塞进去 Auction.bids里面 ''' auction = Auction(term, bids) for b in auction.bids: # print ("%s\t%s"%(b.value,b.name)) print ("bid:%6.2f %s" % (float(b.value), b.name)) print(" ") #这里应该读入一个 slots executeVCG()里面有 但是这里似乎暂时没加上去 这样Auction里面才同时有 bids 和 slots auction.executeVCG(slots) print(" ") print("%12s %8s %8s %8s\n" % ("clicks", "price", "profit", "bidder")) for slot in slots: print("slot: %6.2f %8.3f %8.3f %s" % ( float(slot.clickThruRate), float(slot.price), float(slot.profit), slot.bidder)) '''这三个应该是各个 column 的 sum的初始化''' cls = 0; rev = 0; val = 0; for s in slots: cls += float(s.clickThruRate); rev += s.price; val += s.profit; print ("sums: %6.2f %8.3f %8.3f\n" % (cls, rev, val))
def debug(self): app.set_auction( Auction( pickle.load( open("/Users/vkrasnoperov/Envs/auction/test.auc", "r"))['lots']))