def exampleVcg(): slot_amount = 3 slots = dict((i,Slot(i,0,120)) for i in range(slot_amount)) bidderInfos = { 0: BidderInfo(0,1000,100,1,{0:1,1:1,2:1}), 1: BidderInfo(1,1000,100,1,{0:1,1:1,2:1}), 2: BidderInfo(2,1000,100,1,{0:1,1:1,2:1}), 3: BidderInfo(3,1800,100,3,{0:1,1:1,2:1}), 4: BidderInfo(3,1900,100,2,{0:1,1:1,2:1}), } proc = TvAuctionProcessor() proc.vcgClass = processor.Zero res = proc.solve(slots,bidderInfos,None,None)
def example4(): '''tests for uncorrelated bids''' slot_amount = 168/4 bidder_amount = 30 slots = dict((i,Slot(i,0,120)) for i in range(slot_amount)) bidderInfos = dict( (i,BidderInfo(i,incr*times*length,length,times,dict((i,1) for i in slots))) for (i,(incr,length,times)) in enumerate(zip(rand_increments,rand_lengths,rand_times)[:bidder_amount]) ) proc = TvAuctionProcessor() proc.vcgClass = processor.Zero return proc.solve(slots,bidderInfos,5,1)
def exampleRealistic1(): slot_length = 120 slot_amount = 336 # two weeks, each hour slot_baseline = 10000 slot_price_baseline = 1.0 # the price for the baseline is 1.0 per second def slot_reach(slot_id): slot_hour = slot_id % 24 slot_prio = (slot_hour-3) % 24 # bottom point is at 3am return -0.2 * math.cos( slot_prio*math.pi/12 ) # reach oscillates between +- 20% during the day slots = {} slots_reaches = {} for slot_id in range(slot_amount): slot_modifier = slot_reach(slot_id) slot_modifier_sig = 1 if slot_modifier >= 0 else -1 # the price growth/shrinks less than the reach, in our case as a sqrt price = round(slot_price_baseline * (1 + slot_modifier_sig*math.pow(abs(slot_modifier),1.5)),2) slots[slot_id] = Slot(slot_id,price,slot_length) slots_reaches[slot_id] = int(slot_baseline*(1+slot_modifier)) # each bidder wants 75000 as a baseline, which is approx. (sum(s.reach for s in slots)/ 50) * 1.1 bidder_amount = 50 bidder_reach_baseline = 200000 bidder_reach_modifiers = [1.16, 1.45, 1.23, 1.85, 0.92, 1.29, 1.42, 1.53, 2.0, 1.89, 0.98, 1.94, 1.49, 1.68, 1.7, 1.11, 1.73, 1.76, 1.71, 0.92, 1.61, 1.54, 1.6, 0.81, 1.25, 1.05, 1.81, 1.92, 1.42, 1.36, 1.91, 1.59, 0.97, 0.88, 1.35, 1.6, 1.15, 1.94, 1.53, 1.99, 1.81, 1.44, 1.69, 1.07, 1.83, 1.46, 1.68, 1.8, 1.6, 1.73] bidder_price_baseline = 1.5 bidder_price_modifiers = [1.18, 0.88, 1.04, 1.05, 1.06, 1.16, 1.09, 0.88, 1.15, 0.99, 1.15, 0.95, 1.02, 1.18, 1.14, 1.17, 1.16, 0.83, 1.19, 0.8, 0.87, 1.2, 0.85, 1.19, 0.86, 0.96, 1.03, 0.84, 0.91, 0.8, 1.14, 0.84, 1.1, 0.99, 1.2, 1.16, 1.18, 0.85, 1.13, 0.96, 1.08, 1.17, 0.92, 1.06, 1.1, 1.18, 0.81, 1.04, 1.0, 1.17] bidder_length_baseline = 30 bidder_length_modifiers = [2.0, 1.59, 1.53, 1.58, 1.14, 1.0, 0.82, 1.72, 0.93, 1.93, 0.94, 0.83, 1.34, 1.91, 1.98, 1.45, 1.49, 0.83, 1.8, 1.32, 1.46, 1.03, 0.98, 1.75, 0.97, 0.9, 1.26, 1.74, 0.97, 1.43, 0.83, 1.8, 1.29, 1.57, 1.68, 1.93, 1.99, 1.4, 1.08, 1.61, 1.35, 1.93, 0.88, 1.54, 0.81, 1.55, 1.42, 1.27, 1.67, 1.12] # we use the predefined slot reach bidderInfos = {} for bidder_id,reach_mod,price_mod,length_mod in zip(range(bidder_amount),bidder_reach_modifiers,bidder_price_modifiers,bidder_length_modifiers): reach = int(bidder_reach_baseline*reach_mod) length = int(bidder_length_baseline * length_mod) # price is correlated to reach and length budget = round(bidder_price_baseline * price_mod * length * reach,2) # ('id','budget','length','attrib_min','attrib_values')) bidderInfos[bidder_id] = BidderInfo(bidder_id, budget, length, reach, slots_reaches) proc = TvAuctionProcessor() proc.vcgClass = processor.Zero return proc.solve(slots,bidderInfos,timeLimit=10)