1 Introduction

Market mechanism plays a very important role in Economy to match the product provider and consumer. In recent years, many new electronic commercial companies appear, e.g., Taobao, Uber, DiDi, AirBnB. Compared with the traditional models, such new market models are more complicated and involve more people. Thus, fairness and efficiency should be considered as the key features of the market mechanism.

Generally speaking, market contains two participants, the supplier and the buyer. The supplier has some product to be sold so as to maximize his revenue, while the buyer wants to buy some products within his budget to maximize his utility. The supplier sets the price for each product and allocates the product to buyers. When the price goes higher, the demand of buyers will decrease accordingly. If the supply equals to the demands, such situation is called the market equilibrium. Arrow and Debreu formally defined the market equilibrium (Arrow and Debreu 1954), which satisfies the following conditions.

  • market clearance: the product is sold out.

  • budget bound: the total payment of a buyer is no more than his budget.

  • individual optimal: each buyer get the optimal utility w.r.t. the designated price.

In the study of the market equilibrium, some well-adopted utility functions have been analyzed. Linear utility market, in which the utility of each buyer is a linear combination of the assigned amounts of products, is well analyzed by Adsul et al. (2010), Chen et al. (2011, 2012, 2016). The Cobb-Douglas utility function, which has the form \(x^ay^{1-a}\) and first introduced by Cobb and Douglas (1928), is also well adopted in market equilibrium (Brânzei et al. 2014; Cheng et al. 2018).

In this paper, we consider the generalization of the market equilibrium where each buyer may have an optional preference and can be satisfied by any product in his preferences. Formally, the supplier has two types of products, A and B. Each buyer has a preference which denotes the product the buyer may buy. The preference may be a single product, \(\{A\}\) or \(\{B\}\), or optional \(\{A, B\}\). In the latter case, both products may fit the buyer, but he can only buy one of them. The supplier decides the price of each product and assigns some amount of product to the buyers according to their preferences and budgets. In a fair market, each buyer has no interest in switching to another product, i.e., he cannot get more utility via switching. Thus, the prices of the product must be determined carefully and these two products may not be sold out (an example is shown in the latter part of this section).

The problem we studied in this paper is described as follows.

Selling with preference

A supplier has two types of products, A and B, to be sold to a set of buyers \(I=\{1, 2, \ldots , n\}\). The amounts of them are \(m_A\) and \(m_B\) respectively. The preference of each buyer is either product A or product B, or both, i.e., each buyer’s preference is one of the three forms, \(\{A\}\), \(\{B\}\), \(\{A,B\}\). Each buyer can only choose one type of product to buy. The budget of buyer i is \(b_i\). When buyer i buys some products, he get some utility. In this paper, we consider the linear utility function. Precisely speaking, the utility of buyer i is

$$\begin{aligned} u_i = \left\{ \begin{array}{l@{\quad }l} c_{iA}\cdot x_{iA} &{} \text {if}\,\text {buyer}\, i\, \text {buys}\, x_{iA}\, \text {amount of product} A\\ c_{iB}\cdot x_{iB} &{} \text {if}\,\text {buyer}\, i\, \text {buys}\, x_{iB}\, \text {amount of product} B\\ \end{array} \right. \end{aligned}$$

where \(c_{iA}\) and \(c_{iB}\) are user i’s utility coefficients for buying product A and product B respectively.

The supplier decides the price of each product and assigns some amount of products to each buyer. We say the outcome is semi market equilibrium if the following conditions hold.

  • Market semi clearance At least one type of product is fully assigned, i.e., either \(\sum _{i\in I} x_{iA} = m_A\), or \(\sum _{i\in I} x_{iB} = m_B\).

  • Budget bound The total cost of each buyer is upper bounded by his budget, i.e., \(x_{iX}\cdot p_X\le b_i\) for \(i\in I\) and \(X\in \{A,B\}\).

  • Individual optimality Each buyer’s utility is maximized w.r.t. the designated price, i.e., \(c_{iX}\cdot b_i/p_{X} \ge c_{iX'}\cdot b_i/p_{X'}\) if the supplier assigns product X to buyer i, where \(\{X,X'\}=\{A,B\}\).

Consider a simple example. The amounts of two products are 1 and 1.5 respectively. The budget of two buyers are both 1, the utility functions are \(u_{1A}=u_{1B}=u_{2A}=u_{2B}=x\), where x is the assigned amount to the buyer. The supplier sets \(p_A=p_B=1\) and allocates 1 product A to buyer 1 and 1 product B to buyer 2. This configuration is semi market equilibrium, product A is sold out while product B has some remaining amount. The supplier cannot decrease the price to have another semi market equilibrium.

The remaining part of the paper is organized as follows. In Sect. 2, we show that in satisfying the condition of semi market equilibrium, maximizing the total utility among buyers is NP-hard, then give some important characteristics of the problem. In Sect. 3, we introduce an iterative algorithm with an approximation ratio 1.5. In Sect. 4, we present a PTAS for the problem, which is a (\(1+\epsilon \))-approximation algorithm with the running time \(O(2^{1/\epsilon }+n\log n)\) for any positive \(\epsilon \). We conclude this paper in Sect. 5.

2 Characteristics of the selling with preference

We first show it is NP-hard to find the maximum total utility for the selling with preference problem.

Theorem 1

Maximizing the total utility among buyers is NP-hard in satisfying the semi market equilibrium.

Proof

We prove the NP-hardness by the reduction from the partition problem. In the partition problem, given a set of values \(V=\{v_1, v_2, \ldots v_n\}\), we are asked whether V can be partitioned into two disjoint sets \(V_1\) and \(V_2\) such that \(\sum _{i\in V_1} v_i = \sum _{i\in V_2} v_i\).

Now we construct an instance of the selling problem from the partition problem. The amount of two products are both \(m_A=m_B=\sum _{i\in V} v_i/2\). There are n buyers and each buyer’s preference is \(\{A,B\}\). For buyer i, the budget is \(v_i\) and the utility function is \(u_i=x_{iA}\) if assigned with product A, or \(u_i=x_{iB}\) if assigned with product B. Thus, the maximum possible total utility is \(\sum _{i\in V} v_i\).

According to the condition of individual optimality, if \(p_A<p_B\) or \(p_A>p_B\), all buyers will prefer the product with a lower price. In such situation, all amount of either product A or product B remains unassigned, which is not optimal. Thus, in the constructed instance, the supplier must set price \(p_A=p_B\).

In one direction, if the answer of the partition problem is yes, i.e., \(V=V_1+V_2\) and \(\sum _{i\in V_1} v_i = \sum _{i\in V_2} v_i=\sum _{i\in V} v_i/2\). Then for the constructed selling problem, set \(p_A=p_B=1\) and assign \(v_i\) product A (or B) to buyer i if \(i\in V_1\) (or \(i\in V_2\)). In this case, the total utility is \(\sum _{i\in V} v_i\) and get the maximum value.

In another direction, assume that the constructed selling problem can be solved with the total utility \(\sum _{i\in V} v_i\). Since the amount of each product is \(\sum _{i\in V} v_i/2\), product A and product B are both fully assigned. Note that \(p_A=p_B\) and the coefficient of each buyer on each product is 1, the designated prices are \(p_A=p_B=1\). Each buyer i is assigned with the amount of \(v_i\). Therefore, the solution of the selling problem leads to the yes answer of the partition problem.

Therefore, we conclude that maximizing the total utility among buyers is NP-hard in satisfying the semi market equilibrium. \(\square \)

We analyze the characteristics of the assignment satisfying the semi market equilibrium. Let \(r_i=\frac{c_{iA}}{c_{iB}}\). If the preference of buyer i is \(\{A\}\), then \(r_i=+\infty \); if the preference of buyer i is \(\{B\}\), then \(r_i=0\).

Lemma 2

In an assignment satisfying the semi market equilibrium, \(r_i\ge r_j\) for any buyer i assigned at A and any buyer j assigned at B.

Proof

Suppose buyer i is assigned at A with price \(p_A\) and buyer j is assigned at B with price \(p_B\). Due to individual optimality, we have \(\frac{b_i}{p_A}\cdot c_{iA} \ge \frac{b_i}{p_B}\cdot c_{iB}\) and \(\frac{b_j}{p_B}\cdot c_{jB}\ge \frac{b_j}{p_A}\cdot c_{jA}\), thus, we have \(\frac{p_A}{p_B}\le \frac{c_{iA}}{c_{iB}}\) and \(\frac{p_A}{p_B} \ge \frac{c_{jA}}{c_{jB}}\) Therefore,

$$\begin{aligned} r_i=\frac{c_{iA}}{c_{iB}} \ge \frac{p_A}{p_B} \ge \frac{c_{jA}}{c_{jB}}=r_j. \end{aligned}$$

\(\square \)

Corollary 3

Given price pair (\(p_A, p_B\)), if buyer i has the same utility by assigning on both products, \(r_i=\frac{p_A}{p_B}\).

Since each buyer will select the product with the higher utility, we have the following fact.

Fact 1

For two assignments C and \(C'\) with price pairs (\(p_A, p_B\)) and (\(p_A', p_B'\)) respectively, if \(p_A\ge p_A'\) and \(p_B\ge p_B'\), then the total utility of C is no more than the total utility of \(C'\).

Proof

To show the correctness of this fact, we consider the utilities \(u_i\) on each buyer i of these two price pairs. If buyer i is assigned on the same product for these two price pairs, since \(p_A\ge p_A'\) and \(p_B\ge p_B'\), the utility is higher on \(C'\). Otherwise, w.l.o.g., assume buyer i is assigned on A w.r.t. C and on B w.r.t. \(C'\). In this case, assigning buyer i on B with price \(p_B'\) has more utility than on A with price \(p_A'\), which is higher than the assignment with price \(p_A\). \(\square \)

Consider the assignment which only satisfies the budget bound and the individual optimality. We will find the relationship between the assignment with the maximum total utility in terms of the amount of products. We say an assignment is fair if it satisfies the budget bound and the individual optimality.

Lemma 4

In a fair assignment with price \(p_A\) and \(p_B\), if the assigned amount of product A and product B are at least \(m_A\) and \(m_B\) respectively, the total utility is at least the maximum assignment satisfying the semi market equilibrium.

Proof

Consider a fair assignment, the prices of product A and product B are \(p_A\) and \(p_B\), and the amount of assigned products are \(l_A\) and \(l_B\).

We claim that for any fair assignment with higher utility, the assigned amount of product A and product B cannot be less than \(l_A\) and \(l_B\), respectively.

Consider the price of product B decreased to \(p_B^-\), then some buyers may have a higher utility by switching from A to B. Let \(S_{AB}\) be the set of such buyers and the assigned amount of these buyers will be changed from \(\sum _{i\in S_{AB}} b_i/p_A\) to \(\sum _{i\in S_{AB}}b_i/p_B^-\). The assigned amount in A is decreased while the assigned amount in B is increased. At this stage, the claim holds. If the price of A decreased to \(p_A^-\), some buyers may have a higher utility by switching from B to A. Let \(S_{BA}\) be the set of such buyers. The assigned amount of these buyers will be changed from \(\sum _{j\in S_{AB}} b_j/p_B^-\) to \(\sum _{j\in S_{AB}} b_j/p_A^-\).

In this configuration, the assigned amount in A is

$$\begin{aligned}\frac{l_Ap_A-\sum _{i\in S_{AB}}b_i+\sum _{j\in S_{BA}}b_j}{p_A^-} \ge l_A -\sum _{i\in S_{AB}}b_i/p_A+\sum _{j\in S_{BA}}b_j/p_A \end{aligned}$$

while in B is

$$\begin{aligned} \frac{l_Bp_B+\sum _{i\in S_{AB}}b_i-\sum _{j\in S_{BA}}b_j}{p_B^-} \ge l_B+\sum _{i\in S_{AB}}b_i/p_B-\sum _{j\in S_{BA}}b_j/p_B. \end{aligned}$$

The right parts of the above inequalities lower bound the assigned amount of product A and product B after decreasing the prices. Next, we will show that these two lower bounds cannot be strictly less than \(l_A\) and \(l_B\) simultaneously.

  • If \(\sum _{j\in S_{BA}}b_j/p_A^- < \sum _{i\in S_{AB}}b_i/p_A\), we have \(l_A-\sum _{i\in S_{AB}}b_i/p_A+\sum _{j\in S_{BA}}b_j/p_A^- < l_A\). In this case, \(\sum _{j\in S_{BA}}b_j<\frac{p_A^-}{p_A}\sum _{i\in S_{AB}}b_i< \sum _{i\in S_{AB}}b_i < \frac{p_B}{p_B^-}\sum _{i\in S_{AB}}b_i\), thus we have \(\frac{\sum _{i\in S_{AB}}b_i}{p_B^-}> \frac{\sum _{j\in S_{BA}}b_j}{p_B}\). Therefore, \(l_B-\sum _{j\in S_{BA}}b_j/p_B+\sum _{i\in S_{AB}}b_i/p_A^- > l_B\).

  • If \(\sum _{j\in S_{BA}}b_j/p_A^- > \sum _{i\in S_{AB}}b_i/p_A\), we have \(l_A-\sum _{i\in S_{AB}}b_i/p_A+\sum _{j\in S_{BA}}b_j/p_A^- > l_A\). In this case, \(\sum _{j\in S_{BA}}b_j> \frac{p_A^-}{p_A}\sum _{i\in S_{AB}}b_i < \sum _{i\in S_{AB}}b_i > \frac{p_B}{p_B^-}\sum _{i\in S_{AB}}b_i\), thus we have \(\frac{\sum _{i\in S_{AB}}b_i}{p_B^-} < \frac{\sum _{j\in S_{BA}}b_j}{p_B}\). Therefore, \(l_B-\sum _{j\in S_{BA}}b_j/p_B+\sum _{i\in S_{AB}}b_i/p_A^- < l_B\).

Assume that in the optimum assignment, the designated prices are \(p_A^*\) and \(p_B^*\), and the assigned amount on A and B are \(m_A^*\) and \(m_B^*\), respectively. Note that \(m_A^*\le m_A\), \(m_B^*\le m_B\) and the maximum assignment is also fair. Consider a fair assignment \(\mathcal {A}\) with the assigned amount \(l_A\ge m_A\) and \(l_B\ge m_B\), let \(p_A\) and \(p_B\) denote the prices of such assignment. We claim that \(p_A\le p_A^*\) and \(p_B\le p_B^*\), otherwise, the assigned amount will violate \(l_A\ge m_A\) or \(l_B\ge m_B\). According to Fact 1, the total utility of the assignment \(\mathcal {A}\) is no less than the total utility of the optimum assignment.

Fact 2

Just considering the fair assignment, suppose the total utility U can be achieved w.r.t. the assignment \(\mathcal {A}\) such that the prices are \(p_A\) and \(p_B\) respectively. If the prices are updated to \(p_A/c\) and \(p_B/c\), where c is a positive real number, an assignment with the total utility U/c can be achieved too.

3 An iterative 1.5-approximation algorithm

With the help of Lemma 4, we give an iterative algorithm Product-Assignment to maximize the total utility. Let \(S_A\) and \(S_B\) be the set of buyers assigned to A and B respectively.

figure a
figure b

Theorem 5

Product-Assignment can be done in \(O(n\log n)\) time and with the approximation ratio of 1.5.

Proof

Let’s first consider the running time of Product-Assignment. According to Lemma 2, \(r_i\ge r_j\) for any buyer i assigned at A and any buyer j assigned at B. From the criteria in Update-Assignment, the buyer with the lowest budget will be selected for swapping. We may sort buyers with respect to the value of \(r_i\). If more than one buyer have the same value, the buyer with lower budget appears first. The running time of sorting is in \(O(n\log n)\). The For loop in Product-Assignment can be done in O(n) time. For the procedure Update-Assignment, the decrease of the prices can be computed in constant time according to the sequence of \(r_i\). We claim that each buyer can be swapped at most once. Otherwise, the amount constraint of product A or B will be violated since the prices are decreasing. Therefore, the total running time of the procedure Update-Assignment is O(n) and thus Product-Assignment can be done in \(O(n\log n)\) time.

Consider the final configuration \(\mathcal {C}\) of the assignment from the algorithm, either A or B is fully assigned. W.l.o.g., assume that product A is fully assigned to buyers in \(S_A\) and some amount of product B remains unassigned. Let \(\delta \cdot m_B\) be the free product in B. There must exist some buyer \(i\in S_A\) such that assigning i to B with price \(p_B\) has the same utility. Otherwise, the price of B can be further decreased. However, switching buyer i from A to B will either reach or beyond the amount \(m_B\), i.e., \(\frac{b_i}{p_B}\ge \delta \cdot m_B\).

If buyer i can be partially assigned to both A and B, and the occupation ratio in both products are exactly equal, we may decrease the prices \(p_A\) and \(p_B\) with the same ratio until both product fully utilized. According to Lemma 4, the total utility is at least the optimal solution. We use this idea to upper bound the approximation ratio.

Assume buyer i can be split to buyer \(i_A\) and \(i_B\) with budget \(b_{iA}\) and \(b_{iB}\) respectively. Thus, \(b_i=b_{iA} + b_{iB}\). Further assume that from the configuration \(\mathcal {C}\), switching buyer \(i_B\) to product B lead to a configuration \(\mathcal {C'}\) in which the occupation ratio of each product are equal. That means

$$\begin{aligned} \frac{\delta \cdot m_B - \frac{b_{iB}}{p_B}}{m_B} = \frac{\frac{b_{iB}}{p_A}}{m_A}. \end{aligned}$$

Thus,

$$\begin{aligned} b_{iB} = \frac{\delta }{\frac{1}{p_A\cdot m_A} + \frac{1}{p_B\cdot m_B}} \end{aligned}$$

The approximation is upper bounded by

$$\begin{aligned} \frac{m_A}{m_A - \frac{b_{iB}}{p_A}} = \frac{m_A}{m_A - \frac{\delta }{\frac{1}{ m_A} + \frac{p_A}{p_B\cdot m_B}}} = \frac{m_A\cdot p_A + m_B\cdot p_B}{ m_A\cdot p_A + (1-\delta ) \cdot m_B\cdot p_B} = \frac{1 + k}{1 + k - \delta } \end{aligned}$$

where \(k = \frac{m_A\cdot p_A}{m_B\cdot p_B}\).

From the above analysis, the higher value of \(\delta \), the higher of the approximation ratio. Since \(b_i\ge \delta \cdot m_B\cdot p_B\), large \(\delta \) means the higher budget of buyer i. We use this fact to give another bound of the approximation ratio. If assign buyer i to product A, the price of product A is at least \(\frac{b_i}{m_A}\) and all amount of product A is assigned to buyer i. If assign buyer i to product A with price \(p_A\), the assigned amount is \(\frac{b_i}{p_A}\). In this case, the approximation ratio is at most \(\frac{m_A\cdot p_A}{b_i}\). Similarly, if assign buyer i to product B with price \(p_B\), the approximation ratio is at most \(\frac{m_B\cdot b_B}{b_i}\). Thus, if only consider buyer i with the price \(p_A\) or \(p_B\), the approximation ratio is upper bounded by

$$\begin{aligned} \max \left\{ \frac{m_A\cdot p_A}{b_i}, \frac{m_B\cdot p_B}{b_i}\right\} \le \frac{\max \{m_A\cdot p_A, m_B\cdot p_B\}}{\delta \cdot m_B\cdot p_B}=\frac{\max \{k, 1\}}{\delta }. \end{aligned}$$

Combining the above analysis, the approximation ratio is at most

$$\begin{aligned} \min \left\{ \frac{1 + k}{1 + k - \delta }, \frac{\max \{k, 1\}}{\delta }\right\} \end{aligned}$$
  • If \(k\ge 1\), the approximation ratio is at most \(\min \left\{ \frac{1 + k}{1 + k - \delta }, \frac{k}{\delta }\right\} \). These two values are equal when \(\delta = \frac{k^2+k}{2k+1}\). Thus, the ratio is \(\frac{2k+1}{k+1}\le 1.5\).

  • If \(k<1\), the approximation ratio is at most \(\min \left\{ \frac{1 + k}{1 + k - \delta }, \frac{1}{\delta }\right\} \). These two values are equal when \(\delta = \frac{k+1}{k+2}\). Thus, the ratio is \(\frac{k+2}{k+1}\le 1.5\).

4 A PTAS to maximize the total utilities

In this section, we give a polynomial-time algorithm scheme (PTAS) to maximize the total utilities for the selling with preference.

According to Lemma 4 and Fact 2, we may fix the price \(p_A\) and modify the price \(p_B\) to find a good fair assignment, then update the prices with the same ratio to almost fully utilize both products.

Given prices \(p_A\) and \(p_B\), if no buyer has the same utility on both products, that means each buyer prefers a unique product, in this case, the assignment is optimal w.r.t. the designated prices. However, for any designated price pair, some buyers may have the same utilities on both products. How to allocate them to these two products is the key point of the problem.

Fact 3

Fix \(p_A\), the number of prices \(p_B\) such that at least one buyer has the same utility on both products w.r.t. (\(p_A\), \(p_B\)) is at most n.

Now we show that considering these n price pairs is sufficient to have a good solution. Let (\(p_A, p_B^1\)), (\(p_A, p_B^2\)), ...be such pairs satisfying \(p_B^i<p_B^{i+1}\) for any \(i\ge 1\). Let (\(p_A\), p) be a price pair such that \(p_B^i< p < p_B^{i+1}\). From the previous analysis, we know that each buyer has a unique preferred product and the total utilities are fixed. W.l.o.g., let \(S_A\) and \(S_B\) denote the buyer sets who prefer product A and B respectively. For both (\(p_A\), \(p_B^{i}\)) and (\(p_A\), \(p_B^{i+1}\)), some buyers may prefer both A and B. Since \(p_B^{i}\) is the highest value below p such that some buyer has the same utility on A and B and allocating all these buyers on A is also a candidate solution, which is exactly (\(S_A, S_B\)). The case for \(p_B^{i+1}\) is similar. Thus, in the algorithm, we have only need to consider these price pairs.

For all such pairs, according to Lemma 4 and Fact 2, we have to find the assignment as close to (\(m_A, m_B\)) as possible. For any pair (\(p_A, p_B\)), if we decrease the value of \(p_B\), some buyers may switch to product B; on the other hand, if increase \(p_B\), some buyers may switch to product A. The switching is monotone w.r.t. the change of the price \(p_B\). Thus, there is only one “good” pair can have the optimum value.

For the price pair (\(p_A,p_B\)), let \(S_A'\) and \(S_B'\) be the buyer sets who prefer only product A and B respectively. Let \(S_{AB}'\) be the buyer set who prefer both A and B.

  • If allocate \(S_A'\) and \(S_{AB}'\) on A and allocate \(S_B'\) on B, the assigned amount of A and B are \(\sum _{i\in S_A'\cup S_{AB}'} \frac{b_i}{p_A}\) and \(\sum _{i\in S_B'} \frac{b_i}{p_B}\), respectively.

  • If allocate \(S_A'\) on A and allocate \(S_B'\) and \(S_{AB}'\) on B, the assigned amount of A and B are \(\sum _{i\in S_A'} \frac{b_i}{p_A}\) and \(\sum _{i\in S_B\cup S_{AB}'} \frac{b_i}{p_B}\), respectively.

If the following two inequalities hold, we say that the price pair (\(p_A, p_B\)) is “good”.

$$\begin{aligned} \frac{\sum _{\text {buyers\ prefer\ A}}b_i/p_A}{\sum _{\text {buyers\ only\ prefer\ B}}b_i/p_B}= \frac{\sum _{i\in S_A'\cup S_{AB}'} b_i/p_A}{\sum _{i\in S_B'} b_i/p_B}\ge \frac{m_A}{m_B}\end{aligned}$$
(1)
$$\begin{aligned} \frac{\sum _{\text {buyers\ only\ prefer\ A}}b_i/p_A}{\sum _{\text {buyers\ prefer\ B}}b_i/p_B}= \frac{\sum _{i\in S_A'} b_i/p_A}{\sum _{i\in S_B'\cup S_{AB}'} b_i/p_B}\le \frac{m_A}{m_B} \end{aligned}$$
(2)

For other price pair (\(p_A, p_B'\))

  • if \(p_B'<p_B\), all buyers in \(S_{AB}'\) prefer product B and the ratio between the assigned amount in A and B cannot larger than \(\frac{m_A}{m_B}\), i.e., inequality (1) does not hold.

  • if \(p_B'>p_B\), all buyers in \(S_{AB}'\) prefer product A and the ratio between the assigned amount in A and B cannot smaller than \(\frac{m_A}{m_B}\), i.e., inequality (2) does not hold.

To allocate buyers on both products w.r.t. the “good” price pair, we implement the idea for solving the Partition problem. Buyers are sorted in an non-increasing order w.r.t. the budget and allocate each buyer one by one on the side such that the configuration is more close to (\(m_A, m_B\)). Precisely, we define the config ratio to denote how “good” an assignment is.

$$\begin{aligned} \text {config\ ratio}=\frac{\frac{\sum _{\text {buyer\ i\ assigned\ on\ A}}b_i}{p_A\cdot m_A}}{\frac{\sum _{\text {buyer\ i\ assigned\ on\ B}}b_i}{p_B\cdot m_B}} =\frac{p_B\cdot m_B\cdot \sum _{\text {buyer\ i\ assigned\ on\ A}}b_i}{p_A\cdot m_A\cdot \sum _{\text {buyer\ i\ assigned\ on\ B}}b_i}.\end{aligned}$$

The assignment will be better if the config ratio is closer to 1.

figure c

Theorem 6

Product-Assignment-2 achieves a semi market equilibrium with the running time \(O(2^{1/\epsilon }+n\log n)\) and the approximation ratio is \(1+\epsilon \).

Proof

We first show the correctness of the algorithm, i.e., the assignment satisfies (1) market semi clearance, (2) budget bound, and (3) individual optimality. On finishing the algorithm, at least one product is sold out, all buyers do not violate the budget bound. To show the property of individual optimality, we can see that \(S_A'\) and \(S_B'\) are buyers who only prefer A or B, these buyers are assigned properly. For buyers in \(S_{AB}'\), on the price (\(p_A, p_B\)), assigning on any product will have the same utility. Thus, the assignment is semi market equilibrium.

For the time complexity, we only need to consider line 4, line 8, line 11, and the for loop in line 12–18.

  • Line 4, for any fixed \(p_A\), there are at most n values of \(p_B\) to be considered. To handle them one by one, we may use the parameter \(r_i\) in Lemma 2. All these \(r_i\) can be sorted in \(O(n\log n)\) time.

  • Line 8, sorting the budgets of the buyers in \(S_{AB}'\) takes \(O(n\log n)\) time.

  • Line 11, computing the optimum assignment from \(b_{i_1}\) to \(b_{i_\ell }\) can be done by brute force in \(O(2^{\lceil 1/\epsilon \rceil })\) time.

  • Line 12–18, each round takes constant time and thus the total running time of the for loop is O(n).

Combining the above analysis, the time complexity of the algorithm is

$$\begin{aligned} O(2^{\lceil 1/\epsilon \rceil } + n\log n). \end{aligned}$$

We now show the approximation ratio of the algorithm is \(1+\epsilon \).

Claim In the final configuration \(\mathcal {A}\), the approximation ratio of the algorithm is upper bounded by \(\max \left\{ \frac{p_B\cdot m_B\cdot \sum _{i\in A}b_i}{p_A\cdot m_A\cdot \sum _{i\in B}b_i}, \frac{p_A\cdot m_A\cdot \sum _{i\in B}b_i}{p_B\cdot m_B\cdot \sum _{i\in A}b_i}\right\} \)

Proof

W.l.o.g., assume that \(\frac{p_B\cdot m_B\cdot \sum _{i\in A}b_i}{p_A\cdot m_A\cdot \sum _{i\in B}b_i}\ge 1\).

If we update the prices \(p_A\) and \(p_B\) with the same rate until achieving configuration \(\mathcal {A}_1\) in which product B is fully utilized, i.e., \(\sum _{i\in B}b_i=p_B\cdot m_B\), the usage of product A is no less than \(m_A\), i.e., \(\sum _{i\in A}b_i\ge p_A\cdot m_A\). According to Lemma 4, the total utilities is no less than the optimum solution.

If we update the prices with the same rate until achieving configuration \(\mathcal {A}_2\) in which product A is fully utilized, i.e., \(\sum _{i\in A}b_i=p_A\cdot m_A\), the usage of product B is no more than \(m_B\), i.e., \(\sum _{i\in B}b_i\le p_B\cdot m_B\), . According to Lemma 4, the total utilities is no more than the optimum one.

The decreased rate of prices from \(\mathcal {A}_1\) to \(\mathcal {A}_2\) is \(\frac{p_B\cdot m_B\cdot \sum _{i\in A}b_i}{p_A\cdot m_A\cdot \sum _{i\in A}b_i}\). Since the utility of each buyer is in proportion to the assigned amount, the approximation ratio of the algorithm can be bounded by \(\frac{p_B\cdot m_B\cdot \sum _{i\in A}b_i}{p_A\cdot m_A\cdot \sum _{i\in A}b_i}\). Thus, this claim holds.

Consider the final configuration \(\mathcal {A}\) where \(S_A\) and \(S_B\) are buyer sets on product A and B respectively. Let

$$\begin{aligned} \frac{\sum _{i\in S_A}b_i}{p_A\cdot m_A} + \frac{\sum _{i\in S_B}b_i}{p_B\cdot m_B}=2H \end{aligned}$$

and

$$\begin{aligned} \left|\frac{\sum _{i\in S_A}b_i}{p_A\cdot m_A} - \frac{\sum _{i\in S_B}b_i}{p_B\cdot m_B}\right|=D. \end{aligned}$$

Thus, the approximation ratio can be upper bounded by \(\frac{H+D}{H-D}\).

Let \(\mathcal {A}'\) be the configuration after the optimal assignment of \(\{b_{i_1}, \ldots , b_{i_{\ell }}\}\). Let \(S_A'\) and \(S_B'\) be the current buyer sets on products A and B, respectively. W.l.o.g., assume that in \(\mathcal {A}'\), the config ratio is no less than 1.

  • If \(\frac{\sum _{i\in S_A'}b_i}{p_A\cdot m_A}\ge H\). In this case, according to the algorithm, all the remaining buyers will be assigned on product B. We claim that it is optimum. Otherwise, in the optimum solution, only considering buyers in \(S_A'\), \(S_B'\) and \(\{i_1, \ldots , i_{\ell }\}\), \(\frac{\sum _{i\in A}b_i}{p_A\cdot m_A} < H\), which violate the optimum allocation by brute force.

  • Else, \(\frac{\sum _{i\in S_A'}b_i}{p_A\cdot m_A} < H\). In this case, let k denote the first buyer whose adding leads to \(\frac{\sum _{i\in X}b_i}{p_X\cdot m_X} \ge H\), where \(k>\ell \) and \(X\in \{S_A',S_B'\}\). Since the remaining buyers are sorted by their budgets, we have \(\frac{b_k}{p_X\cdot m_X}\ge D\). Note that the budget of buyer in \(\{i_1, \ldots , i_{\ell }\}\) is no less than \(b_k\), thus, \(b_j\ge b_k\ge p_X\cdot m_X\cdot D\) for all \(j\in \{i_1, \ldots , i_{\ell }\}\). Let \(A_1\) be the set containing all buyers from \(\{i_1, \ldots , i_{\ell }\}\) who are assigned at A and let \(B_1\) be the set containing all buyers from \(\{i_1, \ldots , i_{\ell }\}\) who are assigned at B. Thus,

    $$\begin{aligned} \frac{D}{H}\le \frac{\frac{b_k}{p_X\cdot m_X}}{\frac{\sum _{i\in A_1}b_i}{p_A\cdot m_A} + \frac{\sum _{i\in B_1}b_i}{p_B\cdot m_B}}\le \frac{\frac{b_k}{p_X\cdot m_X}}{\frac{\sum _{i\in A_1}b_k}{p_A\cdot m_A} + \frac{\sum _{i\in B_1}b_k}{p_B\cdot m_B}}\le \frac{r_{max}\cdot \max \left\{ \frac{m_A}{m_B},\frac{m_B}{m_A}\right\} }{\ell }=\epsilon /3. \end{aligned}$$

    By setting \(\epsilon \) smaller enough, the difference between the assignment on A and B can be sufficiently smaller too. Thus, the approximation ratio is upper bounded by

    $$\begin{aligned} \frac{H+D}{H-D}=1+\frac{2D}{H-D}\le 1+\frac{3D}{H}\le 1+\epsilon . \end{aligned}$$

\(\square \)

5 Concluding remark

With the great development of information technology, the market economy changed radically. Many revolutionary market models appear and improve our daily life. We should pay more attention to analyze and evaluating the existed and the new coming models. In this work, we study the market equilibrium by considering the buyer’s preference. It is a simple try on two types of products. An interesting future work might be considering many types of products and more complicated buyer behaviors, e.g., buyer’s interested bundle contains multiple types of products and the optional preference may be the subset of his interested bundle.