The checkpoint ordering problem

Abstract We suggest a new variant of a row layout problem: Find an ordering of n departments with given lengths such that the total weighted sum of their distances to a given checkpoint is minimized. The Checkpoint Ordering Problem (COP) is both of theoretical and practical interest. It has several applications and is conceptually related to some well-studied combinatorial optimization problems, namely the Single-Row Facility Layout Problem, the Linear Ordering Problem and a variant of parallel machine scheduling. In this paper we study the complexity of the (COP) and its special cases. The general version of the (COP) with an arbitrary but fixed number of checkpoints is NP-hard in the weak sense. We propose both a dynamic programming algorithm and an integer linear programming approach for the (COP) . Our computational experiments indicate that the (COP) is hard to solve in practice. While the run time of the dynamic programming algorithm strongly depends on the length of the departments, the integer linear programming approach is able to solve instances with up to 25 departments to optimality.


Introduction
In this paper we introduce and analyse a new variant of a row layout problem. An instance of the Checkpoint Ordering Problem (COP) consists of n one-dimensional departments, with given positive lengths 1 , . . . , n and weights w 1 , . . . , w n , and a checkpoint on a fixed position, e.g. leftaligned or at the center position. The optimization problem can be written down as min π ∈ n i∈ [n] where n is the set of permutations of the indices [n] := {1, 2, . . . , n} and z π i is the distance between the center of department i and the checkpoint with respect to a particular permutation π ∈ n .
Let us start with elaborating on the connections of the (COP) to the Linear Ordering Problem (LOP), the Single-Row Facility Layout Problem (SRFLP) and scheduling on identical parallel machines with the objective of minimizing the sum of weighted completion times.
directions on a straight-line path [1]. An instance of the (SRFLP) consists of n one-dimensional departments, with given positive lengths 1 , . . . , n , and pairwise weights w ij . The optimization problem can be written down as min π ∈ n i,j∈ [n] i<j w ij z π ij , ( 2 ) where n is the set of permutations of the indices [n] and z π ij is the center-to-center distance between departments i and j with respect to a particular permutation π ∈ n . Note that the weights are assumed to be non-negative for all row layout problems to ensure boundedness of the objective value of the optimal layout. For the (SRFLP) w ij ≥ 0 further guarantees that all departments are placed next to each other without spacing. For the (COP) we do not need this restriction on the weights as space between the departments is not allowed.
Several practical applications of the (SRFLP) have been identified in the literature, such as the arrangement of rooms on a corridor in hospitals, supermarkets, or offices [2], the assignment of airplanes to gates in an airport terminal [3], the arrangement of machines in flexible manufacturing systems [1], the arrangement of books on a shelf and the assignment of disk cylinders to files [4].
Similar applications are conceivable for the (COP), e.g. the rooms on a corridor could be arranged such that the weighted sum of their distances with the office of the head is minimized or planes could be assigned to gates such that the weighted sum of their distances from the entrance of the airport terminal is minimized. When comparing the (SRFLP) with the (COP), we observe that the problems are quite similar. One difference is that an (SRFLP) instance has n 2 weights while a (COP) instance has only n weights.

The Linear Ordering Problem (LOP)
Ordering problems associate to each ordering (or permutation) of the set [n] a profit and the goal is to find an ordering of maximum profit. In the simplest case of the Linear Ordering Problem (LOP) , this profit is determined by those pairs (u, v) ∈ [n] × [n], where u comes before v in the ordering. Thus in its matrix version the (LOP) can be defined as follows. Given an n × n matrix A = (a ij ) of integers, find a simultaneous permutation π of the rows and columns of A such that i,j∈[n] i<j a π(i),π(j) , is maximized. Equivalently, we can interpret a ij as weights of a complete directed graph G with vertex set V = [n]. A tournament consists of a subset of the arcs of G containing for every pair of nodes i and j either arc (i, j) or arc (j, i), but not both. Then the (LOP) consists of finding an acyclic tournament, i.e. a tournament without directed cycles, of G of maximum total edge weight. Although the (LOP) and the (COP) have apparently a similar structure, it is harder to directly relate these two problems. We will show in Section 2 that the (COP) with left-aligned or right-aligned checkpoint is in fact a (LOP) with some additional structure and can be solved efficiently by a greedy algorithm.

Scheduling on identical parallel machines
Furthermore we can relate the (COP) to the NP-hard [5] scheduling on identical parallel machines with the objective of minimizing the total weighted completion time that is defined as follows: We are given a set of jobs J that have to be scheduled on m identical parallel machines. Each job j ∈ J is specified by its processing time p j ≥ 0 and by its weight w j ≥ 0.
Every machine can processat most one job at a time, and every job has to be processed on one machine in an uninterrupted fashion. The completion time of job j is denoted by C j . The goal is to minimize the total weighted completion time i∈J w i C i . In the standard classification scheme of [6], this scheduling problem is denoted by P|| w j C j for m part of the input, and by Pm|| w j C j for constant m.
For the special case of only one machine the problem can be solved in polynomial time by Smith's Rule [7] that suggests to process the jobs in the order of non-increasing ratios w j /p j . For a constant number m ≥ 2 of machines, the problem is weakly NP-hard as it can be solved in pseudopolynomial time by dynamic programming approaches [8][9][10]. For m part of the input, the problem is NP-hard in the strong sense by transformation from 3-PARTITION [11]. For further details on the complexity of various related variants of this scheduling problem we refer to problem SS13 in [11]. For a more general overview on machine scheduling we refer to the survey article by [12].
From a computational point of view P|| w j C j has been tackled by various branch-and-bound methods [13][14][15][16][17], for which determining the optimal solution of instances with 30 or more jobs and two or more identical machines is typically difficult [18].
When comparing P|| w j C j and the (COP), we observe that there two important differences between the two problems: (1) The checkpoint must not lie exactly at a splitting point of two departments but it can also be covered by a department. I.e. the checkpoint does not necessarily define a partition of the departments. When considering a scheduling set-up the (COP) can be described as follows: It is allowed to split one arbitrary job into two parts at any point and then the two parts have to be scheduled first on the two machines. (2) For the (COP) the sum of the lengths of the departments that are placed to the left and to the right of the checkpoint are predetermined through the position of the checkpoint. E.g. for a centered checkpoint the sum of the lengths of the departments to the left and to the right of the checkpoint has to be equal. For P|| w j C j the identical machines typically have no capacity restrictions.
Due to these differences it is not possible to directly carry over polyhedral results, dynamic programming algorithms and (mixed) integer linear programming (ILP) models and their corresponding approximation results [19] from scheduling on identical parallel machines to the (COP).

Toy examples
Now let us further clarify the similarities and differences of the (SRFLP) and the (COP) with the help of a toy example: We consider 4 departments with lengths 1 = 1, 2 = 2, 3 = 3, 4 = 4. Additionally we are given the pairwise weights w 12 = w 14 = w 34 = 1, w 13 = w 24 = 2. For the (COP) we assign department 1 to row 2 and all other departments to row 1 and hence disregard the weights w 24 = 2 and w 34 = 1. Figure 1 illustrates the optimal layouts and the associated costs for both problems.
Finally we also want to clarify the workings of the (LOP) with the help of a toy example. We consider 4 objects and the weights w 12 = w 41 = w 34 = 1, w 31 = w 24 = 2. Figure 2 illustrates the optimal ordering of the objects and the corresponding benefit.

Outline
The main contributions of this paper are the following: • We propose a new combinatorial optimization problem that is both of theoretical and practical interest. • We study the complexity of the (COP) and its special cases, pointing out several connections to related problems.
• We propose two exact approaches for the (COP), namely a dynamic programming algorithm and an ILP approach. • We demonstrate the practical difficulty of the (COP) in a computational study. In this context let us also refer to our companion paper [20] for a comparison of the empirical difficulty of several row facility layout problems (including the (COP) ) on a variety of well-known benchmark instances.
The paper is structured as follows. In Section 2 we study the complexity of the (COP) and its special cases. In Sections 3 and 4 we suggest a dynamic programming algorithm and an ILP approach for the (COP) respectively. Finally in Section 5 we conduct computational experiments, indicating the practical applicability and limitations of the approaches suggested. Section 6 concludes the paper.

Complexity of the Checkpoint Ordering Problem
Consider the decision variant of the (COP) : given some value M we ask whether there exists a permutation of the departments such that the obtained costs are at most M: Decision Checkpoint Ordering (DCO): Instance: n departments with given lengths i ∈ N, i ∈ [n], and integer weights w i , i ∈ [n], and a checkpoint on a fixed position. Question: Is there an ordering π of the departments such that the total costs i∈[n] w i z π i are ≤ M? In the following proof we assume w.l.o.g. that the checkpoint is located at the center in order to simplify the presentation.

Theorem 1: DCO is NP-complete.
Proof: It is clear that DCO ∈ NP since a nondeterministic algorithm needs only to guess an ordering π and then can check in polynomial time if the corresponding costs are ≤ M.
To prove that DCO is NP-complete, we give an NP-complete problem and a polynomial-time transformation to DCO. The following problem is NP-complete (see Section 3.1.5 of [11], originally proven by [21]): PARTITION: Instance: A finite set A and a 'size' s(a) ∈ N for each a ∈ A such that a∈A s(a) = 2B is even. Question: Is there a subset A ⊆ A such that a∈A s(a) = B?
Now we transform an instance of PARTITION to an instance of DCO as follows. We replace each element a ∈ A with given size s(a) by a department a with length a = s(a) and weight w a = s(a). Additionally to this local replacement we use an enforcer by introducing a further department t with length t = 1 and weight w t = 2(B + 1) 2 . Clearly this DCO instance can be constructed from the PARTITION instance in polynomial time.
If the ordering π is optimal then the center of department t is located exactly above the checkpoint because of the large weight of department t. Due to the definition of the weights of the departments a ∈ A, it does not change the objective value if we switch the positions of two departments both located left or right of t. Hence the only way to influence the objective value is to decide whether the departments should be located left or right of t. If we can find a subset A ⊆ A of the departments such that a∈A a = B and place them left of t and all other departments right of t, then the corresponding ordering π is for sure optimal. If the sum of lengths of the departments left of t in the optimal ordering π does not give B, then there exists no subset A ⊆ A such that a∈A s(a) = B.
In summary we have shown that there exists an ordering π of the departments such that the total costs are ≤ M := B(B + 1) if and only if there exists a subset A ⊆ A of the corresponding PARTITION instance such that a∈A s(a) = B.
In the layout context the above result can be interpreted as follows: The minimization of the inter-row costs that occur in all multi-row layout problems is NP-hard, even in its simplest version. This is not only an interesting theoretical insight on its own but also supports our definition of the Single-Row bound in our companion paper [20]. Next let us consider some more specialized versions of the (COP) that turn out to be solvable by a greedy algorithm and hence in particular in polynomial time.
First we assume that all departments have the same length. In this case the optimal permutation of the departments can be obtained by a simple greedy selection. We choose the permutation π with the following property: The higher the weight of a department the smaller is its distance from the checkpoint. Next we give a short formal argument for the above claim and refer to Figure 3 for a toy example of this variant of the (COP). Fact 2: A permutation π is optimal for the (COP) with identical department lengths iff it ensures the inequalities where z i , i ∈ [n], denotes the distance of the center of department i from the checkpoint.

Proof:
The change of the objective function caused by swapping two departments i and j is −(z i − z j )(w i − w j ). Hence in particular the change in the objective function caused by this swap is independent of the length and weights of all other departments k ∈ [n], k = i, k = j. Now assume that there exists an optimal permutation that does not ensure one inequality in (3), i.e. −(z i − z j )(w i − w j ) < 0 for some departments i and j. Now swapping the two departments improves the objective value. As all other departments are not affected by pairwise swaps, it is not possible to improve the objective value by an arbitrary number of pairwise changes if (3) holds. Hence (3) is not only a necessary condition but also a sufficient one.
Note that the special case of the (SRFLP) where all department lengths are equal and the weights are binary is still NP-hard [22]. This problem is called Minimum Linear Arrangement (LA), belongs to the class of graph layout problems and is NP-hard even if the underlying graph G is bipartite [11]. (LA) was originally proposed by Harper [23,24] to develop error-correcting codes with minimal average absolute errors and was since then applied to VLSI design [25], single machine job scheduling [26,27] and computational biology [28,29]. There exist approximation algorithms for (LA) with performance guarantee O( log n) [30,31] and O( log n log log n) [32,33]. For further details on graph layout problems we refer to the survey paper of Díaz et al. [34].
Next we assume that the checkpoint is left-aligned or right-aligned. Also in this case the optimal permutation of the departments can be obtained by a simple greedy selection. We choose the permutation π with the following property: The higher the relative weight w i / i of a department i, the smaller is its distance from the checkpoint. Next we give a short formal argument for the above claim and refer to Figure 3 for a toy example of this variant of the (COP) . To facilitate the presentation of the proof, we assume w.l.o.g. that (1) the checkpoint is left-aligned and (2) the relative weights w i / i , i ∈ [n], are all distinct.
The following result is in fact known as Smith's Rule [7] in the scheduling context, where it describes a greedy algorithm to solve single-machine scheduling with the objective of minimizing the sum of completion times. For convenience we restate the proof in our notation. Fact 3: [7] The permutation π is optimal for the (COP) with a left-aligned checkpoint iff it satisfies the conditions Proof: Assume that there exists an optimal permutation that does not satisfy condition (4) for two departments i and j: w i i < w j j and π(i) < π(j). Then there are also two neighboring departments k and l (π(i) ≤ π(k) < π(k) + 1 = π(l) ≤ π(j)) that do not satisfy condition (4): w k k < w l l and π(k) + 1 = π(l). Now if we swap k and l, the value of the objective function changes by the term w k l −w l k . But this term is negative as w k k < w l l holds which yields a contradiction to the assumption that the permutation was optimal. Finally note that condition (4) defines a unique permutation, hence it is not only necessary but also sufficient.
We can interpret the (COP) with left-aligned checkpoint also as a (LOP) with special structure. We collect the lengths of the departments in a column vector and the weights of the departments in a column vector c. Now we aim to find a simultaneous permutation π of the rows and columns of A = c such that i,j∈[n] i<j a π(i),π(j) , is minimized. Contrary to the general (LOP), which is NP-hard [22], the matrix entries of W are not independent but determined by an outer product of two vectors. We have just seen in Fact 3 that the (COP) with left-aligned checkpoint can be solved by a simple greedy heuristic. Hence this special structure of the (LOP) cost matrix W as an outer product of two vectors is the reason why this (LOP) version can be solved in polynomial time.
We summarize the above results as follows: The (COP) is NP-hard and its 'hard' part is to determine where the centers of the departments are located with respect to the checkpoint in the optimal solution. In the following section we show that the (COP) with one checkpoint that is neither left-nor right-aligned can be solved by a dynamic programming algorithm and hence is NP-hard in the weak sense. If the number of checkpoints is not part of the input, then the (COP) is NP-hard in the strong sense. . In (a) we display the optimal layout for the (COP) with identical department lengths equal to 1 and weights w 1 = 1, w 2 = 2, w 3 = 3, w 4 = 4, w 5 = 5. The corresponding layout costs are 0.5 · 5 + 0.5 · 4 + 1.5 · 3 + 1.5 · 2 + 2.5 · 1 = 14.5.

A Dynamic Programming Algorithm for the (COP)
We exploit the following two simple properties of (COP) layouts for designing a dynamic programming algorithm: • In every (COP) layout there is at most one department covering the checkpoint. All other departments lie completely to the left or to the right of the checkpoint. • In an optimal (COP) layout all departments, except for the department covering the checkpoint, have to be arranged in non-increasing order from the checkpoint to the border of the layout with respect to their relative weights w i / i , i ∈ [n]. This structural characteristic is denoted as V-shaped property [35,36].
In order to simplify the description of our dynamic programming algorithm we assume w.l.o.g. that the checkpoint is centered and hence that the sum of the lengths of the departments to the left and to right of the checkpoints has to be equal. Now let us outline the workings of our dynamic programming algorithm in detail. The input for our algorithm is a (COP) instance, where the list of departments is given in nondecreasing order with respect to their relative weights w i / i , i ∈ [n]. First we choose one of the given departments as center department that covers the checkpoint, where c is the length of the center department, 1 c is the length of the part of the center department left to the checkpoint and 2 c is the length of the part of the center department right to the checkpoint. Hence c = 1 c + 2 c and additionally due to symmetry we can always assume w.l.o.g. that 1 c ≥ 2 c holds. Next we choose an alignment of the center department above the checkpoint: We start with the right end of the center department above the checkpoint and then shift the center department 0.5 to the right in each iteration until the center of the center department is placed directly above the checkpoint. Clearly it suffices to consider 0.5 shifts of the center department as the checkpoint is centered and i ∈ N, i ∈ [n]. In the inner loops we determine with the help of the following recursive relation whether to place the remaining departments to the left or to the right of the checkpoint where s indicates the remaining free space to the left of the checkpoint and M gives the overall remaining free space either to the left or to the right of the checkpoint, which is equal to the sum of the lengths of the departments not yet assigned. As we arrange the departments in non-increasing order with respect to their relative weights w i / i , i ∈ [n], from the checkpoint to the border, the V-shaped property of the resulting layout is ensured. We refer to Algorithm 1 for a detailed description of our dynamic programming algorithm that we implemented in C. In Section 5 we computationally compare the dynamic programming algorithm to an ILP approach for the (COP) that we suggest in the following section. In summary our dynamic programming algorithm for solving the (COP) runs in pseudo-polynomial time, to be precise in Hence the (COP) with one checkpoint is NP-hard in the weak sense. If the number of checkpoints is not part of the input, then the (COP) is NP-hard in the strong sense, which can be proven by a deduction from 3-PARTITION.

7:
Choose a center department and remove it from the list of departments. 8:

15:
for s from 0 to M do 16:
x ij = 1, if department i lies to the left of department j, 0, otherwise, in order to relate the positions of the n − 1 departments to each other and to the checkpoint n that is again w.l.o.g. assumed to be centered. To ensure transitivity on the ordering variables we use the 3-cycle inequalities that rule out the existence of directed 3-cycles and are sufficient for guaranteeing that there is no directed cycle. Now the distances of the departments from the checkpoint can be expressed as quadratic terms in ordering variables: For department i ∈ [n − 1], we sum up the lengths of the departments left of i plus i /2 and denote it by d i . Furthermore we compute the position of the checkpoint d c as S/2, i.e. the total length of the departments divided by 2. Then we subtract d i from d c . This difference gives the distance of the center of department i from the checkpoint, if department i is located to the left of the checkpoint. If department i is located to the right of the checkpoint, this difference is minus the distance of the center of department i from the checkpoint. Therefore we multiply this difference by the term (2x in − 1) that is 1, if the center of department i lies to the left of the checkpoint and −1 if the center of department i lies to the right of the checkpoint: with The additional multiplication with (2x in − 1) ensures a correct calculation of all distances through the following constraints: Expanding and simplifying (9) yields To model the (COP) as an ILP we apply standard linearization and introduce new variables for all products of ordering variables in (11): Note that we have to introduce y inji for all i = j as the variable i appears twice in the indices. Now (11) can be further rewritten as: Moreover we use the following standard constraints to relate the orderings variables and their products: In summary we obtain the following ILP model for the (COP) : min i∈ [n] w i z in s.t. (6), (8), (13), (14), In the following section we computationally compare an ILP approach based on this model with our dynamic programming algorithm introduced in the previous section.

Computational experiments
We report the results of computational experiments with our dynamic programming algorithm and ILP approach respectively. All computations were conducted on an Intel Xeon E5160 (Dual-Core) with 2 GB RAM, running Debian 5.0 in 64-bit mode. The algorithms were implemented in C (dynamic programming algorithm) and Gurobi 6.5 (ILP) respectively. To generate (COP) instances we use layout benchmark instances from the literature by simply choosing one department i as checkpoint and deducing the (COP) weights from the pairwise weights as follows: w j = w ij , j ∈ [n], j = i. In order to test the effect of varying department lengths on our approaches, we generated additional instances using the same weights but substituting the original department lengths lying in the range of 1-20 with random department lengths between 1 and 10,000. We add an L to the instance name for indicating the instances with the new random department lengths. All instances considered can be downloaded from http://tinyurl.com/layoutlib. In Tables 1 and 2 we state the results of our ILP approach. For instances with up to 25 departments the ILP succeeds in determining the optimal solution. For instances with a higher number of departments (except from 'ste36.5') we observe quite large gaps even after 24h. The performance of the ILP approach is hardly influenced by the department lengths as can be seen by comparing the results in Tables 1 and 2. In Tables 3 and 4 we state the results of our dynamic programming algorithm that determines the optimal solution for all benchmark instances with short department lengths within seconds. As our dynamic programming algorithm runs in O(n 2 · S · max i∈[n] { i }), it is much slower on the benchmark instances with large department lengths, where it is able to solve instances with up to 33 departments. If the dynamic programming algorithm does not finish within the time limit, then it does not provide a lower bound and hence also no global gap for the optimal solution. Comparing our two approaches we observe that the dynamic programming algorithm is clearly superior for all benchmark instances from the facility layout literature that only contain departments with short lengths ≤ 100. For instances with department lengths up to 10000 the dynamic programming algorithm is still preferable although there already exist instances (see e.g. 'ste36.5') on which the ILP yields clearly better results. Finally for instances with even larger department lengths the ILP gradually outperforms the dynamic programming algorithm.

Conclusion
In this paper we proposed a new variant of a row facility layout problem and two exact algorithms for solving it. The Checkpoint Ordering Problem (COP) is weakly NP-hard. It is both of theoretical and practical interest and has several important relations to other well-studied combinatorial optimization problems. In our computational study we showed that the (COP) is hard to solve in practice for both dynamic programming and ILP approaches.
It would be interesting to examine if the models, results and algorithms for scheduling on two parallel machines, which is a very well-studied problem, can be used to obtain stronger approximation results and/or to design stronger exact approaches for the (COP) in particular and layout problems in general.