Optimizing a mail-order with discount and shipping costs

Optimizing a mail-order with discount and shipping costs

Information Processing Letters 82 (2002) 93–97 Optimizing a mail-order with discount and shipping costs Peter Damaschke Computing Science, Chalmers U...

60KB Sizes 0 Downloads 23 Views

Information Processing Letters 82 (2002) 93–97

Optimizing a mail-order with discount and shipping costs Peter Damaschke Computing Science, Chalmers University, 41296 Göteborg, Sweden Received 1 December 2000; received in revised form 1 May 2001 Communicated by S.E. Hambrusch

Abstract We address the problem of minimizing the total cost of a mail-order if a customer can choose among different companies. These companies may offer the items in his shopping list at different prices, and they add some charges or give discount, depending on the total value of ordered goods. While this optimization problem is hard in general, we show that it can be efficiently solved for some typical discount policies, either exactly or by invoking an approximation scheme for the Knapsack problem.  2002 Elsevier Science B.V. All rights reserved. Keywords: Algorithms; Optimization; Piecewise linear cost functions; Knapsack

1. Introduction We address the following optimization problem which we call the discount problem: A customer wants to order a set of goods (items) offered by several mail-order companies. Item i (i = 1, . . . , n) can be bought from company j at price pi,j . The customer can choose, for every item i, which company j (i) he wants to buy  that item from. The total cost of an order is thus i pi,j (i) . The customer’s objective is, of course, to minimize the total cost. The problem becomes interesting if the companies give discount for large orders, i.e., if the total cost is no longer simply the sum of prices. The solution where one chooses, for any i, some j (i) with minimum pi,j (i) would be optimal if no discount is given. We refer to it as the trivial solution. We will make some assumptions which meet usual discount policies. First of all, we assume that the discount given by a company, i.e., the deduction E-mail address: [email protected] (P. Damaschke).

from price, only depends on the total price p of items ordered there. In other words, the discount is a function d of order value p. We name it the discount function. In this paper, d(p) is always understood to be the absolute value of deduction, not the percentage. If a company charges the customer for shipping costs, they can be considered as a negative discount. In particular, d can have negative values. Typical discount policies tend to be quite simple so as not to confuse customers. Some examples are: The discount is some percentage c of the total price exceeding some threshold t, that is, d(p) = c · (p − t) if p > t and d(p) = 0 otherwise; shipping is free if the order value p exceeds some threshold, or combinations of rules like these. Note that, due to such rules, the discount function d is composed of linear functions between certain thresholds. This gives reason to consider only piecewise linear discount functions in this paper. If the discount function has jumps, the amount paid by the customer, that is p − d(p), can decrease in

0020-0190/02/$ – see front matter  2002 Elsevier Science B.V. All rights reserved. PII: S 0 0 2 0 - 0 1 9 0 ( 0 1 ) 0 0 2 4 8 - 4

94

P. Damaschke / Information Processing Letters 82 (2002) 93–97

some cases although more items are ordered. We will not exclude this effect in general. However, a discount function with jumps can be replaced with an “equivalent” continuous discount function if the following moderate condition is satisfied: The company offers items with arbitrary sums of prices (that means in practice, with a rather dense spectrum of sums of prices). If this is true, consider a jump from y to z (y < z) at value p, that is d(p − ε) = y and d(p + ε) = z. Then any order whose total value is slightly smaller than p can be extended by ordering some additional “petty” items which are not really needed, until value p is reached. Therefore, the jump of d at argument p can be replaced with a line of slope 1 through point (p, z), going to the left until it meets the original graph of d. Generalizing this same argument, if d has pieces with slope larger than 1 and the above condition is fulfilled, we can introduce an equivalent discount function where all slopes are at most 1. A company may want to fix its discount function in such a way that a customer can never increase the total discount by splitting his/her order cleverly into several smaller orders. This condition is obviously equivalent to subadditivity: For any p, p we have d(p)+d(p )  d(p + p ). For non-negative discount functions this is in turn equivalent to convexity, i.e., the slopes never decrease as p grows. We do not demand that d must be a monotone non-decreasing function since the charge for shipping costs might increase with p, and monotonicity will not be assumed in our result. However, monotone nondecreasing discount functions are probably the typical real-world case. We reformulate the discount problem as follows. Consider any solution. Whenever an item is bought from another company than in the trivial solution, this is called a switch. A switch increases the total price but may also increase the total discount. The gain of the considered solution is defined as the costs of the trivial solution minus the costs of the considered solution. In the rest of this note we always refer to the maximization version of our problem: We give an algorithm for maximizing the gain on instances with convex discount functions, and a fully polynomial-time approximation scheme (FPTAS) on instances where the discount functions satisfy a somewhat weaker assumption. For instances where the dis-

count is at most some constant fraction of price (which is certainly true in real-world cases), the latter result yields immediately an FPTAS also for the cost minimization version of the problem.

2. Well-splittable optimization problems We start with a general observation that we will apply to the discount problem with piecewise linear discount functions later on. It deals with optimization problems that can be split into a constant number of easier problems. Let f be a function that we want to maximize on some domain X. Suppose this maximum is nonnegative. Assume that we have k sets X1 , . . . , Xk whose union covers X, further sets Yi ⊇ Xi , and functions gi defined on Yi , such that: gi (x) = f (x) for x ∈ Xi , and gi (x)  f (x) for x ∈ Yi . Finally assume that an algorithm G is available with the following property: G finds, for any given ε > 0, some solution x ∈ Yi where gi (x)  (1 − ε) · maxy∈Yi gi (y) (or reports that the maximum on Yi is negative). G may be an approximation scheme (with arbitrarily small ε > 0) or an exact algorithm (with ε = 0). Lemma 1. Under the above condition, we can find, by k calls to G with parameter ε  0, a point x ∈ X where f (x) is at least 1 − ε times the maximum value on X. Proof. For each i, find xi ∈ Yi such that gi (xi )  (1 − ε) · maxy∈Yi gi (y), by calling G. Since f  gi on Yi , we have f (xi )  (1 − ε) · maxy∈Yi gi (y). Since f = gi on Xi , it follows f (xi )  (1 − ε) · maxy∈Xi f (y). Hence the maximum of the k values f (xi ) computed in this way is a solution as desired. ✷ In particular, if G is an exact maximization algorithm, we find an exact solution for f .

3. Convex discount functions As discussed in the introduction, convex discount functions are of particular interest. Now we study

P. Damaschke / Information Processing Letters 82 (2002) 93–97

instances of the discount problem where all companies have convex discount functions. Recall that we consider piecewise linear discount functions d. The word piece refers to a maximal interval (l, r) (maximal with respect to inclusion) where d is linear, say d(p) = ap + b for l < p < r. With these denotations, the extension of a piece is the linear function ap + b for arbitrary p. Theorem 2. The discount problem with convex discount functions can be solved in time which is linearly bounded by the number of items and the product of the numbers of pieces of the discount functions. Consequently, if the number of companies and their discount functions are fixed, and the input consists of order and prices only, then we always get a linear-time solution. Proof. Let f (x) be the gain of solution x. We split the domain X of solutions into subsets Xi as follows: Choose one piece from each discount function and replace each discount function with the extension of this piece. The number k of such choices is the product of piece numbers of the discount functions. Index them by i = 1, . . . , k and let Xi be the set of those solutions where the value of goods ordered from each company is in the chosen piece. Due to convexity, the extensions are smaller than the original discount functions outside the chosen pieces. Let gi be the gain pretending that these linear functions are the discount functions, and let Yi be just X. It follows that the gi meet the assumptions of Lemma 1. If the required algorithm G runs in linear time, the theorem will be proven. Actually, maximizing gi is not a problem at all: Consider any item. Let p be its price in the trivial solution, say at company A, and p + q the price when it is bought from some other company B. Let s and t denote the slope of the discount function of A and B, respectively. Then, in case of a switch to B, the gain will be pt + qt − ps − q. Therefore, the customer will chose some B where this term is maximized, and if it is negative for all B = A, the item is bought from A. ✷

95

4. An approximable case: one semi-convex discount function The complexity jumps from simple to hard if the discount functions are not convex, already in a very special case: Proposition 3. The discount problem is NP-hard, even if there are only two companies A, B, the discount function of A is a threshold function (say d = 0 for p < t and d = 1 otherwise), and that of B is identically zero. Proof. Let pi and pi + qi be the price of item i at B and A, respectively, with pi , qi > 0. In the trivial solution, all items are bought from B. Let S be the set of switched  items. The customer gets discount if and only if i∈S (pi + qi )  t. Hence it is an equivalent  problem to satisfy this inequality with minimum i∈S qi . Considering the complement of S, this is exactly the Knapsack problem with capacity t, volumes pi + qi and values qi . ✷ On the other hand, there exist well-known FPTAS for Knapsack [1,4]. Thus it is a natural question which cases of the discount problem admit an FPTAS as well. In the following we present such a case. We introduce the notion of a semi-convex (and piecewise linear) function d. The left extension and right extension of a piece (l, r) where d(p) = ap + b is defined to be the function ap + b for arbitrary p < r and p > l, respectively. (These one-sided extensions are undefined for other p.) We call a piecewise linear function d semi-convex if, for every piece, at least one of the left and right extension is less than or equal to d on its domain. Note that this class includes, e.g., convex functions, functions with only two pieces, and piecewise constant monotone functions. Also note that, if a monotone function d with jumps is semi-convex then so is the function obtained from d by replacing the jumps by pieces of slope 1 (as described in the introduction), just because the left extensions of the new pieces satisfy the condition. Theorem 4. There exists an FPTAS for maximizing the gain in any case of the discount problem such

96

P. Damaschke / Information Processing Letters 82 (2002) 93–97

that: the discount functions are fixed and they are convex, except one of them which may be only semiconvex. Proof. Since this is an extension of the proof of Theorem 2, we only discuss the new things. Let C denote the only company with semi-convex discount function c. Partition the domain of solutions and use new, linear discount functions as before. The only modification is that we use only the left or right extension of every piece of the semi-convex discount function, rather than the two-sided extension, such that the Yi become proper subsets of X. Consider a choice of pieces, one from each discount function, where the left extension of some piece (l, r) of c is used. (The case of a right extension is settled below.) In the following we want to maximize the resulting gi for this choice. We temporarily forbid ordering items from C. By the same argument as in Theorem 2, it is clear for every item which company (distinct from C) it should be ordered from, to maximize gi under this additional constraint. For a = 1, . . . , n, let pa be the price of item a in the obtained intermediate solution, and pa + qa its price at C. For any solution, let S be the set of items bought from C, and v(S) the sum of their prices at C. We make up the following instance of Knapsack: Item a gets volume pa + qa , and the value of item a is the increase of gain gi when we move item a from its place in the intermediate solution to C. The knapsack gets capacity r. (Items with negative values are surely not put into the knapsack.) Since v(S)  r is required in Yi , this instance of Knapsack is equivalent to maximizing gi . Similarly, if the right extension of (l, r) is used, we wish to maximize gi while v(S)  l is required in Yi . Now let I denote the set of all items, and imagine a knapsack of capacity v(I ) − l containing the complement set I \S. Volumes of items are defined exactly as in the “left case”. Thus v(S)  l is satisfied if and only if the members of I \ S fit in the knapsack. The value of an item is now defined as the decrease of gain gi when we move the item to C. By this, maximizing gi is equivalent to maximizing the value in I \ S. In either case, we get an approximate solution to subproblem i by calling an FPTAS for Knapsack.

Finally, application of Lemma 1 gives the result: Note that the gi satisfy, by semi-convexity, the premises of the lemma. ✷

5. Conclusions One might wonder if this result is extendible to more than one semi-convex function. But we see immediately that no polynomial algorithm can guarantee constant approximation ratio for gain maximization, even for two companies that have threshold functions as discount functions, and where all items have equal prices at both companies. Namely, if t and t  are the thresholds, and the items on a shopping list have total price t + t  then the customer gets discount from both companies if and only if he can split his order into orders of value t and t  . That is, he must solve the Subset Sum problem. Consequently, no FPTAS for gain maximization and cost minimization can exist in the case two threshold functions. However, we have already argued that non-continuous discount functions are rather artificial. So it remains interesting to extend Theorem 4 to more general cases with continuous discount functions. We might have to invoke the PTAS (rather than FPTAS) for the multiple knapsack problem from [2]. Finally we mention two neighboring subjects. The traveling purchaser problem (see [3,6]) is similar in spirit to the discount problem, but there is no close relation. The traveling purchaser can also decide which company he buys each item from, but the companies reside at different points in a geometric space, and the total cost is the sum of prices plus travel costs. Furthermore, the off-line version of shutdown scheduling [5] with unrelated machines (i.e., if jobs have unrelated profits and processing times on different machines) seems to be quite similar to the discount problem.

References [1] O.H. Ibarra, C.E. Kim, Fast approximation algorithms for the Knapsack and sum of subset problems, J. ACM 22 (1975) 463– 468. [2] H. Kellerer, A polynomial time approximation scheme for the multiple knapsack problem, in: Proc. APPROX’99, Lecture

P. Damaschke / Information Processing Letters 82 (2002) 93–97

Notes in Comput. Sci., Vol. 1671, Springer, Berlin, 1999, pp. 51–62. [3] G. Konjevod, S.O. Krumke, M. Marathe, Budget constraint minimum cost connected medians, in: 26th WG’2000, Lecture Notes in Comput. Sci., Vol. 1928, Springer, Berlin, 2000, pp. 267–278. [4] E. Lawler, Fast approximation algorithms for knapsack problems, Math. Oper. Res. 4 (1979) 339–356.

97

[5] V. Liberatore, Scheduling jobs before shut-down, in: 7th SWAT’2000, Lecture Notes in Comput. Sci., Vol. 1851, Springer, Berlin, 2000, pp. 175–188. [6] R. Ravi, F.S. Salman, Approximation algorithms for the traveling purchaser problem and its variants in network design, in: 7th ESA’99, Lecture Notes in Comput. Sci., Vol. 1643, Springer, Berlin, 1999, pp. 29–40.