Example #1
0
def targetMV(bundles, revenue, pricePrediction, verbose = False):
    """
    Returns bid according to targetMV strategy.
    1) solve for optimal bundle
    2) for all goods in optimal bundle, bid marginal utility for that good.
    """
    
    b = numpy.atleast_2d(bundles)
    
    rev = numpy.atleast_1d(revenue)
    
    pp = numpy.atleast_1d(pricePrediction)
    
    
    [optBundle, optSurplus] = acq(b, rev, pp)
                                  
    
    if verbose:
        print "optBundle  = {0}".format(optBundle)
        print "optSurplus = {0}".format(optSurplus)
        
    n_goods = bundles.shape[1]
    bid = numpy.zeros(n_goods, dtype = numpy.float)
    
    for goodIdx, good in enumerate(optBundle):
        if good:
            bid[goodIdx] = marginalUtility(bundles, valuation, 
                                           pricePrediction, goodIdx)
            
    if verbose:
        print "bid = {0}".format(bid)
        
    return bid
Example #2
0
def straightMV(bundles, revenue, pricePrediction, verbose = False):
    b = numpy.atleast_2d(bundles)
    rev = numpy.atleast_1d(revenue)
    pp = numpy.atleast_1d(pricePrediction)
    
    n_goods = bundles.shape[1]
    marginalValueBid = numpy.zeros(n_goods,dtype=numpy.float64)
    for goodIdx in xrange(n_goods):
        marginalValueBid[goodIdx] = \
                marginalUtility(b,rev,pp,goodIdx)
                                 
    if verbose:
        print marginalValueBid
                                         
    return marginalValueBid
Example #3
0
def targetMVS(bundles, revenue, pricePrediction, verbose = False):

    ppView      = numpy.atleast_1d(pricePrediction).astype('float')
    
    optBundle = acq(bundles, revenue, pricePrediction, verbose)[0]
    
    ppCopy = ppView.copy()
    ppCopy[~optBundle] = numpy.float('inf')
    
    if verbose:
        print "Computing bid via targetMVS"
        print "Optimal Bundle = {0}".format(optBundle.astype('int'))
        print "Price Prediction Copy = {0}".format(ppCopy)
    
    bids = numpy.zeros(ppView.shape[0])
    
    for goodIdx in numpy.flatnonzero(optBundle == True):
        bids[goodIdx] = marginalUtility(bundles, revenue, ppCopy, goodIdx)
    
    if verbose:
        print "bids = {0}".format(bids)    
        
    return bids