Esempio n. 1
0
try:
  bids = np.array(ast.literal_eval(data_in['bids']))
  costs = np.array([ast.literal_eval(data_in['costs_{}'.format(i)]) for i in range(n)])

except KeyError:
  bs = [ast.literal_eval(data_in['b_lower']), ast.literal_eval(data_in['b_upper'])]
  css = [ast.literal_eval(data_in['cs_{}'.format(i)]) for i in range(n)]

# Verify sufficiency
cdfs = []
for bounds in zip(lower_extremities, upper_extremities):
  cdfs.append(ss.uniform(loc=bounds[0], scale=bounds[1]-bounds[0]))

try:
  step = len(bids) // 35
  s_costs, s_bids = verify_sufficiency(costs, bids, b_upper, cdfs, step=step)

except NameError:
  # Define inverse bid function
  def cost_func(l, cs, x):
    return l + sum([c*(x-bs[0])**i for c,i in zip(cs, range(1,len(cs)+1))])
  
  # Compute bids and costs
  bids = np.linspace(bs[0], bs[1], 10000)
  cost_funcs = [partial(cost_func, l, cs) for l,cs in zip(lower_extremities, css)]
  costs = np.array([[f(b) for b in bids] for f in cost_funcs])

  step = len(bids) // 50
  s_costs, s_bids = verify_sufficiency(costs, bids, b_upper, cdfs, step=step)

# Plot
Esempio n. 2
0
except KeyError:
  bs = [ast.literal_eval(data_in['b_lower']), support[1]]
  css = [ast.literal_eval(data_in['cs_{}'.format(i)]) for i in range(n)]

# Verify sufficiency
cdfs = []
for p in params:
    loc = p['location']
    scale = p['scale']
    a = (support[0] - loc) / scale
    b = (support[1] - loc) / scale
    cdfs.append(ss.truncnorm(a, b, loc=loc, scale=scale))

try:
    step = len(bids) // 35
    s_costs, s_bids = verify_sufficiency(costs, bids, support[1], cdfs, step=step)

except NameError:
    # Define inverse bid function
    def cost_func(cs, x):
        return bs[0] + sum([c*(x-bs[0])**i for c,i in zip(cs, range(len(cs)))])

    # Compute bids and costs
    bids = np.linspace(bs[0], bs[1], 10000)
    cost_funcs = [partial(cost_func, cs) for cs in css]
    costs = np.array([[f(b) for b in bids] for f in cost_funcs])

    step = len(bids) // 50
    s_costs, s_bids = verify_sufficiency(costs, bids, support[1], cdfs, step=step)

# Plot