コード例 #1
0
def selection(inventory, revenue):
    "Takes in the item and time and checks its corresponding inventory"
    print "Selection called"

    bernoulli_n = 1
    if (inventory.cur < inventory.maxi):
        decision = 0
        number_items_dp = 0

    else:  # add item to selection with some probability
        number_items_dp = inventory.cur - inventory.maxi
        # Commpute the probability
        prob = (float)(revenue.dp / (revenue.dp + revenue.cp))

        # make a Bernoulli draw with probability "prob"
        #decision=bernoulli.rvs(prob,loc=0,size=1) # part of scipy
        decision = binomial(bernoulli_n, prob, 1)

    it = d.get1(db_name, 'product', inventory.id)
    it['number_items_dp'] = number_items_dp
    it['decision'] = it['decision']
    d.replace1(db_name, 'product', it, it['id'])

    return decision
コード例 #2
0
ファイル: main.py プロジェクト: at3103/Dynamic-Pricing
def selection(inventory,revenue):
    "Takes in the item and time and checks its corresponding inventory" 
    print "Selection called"
    
    bernoulli_n=1
    if(inventory.cur<inventory.maxi):
        decision=0
        number_items_dp=0

    else:# add item to selection with some probability 
        number_items_dp=inventory.cur-inventory.maxi
        # Commpute the probability 
        prob=(float)(revenue.dp/(revenue.dp+revenue.cp))
            
        # make a Bernoulli draw with probability "prob"
        #decision=bernoulli.rvs(prob,loc=0,size=1) # part of scipy
        decision=binomial(bernoulli_n,prob,1)

    it=d.get1(db_name,'product',inventory.id)
    it['number_items_dp']=number_items_dp
    it['decision']=it['decision']
    d.replace1(db_name,'product',it,it['id'])
    
    return decision
コード例 #3
0
def bidding(item, buyer_offer, customer_loyalty, buyer_demand, profit_margin):
    it = d.get1(db_name, 'product', item)

    return bidding_compute(it, buyer_offer, customer_loyalty, buyer_demand,
                           profit_margin)
コード例 #4
0
ファイル: main.py プロジェクト: at3103/Dynamic-Pricing
def bidding(item, buyer_offer,customer_loyalty,buyer_demand,profit_margin):    
    it=d.get1(db_name,'product',item)
    bidding_compute(it,buyer_offer,customer_loyalty,buyer_demand,profit_margin)
    return