当前位置: 首页>>代码示例>>Python>>正文


Python gsp.GSP类代码示例

本文整理汇总了Python中gsp.GSP的典型用法代码示例。如果您正苦于以下问题:Python GSP类的具体用法?Python GSP怎么用?Python GSP使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了GSP类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: expected_utils

    def expected_utils(self, t, history, reserve):
        """
        Figure out the expected utility of bidding such that we win each
        slot, assuming that everyone else keeps their bids constant from
        the previous round.

        returns a list of utilities per slot.
        """
        # TODO: Fill this in
        last_round = history.round(t-1)
        last_round_bids = filter(lambda (ID, bid):ID != self.id, last_round.bids)


        last_round_clicks = last_round.clicks

        allocation, _ = GSP.compute(last_round_clicks, reserve, last_round_bids)
        num_slots = len(allocation)

        utilities = []

        for slot in range(num_slots):
            last_round_k = allocation[slot] #take the person from last round in slot k
            bid_i = reserve # default bid to reserve price
            for ID, bid in last_round_bids: # go through each of last rounds' bids, and set that slot's bid 
                if last_round_k == ID:
                    bid_i = bid
            utilities += [(self.value - bid_i) * last_round_clicks[slot]]

        if utilities == []:
            return [0]

        return utilities
开发者ID:buffalohird,项目名称:Marfalo-and-Bark,代码行数:32,代码来源:bugsbb.py

示例2: bid_range_for_slot

 def bid_range_for_slot(slot, slot_clicks, reserve, bids):
     """
     Compute the range of bids that would result in the bidder ending up
     in slot, given that the other bidders submit bidders.
     Returns a tuple (min_bid, max_bid).
     If slot == 0, returns None for max_bid, since it's not well defined.
     """
     # Conveniently enough, bid ranges are the same for GSP and VCG:
     return GSP.bid_range_for_slot(slot, slot_clicks, reserve, bids)
开发者ID:karashen,项目名称:CS136_SearchAuctions,代码行数:9,代码来源:vcg.py

示例3: runSecondPriceAuction

    def runSecondPriceAuction(self, reqList, sellerGraph):
        '''
        Function to call GSP mechanism
        '''
        allocation = []
        self.__logger.debug("[AdExchange][runSecondPriceAuction]")
        self.__logger.debug("Fiber allocation decisions.")

        allocationDict = {}
        for key, v in reqList.items():
            k1,k2=key.split("#")
            # n denotes the number of customers bidding for that conduit
            n = len(v)
            slot_click = [1] * n

            shortestPath = nx.shortest_path(sellerGraph, source=k1, target=k2)
            gCoP = self.getCostOfPath(shortestPath, sellerGraph)
            lIP = self.linksInPath(shortestPath)
            k = len(lIP)
            reserve = max(self.__reserve, gCoP/k)

            bids = []
            for item in v:
                bids.append((item.clientName, item.bidPerStrand))

            if nx.has_path(sellerGraph, k1, k2) and self.resourceAvailable(sellerGraph, shortestPath, v):
                (alloc, payments) = GSP.compute(slot_click, reserve, bids)
                allocation.extend(zip(alloc, [i * k for i in payments]))
                for (kTest, vTest) in allocation:
                    allocationDict[kTest] = vTest

                # Updates sellerGraph with the allocation
                self.__logger.debug("Before > {}".format(self.availableAttributes(shortestPath, sellerGraph)))
                self.updateSellerGraph(sellerGraph, shortestPath, v)
                self.__logger.debug("After > {}".format(self.availableAttributes(shortestPath, sellerGraph)))
            else:
                self.__logger.info("Link does not exists or No resources available for the request")
        return self.updateRequestList(reqList, allocationDict)
开发者ID:52-41-4d,项目名称:GreyFiber,代码行数:38,代码来源:adexchange.py

示例4: test_mechanism

def test_mechanism():
    num_slots = 4
    slot_clicks = [1] * 4   # don't actually matter for gsp
    bids = zip(range(1,6), [10, 12, 18, 14, 20])

    reserve = 0

    (alloc, payments) = GSP.compute(slot_clicks, reserve, bids)
    assert alloc == [5,3,4,2]
    assert payments == [18, 14, 12, 10]

    reserve = 11
    (alloc, payments) = GSP.compute(slot_clicks, reserve, bids)
    assert alloc == [5,3,4,2]
    assert payments == [18, 14, 12, 11]

    reserve = 14
    (alloc, payments) = GSP.compute(slot_clicks, reserve, bids)
    assert alloc == [5,3,4]
    assert payments == [18, 14, 14]

    reserve = 15
    (alloc, payments) = GSP.compute(slot_clicks, reserve, bids)
    assert alloc == [5,3]
    assert payments == [18, 15]

    reserve = 19
    (alloc, payments) = GSP.compute(slot_clicks, reserve, bids)
    assert alloc == [5]
    assert payments == [19]


    reserve = 22
    (alloc, payments) = GSP.compute(slot_clicks, reserve, bids)
    assert alloc == []
    assert payments == []
开发者ID:philipjlin,项目名称:Sponsored_Search_Auctions,代码行数:36,代码来源:test_gsp.py

示例5: compute

 def compute(s):
     (min, max) = GSP.bid_range_for_slot(s, clicks, reserve, other_bids)
     if max == None:
         max = 2 * min
     return (s, min, max)
开发者ID:philipjlin,项目名称:Sponsored_Search_Auctions,代码行数:5,代码来源:pjl14bb.py

示例6: bid_range

 def bid_range(slot, reserve):
     return GSP.bid_range_for_slot(slot, slot_clicks, reserve, bids)
开发者ID:philipjlin,项目名称:Sponsored_Search_Auctions,代码行数:2,代码来源:test_gsp.py


注:本文中的gsp.GSP类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。