Optimal Composition Ordering Problems for Piecewise Linear Functions

In this paper, we introduce maximum composition ordering problems. The input is $n$ real functions $f_1,\dots,f_n:\mathbb{R}\to\mathbb{R}$ and a constant $c\in\mathbb{R}$. We consider two settings: total and partial compositions. The maximum total composition ordering problem is to compute a permutation $\sigma:[n]\to[n]$ which maximizes $f_{\sigma(n)}\circ f_{\sigma(n-1)}\circ\dots\circ f_{\sigma(1)}(c)$, where $[n]=\{1,\dots,n\}$. The maximum partial composition ordering problem is to compute a permutation $\sigma:[n]\to[n]$ and a nonnegative integer $k~(0\le k\le n)$ which maximize $f_{\sigma(k)}\circ f_{\sigma(k-1)}\circ\dots\circ f_{\sigma(1)}(c)$. We propose $O(n\log n)$ time algorithms for the maximum total and partial composition ordering problems for monotone linear functions $f_i$, which generalize linear deterioration and shortening models for the time-dependent scheduling problem. We also show that the maximum partial composition ordering problem can be solved in polynomial time if $f_i$ is of form $\max\{a_ix+b_i,c_i\}$ for some constants $a_i\,(\ge 0)$, $b_i$ and $c_i$. We finally prove that there exists no constant-factor approximation algorithm for the problems, even if $f_i$'s are monotone, piecewise linear functions with at most two pieces, unless P=NP.


Introduction
In this paper, we introduce optimal composition ordering problems and mainly study their time complexity. The input of the problems is n real functions f 1 , . . . , f n : R → R and a constant c ∈ R. In this paper, we assume that the input functions are piecewise linear, and the input length of a piecewise linear function is the sum of the sizes of junctions and coefficients of linear functions. We consider two settings: total and partial compositions. The maximum total composition ordering problem is to compute a permutation σ : [n] → [n] that maximizes f σ(n) • f σ(n−1) • · · · • f σ(1) (c), where [n] = {1, . . . , n}. The maximum partial composition ordering problem is to compute a permutation σ : [n] → [n] and a nonnegative integer k (0 ≤ k ≤ n) that maximize f σ(k) • f σ(k−1) • · · · • f σ(1) (c). For example, if the input consists of f 1 (x) = 2x − 6, f 2 (x) = 1 2 x + 2, f 3 (x) = x + 2, and c = 2, then the ordering σ such that σ(1) = 2, σ(2) = 3, and σ(3) = 1 is optimal for the maximum total composition ordering problem.
In fact, (c))) = f 1 (f 3 (c/2 + 2)) = f 1 (c/2 + 4) = c + 2 = 4 provides the optimal value of the problem. The ordering σ above and k = 2 is optimal for the maximum partial composition ordering problem, where f 3 • f 2 (c) = 5. We remark that the minimization versions are equivalent to the maximization ones.
As we will see in this paper, the optimal composition ordering problems are natural and fundamental in many fields such as artificial intelligence, computer science, and operations research. However, to the best of the authors' knowledge, no one explicitly studies the problems from the algorithmic point of view. We below describe the single machine time-dependent scheduling problems and the free-order secretary problem, which can be formulated as the optimal composition ordering problems.

Time-dependent scheduling
Consider the machine scheduling problems with time-dependent processing times, called time-dependent scheduling problems [5,12].
Let J i (i = 1, . . . , n) denote a job with a ready time r i ∈ R, a deadline d i ∈ R, and a processing time p i : R → R, where r i ≤ d i is assumed. Different from the classical setting, the processing time p i is not constant, but depends on the starting time of job J i . The model has been studied to deal with learning and deteriorating effects, for example [13-15, 20, 21]. Here each p i is assumed to satisfy p i (t) ≤ s + p i (t + s) for any t and s ≥ 0, since we should be able to finish processing job J i earlier if it starts earlier. Among time-dependent settings, we consider the single machine scheduling problem to minimize the makespan, where the input is the start time t 0 (= 0) and a set of J i (i = 1, . . . , n) above. The makespan denotes the time when all the jobs have finished processing, and we assume that the machine can handle only one job at a time and preemption is not allowed. We show that the problem can be seen as the minimum total composition ordering problem.
For simplicity, let us first consider the simplest case, that is, each job has neither the ready time r i nor the deadline d i . Let c = t 0 , and for each i ∈ [n], define the function f i by f i (t) = t + p i (t). Note that job J i has been finished processing at time f i (t) if it is started processing at time t. This implies that f σ(n) • f σ(n−1) • · · · • f σ(1) (t 0 ) denotes the makespan of the scheduling problem when we fix the ordering σ of the jobs. Therefore, the problem is represented as the minimum total composition ordering problem. More generally, let us consider the case in which each job J i also has both the ready time r i and the deadline d i with d i ≥ r i . Define the function f i by Then the problem can be reduced to the minimum total composition ordering problem ((f i ) i∈[n] , c = t 0 ). A number of restrictions on the processing time p i (t) has been studied in this literature (e.g., [3,6,16]).
In the linear deterioration model, the processing time p i is restricted to be a monotone increasing linear function that satisfies p i (t) = a i t + b i for two positive constants a i and b i . Here a i and b i are respectively called the deterioration rate and the basic processing time of job J i . Gawiejnowicz and Pankowska [13], Gupta and Gupta [14], Tanaev et al. [20], and Wajs [21] obtained the result that the time-dependent scheduling problem of this model (without the ready time r i nor the deadline d i ) is solvable in O(n log n) time by scheduling jobs in the nonincreasing order of ratios b i /a i . As for the hardness results, it is known that the proportional deterioration model with ready time and deadline, the linear deterioration model with ready time, and the linear deterioration model with a deadline are all NP-hard [4,11].
Another important model is called the linear shortening model introduced by Ho et al. [15]. In this model, the processing time p i is restricted to be a monotone decreasing linear function that satisfies p i (t) = −a i t + b i with two constants a i and b i with 1 > a i > 0, b i > 0. They showed that the timedependent scheduling problem of this model can be solved in O(n log n) time by again scheduling jobs in the nonincreasing order of the ratios b i /a i .

Free-order secretary problem
The free-order secretary problem is another application of the optimal composition ordering problems, which is closely related to a branch of the problems such as the full-information secretary problem [9], knapsack and matroid secretary problems [1,2,19] and stochastic knapsack problems [7,8]. Imagine that an administrator wants to hire the best secretary out of n applicants for a position. Each applicant i has a nonnegative independent random variable X i as his ability for the secretary. Here X 1 , . . . , X n are not necessarily based on the same probability distribution, and assume that the administrator knows all the probability distributions of X i 's before their interviews, where such information can be obtained by their curriculum vitae and/or results of some written examinations. The applicants are interviewed one-by-one, and the administrator can observe the value X i during the interview of the applicant i. A decision on each applicant is to be made immediately after the interview. Once an applicant is rejected, he will never be hired. The interview process is finished if some applicant is chosen, where we assume that the last applicant is always chosen if he is interviewed since the administrator has to hire exactly one candidate. The objective is to find an optimal strategy for this interview process, i.e., to find an interview ordering together with the stopping rule that maximizes the expected value of the secretary hired.
Let x}]. For example, let us assume that X i is an m-valued random variable that takes the value a j i with probability p j i ≥ 0 (j = 1, . . . , m). Here we assume that a 1 i ≥ · · · ≥ a m i ≥ 0 and m j=1 p j i = 1. Then we have Note that this f i is a monotone piecewise linear function with at most (m + 1) pieces. We now claim that our secretary problem can be represented by the maximum total composition ordering problem ((f i ) i∈[n] , c = 0). Let us consider the best stopping rule for the interview to maximize the expected value for the secretary hired when the interview ordering is fixed in advance. Assume that the applicant i is interviewed in the ith place. Note that E[X n ] (= f n (0)) is the expected value under the condition that all the applicants except for the last one are rejected, since the last applicant is hired. Consider the situation that all the applicants except for the last two ones are rejected. Then it is a best stopping rule that the applicant n − 1 is hired if and only if X n−1 ≥ f n (0) is satisfied (i.e., the applicant n is hired if and only if X n−1 < f n (0)), where f n−1 • f n (0) is the expected value for the best stopping rule, under this situation. By applying backward induction, we have the following best stopping rule: we hire the applicant i (< n) and stop the interview process, if X i ≥ f i+1 • · · · • f n (0) (otherwise, the next applicant is interviewed), and we hire the applicant n if no applicant i (< n) is hired. We show that f 1 • · · · • f n (0) is the maximum expected value for the secretary hired, if the interview ordering is fixed such that the applicant i is interviewed in the ith place.
Therefore, the secretary problem (i.e., finding an interview ordering, together with a stopping rule) can be formulated as the maximum total composition ordering problem ((f i ) i∈[n] , c = 0).

Main results obtained in this paper
In this paper, we consider the computational issues for the optimal composition ordering problems, when all f i 's are monotone and almost linear.
We first show that the problems become tractable if all f i 's are monotone and linear, i.e., f i (x) = a i x + b i for a i ≥ 0. Theorem 1. The maximum partial and total composition ordering problems for monotone nondecreasing linear functions are both solvable in O(n log n) time.
Recall that the algorithm for the linear shortening model (resp., the linear deterioration model) for the time-dependent scheduling problem is easily generalized to the case when all a i 's satisfy a i < 1 (resp., a i > 1). The best composition ordering is obtained as the nondecreasing order of ratios b i /a i . This idea can be extended to the maximum partial composition ordering problem in the mixed case (i.e., some a i > 1 and some a i < 1) of Theorem 1. However, we cannot extend it to the maximum total composition ordering problem. In fact, we do not know if there exists such a simple criterion on the maximum total composition ordering. We instead present an efficient algorithm that chooses the best ordering among linearly many candidates.
We also provide a dynamic-programming based polynomial-time algorithm for the exact k-composition setting.
Theorem 2. The maximum exact k-composition ordering problem for monotone nondecreasing linear functions is solvable in O(k · n 2 ) time.
We next consider monotone, piecewise linear case. It can be directly shown from the time-dependent scheduling problem that the maximum total composition ordering problem is NP-hard, even if all f i 's are monotone, concave, and piecewise linear functions with at most two pieces, i.e., f i (x) = min{a 1 It turns out that all the other cases become intractable, even if all f i 's are monotone and consist of at most two pieces. Furthermore, the problems are inapproximable. Theorem 3. (i) For any positive real number α (≤ 1), there exists no α-approximation algorithm for the maximum total (partial) composition ordering problem even if all f i 's are monotone, concave, and piecewise linear functions with at most two pieces, unless P=NP.
(ii) For any positive real number α (≤ 1), there exists no α-approximation algorithm for the maximum total (partial) composition ordering problem even if all f i 's are monotone, convex, and piecewise linear functions with at most two pieces, unless P=NP.
is a monotone, convex, and piecewise linear function with at most two pieces. As for the positive side, if each f i is a monotone, convex, and piecewise linear function with at most two pieces such that one of the pieces is constant, then we have the following result, which implies that the two-valued free-order secretary problem can be solved in O(n 2 ) time.
Then the maximum partial composition ordering problem is solvable in O(n 2 ) time.
We summarize the current status on the time complexity of the maximum total composition ordering problem in Table 1. Here the bold letters represent our results, and the results for the minimum and/or partial versions are described as the ones for the maximum total composition ordering problem, since the minimum and partial versions can be transformed into the maximum total one as shown in Section 3. Table 1: The current status on the time complexity of the maximum total composition ordering problem.

Functions
Complexity O(n log n) [13,14,20,21] The organization of the paper The rest of the paper is organized as follows. In Section 2, we show that the minimum and/or partial versions of the optimal composition ordering problem can be formulated as the maximum total composition ordering problem. In Section 3, we prove the partial composition part of Theorem 1 and Theorem 4, and in Section 4, we prove the total composition part of Theorem 1 and Theorem2. Finally, Section 5 provides a proof of Theorem 3.

Properties of Function Composition
In this section, we present two basic properties of the optimal composition ordering problems, which imply that the maximum total composition ordering problem represents all the other composition ordering problems namely, the minimum partial, the minimum total, and the maximum partial ones.
Let us start with the lemma that the minimization problems are equivalent to the maximization ones. For a function f : R → R, define a functionf : For example, if f (x) = 2x − 3, then we havef (x) = 2x + 3. By the definition, we havef = f , andf inherits several properties for f , e.g., linearity and monotonicity.
Lemma 5. Let c be a real, and for i = 1, . . . , n, let f i : R → R be real functions. Then we have the following two statements.
(a) A permutation σ : [n] → [n] is optimal for the maximum total composition ordering problem c) if and only if it is optimal for the minimum total composition ordering problem and an integer k with 0 ≤ k ≤ n form an optimal solution for the maximum partial composition ordering problem ((f i ) i∈[n] , c) if and only if they form an optimal solution for the minimum partial composition ordering problem Proof. For any permutation σ : [n] → [n] and an integer k with 0 ≤ k ≤ n, we have which proves the lemma.
Due to the lemma, this paper deals with the maximum composition ordering problems only. We next show the relationships between total and partial compositions. For a function f : Lemma 6. Let c be a real, and for i = 1, . . . , n, let f i : R → R be real functions. Then the objective value of the maximum partial composition ordering problem ((f i ) i∈[n] , c) is equal to the one of the maximum total composition ordering problem ((f i ) i∈[n] , c). Moreover, we have the following relationships for the optimal solutions.
(a) If a permutation σ : [n] → [n] and an integer k with 0 ≤ k ≤ n form an optimal solution for the maximum partial composition ordering problem ((f i ) i∈[n] , c), then σ is optimal for the maximum total composition ordering problem ((f i ) i∈[n] , c).
denote an optimal permutation for the maximum total composition ordering problem ((f i ) i∈[n] , c). Then let k denote the number of i's such that and τ : [n] → [n] denote a permutation such that τ (j) (j ≤ k) is equal to the jth σ(i) that satisfies (3). Then (τ, k) is optimal for the maximum partial composition ordering problem ((f i ) i∈[n] , c).
Proof. Let σ : [n] → [n] be a permutation and k be a nonnegative integer. Then we have This implies that the objective value of the maximum partial composition ordering problem ((f i ) i∈[n] , c) is at most the one of the maximum total composition ordering problem On the other hand, for a permutation σ : [n] → [n], let τ and k be defined as the statement in the lemma. Then we have by the definition of τ , which implies that the objective value of the maximum partial composition ordering problem ((f i ) i∈[n] , c) is at least the one of the maximum total composition ordering problem ((f i ) i∈[n] , c). Therefore, the objective values of the two problems are same. Moreover, this together with (4) and (5) implies (a) and (b) in the lemma.
From Lemmas 5 and 6, it is enough to consider the maximum total composition ordering problem. However, the properties of the functions f i are not always inherited. For example, the partial composition ordering problem for the linear functions does not correspond to the total one for the linear functions.

Maximum Partial Composition Ordering Problem
In this section, we discuss tractable results for the maximum partial composition ordering problem for monotone and almost-linear functions. By Lemma 6, we deal with the problem as the maximum total composition ordering problem for functions Recall that the objective value of the maximum partial composition ordering problem ((f i ) i∈[n] , c) is equal to the one of the maximum total composition ordering problem ((f i ) i∈[n] , c). Let us start with the maximum partial composition ordering problem for monotone linear functions The following binary relation plays an important role for the problem.
Note that the relation is not total relation in general, here a relation is called total if f g or g f for any f, g. For example, let f 1 (x) = max{2x, 3x} and f 2 (x) = max{2x − 1, 3x + 1}. Then However, if two consecutive functions are total, then we have the following easy but useful lemma.
It follows from the lemma that, for monotone functions f i , there exists a maximum total composition where the proof is given as the more general form in Lemma 10.
The relation is total if all functions are linear or of the form max{ax + b, x} with a ≥ 0.
Lemma 9. The relation is total for linear functions. Proof.
Then we have Since the last inequality consists of the constants only, we have The totality of the relation is proven in Lemma 15, when all functions are of the form max{ax + b, x} with a ≥ 0. We further note that the relation is transitive for linear functions f (x) = ax + b with a > 1, since gives an optimal solution for the maximum total composition ordering problem. Therefore, it can be solved efficiently by sorting the elements by b i /(1 − a i ). The same statement holds when all linear functions have slope less than 1. This idea is used for the linear deterioration and linear shortening models for time-dependent scheduling problems. However, in general, this is not the case, i.e., the relation does not satisfy transitivity. Let f 1 (x) = 2x + 1, f 2 (x) = 2x − 1, and f 3 (x) = x/2.
Then we have f 1 ≺ f 2 , f 2 ≺ f 3 , and f 3 ≺ f 1 , which implies that the transitivity is not satisfied for linear functions, and f 1 ≺ f 2 , f 2 ≺ f 3 , and f 3 ≺ f 1 hold, implying that the transitivity is not satisfied for the functions of the form max{ax + b, x} with a ≥ 0. These show that the maximum total and partial composition ordering problems are not trivial, even when all functions are monotone and linear.
We first show the following key lemma which can be used even for non-transitive relations. Proof. Without loss of generality, we may assume that σ is the identity permutation. Let σ be an optimal solution for the maximum total composition ordering problem such that it has the minimum inversion number. Here, the inversion number denotes the number of pairs (i, j) with i < j and σ (i) > σ (j). Then we show that σ is the identity permutation by contradiction. Assume that σ (l) > σ (l + 1) for some l. Then consider the following permutation: Since σ (l + 1) < σ (l) implies f σ (l+1) f σ (l) by the condition of the identity σ, Lemma 8 implies that τ is also optimal for the problem. Since τ has an inversion number smaller than the one for σ , we derive a contradiction. Therefore, σ is the identity.
As mentioned above, if the relation is in addition transitive (i.e., is a total preorder), then such a σ always exists.
To efficiently solve the maximum partial composition ordering problem for the linear functions, we show that for f i (x) = max{a i x + b i , x} (a i ≥ 0), (i) there exists a permutation σ which satisfies the condition in Lemma 10 and (ii) the permutation σ can be computed efficiently. We analyze the relation in terms of the following γ and δ, and provide an efficient algorithm.
We prove that the lexicographic order satisfies the condition in Lemma 10 and thus, the order is the optimal solution.
Lemma 12. For monotone nondecreasing linear functions f i (i ∈ [n]), let σ denote a permutation compatible with the lexicographic order with respect to (δ(f i ), γ(f i )). Then i ≤ j implies f σ(i) f σ(j) for any i, j ∈ [n].
Before proving Lemma 12, we discuss algorithms for the maximum partial composition ordering problem.

Algorithms
By Lemma 12, the maximum total composition ordering problem ((f i ) i∈[n],c ) such that f i 's are monotone nondecreasing linear functions can be solved by computing the lexicographic order with respect to (δ(f i ), γ(f i )). Therefore, it can be solved in O(n log n) time. This is our algorithm for the partial composition part of Theorem 1. We remark that the time complexity O(n log n) of the problem is the best possible in the comparison model. We also remark that the optimal value for the maximum partial composition ordering problem for f i (x) = a i x + b i (a i ≥ 0) forms a piecewise linear function (in c) with at most (n + 1) pieces.
Next, for i ∈ [n], let f i (x) = a i x + b i be a monotone nondecreasing linear function and let h i (x) = max{f i (x), c i } for some constant c i . We give an efficient algorithm for the maximum partial composition ordering problem ((h i ) i∈[n] , c), which is the tractability result of Theorem 4. As mentioned in the introduction, the problem includes the two-valued free-order secretary problem, and it is a generalization of the maximum partial composition ordering problem for monotone linear functions. By Lemma 6, we instead consider the maximum total composition ordering problem for the functions where R + is the set of nonnegative real numbers.
Lemma 13. Let c ∈ R, and let h i (i ∈ [n]) be a function defined as (7). Then there exists an optimal solution σ for the maximum total composition ordering problem ((h i ) i∈[n] , c) such that no i (> 1) satisfies Proof. Let σ denote an optimal solution for the problem. Assume that there exists an index i that satisfies the condition in the lemma. Let i * denote the largest such i. Then by the definition of i * , we . This implies that (σ(i * ), . . . σ(n), σ(1). . . . , σ(i * − 1)) is also an optimal permutation for the problem. Moreover, in the composition according to this permutation, the constant part ofh i (i = i * ) is not explicitly used by the definition of i * and c σ(i) < c σ(i * ) for any i (< i * ), which completes the proof.
It follows from Lemma 13 that an optimal solution for the problem can be obtained by solving the following n + 1 instances of the maximum partial composition ordering problem for monotone nondecreasing linear functions ((f i ) i∈[n] , c) and ((f i ) i∈[n]\{k} , c k ) for all k ∈ [n].
Therefore, we have an O(n 2 log n)-time algorithm by directly applying Theorem 1 to the problems. Moreover, we note that the maximum partial composition ordering problem for monotone nondecreasing linear functions can be solved in linear time if we know the lexicographic order. This implies that the problem can be solved in O(n 2 ) time by first computing the lexicographic order with respect to (δ(f i ), γ(f i )). This is our algorithm for Theorem 4.

The proof of Lemma 12
In this subsection, we prove Lemma 12. We first consider the relationship between two linear functions. The proof can be found in Appendix.
Lemma 14. Let f i (x) = a i x + b i and f j (x) = a j x + b j be (non-identity) monotone nondecreasing functions (i.e., (a i , b i ), (a j , b j ) = (1, 0), a i , a j ≥ 0). Then we have the following statements; (a) if a i , a j = 1, then f i f j , By this lemma, the relation is total preorder for the both cases a 1 , a 2 , . . . , a n ≥ 1 and a 1 , a 2 , . . . , a n < 1. Moreover, the permutation σ : [n] → [n] such that γ(f σ(1) ) ≤ · · · ≤ γ(f σ(n) ) is optimal for the cases. This result matches the results in the time-dependent scheduling problem of the linear deterioration model (when a 1 , a 2 , . . . , a n ≥ 1) and the linear shortening model (when a 1 , a 2 , . . . , a n < 1).
Next we characterize the relationship between two functions of the form max{a i x + b i , x}, the proof can be found in Appendix.

Lemma 15. For (non-identity) monotone nondecreasing linear functions
Note that Lemma 15 implies that the relation is total for the functions of the form max{ax + b, x} with a ≥ 0. Moreover, it is easy to check that the lexicographic order with respect to (δ(f i ), γ(f i )) satisfies the condition in Lemma 10, i.e., i < j implies f σ(i) f σ(j) for the permutation σ that is compatible with the ordering. Therefore, we have Lemma 12.

Maximum Total Composition and Exact k-composition Ordering Problems
In this section we prove the total composition part of Theorem 1 and Theorem 2. Different from the case when each function is of form max{a i x + b i , x}, the binary relation for linear functions does not satisfy the condition in Lemma 10. In fact, we do not know if there exists such a simple criterion on the maximum total composition ordering. We instead present an efficient algorithm that chooses the best ordering among linearly many candidates. Our main result is the following lemma.
Lemma 16. For monotone nondecreasing linear functions f i (i ∈ [n]), let σ denote a permutation compatible with the lexicographic order with respect to (δ(f i ), γ(f i )). Then an optimal solution for the maximum total composition ordering problem for some t.
Before proving Lemma 16, we discuss algorithms for the maximum total composition and the exact k-composition ordering problems.

Algorithm for Total Composition
In this subsection, we prove the total composition part of Theorem 1, i.e., we provide an efficient algorithm for the maximum total composition ordering problem ( be a permutation compatible with the lexicographic order with respect to (δ(f i ), γ(f i )). Then there exists an optimal solution of the form (σ(t), σ(t + 1), . . . , σ(n), σ(1), σ(2), . . . , σ(t − 1)) for some t by Lemma 16. Therefore, the problem can be computed in polynomial time by checking n permutations above. To reduce the time complexity, let and hence the problem is solvable in O(n log n) time.

exact k-composition
In this subsection, we prove Theorem 2, i.e., we provide an efficient algorithm for the maximum exact kcomposition ordering problem ((f i (x) = a i x+b i ) i∈[n] , c), where a i ≥ 0. We use a dynamic programming to find the optimal value.
For each i, j, l, the value m(i, j, l) satisfies the following relation: To evaluate max n i=1 m(i, n, k), our algorithm calculate the values of m(i, j, l) for 0 ≤ i, j ≤ n and 0 ≤ l ≤ k. Therefore, we can obtain the optimal value for the problem in O(k · n 2 ) time. The detailed algorithm for the maximum exact k-composition problem is shown in Algorithm 1.

The proof of Lemma 16
In this subsection, we prove Lemma 16. To overcome the difficulty that the binary relation for linear functions does not satisfy the condition in Lemma 10, we discuss relationships among three or four functions.

Algorithm 1 Maximum Exact k-Composition
1: sort the input functions according to the lexicographic order of (δ(f i ), γ(f i )) 2: for l = 0 to k do 3: for j = l to n do 4: for i = 1 to n do 5: if l = 0 then m(i, j, l) ← c 6: end for 9: end for 10: end for 11: return max n i=1 m(i, n, k) The following lemma shows the relationships between γ(f i ), γ(f j ), γ(f j • f i ) and γ(f i • f j ) for monotone linear functions. The proof can be found in Appendix.

Lemma 19. For monotone nondecreasing linear functions
Proof. We only prove Lemma 18 since Lemma 19 can be proved in a similar way. Let

holds by (a) and (f ) in Lemma 17, and
holds by (a) and (b) in Lemma 14. Thus, we have On the other hand, if a 2 · a 3 < 1, then γ(g) ≥ γ(f 2 ) ≥ γ(f 4 ) holds by (a) and (g) in Lemma 17, and By Lemmas 18 and 19, we obtain the following lemma.
Next, we provide inequalities for compositions of three functions.

Lemma 21. For monotone nondecreasing linear functions
, then we have Lemma 22. For monotone nondecreasing linear functions , then we have Proof. We only prove Lemma 21 since Lemma 22 can be prove in a similar way. If a 2 · a 3 ≥ 1, then (d) in Lemma 17,and γ Lemma 17. By Lemmas 14,17,20,21, and 22, we get the following lemmas.

Negative Results
In the previous sections, we show that both the total and partial composition ordering problems can be solved efficiently if all f i 's are monotone linear. It turns out that they cannot be generalized to nonlinear functions f i . In this section, we show the optimal composition ordering problems are in general intractable, even if all f i 's are monotone increasing, piecewise linear functions with at most two pieces. We remark that the maximum total composition ordering problem is known to be NP-hard, even if all f i 's are monotone increasing, concave, piecewise linear functions with at most two pieces [4], which can be shown by considering the time-dependent scheduling problem.
For our reductions, we use the following NP-complete problems (see [10,18]).
Partition: Given n positive integers a 1 , . . . , a n with n i=1 a i = 2T , ask whether exists a subset I ⊆ [n] such that i∈I a i = T .
ProductPartition: Given n positive integers a 1 , . . . , a n with n i=1 a i = T 2 , ask whether there exists a subset I ⊆ [n] such that i∈I a i = T .
We use Partition problem for concave case and ProductPartition for convex case.

Monotone increasing, concave, piecewise linear functions with at most two pieces
In this section, we consider the case in which all f i 's are monotone increasing, concave, piecewise linear functions with at most two pieces, that is, f i is given as for some reals a 1 i , a 2 i , b 1 i and b 2 i with a 1 i , a 2 i > 0. Proof for Theorem 3 (i). We show that Partition can be reduced to the problem. Let a 1 , . . . , a n denote positive integers with n i=1 a i = 2T . We construct n + 2 functions f i (i = 1, . . . , n + 2) as follows: It is clear that all f i 's are monotone, concave, and piecewise linear with at most two pieces. Moreover, we note that all f i 's (i = 1, . . . , n + 1) satisfy We claim that 3T is the optimal value for the maximum partial (total) composition ordering problem ((f i ) i∈[n+1] , c = 0) if there exists a partition I ⊆ [n] such that i∈I a i = T , and the optimal value is at most 3T − 1/2 if i∈I a i = T for any partition I ⊆ [n]. This implies that the optimal value for the maximum partial (total) composition ordering problem ((f i ) i∈[n+2] , c = 0) is at least 3αT if i∈I a i = T for some I ⊆ [n], and at most 3T if i∈I a i = T for any partition I ⊆ [n], since f n+2 (3T ) = 3αT + 3T − 1/2 > 3αT and f n+2 (x) ≤ x if x ≤ 3T − 1/2. Thus, there exists no αapproximation algorithm for the problems unless P=NP.
By Lemma 6, we have the following corollary. We also have the following corollary.
Corollary 25. The maximum total composition ordering problem is NP-hard, even if all f i 's are represented by f i (x) = max{x, min{a 1 5.2 Monotone increasing, convex, piecewise linear functions with at most two pieces In this section, we consider the case in which all f i 's are monotone increasing, convex, piecewise linear functions with at most two pieces, that is, f i is given as for some reals Before showing the intractability of the problems, we present two basic properties for the function composition.
For an integer i ∈ [n], let g i = a i (x − d) + d. Then we have Thus, n i=1 a i > 0 implies the following inequalities: We are now ready to prove the intractability.
By Lemma 6, we also have the following result.