1. Homepage
  2. Programming
  3. Python II Assignment: Revenue maximization

Python II Assignment: Revenue maximization

Engage in a Conversation
PythonRevenue maximization

1 Revenue maximization

1.1 One item, one buyer

Revenue maximization is one of the most prominent problems in economics. Suppose we want to sell a laptop to potential buyer, that has a value (probability) distribution F describing how they value the laptop (this is called the Bayesian setting in the literature). We consider the following posted price selling mechanism: CourseNana.COM

  1. The seller sets a price p ≥ 0.
  2. A value v is generated from a random variable X ∼ F.
  3. The item is sold to the buyer if and only if v ≥ p.

The expected revenue of the seller using the posted price p, given the distribution F, is CourseNana.COM

R(p, X) = p · P(X ≥ p), 1 CourseNana.COM

which is the selling price p times the probability that we sell the laptop. In order to maximize revenue the seller would like to solve the problem max R(p, X).p≥0(1) CourseNana.COM

Take X ∼ Unif[a, b], i.e, the uniform distribution on the interval [a, b]. a) [4 points] Write a function that takes as inputs a and b, and outputs a selling price (1) by using an appropriate optimization method with initial estimate a. b) [4 points] For (a, b) ∈ {(0, 1), (10, 20), (20, 60), (40, 100)}, plot R(p, X) as a function of p ∈ [a, b] and also indicate the maximum found in a). Use a different plot for every combination (a, b). CourseNana.COM

1.2 Multiple items, one buyer

We next consider the setting in which the seller has multiple items i = 1, . . . , m for sale. For every item i = 1, . . . , m the buyer has a value distribution Fi that models how they value item i. We assume the distributions to be independent of each other. This time the seller uses a bundling selling mechanism, which works as follows: CourseNana.COM

  1. The seller sets a price p ≥ 0.
  2. For i = 1, . . . , m, a value vi is generated from a random variable Xi that is distributed according to the distribution Fi . These values describe how much the buyer values item
  3. The items are sold as a bundle to the buyer if and only if ∑i vi ≥ p. The revenue function of the seller using the bundling price p, given distributions F1 , . . . , Fm , is now !R(p, X1 , . . . , Xm ) = p · P∑ Xi ≥ pi=1

which is the bundling price times the probability that the total value that the buyer has for the items exceed the price. The goal is now to solve CourseNana.COM

max R(p, X1 , . . . , Xm ).p≥0(2) CourseNana.COM

We assume that Xi ∼ Unif[ai , bi ] for i = 1, . . . , m. c) [2 points] Write a function that takes as input the numbers a1 , . . . , am , b1 , . . . , bm and sample size T , and outputs T samples from ∑m i=1 Xi . One sample from the random variable Y = ∑mX is obtained by generating a sample for every individual Xi and summing them i=1 i up. d) [4 points] Write a function that takes as input a price p and a list of numbers, and returns p times the fraction of numbers that is greater or equal than p. When the numbers represent a sum of samples, this function can be seen as an empirical estimate for p · P (∑m i=1 Xi ≥ p). For plotting purposes in part g) it is good to “vectorize” this function w.r.t. p. e) [3 points] Write a function that takes as input a1 , . . . , am , b1 , . . . , bm and T additional numbers. It should find the price that maximizes the function constructed in part d) for these T numbers. Optimization should be done using the Nelder-Mead method and with ∑i ai as an initial estimate. This function solves the expression in (2) “empirically”. f) [2 points] Consider the case with three items, where a1 = 0, b1 = 1, a2 = 0, b2 = 2, a3 = 1, b3 = 2, and generate T = 1000 samples of ∑i Xi using the function of part c). Apply the function of part e) to these samples. g) [2 points] Generate a plot on the interval [0, 5] of the revenue under different values for p and indicate the optimal price maximizing the revenue in (2) in your plot. CourseNana.COM

1.3 Multiple items, multiple buyers

We continue with the setting where the seller has m items for sale, but where there are n potential buyers. For every combination of item i and buyer j, we now have a value distribution Xi j from which buyer’s j value for item i is generated. Every buyer can get assigned at most one item, and therefore the goal will be to create a (partial) matching between items and buyers. A (partial) matching M between items I = {1, . . . , m} and buyer B = {1, . . . , n} is a collection of edges M ⊆ {(i, j) : i ∈ I and j ∈ B} so that every item i is assigned to at most one buyer (i.e., i appears in at most one edge in M), and every buyer j to at most one item (i.e., j appears in at most one edge in M). Note that some items might remain unsold, and some buyers might not receive an item. CourseNana.COM

We consider the following matching mechanism: CourseNana.COM

  1. The seller sets a price pi ≥ 0 for every item i = 1, . . . , m.
  2. A value vi j is generated from random variable Xi j ∼ Fi j for every i = 1, . . . , m and j = 1, . . . , n.
  3. Select a matching M ⊆ {(i, j) ∈ I × B : vi j > pi } that maximizes the sum of the prices of the matched items in M. That is, we can only match an item i to a buyer j if the buyer’s value vi j exceeds the price pi for item i. Example 1. Suppose we have two items and two potential buyers as illustrated in Figure 1.

Figure 1: An example where the edges contain the generated values of the vi j (for the sake of this example it is not important which distributions these numbers come from). On the right we have only selected the edges for which vi j > pi . CourseNana.COM

The only edges for which vi j > pi are (1, 2) and (2, 2). The matching M = {(1, 2)} (consisting of one edge) that assigns item 1 to buyer 2 gives a (total) price of 5 for the seller, and the matching M = {(2, 2)} that assigns item 2 to buyer 2 a price of 4. The maximum matching therefore is given by assigning item 1 to buyer 2; note that item 2 remains unassigned. CourseNana.COM

h) [5 points] Write a function that takes as input a vector of item prices p = (p1 , . . . , pm ) and a matrix V = (vi j ) of realized values for i = 1, . . . , m and j = 1, . . . , n. It should output a matching satisfying the conditions in Step 3. of the matching mechanism, as well as the sum of the prices of the matched items. (Explain in your report how you model a matching in Python.) CourseNana.COM

You can solve this question by using the function LINEAR SUM ASSIGNMENT from SciPy’s optimization module. For this you first have to find an appropriate input matrix based on the vector p and matrix V ; explain in your report how you do this. CourseNana.COM

Hint: Note that LINEAR SUM ASSIGNMENT requires you to input an edge weight for every possible edge (also those with vi j ≤ pi ). Choose a weight of zero for those edges. Don’t forget to remove edges from the final matching corresponding to such edges. We will use exhaustive search to search for prices that perform well on average. In mathematical terms, we are trying to (empirically) solve CourseNana.COM

maxp=(p1 ,...,pm )E[R(p,V )],(3) CourseNana.COM

where the expectation is taken w.r.t. the randomly generated entries vi j of the matrix V , and where R(p,V ) denotes the sum of the matched edges that you get as output of your function created in part h). i) [3 points] Create a function that takes as input a vector of item prices p = (p1 , . . . , pm ), a number n of buyers, and a number K. It should output the average (of the prices of the matched items) of K runs of your function in part h). In every run use a value matrix V of size m × n whose elements vi j are generated independently with distribution Unif[0, 1]. This function empirically estimates the quantity E[R(p,V )] in (3). For ∆ ∈ N, let CourseNana.COM

P∆ = {p = (p1 , . . . , pm ) ∈ [0, 1]m ∆ · p ∈ {0, 1, 2, . . . , ∆}m }. CourseNana.COM

In other words, for every vector (p1 , . . . , pm ) ∈ P every element pi is of the form ki /∆ for some ki ∈ {0, 1, 2, . . . , ∆}. The set P, roughly speaking, models an m-dimensional “grid” of the hypercube [0, 1]m with step size ∆ in every component. j) [4 points] Write a function that for given m and n, and numbers K and ∆, applies the function in part i) with K runs to every p ∈ P∆ .2 It should output prices that maximize the objective of function i). k) [1 points] Run the function in part j) for m = 2, n = 3, ∆ = 50 and K = 100. CourseNana.COM

For the sake of a good comparison, you should use for every p the same random values vi j in the K runs. CourseNana.COM

Get in Touch with Our Experts

WeChat WeChat
Whatsapp WhatsApp
Python代写,Revenue maximization代写,Python代编,Revenue maximization代编,Python代考,Revenue maximization代考,Pythonhelp,Revenue maximizationhelp,Python作业代写,Revenue maximization作业代写,Python编程代写,Revenue maximization编程代写,Pythonprogramming help,Revenue maximizationprogramming help,Pythonassignment help,Revenue maximizationassignment help,Pythonsolution,Revenue maximizationsolution,