示例#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
示例#2
0
def targetPrice(bundles, revenue, pricePrediction, verbose = False):
    bundleView  = numpy.atleast_2d(bundles)
    revenueView = numpy.atleast_1d(revenue)
    ppView      = numpy.atleast_1d(pricePrediction)
    
    if verbose:
        print "Computing bid via targetPrice strategy."

        
    optBundle = acq(bundleView, revenueView, ppView, verbose)[0]

    bid = ppView.copy()
    bid[~optBundle] = 0.0
    
    if verbose:
        print "Optimal Bundle   = {0}".format(optBundle)
        print "Price Prediction = {0}".format(ppView)
        print "bid              = {0}".format(bid)
        
    return bid
示例#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