Exemplo n.º 1
0
def example1():
    '''tests core pricing.'''
    slots = dict((i,Slot(i,0.0,120)) for i in range(3))
    bidderInfos = dict([
        (0,BidderInfo(0,1000,100,1,dict((i,1) for i in slots))),
        (1,BidderInfo(1,1000,100,1,dict((i,1) for i in slots))),
        (2,BidderInfo(2,1000,100,1,dict((i,1) for i in slots))),
        (3,BidderInfo(3,1800,100,3,dict((i,1) for i in slots))),
    ])
    proc = TvAuctionProcessor()
#    proc.vcgClass = processor.Zero
    return proc.solve(slots,bidderInfos,100,100,None)
Exemplo n.º 2
0
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)
Exemplo n.º 3
0
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)
Exemplo n.º 4
0
 def testName(self):
     slots = dict((i,Slot(i,1.0,120)) for i in range(3))
     multiple = ((2000,3), (800,1))
     bidderInfos = dict([
         (0,BidderInfo(0,100,((1000,1),),dict((i,1) for i in slots.iterkeys()))),
         (1,BidderInfo(1,100,((1000,1),),dict((i,1) for i in slots.iterkeys()))),
         (2,BidderInfo(2,100,((1000,1),),dict((i,1) for i in slots.iterkeys()))),
         (3,BidderInfo(3,100,((1800,3),),dict((i,1) for i in slots.iterkeys()))),
         (4,BidderInfo(4,100,multiple,dict((i,1) for i in slots.iterkeys()))),
     ])
     
     processor = TvAuctionProcessor()
     processor.core_algorithm = processor.coreClass.TRIM_VALUES
     processor.solve(slots, bidderInfos)
Exemplo n.º 5
0
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)
Exemplo n.º 6
0
 def _solve(self, scenario, options):
     slots, bidder_infos = scenario
     proc = TvAuctionProcessor()
     res = proc.solve(slots, bidder_infos, **options)
     return res