FROM LOCAL SEARCH TO LOCAL SEARCH PROGRAMMING
Habilitation à Diriger des Recherches présentée le 11 mars 2014 par par
Thierry BENOIST
devant le jury composé de :
Jean-Charles BILLAUT, Prof. de l’Université de Tours
Examinateur
Stéphane DAUZERE-PERES, Prof. de l'Institut Mines-Telecom
Examinateur
Claude JARD, Prof. de l’Université de Nantes
Examinateur
Narendra JUSSIEN, Prof. de l'Institut Mines-Telecom
Examinateur
Louis-Martin ROUSSEAU, Prof. de l’Ecole Polytechnique de Montréal
Rapporteur
Frédéric SAUBION, Prof. de l’Université d’Angers
Examinateur
Marc SEVAUX, Prof. de l’Université Bretagne Sud
Rapporteur
Michael TRICK, Prof. of Carnegie Mellon University
Rapporteur
Acknowledgements Mike Trick made me the great honor to act as a referee and to come all the way to Nantes to attend to the defense. He is a kind of guru for all those (including myself) who focus on concrete applications of OR and his presence means a lot to me. All members of the jury share this passion for applied science and I am deeply grateful to all of them for their interest in my work and for their kind advices. Although only one name can appear on the cover of this memoir, a habilitation thesis is clearly not meant to be a solitary work. Mine is the result of a fruitful collaboration with all the members of the LocalSolver team: Frédéric Gardi, Bertrand Estellon, Karim Nouioua, Romain Megel and Julien Darlay. It all started when Frederic came one day with this audacious idea of embedding local search mechanisms into a general-purpose solver, and all those people happily joined in year after year, each bringing his new ideas and hard work. It is a great pleasure to continue this adventure with them. I am also indebted to all those who supported us when LocalSolver was only an emerging research project, including Yves Caseau, Denis Montaut (who compared LocalSolver to hard drugs), Alain Nguyen, Francis Sourd, and all the members of our informal group of OR industrial teams. I am also obliged to the Bouygues Group who incubated this project, with the unfailing support of our hierarchy Etienne Gaudin, Gilles Zancanaro and Alain Pouyat.
Contents
Synthesis: "From Local Search to Local Search Programming" o
Abstract. Local Search basically consists in applying iteratively some changes (called moves) to a solution so as to improve the objective function. Although incomplete, Local Search allows operations researchers to obtain good quality solutions in short running times, of the order of the minute. In this dissertation, we consider the different components of a Local Search algorithm, namely the definition of the model, the design of neighborhoods (moves), the implementation of incremental algorithms for these transformations, and finally the choice of an exploration strategy (meta-heuristic) and we study their design for several practical optimization problems. Then we will reconsider each of these layers, in reverse order, trying to see how they can be automated and thus turned into problem-independent techniques. Such an automation is intrinsic to meta-heuristic but requires innovative algorithms when it comes to automating the incremental evaluation of changes in a general optimization problem or designing general-purpose neighborhoods. We conclude that a mathematical programming solver can profitably integrate local search techniques. This general-purpose solver (LocalSolver) follows a model&run paradigm, that is to say that OR practitioners can focus on the modeling of the problem using a simple formalism, and then defer its actual resolution to the solver. We explain how generic moves, algorithms and heuristics are designed in LocalSolver and we illustrate the efficiency of this model&run solver on several examples. We show that this approach opens interesting perspectives in terms of problem modeling.
Appendix: o o
o o o
o
T. Benoist, F.Gardi and A. Jeanjean (2012). Lessons learned from 15 years of operations research for French TV channel TF1. Accepted in Informs Interfaces. T. Benoist, B. Estellon, F.Gardi, R. Megel and K. Nouioua (2011b). LocalSolver 1.x: a black-box local-search solver for 0-1 programming. In 4OR, A Quarterly Journal of Operations Research 9(3), pp. 299-316. T. Benoist (2010). Characterization and automation of matching-based neighborhoods. CPAIOR'10, Bologna (Italy). T. Benoist (2007). Towards optimal formwork pairing on construction sites. In RAIRO Operations Research vol 41 n° 4 (2007) 381-398. T. Benoist (2008). Soft car sequencing with colors: Lower bounds and optimality proofs. In European Journal of Operational Research Volume 191, Issue 3, 16 December 2008, Pages 957971. T. Benoist, B. Estellon, F. Gardi, A. Jeanjean (2011a). Randomized local search for real-life inventory routing. Transportation Science, 45(3), pp. 381-398
From Local Search to Local Search Programming Thierry Benoist Innovation24 & LocalSolver 24, avenue Hoche 75008 Paris
Local Search basically consists in applying iteratively some changes (called moves) to a solution so as to improve the objective function. However this so-called descent is likely to reach solutions which cannot be improved by any of our moves, while much better solutions may exist somewhere else in the search space. The existence of these locally optimal solutions led to the development of various diversifications strategies in order to escape from these local optima. These strategies are usually referred to as metaheuristics. Local Search is so widely used by Operations Research practitioners that introducing this technique may seem pointless. Indeed the above lines can be found in the introduction of most meta-heuristics textbooks. Although incomplete, Local Search allows operations researchers to obtain good quality solutions in short running times (of the order of the minute). In particular, when a large-scale combinatorial optimization problem has no underlying linear structure (hence a poor linear relaxation) or no underlying propagation structure (that is, each decision has little impact on the remaining search space), then Local Search has shown its efficiency compared to tree-search based methods like Mixed Integer Programming or Constraint Programming. The results of the international competitions organized since 1999 by the French Society of Operations Research (ROADEF) are revealing in this regard. A closer look at the results of these Roadef Challenges1 also illustrates that designing and implementing local-search algorithms is not straightforward, and the differences between local-search approaches of different competitors can be significant. After a preliminary section on optimization models, we will follow two symmetrical directions. First we will analyze the four components of a Local Search algorithm namely the definition of the model, the design of neighborhoods (moves), the implementation of incremental algorithms for these transformations, and finally the choice of an exploration strategy (meta-heuristic). Then we will reconsider each of these layers, in reverse order, trying to see how they can be automated.
1
http://challenge.roadef.org
1
All along this synthesis, our views will be illustrated on the following problems2: Car Sequencing (Benoist 2008), introduced in section 2.1 Formwork Pairing (Benoist 2007) introduced in section 2.1 Eternity II (Benoist 2008) introduced in section 2.1 Inventory Routing (Benoist et al 2011b) introduced in section 2.2 Paint Shop Scheduling (Kamijo & Benoist 2013) introduced in section 3.4
1 Optimization models We will see in the next section that the design of a Local Search algorithm starts with the choice of a model for the problem and we will advocate in our final section for a model & run approach of Local Search. This focus on modeling leads us to start with preliminary remarks on the specification model (a formal representation of the practical problem at stake) and the operational model (a translation of these requirements into a mathematical model suitable for a given solving algorithm).
1.1 The specification model When addressing a management problem by Operations Research, the modeling task consists in listening to the business requirements (operational context, economic objectives, optimization perimeter…) in order to formalize these needs in mathematical terms. The output of this step is a specification model defining what data defines the problem, what is a solution to this problem and what cost is assigned to this solution (assuming we are in a minimization context). At this stage a good practice is to implement an input and output checker, namely a program able to check the consistency of input data and to check the validity and cost of a given solution. Provided that the defined problem is in NP, this checking program should have polynomial complexity [Garey & Johnson, 1979]. This specification model is completely independent of the resolution technique but it must have the following properties:
2
the assumptions on data should be verified in practice. Otherwise, either the assumptions must be changed or the data must be purified. the solutions currently used for this problem must satisfy the constraints specified in our model. Indeed optimization usually applies on an existing process which means that the problem has solutions. For example [Puget, 2012] cites the case of a rail industry customer for which no feasible train scheduling could be found. Actually trains did circulate everyday what suggested that the model featured constraints that were not always satisfied in practice. more generally, finding a "solution" should be relatively easy so as to ensure that a reasonable resolution technique will never return "No solution". Indeed a partial solution is often much more useful than no solution at all. For inventory routing optimization [Benoist et al. 2011a], our industrial client initially wanted to include a no stock-out constraint stating that no customer should ever see its inventory level drop below a so-called safety level. Instead, we modeled this
Three of these papers are available in the appendix of this synthesis.
2
requirement as a first-rank objective: minimizing the number of time steps during which a customer remains below its safety level. Not only did we observe that in practical solutions, it could happen for a few hours, but also it helped identifying data inconsistencies because when the algorithm did not manage to avoid stock-outs for a customer, it often meant that an error in the distance matrix or in the consumption forecasts for instance made this very customer hard to serve. Conversely any solution satisfying the constraints of the model should be considered as acceptable by end-users. This comprehensiveness of the model is important since any fault in the model might be intensively exploited by an optimization algorithm, yielding solutions where a unwanted situation appears repeatedly. A few years ago we built a software program building TV advertising plans [Benoist et. al 2012]. Fortunately we were able to develop a first MIP-based prototype in a few days and could present our first plans using an Excel-based visualization. It turned out that the actual problem was far more complex than we had originally believed. Most of our plans were rejected by experts because they presented patterns unacceptable to our customers: commercials in consecutive TV breaks, an unbalanced dispatch of commercials among days of the week, or repeated broadcasting hours on consecutive days (i.e., risk that the commercial will be seen by the same viewers every day). These side constraints were so implicit in the practice of advertising planning that they had been omitted in the specifications.
In conclusion one could say that the specification model should represent the real-world problem, the whole real-world problem and nothing but the real-world problem. The reader interested in the challenges of modeling real-life problems as Operations Research problems is invited to read our paper Lessons Learned from 15 Years of Operations Research for French TV Channel TF1, co-written with Frédéric Gardi and Antoine Jeanjean and inserted in appendix of this thesis. This specification model can also be named the Mathematical Problem or simply the Problem. The problems defined in [Garey & Johnson, 1979] are good examples of mathematical modeling independent of any resolution technique.
1.2 The operational model When it comes to solving3 the problem, modeling means transforming the specification model into an optimization model adapted to the chosen technique. This model must respect the modeling limitations of the chosen technique (allowed variables and expressions), and should produce solutions which are relevant to the specification model. For a given technique, several models can be designed whose performances may be strongly different.
3
Note that in all this synthesis we use the phrase "solving the problem" in a practical sense that is to say that we are interested here in producing valid solutions, not in proving that a solution is optimal. The algorithms to be used for proving the optimality of a solution are not necessarily the same as the algorithms able to find good solutions quickly. It is the case in LocalSolver, where lower bounds are obtained with inference and relaxations techniques that will not be described here.
3
It is often possible to have a one to one correspondence between solutions of both models but this is not always the case. For instance some resolution techniques may require discretizing continuous variables in which case the solution set is a subset of the original one. Also linear programming approaches require linearizing non linear constraints what can lead to an outer or inner approximation. Practical consideration may also lead to adding arbitrary constraints making the problem easier to solve (assumptions on the form of solutions for instance). For example solving a problem by Mixed Integer Programming (MIP) requires formulating a model made of linear expressions only, with continuous or integer variables. Implicitly it defines a search space which is larger than the solution set since infeasible solutions (with respect to integrity constraints) we be considered during search. It may also allow feasible solutions which are invalid with respect to the specification model, provided that the resolution technique guarantees that such solution will never be generated. This is a case when: minimize max(x,y) is linearized as minimize z subject to z>x z>y In this model z=2; x=y=0 is a valid solution which is invalid in the specification model but the resolution technique prevents the appearance of this solution. What makes the difference between several MIP models is the choice of variables and constraints. For instance network related problems can sometimes be modeled with node-arc or node-chain formulations [see Fulkerson 1971, Ouorou et al. 2000]. More generally, extended formulations are often an interesting alternative, combined with delayed column generation (or not) if the number of induced columns is huge. As for constraints, we refer the reader to the celebrated book of [Nemhauser and Wolsey, 1988] for an introduction to the importance of valid inequalities, cuts and facets in MIP modeling. Similarly using Constraint Programming (CP) as resolution paradigm requires expressing the problem with the variables and constraints available in the chosen framework. If continuous variables are not available in this framework they will be turned into finite-domain variables (or to boolean variables in a SAT model). Likewise, binary CSPs require reformulating non-binary constraints [see Rossi & Dhar 1990]. Like for Mixed Integer Programming, different CP models can have radically different performances for the same problem. And even two constraints with the same semantics can achieve different levels of consistency, what complicates the modeling effort. Various modeling techniques have been defined in order to design efficient CP models including the addition of redundant constraints (or "implied" constraints) to enhance propagation, the use of global constraints, the combination of different viewpoints or the definition of symmetry-breaking constraints [see Smith 2006]. 4
A profuse literature is available on MIP and CP modeling because these are model & run techniques that is to say that once the model is defined, its actual resolution can be deferred to a solver4. Automating the transformation from an abstract specification model into an operational model for MIP or CP is also a active topic of research. For instance the Essence project [Frisch et al. 2008] aims at defining a specification language explicitly inspired from the Garey & Johnson formalism, and able to produce Constraint Programming models. Also IBM ILOG's OPL language offers modeling objects shared in common with CPLEX optimizer and CP optimizer with some automated conversion [IBM, 2012], and Xpress-Kalis offers automatic linearizations for a certain number of arithmetical and logical constraints [FICO 2009]. However, although these techniques may help in some cases, the expertise of the OR researcher remains crucial for most problems.
2 Programming Local Search Algorithms 2.1 Local Search Modeling Since no model & run solver is available for local search, no research paper is focused on the modeling of a problem for a local search approach (to the best of our knowledge) because such a modeling makes no sense without an associated local search algorithm. In this section we will draw the modeling principles governing the design of efficient local search algorithms. Contrary to MIP and CP models local search models do not benefit from the addition of constraints (redundant constraints or valid inequalities or symmetry breaking rules). On the contrary such constraints usually have a negative effect on local search efficiency. However the choice of the form of solutions remains very important and very different models can be designed, even for the simplest problems. For instance the car sequencing problem consists in ordering cars on a production line, according to features spacing constraints of the form “never more that 2 sunroofs in any sequence of 5 vehicles”, called ratio constraints. These constraints model the necessity for cars requiring special operations to be evenly distributed along the line. A solution to this problem can be seen as an array of integers, each giving the position of a vehicle on the line. Equivalently we can define binary variables Xcp equal to 1 if car c is in position p. [Gravel et al. 2005] noticed that cars with identical features play the same role and proposed a more compact model where cars are grouped into classes and Xcp variables now refer to the assignment of a vehicle of class c to position p. This model reads as follows. DATA: n the number of classes m the number of positions, 4
Until recently only MIP could be considered as truly model & run, since CP users usually had to implement a tree search strategy in order to obtain satisfying results. But some CP systems are now designed as model & run solvers (like IBM-CPO)
5
vc the number of vehicle for each class c r the number of options Pk and Qk the spacing constraint for option k : never more that Pk occurrences of option k in any sequence of Qk vehicles fck equal to 1 if vehicles of class c feature option k
MODEL binary variables Assign the expected number of vehicle of each class
Exactly one vehicle per position is equal to 1 if option k appears at position p The penalty is the excess of occurrences of option k in window
The above model is the most classical for the car sequencing problem. Alternatively, a solution can be represented as a permutation of all vehicles (incidentally, this point of view led recently to a very short proof of the NP-completeness of the problem, see [Estellon & Gardi 2012]). All these models lead to different search spaces and thus to different local searches. Throughout this synthesis we will illustrate several notions on this car sequencing problem, used as a continued example. In [Benoist 2007] we introduce the Formwork Pairing Problem, another optimization problem where modeling plays a crucial role for the success of a local search algorithm. Once the framing tasks have been scheduled on a construction site, we consider the optimization of the transportation of formworks from wall to wall. This planning can be formalized into a multi-commodity flow where we want to maximize the number of "parallel edges". Each pair of parallel edges (bold arcs on Figure 2) represents the transportation of two formworks from adjacent positions on a wall to adjacent positions on another wall. This situation is desirable since it allows moving these shuttering materials without disassembling, what yields a significant gain in time. This problem is sketched out in the following figures: given the formwork types and quantities assigned to 10 walls (Figure 1), the goal is to design a flow such that each wall is crossed by the expected number of formworks of each kind (Figure 2).
6
stock
Monday 1x
60
1x
120
1x
180
60
1x
360
60
1x
480
60
Tuesday
3x
60
60
Wednesday 1x
60
Thursday 2x
Friday
60
1x
60
1x
480
1x
240
1x
240
1x
180
2x
480
1x
480
60 120
1x
60
180
1x
480
180 240
3x
60
3x
60
1x
180
1x
180
2x
480
2x
480
360
1x
60
1x
180
480 480 480
Figure 1 - Sample Input Data for the Formwork Pairing Problem (FPP)
stock
60
Monday
Tuesday
60
60
480 180
Wednesday
Thursday
Friday
240
60
60
60
60
480
480
60
480
180
480
60
60 60
360
60
120
240
60 120
60
180
480 60
60
60
480
60
480
480
60
180 240 360 480
480
60
180
180
180 60
480 480
Figure 2 - Possible Solution for this FPP instance
The size of this modeling as a multi-commodity flow (a commodity representing of type of formwork) is quadratic in the number of walls, which corresponds to millions of edges for real-life instances. Another issue is that a large part of this solution has no impact on the objective function, since the arrangement of formworks that are not transported on parallel edges is irrelevant. For these two reasons, we 7
designed a "compact" model centered on pairings, a pairing being a pair of formworks moved together. In this model a solution is a set of pairings: as shown on Figure 3, it means that the transportation of individual formworks is completely ignored. The feasibility of a solution is then defined as the ability to complete this set of pairings into a complete transportation planning. We proved that such a completion is possible if and only if four conditions are met (for example on the overlap of pairings). Any feasible multi-commodity flow induces a feasible pairing set with identical cost and any feasible pairing set can be extended into many multi-commodity flows of identical cost. The advantage of this pairing model is to focus on the important part of the problem (parallel arcs). Besides, we will see in the next section that it allows the definition of very simple neighborhoods. stock
60
Monday
Tuesday
Wednesday
Thursday
Friday
60
60
240
60
60
480
60
60
480
480
180
60
480
180
480
60
60 60
360
60
120
240
60 120
60
180
480 60
60
60
480
60
480
480
60
180 240 360 480
480
60
180
180
180 60
480 480
Figure 3 - The same solution in the "compact" representation
Both of the above examples were optimization problem whose optimization criterion was preserved by our local search modeling. This is not always the case. First, local search can be used to solve satisfaction problems, in which case these problems need to be turned into optimization problems, whose objective function reaches a certain optimum when the solution satisfies the constraints of the original problem. There are often several ways to perform this transformation. For instance, the frequency assignment problem is the problem of assigning frequencies to radio links, subject to interference constraints (minimal distance between frequencies assigned to pairs of links). A "polarized" version of this problem was the subject of the Roadef challenge 2001. Classically, one could define an infeasibility measure as the number of violated interference constraints, or as the sum of "missing distances" between frequencies (something like max(0, wantedDistance - observedDistance)), or any other measure taking value 0 when constraints are satisfied. Interestingly, the winning algorithm of [Dupont et al. 2004] took an orthogonal point of view. Instead of allowing interference constraints to be violated to the expense of a certain cost, he allowed frequency links to have no assigned frequency, in 8
which case interference constraints relative to this link are ignored. In this approach, a solution is the assignment of frequencies to a certain number of links, satisfying all interference constraints, and the objective function to be minimized is the number of unassigned links. Such approaches are possible for many satisfaction problems. Not surprisingly, when Tomy released the Eternity II puzzle 5 in 2007 [Benoist & Bourreau 2008], some competitors searched for a complete tiling minimizing the number of mismatching edges while others tried to arrange as many tiles as possible on the board, while respecting edges constraints. In this case none of them obtained a tiling with no mismatching edge or a feasible tiling using all 256 tiles… In fact, even when the original problem is defined as an optimization problem, a local search model may profitably change the objective function. If we consider a scheduling problem whose objective function is to minimize the number of used resources (resources assigned to at least one task). Such a model can be difficult to optimize because the objective function has huge plateaus, that is to say sets of solutions whose objective value is the same. In such an example it can be useful to use a so-called surrogate objective. Here we could add a secondary criterion minimizing the minimum number of tasks assigned to a resource. Indeed a solution with N resources used, one of which with only one task is more promising than a solution with N resources using, each having at least 10 tasks assigned. In conclusion, a model for a local search approach defines a search space and an objective function. The search space is the set of all possible solutions, including both feasible and infeasible solutions. The term of "infeasible solutions" may be regarded as an oxymoron but is widely accepted6 hence we will keep this naming. The search space is then a set, where each item has a feasibility status (binary) and an objective value (numerical). By convention, we may give an infinite objective function to infeasible solutions, thus assigning a single value to each item of the search space. What is important here is that, although no move has been defined yet, the definition of this search space reflects a certain view of the problem: what is considered as solution, how these solutions are represented, what are the decisions variables…
2.2 The moves The previous section aimed at defining what a solution is, even before considering how such a solution could be transformed. Now that this search space is defined, we can consider how a solution can be transformed into another, thus introducing the search graph [Papadimitriou et al. 1990]. In terms of the search space defined in the previous section each move or transformation is an arc from one solution to another solution. Of course these arcs are not defined one by one. They are introduced 5
the model of this edge-matching puzzle reads as a nursery rhyme (http://www.eternity-puzzle.com): Make a square from all the pieces, With the grey ones round the border; Match all touching pairs of edges Do it first and win US$2 Million! 6 the terms feasible assignment and infeasible assignment would probably be more appropriate when the solution is represented by the assignment of values to variables but as mentioned above a solution can also be represented differently (as a permutation of a given set for instance).
9
implicitly, as families. For instance in the car sequencing problem, exchanging the positions of two cars along the production line is a classical transformation. Here this move is symmetrical that it to say that the opposite move exists in the same family. It is not always the case, for instance a move splitting a task into two parts in a preemptive scheduling model is not symmetrical. For a given solution x, the set of all solutions y such that a move xy exists is called the neighborhood of x. Globally, the set of all moves (all arcs on this graph) is sometimes referred to as the neighborhood structure. Without loss of generality, we will assume in all that follows that the objective function F has to be minimized. When F(y)F(x), xy is called a deteriorating move, and when F(x)=F(y), xy is called an horizontal move. The graph defined by the set of solutions and the transformation arcs can be explored by a local search algorithm that will start from an initial solution and follow these arcs in order to explore the search space (see section 2.4 the various exploration strategies). The characteristics of this graph will have a significant impact on the global performance of the approach. For instance this graph is said to be quasi-ergodic if it is strongly connected that is to say than any pair of solutions x and y is connected by a path in this graph (this is the case of the exchange neighborhood evoked above for the car sequencing problem introduced in section 2.1). This property is highly desirable at least for any y in S*, the set of optimal solutions. [Hajek 1988] also introduces the "connection height": x communicates with S* at height h if there exists a path from x to a point in S* such that the largest value of the objective function F along this path is F(x)+h. If all solutions have a connection height of 0 then it means that from any solution, an optimal solution can be reached following a path of non deteriorating arcs. Finally a local optimum is a solution whose outgoings arcs are all strictly increasing or at least which cannot be connected to any better solution by a non deteriorating path. These notions of connection height and local optimum are important since the most basic heuristic for exploring the search space consists in performing a random walk following non deteriorating arcs only (as we said, we will see in section 2.4 that many other heuristics can be designed but this "descent algorithm" is sufficient so far for considering the properties of a neighborhood). One of the most important points in the design of a local search algorithm is the definition of various families of moves. As observed in the above paragraph, the exchange neighborhood is sufficient in theory for exploring all car permutations, starting from a random one. However we just explained that the idea of local search is not to perform a random walk in this graph but instead to tend to descend in this graph. Then a descent in a search space based on this exchange neighborhood only is likely to end in a local optimum whose objective value can be relatively far from optimum. The most powerful remedy to such a situation consists in adding a new kind of transformation, for instance the mirror inversion of a random sequence of vehicles. This new neighborhood adds arcs between solutions whose distance in the previous graph was potentially long and whose connection height was potentially high. In other terms this mirror move directly links a solution A to a solution B whereas transforming A into B by the way of exchanges would have taken at least n/2 steps (if our mirror reversed a sequence of n vehicles). Besides, this sequence of exchanges is likely to visit solutions much worse than B. Thanks to this new neighborhood, if A was a local optimum in the previous neighborhood and B is better than A, then A is not a local optimum anymore and a descent algorithm will end in a better local optimum. Defining a large variety of transformations for the car sequencing problem (exchange, mirror, deletion and 10
reinsertion), [Estellon et al. 2008] obtained a search space such that, in practice, a descent starting from any solution reached rapidly a quasi-optimal solution. In [Benoist et al. 2011a] we applied this principle intensively for solving a real-life inventory routing problem. The inventory routing problem (IRP) consists in optimizing the distribution of fluids by tank trucks in the long run. It is a generalization of the vehicle routing problem with vendor managed inventory replenishment. The particularity of this problem is that the vendor monitors the customers’ inventories, deciding when and how much each inventory should be replenished by routing trucks. Based on consumption forecasts for each customer, a solution is a set of routes visiting customers and delivering a certain amount of product at each of these stops. In addition to routing constraints, stockouts must be avoided, which means that the quantity of product stored at each customer should stay above a certain safety level. The economic function is the costs of the routes. For this problem, we defined more that 50 neighborhoods, grouped in 10 families, and here again we observed that with such a dense graph a simple descent was sufficient and did not get stuck in local optima.
Figure 4 - Some of the neighborhoods for the Inventory Routing Problem
Does this densification of the graph have a limit? In fact making the graph complete would indeed ensure the absence of local optima. However this theoretical advantage would be of no use in practice since it would make the degree (number of neighbors) of each solution equal to the total number of solutions, and an exploration of this search space would be hardly different from a "generate and test" approach. However, defining a very large scale neighborhood (that is to say giving an exponential number of neighbors to each solution) is relevant when some underlying structure allows finding an improving or at least a non deteriorating arc quickly among the huge number of neighbors. We refer the reader to [Ahuja et al 2002] for a survey of very large-scale neighborhood search techniques.
11
Clearly, having chosen an appropriate model can make the definition of moves very easy. For instance in the Formwork Pairing example given in the previous section, having modeled a solution as a set of pairs induces simple moves as inserting a new pair (possibly removing others). In this case we could define moves consisting in inserting a random pair and removing a (nearly) minimum set of conflicting pairs. This neighborhood ensured that any transformation of this kind lead to a feasible solution. Of course this neighborhood only made sense because we had designed an efficient algorithm for computing this conflicting set. Indeed we will see in the next section that the underlying incremental algorithms governing the time complexity of each move are another crucial point of a successful local search.
2.3 The incremental machinery In section 2.1 we have defined a weighted set of solutions and in section 2.2 we have defined arcs between these sections, thus introducing a graph7 representation of the search space. A local search algorithm follows a path (or several paths) in this graph. Since in practice such an algorithm will be launched with a given time limit, the time needed to follow each arc has a direct impact on the length of the path that will be explored by the algorithm. If we label each arc with a time measure, then an algorithm which is granted a time limit L will walk a path of length smaller than L. This time measure corresponds to the "speed" of each arc (the smaller the faster). [Estellon et al. 2009] insist on the fact that a speed ratio of 10 or even 100 can be observed between algorithms using the same neighborhoods. Indeed the key ideas behind local search are that:
the probability to find a good solution in the neighborhood of another good solution is higher than the probability to find a good solution by randomly generating a brand new solution. the complexity of transforming s0 into an element of N(s0) is smaller than the complexity of building a brand new solution
The locality of transformations is observable in the car sequencing case. When exchanging the position of two cars, only the penalties associated to options featured by exactly one of the two cars will be impacted. And for each such ratio constraint Pi/Qi (see section 2.1 for a description of the problem), at most 2Qi penalties need to be updated. And these first observations can be highly refined in order to reach state-of-the-art algorithmic performances [Estellon & al 2008]. Similarly, in our Inventory Routing application, inserting a delivery in a route only require rescheduling the end of this route and recomputing inventory levels for this client until the next complete refueling (see details in [Benoist et al. 2011a]). An important aspect of incremental algorithms associated to transformations (namely algorithms modifying only what is impacted by each transformation), is the difference between evaluating a move and actually performing the move.
7
recall that this graph representation is of course implicit but used here for illustration purpose only: no actual local search algorithm implements such a graph structure.
12
In the previous section we introduced the search graph where arcs from a solution to another represented a move and we mentioned the fact that most local search walks follow a large majority of non-deteriorating arcs, while crossing deteriorating arcs (or up-hill arcs) is enforced occasionally in order to escape from local optima. However, when arcs are randomly chosen among outgoing arcs of a solution, the probability of selecting a deteriorating arc is high, and detecting that an arc is deteriorating requires evaluating the objective function at its extremity. In practice it means that a large part of the search time will consists in following an arc just to detect that the objective function is in fact worse at its extremity and then coming back to select another outgoing arc. Based on this observation, most local search algorithms proceed with 3 functions:
eval does the minimum possible work to evaluate the objective function that would result from a move (or at least detect if the resulting solution is feasible) rollback just come back to the previous solution commit actually perform the move and possibly update data structures that will be needed for selecting the next move
In terms of the search graph it means that for each arcs x y we virtually introduce an intermediate node y' and 3 arcs: x->y' (evaluate) y'->x (rollback) y'->y (commit). The computational times (tcommit ,teval and trollback) attached to these three actions are different and tcommit can be significantly higher than teval and trollback since this "commit arc" will be crossed less often that the two others. This distinction is very clear in [Benoist et al. 2011a] where building a delivery route requires finding an available driver, an available tractor and an available trailer. In order to find available resources (drivers, tractors, trailers) very quickly, we use a structure giving for any resource and any time point (date/hour) the task covering this point if any, the closest task for this resource ending before this point if any and the closest task starting after this point if any. For this we divide the horizon into m intervals U0, U1…Um-1 of equal length u. Then, an array I is defined such that Ii refers to the first operation whose starting date is larger than the left endpoint of Ui. The next operation after date d is found by searching the operations between the one pointed by Ii with i = ⌊d/u⌋ and the one pointed by Ii+1. In this way, the search is done in O(k) time in the worst case, with k the number of operations contained in the interval Ui. If u corresponds to the entire horizon (m = 1), then k is the number of tasks of the resource; on the other hand, if u corresponds to the smallest granularity for expressing time (here the minute, leading to m= 21600), then k = 1. Clearly, updating this structure is only needed when a move is actually performed whereas using this structure makes the evaluation of moves faster. In [Benoist et al. 2011a] we show that for a given estimation of the percentage of moves that will be committed we can analytically compute the optimal granularity u for the above structure. Concerning the rollback operation, the most widely used technique consists in storing the modifications induced by the currently attempted transformation, in order to be able to revert these modifications in minimal time. The complexity of algorithms can also influence the choice of moves. In the same application, each transformation triggers the update of the quantity of product delivered during each visit on a customer site. Formally this computation of quantities is a maximum flow problem. Hence we could either compute an optimal flow after each transformation or use an incremental heuristic restoring the 13
feasibility of the flow. This choice is important since the same shift insertion (for instance) can lead to a feasible flow with the first method whereas the second method would lead to the infeasible flow (one where some customers experience stock-outs). In terms of the search graph, the first method is unquestionably much better. However, our practical experiments showed that the heuristic approach was 2000 times faster than the exact one, with an average difference of 2% in terms of the total quantity of delivered product. Consequently we chose the second neighborhood since it could be explored much faster. The heuristic (see next section) can also influence the incremental evaluation of moves. Indeed if we decide that deteriorating edges will never be followed or if we choose to never visit infeasible solutions, then the evaluation algorithms can be significantly improved following a "first-fail" principle. As soon as we are sure that the move will deteriorate the objective function (or will lead to an infeasible solution), then we can abort its evaluation and rollback to the previous solution. For instance the heuristic flow algorithm evoked above is only launched if the transformed solution satisfies all scheduling constraints. For the car sequencing problem [Estellon et al. 2008] even studied the order in which the ratio constraints are treated and found an efficient ordering rule with an associated stopping criterion.
2.4 The heuristic After introducing the search graph in section 2.2 we insisted in section 2.3 on the "speed" of each arc. Now a local search is a walk in this graph and its execution time is the sum of the duration of all visited arcs (including rollback and commit arcs). As explained in section 2.2 the simplest heuristic consists in randomly applying moves, keeping only the non-deteriorating ones. In terms of the search graph it means choosing an outgoing edge for the current solution and rolling back to this solution if the extremity of this edge turns out to be worse than the current solution. Defining a strategy essentially means defining a selection procedure and an acceptance criterion. Here our acceptance criterion defines a descent, with the crucial property that horizontal moves are always accepted (thus allowing a good diversification of the search). As for our random selection of moves, it can be classically implemented as a uniform selection of a type of move (say insertion or deletion if we defined only these two moves), with some randomness within each move, for the choice of the insertion point for instance. Any variant is possible. For instance we can have generic and targeted versions of the same transformation: in [Benoist et al. 2011a] it means that a GenericInsertion inserts a new delivery for a randomly selected customer, while a TargetedInsertion inserts a new delivery for one of the customers suffering from a shortage of product. For the acceptance criterion, a variety of methods have been introduced for accepting deteriorating moves from time to time thus enabling the algorithm to escape from local optima (including the emblematic Simulated Annealing [Kirkpatrick et al. 1983]). Other approaches favor the selection of the most improving move for the current solution or at least the best among a large number of transformations (for instance the best reinsertion of a given customer). Such best-fit selection rules are often combined with a Tabu mecanism [Glover 1989]; this is what is implemented in [Benoist 2007]: we select the best non-Tabu move among 500. It would be of little interest to list or classify here all meta-heuristics. This job has already been done brilliantly in books like [Gendreau & Poitevin 2010] or [Aarts & Lenstra 1997]. Instead we will rather 14
focus on the relative importance of the search graph itself and the strategy (heuristic) for exploring this search graph. First of all it shall be noted that presenting a local search algorithm for a problem as a "meta-heuristic" is a metonymy is the sense that the meta-heuristic is only a component of the whole algorithm. Such a figure of speech is harmless in itself: when farmers count in terms of heads of cattle they are fully aware that there is a whole cow under each head. However [Gardi 2007] observed that students following a course on meta-heuristics tend to forget that there is a whole algorithm behind each meta-heuristic, what advocates for favoring the term "Local Search" in teaching. Beyond this linguistic debate, let us compare in the following table two algorithms for the car sequencing problem with colors (both competing in Roadef Challenge 2005). model moves algorithms heuristic Competition rank
[Estellon et al. 2008] Assignment (Classes to positions) swap, forward insertion, backward insertion, reflection and random shuffle Highly optimized Descent
[Benoist 2008] Assignment (Cars to positions)
Optimized (Eval/commit/rollback) "Star-relinking"
1st
12th
swap
What we can observe is that, based on a similar model, [Estellon et al. 2008] won the competition by focusing on the moves and the algorithms (our sections 2.2 and 2.3) whereas [Benoist 2008] built an elaborated heuristic8 on a swap-based neighborhood. The lesson that we can draw from this example is that before considering using a more elaborated heuristic than a pure descent, a good practice if to try first to improve the model, the variety of neighborhoods and the efficiency of underlying algorithms. It is only once no more significant improvement can be expected on these three layers that refining the search strategy (heuristic) should be considered. To put it differently we could rephrase the old saying of computer programmers "Do not comment bad code, rewrite it" into "Do not explore (heuristically) a bad search graph, redesign it".
8
which can also be interpreted as large transformations exploiting the polynomiality of a subproblem.
15
3 Local Search Programming As mentioned in introduction, Local Search is widely appreciated because it allows operations researchers to obtain good quality solutions in short running times (of the order of the minute). However, designing and implementing local-search algorithms is not straightforward. The algorithmic layer dedicated to the evaluation of moves (section 2.3) is particularly difficult to engineer, because it requires both expertise in algorithms and dexterity in computer programming. On the contrary, Integer Programming (IP) is surely one of the most powerful tools of operations research. Although limited when faced with large-scale combinatorial problems (because of its underlying intrinsically exponential tree-search approach) its success among practitioners is mainly due to the simplicity of use of IP solvers: the engineer models its problem as an integer program and the solver solves it by branch & bound (& cut). This “model-and-run” approach, when effective, reduces considerably the development and maintenance efforts in optimization software projects. For example, for the car sequencing problem that we introduced in section 2.1, writing an effective local search algorithm requires defining neighborhoods (section 2.2), designing efficient algorithms for performing these moves (section 2.3) and finally applying a search strategy to explore this search space. On the contrary using an IP solver for this problem only requires defining a model, but the best commercial solvers are unable to produce decent9 solutions for production lines with more than 500 cars. This kind of situation motivated the development of LocalSolver, a mathematical programming solver based on local search. Indeed the principle of LocalSolver is to "combine the simplicity of use of a modeland-run solver and the power of local-search techniques for combinatorial optimization". In other words our goal is to let OR practitioners focus on the modeling of the problem using a simple formalism, and then to defer its actual resolution to a solver based on efficient and reliable local-search techniques. In order to achieve this goal, the solver must be able to apply generic autonomous moves, based on efficient incremental algorithms, within a global adaptive search strategy. Thus it requires automating the 3 aspects of Local Search described in section 2.2, 2.3 and 2.4. For this reason, the plan of this second part will be the exact opposite of the plan of the first part. We will consider local search layers in reverse order, considering for each one if and how it can be automated (and in particular how LocalSolver handles each aspect). That is to say that we will first cover the design of autonomous heuristics, before considering the design of reusable software component embedding incremental algorithms, then we will explain how generic moves could be defined in LocalSolver. Finally we will conclude with modeling principles applicable in this model & run context.
9
With the Renault objective function, the best solution of IP solvers after one hour can be several orders of magnitude worse than the solutions obtained by local search in 5 seconds.
16
Since we join a paper describing in details the internal principles of LocalSolver the four sections of this second part will be deliberately unbalanced, with a focus on LocalSolver modeling rather than on LocalSolver machinery.
3.1 Heuristics By definition meta-heuristics are independent of the considered optimization problem. Therefore it seems natural to develop reusable software components encapsulating some well known metaheuristics such as Simulated Annealing or Tabu Search. It can also take the form of programming frameworks for local search as EasyLocal++ [Di Gaspero & Schaerf 2003], HotFrame [Fink & Voß 2002] or Paradiseo [Cahon et al. 2004]. Within these frameworks, a meta-heuristic can be designed as a composition of available meta-heuristic components, while neighborhoods and associated incremental algorithms have to be implemented for the specific problem (for instance deriving from some AbstractMove class). Remember that we insisted in part 1 on the importance of moves and incremental algorithms, while we consider that the search strategy must be kept as simple as possible. Consequently the above frameworks will be of little help for this kind of local search approaches. Nonetheless, this remark does not apply for genetic algorithm for instance, where the top layer of the algorithm is more complex, with a population of solution to be maintained. Beyond the definition of the acceptation criterion, an important aspect of the search strategy is the selection of the next move to be evaluated. Creating problem-independent algorithms for designing this strategy autonomously (using the knowledge obtained from different runs or during a single run) is an active topic of research10 at the intersection of operations research, machine learning and artificial intelligence. In LocalSolver, the search strategy is a simple simulated annealing heuristic with restarts. Multiple searches are run in parallel and periodically synchronized. As for the selection of the next move it is a randomized choice among existing moves. It raises the issue of the determination of the selection probability assigned to each move. An initial analysis of the structure of the problem allows identifying moves that cannot be applied to the given problem and whose selection probability is thus set to zero. Then an adaptive strategy collects statistics on each neighborhood during the search and continuously adjusts these weights.
3.2 Automating local search incremental algorithms As shown in section 2.3, the efficiency of incremental algorithms performing the moves is crucial to the performance of a local search approach. Although these algorithms may seem intrinsically specific to the considered problem, we observe that the same "tricks" can be reused from one problem to another. For 10
see the serie of Learning and Intelligent OptimizatioN Conferences (LION), e.g. 5th International Conference, LION 5, Rome, Italy, January 17-21, 2011, Selected Papers in Lecture Notes in Computer Science, Vol. 6683, CoelloCoello, Carlos A. (Ed.)
17
instance when a linear combination has to be maintained in any problem, we always apply the sum of differences induced by the current move in order to evaluate the new value of this linear expression. And if we want to have a fast access to non-zero terms in this expression, we will update a classical unordered set structure after each committed move. Maintaining the max of a set of variables is a frequent feature as well, for which a good average complexity can be ensured by maintaining the set of supports for this maximum. Even more complex structures can be reused from one problem to another: for problems as different as Inventory Routing [Benoist et al. 2011a] and earthmoving optimization [Jeanjean 2010] many incremental data structure are in fact shared by both programs. The first machinery for incremental evaluation was introduced in Localizer [Michel and Van Hentenryck 2000], the ancestor of Comet [Van Hentenryck and Michel 2005], and iOpt [Voudouris et al 2001]. LocalSolver uses the same principles, based on the exploitation of invariants of combinatorial operators. If the model of the problem is written with a set of mathematical operators (min, max, sum, and so on) then it can be represented as a Directed Acyclic Graph(DAG) which is the syntax tree for this model, where leaves are decision variables, nodes are mathematical operators and constants, and roots are constraints and objective functions. Having equipped each operator with incremental evaluation algorithms, the impact of the modification of a certain number of decision variables can be computed by propagating these changes from leaves to roots in this DAG. In other words, when building the optimization model as a composition of available operators, we are also implicitly designing the evaluation algorithm as a composition of incremental algorithms associated to these operators. Details on the global propagation mechanism (ensuring that each expression is evaluated at most once) and on the algorithms defined for some operators are available in section 4.2 of [Benoist et al. 2011b]. In practice, we observe that, although completely generic, LocalSolver incremental algorithms are reasonably competitive with hand-made algorithms. For instance both LocalSolver and [Estellon et al. 2008] perform millions of transformations per minutes on the car sequencing problem (on similar computers).
3.3 Autonomous moves In the previous sections we have explained that the search strategy can be defined independently of the search graph and implemented as a generic "controller". We have also shown that using invariants of combinatorial operators, an incremental evaluation algorithm can be automatically applied to a model based on these operators. What these two components allow is to define moves without having to program associated evaluation algorithms and search strategy. Roughly speaking, frameworks like ParadisEO are focused on the search strategy (3.1) while Comet and iOpt are focused on evaluation algorithms (3.2). These approaches aim at making the implementation of Local Search algorithms much easier. It shall be noted that there are many pitfalls on this path. Technically it induces a tight integration between the code written by the user and the objects of the framework because neighborhoods must be implemented so that the framework can evaluate them and launch them within its meta-heuristic. Such
18
a tight integration is a price that most programmers are reluctant to pay11, especially when it requires using "yet another language". To overcome this reluctance, a Local Search framework must offer a significant gain in terms of development time. Here, answering the traditional project question "How will you know that you reached your goal?" is quite complex. For instance, an answer like "The goal will be reached once I can write Car Sequencing neighborhoods in three lines of code." is insufficient. Indeed the world of research is full of frameworks that are considered simple by their inventors only, and thus remain unused. The danger here is that potential users find that these 3 lines are short but so difficult to write that they prefer to implement their local search from scratch in their own favorite language. Finally, after passionate debates among the LocalSolver team, we got convinced that there was a huge difference between a few lines of code and no code at all. Hence we chose to follow a model&run paradigm, where the user only has to declare its model using a simple formalism, and then to leave its actual resolution to a solver based on efficient and reliable local-search techniques. In terms of the search graph defined step by step in part I it means that the user merely defines the nodes of this graph (the solutions, section 2.1) and the solver devises arcs in this graph (moves, section 2.2), follows these arcs with great velocity (efficient incremental algorithm, section 2.3), while guiding this walk with a generic search strategy (adaptive meta-heuristic, section 2.4). Achieving this goal requires defining autonomous moves that is to say general purpose transformations of a solution. Our guideline here will be to try to define moves similar to what a practitioner would have designed to solve its problem. In particular, a specificity of this kind of moves is that they strive to preserve the feasibility of solutions. Before describing some autonomous moves implemented in LocalSolver, we can take an "axiomatic" standpoint in order to show that this preservation of feasibility is a kind of characterization of classical local search moves. Consider again our continued car sequencing example, with a model where a solution is represented as a vector of binary decision variables Xcp equal to 1 position p hosts a car of class c. Now, from a feasible solution x, what are the only moves leading to a feasible solution x' and changing only the values of k binary decisions? For k ≤ 3 and for any odd k, no feasible move exists. For k=4 the only feasible moves consist in exchanging the cars on two positions. For k=6 the only feasible moves consists in exchanging the cars on three positions (rotating move), etc12. Not surprisingly these 2-swap and 3-swaps are the most usual moves for this problem. It suggests that looking for autonomous moves preserving the feasibility of the solution is likely to yield moves similar to hand-made transformations. In practice we have shown in [Benoist et al. 2011b] that this kind of generic moves preserving the feasibility of the solution can be designed for 0-1 mathematical programming, exploiting the structure of the model. In addition to basic "K-flip" moves which randomly flip the value of K (binary) decision variables, we can for instance associate moves to constrained sums of boolean variables: for such a sum, 11
interestingly IBM-ILOG first offered Constraint Programming as a framework where the user could implement his own tree search and even his own constraints, within a clean object-oriented design, but in the late 2000s they switched to a model&run paradigm with CP-Optimizer. 12 note that not all potentially feasible moves are likely to help the search: for instance a random swap of the cars on 8 positions will almost always deteriorate the objective function, whereas a mirror operation on the cars on 8 consecutive positions can be more powerful.
19
flipping two booleans in opposite directions preserves the value of this sum. More complex patterns can be exploited with ejections chains applied to the hypergraph induced by boolean variables and constraints. Roughly speaking they consist in flipping an initial binary variable and then iteratively repair the linear constraints violated by this modification, until finally closing the cycle (or not). We refer the reader to [Benoist et al. 2011b] for algorithmic details on these autonomous moves. To the best of our knowledge, the design of such autonomous moves, specialized for maintaining the feasibility of the solution during the move, is novel. They form the key component of LocalSolver. Indeed, they largely improve the effectiveness of the search (that is, the convergence toward high-quality solutions) on largescale structured combinatorial problems (as frequently encountered in OR applications), relatively to the classical k-Flips neighborhood search employed in SAT or Pseudo-Boolean solvers (Selman et al 1996; Walser et al 1998). The observed efficiency of this kind of moves, and more generally of LocalSolver, on combinatorial optimization problems calls for a generalization of this approach. Indeed following the densification principle introduced in section 2.2, new moves are constantly added to the pool of moves operated by the LocalSolver engine: ejection trees, moves escaping from local optima by crossing infeasible regions, etc. We even demonstrated that some very large scale neighborhoods can be automatically designed with an appropriate analysis of the structure of the model. More precisely we show in [Benoist 2010] that some matching based neighborhood can be automatically designed by searching for stable sets in a graph. Matching based neighborhood are exponential-size neighborhoods which can be explored in polynomial time thanks to bipartite matching algorithms. For instance in the car sequencing problem, [Estellon et al. 2006] noticed that selecting a set of K positions sufficiently distant one from another allowed optimally repositioning these K cars through the resolution of a transportation problem. The same principle applies for the Eternity II puzzle when repositioning a set of non adjacent tiles. We observed that, in presence of a bipartite structure, the possibility of such moves was linked to the existence of stable sets with respect to a notion of adjacency in the model. It allows an automatic design of such matching-based neighborhoods by searching for stable sets in a graph (and we proposed a convenient way to implicitly pre-compute billions of stable sets). Our experiments confirm that without prior knowledge on the structure of the problem, we achieve to explore the same neighborhood with the same efficiency, compared to a hand-made implementation of this large scale neighborhood for instance on the Eternity II puzzle. The above examples show that generic moves can be successfully designed for 01-programming, making it possible to solve large-scale non linear combinatorial problems in seconds, just by declaring a model and submitting it to a solver based on local search techniques (LocalSolver). Only decision variables need to take binary values in this context, while intermediate variables can take any integer and even decimal value. Consequently, the class of problems covered by this formalism is surprisingly large: assignment, partitioning, advanced planning and scheduling, packing, etc. For example LocalSolver 3.1 demonstrated its efficiency on the following benchmarks:
20
Routing problems: in 5 minutes on a laptop computer, LocalSolver obtains solutions which are one average within 3% of the known optimal solution for assymetric instances of the TSPLib13 [Reinelt 1991]. On vehicle routing instances (Solomon's benchmark14) the gap with the state of the art is 14%. Besides, rich routing problems can easily be modeled, for instance with timedependant distances. Quadratic assignment: on the QAPLib15 benchmark, the gap to best known solutions is 5% after 5 minutes of running time. The social golfer is another classical benchmark related to quadratic assignment: as detailed in [Benoist et al., 2011b] LocalSolver outperforms MIP solvers and CBLS solvers (Comet) on the CSPLib instances16. LocalSolver was also able to solve a practical quadratic assignment problem is the context of nuclear refueling [Lucas et al. 2013]. Machine reassignment: the Euro/Roadef/Google challenge 2012 consisted in reassigning processes to computers subject to capacity and inter-dependency constraints. A 100-line LocalSolver model ranked 24 in this context (among 82 competing team). It was the only model & run solver to qualify for the final stage of the competition. MIP LIB: the MIP Library17 is a set of mixed integer problems used for comparison between MIP solvers. Although these problems are not appropriately modeled for local search (see the next section on modeling principles), LocalSolver was able to obtain remarkably good solutions on some of the largest and difficult instances. Comparing the solutions obtained after 5 minutes on the same computer, with default settings, LocalSolver had significantly better solutions than the best commercial MIP solvers on nine instances (by a factor x1.6 to x20). See http://www.localsolver.com/news.html?id=32 for details.
In its latest version (4.0), LocalSolver is now able to handle continuous decision variables (see [Jeanjean, 2011] for a study on the efficiency of Local Search for mixed integer problems). This major enhancement now allows solving new families of problems in the field of energy production, supply chain management or facility layout for instance. To achieve this, new moves have been designed for handling these continuous variables and their interaction with discrete variables. Larger neighborhoods are introduced as well in particular for exploring linear sub problems. Another promising extension is the addition of collection structures (sets and lists). Indeed in the current representation a solution is the assignment of values to variables whereas, as pointed out in section 2.1, alternative representations can be worthwhile sometimes. For instance a route in a vehicle routing context can be seen as an ordered list of visited clients. With such a chained structure, classical moves like inserting or deleting a visit have their best complexity. Set structures are also a way of building very compact models. For instance the Google Roadef challenge 2012 can be modeled with integer decision variables giving for each process the index of its hosting machine, and set expressions collecting the set of processes assigned to a given machine. With a prototype version of LocalSolver, we could verify that 13
http://comopt.ifi.uni-heidelberg.de/software/TSPLIB95/ http://web.cba.neu.edu/~msolomon/problems.htm 15 http://www.seas.upenn.edu/qaplib/ 16 http://ianm.host.cs.st-andrews.ac.uk/CSPLib/prob/prob010/index.html 17 http://miplib.zib.de/ 14
21
this approach dramatically decreases the size of the model compared to a 0-1 model. On the largest instance of benchmark A, the required RAM memory falls from 850MB to 15MB. The challenge is that any extension of the formalism must be accompanied by an extension of the pool of generic moves, always keeping in mind our objective to perform moves preserving feasibility, similarly to what an engineer would design for the problem at stake.
3.4 LocalSolver modeling In the first part of this synthesis, we introduced Local Search principles as four steps: defining the model, defining the moves, devising efficient algorithms for performing this moves and finally exploring this search graph with a certain strategy (meta-heuristic). In this second part, we have considered these different components of a Local Search algorithm in reverse order and shown how they can be automated. In section 3.1 we explained that frameworks can be defined within which the user only has to implement the model and the neighborhoods (moves) with associated evaluation algorithms, then the exploration of this search graph can be done automatically. In section 3.2 we went one step further, automating the evaluation algorithms so that the user only has to declare its model and implement some moves. Finally we demonstrated in section 3.3 that a fully declarative approach is possible with the use of general-purpose moves analyzing and exploiting the structure of the optimization model. In this context, that we called Local Search Programming, the user only declare its model and delegates the actual resolution of this model to a solver (LocalSolver). In order to close the loop, the reader may expect us to conclude with an automated mechanism for translating what we called the specification model (section 1.1) into the operational model (section 1.2). In other words it would mean taking a "Garey-Johnson like" model and automatically transforming it into the best possible local search model. We have already explained in section 1.2 that, for Mixed Integer Programming, despite some attempts in this direction this goal cannot be considered as fulfilled and MIP modeling remains a crucial task for obtaining good solutions with a MIP approach. Similarly, even if LocalSolver preprocesses the model it receives in order to transform it into a better model, designing a good model remains very important. Preprocessing is made possible in LocalSolver by our model&run choice. Since the user fully delegates the resolution to the solver, the model actually solved can be slightly different from the input model. Since we do not have to keep the model open to the user during the search (what would be required if the user had to implement moves), we can partially rewrite the model in order to give it a more compact and more efficient form (merging sums, detecting constants terms, and so on). This analysis and rewriting of the model written by the user is a very important feature whose ultimate goal is to make sure that "bad models" are automatically turned into "good models". This is an ongoing work and each new release of LocalSolver brings significant improvements in this direction. Nevertheless, applying the modeling principles exposed in section 2.1 remains essential. Consequently we will conclude with a declination of these principles on LocalSolver models, what will also give a tangible view of the experience of practicing Local Search in a model and run fashion. In one line, a good Local Search model is based on the appropriate decision variables, subject to the right set of constraints, with a well-defined objective function. Since we have used the car sequencing problem as a continued example in this synthesis it is now interesting to see eventually how this problem is modeled in LocalSolver. 22
// 0-1 decisions: // X[c][p] = 1 if class c is at position p, and 0 otherwise X[c in 1..nbClasses][p in 1..nbPositions] 6404 [4 sec, 159242 itr]: obj = (0, 5, 441), mov = 319242, inf = 14.6%, acc = 18.5%, imp = 121 ------------> 5441 [5 sec, 202779 itr]: obj = (0, 4, 447), mov = 405317, inf = 13.8%, acc = 18.1%, imp = 129 ------------> 4447 [6 sec, 242765 itr]: obj = (0, 4, 447), mov = 485311, inf = 13.3%, acc = 17.9%, imp = 129 ------------> 4447 [7 sec, 277800 itr]: obj = (0, 4, 447), mov = 552609, inf = 12.8%, acc = 18%, imp = 242 ------------> 4447 [8 sec, 285872 itr]: obj = (0, 3, 475), mov = 601537, inf = 12.5%, acc = 18.2%, imp = 249 ------------> 3475 Phase 2: [8 sec, 315665 itr]: obj = (0, 3, 475), mov = 601537, inf = 12.5%, acc = 18.2%, imp = 249 ------------> 3475 [9 sec, 352635 itr]: obj = (0, 3, 217), mov = 674614, inf = 12.6%, acc = 17.3%, imp = 747 ------------> 3217 [10 sec, 396592 itr]: obj = (0, 3, 188), mov = 763147, inf = 12.6%, acc = 16.3%, imp = 805 ------------> 3188 [11 sec, 442716 itr]: obj = (0, 3, 173), mov = 855558, inf = 12.7%, acc = 15.5%, imp = 837 ------------> 3173 [12 sec, 487508 itr]: obj = (0, 3, 167), mov = 946007, inf = 12.9%, acc = 15%, imp = 850 ------------> 3167
24
…
Actually, all modeling principles introduced in section 1.3 about hand-made local search algorithms also apply to LocalSolver modeling because these principles govern the definition of the search space to be explored. Even if the exploration of this search space is fully automated, a well designed search space will be easier to explore with LocalSolver, exactly as a better polyhedra is easier to explore with a MIP solver. As we said the choice of the decision variables determines the form of the solutions. The choice of the constraints is important as well since it defines the perimeter within which the search will be performed (even if LocalSolver is able to temporarily visit infeasible regions). For instance turning some constraints into a first rank objective can be profitable sometimes. In particular it can help finding rapidly a solution satisfying all these "constraints". Finally the choice of the objective function determines the "slopes" in the search space: more plateaus can induce a better diversification of the search while a secondary objective can guide the search toward breakthrough solutions. We will not continue on with a local search modeling course but we will conclude with a single example illustrating some of these principles and give a view of the performance that LocalSolver can reach on large-scale non linear combinatorial problems. In a multi-color painting process, N sheets have to be painted with multiple colors in a certain order. We have a single painting machine, and we want to minimize the number of color changes. In other words we have N jobs, each job being a sequence of painting operations (each identified by its color). At each step the machine is able to process an unlimited number of painting operations of the same color (but it cannot process operation o of a job if operation o-1 was not already processed). The goal is to minimize the total number of steps required to process all operations of all jobs.
Job A
4
3
5
1
4
Job B
3
4
2
3
4
Job C
3
4
3
3
2
4
5
4
Figure 5 - Sample Input data for the Paint Shop Scheduling Problem
Here a valid modeling would be to consider a solution as an assignment of operations to painting steps (similarly to the assignment of vehicle to positions in the car sequencing problem). Then the main constraints would be: that operation o of job j cannot be assigned to step k if operation o-1 of the same job j is assigned to some earlier step k' | < scalar >< expression > | < operator > ([< arglist >]) | < expression >< comparator >< expression > < arglist > ::= < expression > [, < arglist >] < operator > ::= bool | and | or | xor | not | if | sum | booleansum | min | max | product divide | modulo | distance | abs | square < comparator > ::= < | | >= | = | !=
where < scalar > is a number and < identifier > a variable name. In summary, LocalSolver uses a functional syntax (only comparators are infixed), with no limitation on the nesting of expressions. Intermediate variables can be introduced as well with operator !=
arity 0 n n n 1 3 n n n n n 2 2 2 1 1 2 2 2 2 2 2
input boolean boolean boolean boolean mixed integer boolean integer integer integer integer integer integer integer integer integer integer integer integer integer integer
output boolean boolean boolean boolean boolean mixed integer integer integer integer integer integer integer integer integer integer boolean boolean boolean boolean boolean boolean
Introducing logical, arithmetic, or relational operators has two important benefits in a local-search context: expressiveness and efficiency. With such low-level operators, modeling is easier than with basic IP syntax, while remaining quickly assimilable by beginners (in particular, for engineers which are not comfortable with computer programming). Besides, the invariants induced by these operators can be exploited by the internal algorithms of the LS solver to speed up local search.
3.2 Constraints and objectives Any boolean expression can be made into a constraint by prefixing the line by constraint. An instantiation of decision variables is valid if and only if all constraints take value 1, coding for satisfied. When modeling a problem, practitioners should remember that local search is not suited for solving severely constrained problems: if some business constraints are not likely to be satisfied, it is recommended to define them in the objective function (as soft constraints) rather than as hard constraints. Moreover, LocalSolver offers a feature making this easy to do: lexicographic objectives. At least one objective must be defined, using the modifier minimize or maximize. Any expression can be used as objective. If several objectives are defined, they are interpreted as a lexicographic objective function. The lexicographic ordering is induced by the order in which objectives are declared. For instance in car sequencing with paint colors, when the goal is to minimize violations on ratio constraints and, as a second criterion, the number of paint color changes, the objective function can be directly specified as: minimize ratio violations; minimize color changes;. This features allows avoiding the classical modeling workaround where a big coefficient is used to simulate the lexicographic order: minimize 1000 ratio violations + color changes;.
6
The number of objectives is not limited and can have different directions (minimization or maximization).
4 Autonomous local search The command line for solving the above toy problem, granting 1 second of running time to LocalSolver 1.1 is: localsolver.exe io lsp=toy.lsp hr timelimit=1 io solution=toy.sol
Then, the printout on standard output should look like this: Parsing LSP file toy.lsp... 25 nodes, 6 booleans 3 constraints, 1 objectives 1 phases, 2 threads *** Initial feasible solution : obj = ( 9 ) *** Solve phase 1 over 1 Running phase for 1 sec and 4294967295 itr using descent * Thread 0 : [ 2 / 2 / 260000 ] moves in 0 sec, obj = ( 7 ) in 0 sec and 3 itr * Thread 1 : [ 3 / 4 / 260000 ] moves in 0 sec, obj = ( 7 ) in 0 sec and 5 itr *** Best solution : obj = ( 7 ) in 0 sec and 3 itr Writing solution in file toy.sol...
By default, LocalSolver 1.1 uses a standard descent (Aarts and Lenstra 1997) as search heuristic, with all available autonomous moves. A simulated annealing heuristic (Aarts and Lenstra 1997) is also available by specifying some options in command line. The chosen heuristic can be multi-threaded (by default, it is bi-threaded if possible). It consists in running several resolution instances with different seeds in parallel, synchronizing the results regularly, and returning the best solution found when the time limit is reached. Multi-threading shall not be seen as a way to speed up the search but rather as a way to increases the robustness of the solver. Autonomous moves are randomly chosen with a non uniform distribution; this distribution is dynamically tuned during the search in function of their accepting and improving rates. The cost of the initial feasible solution found by LocalSolver on this example is 9. This solution is found by a basic greedy randomized algorithm. As explained above, LocalSolver is not designed for solving hardly-constrained optimization problems. Thus, if no initial feasible solution is found by this greedy algorithm, then the user should consider turning one of the constraints into a first level objective function. By the way, this is a fundamental difference with CBLS approaches where a violation measure is defined for each constraint. We believe that such relaxations are the responsibility of the user. Typically, for frequency assignment problems the engineer can chose between assigning a frequency to each link while minimizing interferences or ensuring zero interferences while minimizing the number of unassigned links. The best solution, found by local search after 3 iterations (and 0 second) by thread 0, has cost 7. During the second of allocated time, LocalSolver has performed 260 000 iterations in each thread, which corresponds to the total number of moves attempted, and also to the number of solutions visited during the search. Among these moves, 4
7
have been committed on thread 1 while 3 have strictly improved the cost of the current solution. These statistics can be detailed by move what can be of interest for tuning the solver settings. Ultimately, it creates the file “toy.sol” with the solution: xA=0; yA=1; zA=1; xB=1; yB=0; zB=0;
x1 3m, vi=(0,…2,…0) where the only non-null entry is vi[i-3m+1]=2. • C’={v’1,v’2,…v’m} with: v’1=( 3w ,1,0,…0), v’m=( 3w ,0,…1) and ∀j∈[2,m-1], v’j=( 3w ,0…,1,1,….0), where the two consecutive “1” are at entries {j,j+1}. The size of this instance is polynomial with the size of the original 3-PARTITION instance since it involves the same w(xi) numbers paired with m-1 zeros, 2m-1 additional vectors (involving numbers 0,1 and 3w ) and m symbols.
Formworks Pairing Optimization 12
w(x1) ×
v1 =
v3m =
w(x3m) ×
…
w(x2) ×
….
v2 =
3w×
v3m+2 =
2×
+1×
…
2×
3w×
…
v3m+1 =
= v’1
+1×
3w× +1×
+1×
= v’m
Fig. 4. Transformation from 3-PARTITION to COMPATIBILITY
⇒: Assume C and C’ are compatible. ∀ k≥2, the compatibility string z must contain εkεk (vector v3m+k-1). Since only v’k-1 and v’k contain one εk, they must be neighbours in z that is to say that ψ must satisfy |ψ -1(k-1)-ψ -1(k)|=1. Thus ψ is either the identity or “ψ(j)=m+1-j” and z or its inverse equals ε
ε 22ε 13wε 32ε 13wε 42......ε 13wε m2ε 13w .
3w 1
Each
substring
ε13w covers
substrings z4k+1z4k+2z4k+3 of z such that vϕ(4k+1)[1]+vϕ(4k+2)[1]+vϕ(4k+3)[1]= 3w . Hence {(xϕ(4k+1), xϕ(4k+2), xϕ(4k+3)) | k ∈ [0,m]} is a 3-partition of set X. ⇐: Assume reciprocally that there exists a collection {X’1 … X’m} of subsets of X, each of weight 3w (and of cardinality 3) and define a permutation ϕ on [1,4m-1] such that: • ∀ j ∈ [1,m], ∀ i ∈ [4(j-1)+1, 4(j-1)+3] xϕ(i) ∈X’j • ∀ j ∈ [1,m-1] ϕ(4j) = 3m + j String
z =ε
ε 22ε
3w 1
ε 32ε
3w 1
ε 42......ε
3w 1
ε ε
3w 2 m 1
3w 1
, with permutations ϕ and
ψ=identity proves the compatibility of C and C’. Finally 3-PARTITION can be polynomially transformed into COMPATIBILITY, thus COMPATIBILITY is NP-hard in the strong sense. A polynomial specific case of COMPATIBILITY is given in appendix as well as an NP membership proof (since the size of compatibility string z is not polynomial with the instance size, a more compact certificate of compatibility must be exhibited). We refer the reader to [2] for a more detailed study of this problem. Finally, trying to extend solutions of R(FPP) to solutions of the FPP would require solving N NP-hard COMPATIBILITY problems subject to coupling constraints (for each edge w1→w2, sequences chosen for walls w1 and w2 must induce identical orders on formworks of this edge). This difficulty advocates for the design of heuristic approaches to the FPP (Section 6), possibly using solutions of R(FPP) as an oracle.
Formworks Pairing Optimization 13
6. Greedy Algorithm and Tabu Search for the FPP A naive greedy algorithm consists in arbitrary ordering formworks on first day walls, then using the biggest possible formwork chain from one of these walls for a second day wall, then the second biggest, etc… Applying such a strategy (GreedyFPP) on a construction site means re-using each day the biggest possible formwork assemblies and randomly dispatching the remaining (without studying what ordering would be preferable for next days): it approximately divides the number of junctions by two, compared to moving shutterings one by one (1by1FPP). This section describes a Tabu approach inspired from [9]. It is based on a compact model focused on parallel edges. These pairings are inserted one by one into a pairing set (Section 6.1), ejecting conflicting ones if any (Section 6.3). A Tabu algorithm controls this insertion/ejection heuristic (Section 6.2). 6.1. Pairing model We define a pairing γ as a triplet of P×[1,K]×[1,K] (cf. equation (3)). A pairing γ={(w1,p1)→(w2,p2),k,k’} models a triplet of constraints {Y(w1,p1)→(w2,p2)=1, X(k)(w1,p1)→(w2,p2)=1, X(k’)(w1,p1+1)→(w2,p2+1)=1}. Such a pairing represents a pair of formworks moved together. It constrains nodes (w1,p1) and (w2,p2) to be crossed by commodity k, and nodes (w1,p1+1) and (w2,p2+1) to be crossed by commodity k’. It is said to overlap another pairing γ’ if w1=w’1, w2=w’2, p1+1=p’1 and p2+1=p’2 that is to say that γ,γ’ form a triplet of formworks moved together. Finally we note Eγ={(w1,p1)→(w2,p2), (w1,p1+1)→(w2,p2+1)}. A pairings set Γ is consistent if and only if it satisfies the following four constraints: i. All pairings constraining the same node (w,p) must constrain it to be crossed by the same commodity, because only one formwork can be the pth on wall w. ii. Non-overlapping pairs (γ, γ’) ∈ Γ² must satisfy: wi≠w’i ∨ |pi-p’i|≥2, ∀ i∈{1,2}. Indeed if γ and γ’ share a formwork at their origin for instance, they must move this shared item to the same position i.e. they must overlap. iii. For all wall w, ∀ k ≤ K, the number of positions constrained to be crossed by commodity k must be smaller than aw[k], otherwise the allocated number of formworks of family k would be exceeded on wall w. iv. For each day and each formwork family, the allocations aw[k] of this day, plus the number of formworks of type k waiting on previous walls to be re-used on next days cannot exceed available quantities A[k]: ∀t ≤ T , ∀k ≤ K ,
∑a
w∈Wt
w [k ] +
∑
( w1 , p1 ) →( w2 , p2 )∈ Eγ γ ∈Γ
∪
d ( w1 ) < t ∧ d ( w2 ) >t
X
(k ) ( w1 , p1 )→ ( w2 , p2 )
≤ A[k ]
(21)
In terms of the FPP multi-flow, constraint iv (21) makes sure that the flow crossing each layer (either through nodes or arcs) never exceeds capacities A[k], k≤K. Proposition 4. There is a surjection from the set of FPP solutions to the set of all consistent sets of pairings, mapping each FPP solution of cost c to a consistent set of size Σ|aw|-N-c.
Formworks Pairing Optimization 14
Proof. From any FPP solution, reading the corresponding pairing set is straightforward; its size is exactly the number of saved junctions Σy. And for any consistent pairing set of size s, a flow satisfying the 3s constraints modeled by these s triplets is easy to find, assigning to each unconstrained node-position (from left to right) available commodities from previous nodes, equation (21) avoiding starvation. The cost of this FPP solution is at most Σ|aw|-N-s. The advantage of this pairing model is to focus on the important part of the problem (parallel arcs), breaking a lot of symetries. Besides, in a local search approach, it means that any consistent set is a feasible solution that can be locally modified adding or removing pairings. 6.2. Insertion/Ejection Tabu search In [9] radio links are inserted in the frequency range and interfering links are ejected and added to the Tabu list. Similarly we start with Γ=∅ and insert pairings one by one, conflicting ones being ejected and added to the Tabu list. More precisely, each move consists in selecting a (non-tabu) pairing γ to insert, and removing an ejection set Sγ ⊆ Γ from Γ∪{γ} such that Γ∪{γ}\Sγ is consistent. The computation of a (nearly) minimum-cardinality ejection set is detailed in section 6.3. We compared two version of this Tabu search. The first one (denoted TabuFPP) uses an heuristic inspired from the greedy algorithm to add non-conflicting parings. Once no more pairing can be added without conflict (local optimum), we randomly generate a bunch of pairings and insert the one whose associated ejection set has minimum size. The second approach (denoted GuidedTabuFPP) is a variant using R(FPP) as an oracle: pairings are inserted accordingly to the optimal solution of this multiflow relaxation. More precisely, if X(k)w1→ w2 items of type k are transported from wall w1 to w2 in the R(FPP) solution, this number is taken as an upper bound in the tabu search: any candidate pairing whose insertion would make this bound exceeded is considered as conflicting. The results of this algorithms are discussed in section 7. 6.3. Ejection Set computation Adding a pairing γ to a consistent set Γ may lead to an inconsistent set. We consider here the problem of computing a minimum-cardinality ejection set Sγ⊆Γ such that Γ∪{γ}\Sγ is consistent. Such a set exists for any pairing γ such that {γ} is consistent, since Γ is always a valid ejection set. Physical constraints i and ii require to eject the corresponding conflicting pairings. On the contrary there are several ways to solve conflicts associated to cumulative constraints iii and iv (equation (21)). Any pairing γ causes at most 4 covering conflicts (constraint iii) and 2×(start(w2)-end(w1)) availability conflicts (constraint iv). A covering conflict occurs on a wall w when too many positions are constrained to be covered by a formwork of family k: thus one or two positions must be freed, removing the (at most 4) pairings constraining it. Similarly an availability conflict occurs for a day t and a family k when too many formworks of this family are planned to be moved from a previous wall to a future one (thus unavailable on day t): one or two of these shutterings must be made available on day t, removing the (at most 2)
Formworks Pairing Optimization 15
corresponding pairings. We solve this problem with a (sub optimal) greedy algorithm removing the pairing subset solving the maximum number of conflicts (lookahead), and repeating this step until all conflicts are solved.
7. Computational results The following table lists the results obtained on 16 FPP instances (available at http://e-lab.bouygues.com) where A0 is the 10-wall example of Fig. 2 and others are real instances of Bouygues Habitat, involving an average of 100 walls. The three rightmost columns give the three lower bounds computed on the relaxation R(FPP) of section 4: the continuous optimum of the LP model (with and without Xpress automatically generated cuts) and its optimal integer solution obtained by our RDS strategy (in less than 10 minutes as pointed out in Section 4.4). The left columns correspond to the four resolution algorithms tested: 1by1FPP, GreedyFPP, TabuFPP and GuidedTabuFPP. Less that 1 second CPU is required by 1by1FPP and GreedyFPP. As for the local search approaches, both were stopped after 10000 moves i.e. around 5 minutes. Table 1. Computational results Data Problem A0 A1 B0 B3 B4 B5 B6 B9 C1 C2 C3 C4 C5 C6 C7 C9
Days 5 10 10 8 6 8 26 26 11 19 8 7 8 25 19 26
Walls 10 76 76 80 27 79 154 125 69 143 80 45 79 153 143 125
Families 6 7 21 9 9 9 9 9 9 18 9 21 9 8 18 9
Upper Bounds (solutions) Guided 1by1FPP GreedyFPP TabuFPP TabuFPP 25 17 14 14 174 91 78 76 209 114 94 91 145 86 76 75 48 35 31 31 128 72 66 66 123 73 61 60 60 37 33 33 124 69 63 63 152 68 63 61 151 84 73 73 45 33 28 28 131 74 67 67 259 129 120 116 171 80 64 64 89 50 42 41
RDS 14 74 87 73 31 66 60 33 63 56 68 28 66 1116 59 41
Lower Bounds LP with Cuts 14 72 85 72 31 65 60 33 63 55 67 28 65 110 59 41
LP 14 69 81 70 31 64 58 31 61 52 65 28 64 106 56 39
These results prove that the natural greedy approach to the (NP-hard) FORMWORK PAIRING problem (GreedyFPP) is far from being optimal: the proposed TabuFPP based on a compact model of the problem produces significantly better solutions. Besides, solving a multiflow relaxation of the problem with a Russian-Dolls strategy provides lower bounds that establish the optimality of the TabuFPP solution on 6 of the 16 instances. Finally, when using an optimal solution of this relaxation as a guide to our tabu search (GuidedTabuFPP), two other instances are optimally solved and 5 solutions are improved. In summary 8 instances remain open with gaps ranking from 1.5% to 9%. 6
On C6, our RDS scheme was not sufficient to reach the optimum of the relaxation: 111 is merely a lower bound.
Formworks Pairing Optimization 16
8. Conclusion In this paper we have introduced the FORMWORK PAIRING PROBLEM, arising in construction sites. We have proven its strong NP-hardness and designed a Tabu algorithm producing good solutions. Solving an adequate relaxation with an innovative “Russian Dolls” approach, we obtained both a lower bound and an oracle. This oracle proved to be useful as a guide for the Tabu algorithm, and the lower bound proved the optimality of 50% of our solutions. Compared to the greedy approach, our best Tabu algorithm saves an average of 14% of the number of junctions to be performed. From an industrial point of view it means that the corresponding labor cost can be decreased by 14% through formwork pairing optimization.
Acknowledgement The author is grateful to Fabrice Chauvet for his precious help on complexity proofs.
References [1] J. Agnèse, N. Bataille, E. Bensana, D. Blumstein and G. Verfaillie. Exact and Approximate methods for the Daily Management of an Earth Observation Satellite. In Proc. of the 5th ESA Workshop on Artificial Intelligence and Knowledge Based Systems for Space 1995. [2] T. Benoist and F. Chauvet: Complexity of some FPP related Problems. E-lab Technical Report, 2001. [3] Y. Caseau and F. Laburthe. Improved CLP Scheduling with Task Intervals. In Proc. of the 11th International Conference on Logic Programming, MIT Press, 1994 [4] M.R. Garey and D.S. Johnson: Complexity results for multiprocessor scheduling under resource constraints. SIAM J. Comput. 4, 397-411, 1975. [5] M.R. Garey and D.S. Johnson: Computers and intractability, a guide to the theory of NP-completeness. New York: W. H. Freeman, 1979. [6] Z. Gu, G. L. Nemhauser, and M. W. P. Savelsbergh. Lifted flow cover inequalities for mixed 0-1 integer programs. Vol. 85/3, pp 439-467 Mathematical Programming, 1999. [7] G. L. Nemhauser and L. A. Wolsey. Integer and Combinatorial Optimization. John Wiley & Sons, 1988. Wiley Interscience Series in Discrete Mathematics and Optimization. [8] G. Verfaillie, M. Lemaître, and T. Schiex. Russian Doll Search for Solving Constraint Optimization Problems. In Proc. of AAAI-96, pages 181--187, Portland, OR, 1996. [9] M. Vasquez. Challenge Roadef 2001. In Francoro III, Quebec 2001, to appear in EJOR.
Appendix: Properties of the COMPATIBILITY Problem When there is at most one occurrence of each symbol in the researched string z, one can reformulate the question as follows: naming X the set of symbols appearing in z, is it possible to order symbols of X such that each element (subsets of X) of C∪C’ appears in a consecutive block? Let G be a bipartite graph defined as follow: left vertices represent elements (subsets of X) of collection C, right vertices represent elements of collection C’, and for each pair (c,c’) ∈ C×C’ the corresponding edge is added in G if and only if these subsets intersect without one being included in the other i.e. (c∩c’≠∅)∧(c⊄c’)∧(c’⊄c) Proposition 5. C and C’ are compatible if and only if G contains no node of degree greater or equal to 3 and no cycle. Proof. See [2] (arcs in G represent neighbours in the compatibility string z, hence only degrees 1 and 2 are allowed and cycles are forbidden).
Formworks Pairing Optimization 17 Finally (in this “all different” case) the compatibility question can be decided computing 0(mn) intersections of subsets (c ∩ c’). This polynomial case of COMPATIBILITY can be used to prove its membership to NP. Given C and C’, two compatible vectors, let M be a 3-dimensional matrix such that ∀ i ≤ n, ∀ j ≤ m, ∀ k ≤ K, M[i,j,k] is the number of εk shared by vi and v’j on string z. Such a matrix describes the dispatching of “symbols sets” of C into “symbol sets” of C’ and is valid if and only if M abides:
∀i≤n, ∑M[i, j] = vi j ≤m
and
∀j≤m, ∑M[i, j] = v' j
(22)
i≤n
Proposition 6. Matrix M is a polynomial size compatibility certificate whose validity can be checked in polynomial time. Proof. See [2] (M proves the compatibility of C and C’ when the bipartite graph linking vertices i≤n and j≤m such that (M[i,j]≠0)∧(M[i,j]≠vi)∧(M[i,j] ≠ vj) contains no cycle and no node of degree ≥ 3). Finally, we conclude that COMPATIBILITY belongs to NP.
Soft Car Sequencing With Colors: Properties and Algorithms Thierry Benoist Bouygues e-lab, 1 av. Eugène Freyssinet, 78061 St Quentin en Yvelines Cedex, France
[email protected]
Abstract. This paper is a study of the car sequencing problem, when feature spacing constraints are soft and colors of vehicles are taken into account. Both optimal algorithms and lower bounds are presented for parts of the problem or family of instances. With this set of lower bounds, we establish the optimality (up to the first non trivial criteria) of 54% of best known solutions for the benchmark used for the Roadef Challenge 2005. We also prove that determining the feasibility of a car sequencing instance limited to a pair of simple ratio constraints can be achieved by dynamic programming. Finally, we propose a solving algorithm exploiting these results within a local search approach. To achieve this goal, a new meta-heuristic (star-relinking) is introduced, designed for the optimization of an aggregation of criteria, when the optimization of each single criterion is a polynomial problem.
1. Introduction Car sequencing is a well known combinatorial optimization problem, faced by car manufacturers. It consists in ordering cars on the production line, according to features spacing constraints of the form “never more that 2 sunroofs in any sequence of 5 vehicles”. These constraints model the necessity for cars requiring special operations to be evenly distributed along the line. In its standard1 form it is a decision problem, whose NP-completeness is proven in (Gent 1998). Since cars are produced on demand, the set of vehicle for a day cannot necessarily satisfy those feature spacing constraints. However, cars have to be built even when the corresponding combinatorial problem is infeasible. Indeed minimizing constraints violations means minimizing bottlenecks or minimizing the size of the mobile team (polyvalent workers able to work on different assembly stations). That is the reason why results on infeasible problems are often reported as a number of constraint violations. In this paper we evaluate solutions with a finer penalty function designed by the French automobile manufacturer Renault2: on each constraint window, each supernumerary feature yields one penalty point. Besides, high priority and low priority constraints are distinguished. 1 2
Problem #1 of the CSP lib: http://www.cse.unsw.edu.au/~tw/csplib/prob/prob001/index.html http://www.prism.uvsq.fr/~vdc/ROADEF/CHALLENGES/2005/
Challenge Roadef 2 The second novelty of this problem is that it takes into account the color of each vehicle. Indeed the paint shop is a very special station in the production line, with specific requirements. First, the paint shop has to minimize the consumption of paint solvent. The paint solvent is used to wash spray guns each time the paint color is changed between two consecutive scheduled vehicles, therefore the minimization of color changes is another optimization criteria. On the other hand, long sequences of cars of the same color tend to make visual quality controls inaccurate, thus an upper limit is defined on the length of these color batches. This Soft Car Sequencing Problem with Colors, combining paint changes minimization and two levels of feature spacing constraints, in an instance-dependant lexicographic order, was proposed by Renault to the OR community for the ROADEF Challenge 2005. This paper proposes an analysis of this problem, defined in section 2, describing optimal algorithms for special cases (section 3) and lower bounds adapted to each family of instances (section 4). In order to take advantage of polynomial algorithms of section 3, we also present a new meta-heuristic (named star-relinking), designed for the optimization of an aggregation of criteria, when the optimization of each single criterion is a polynomial problem. This meta-heuristic is introduced and applied to this car sequencing problem in section 5.
2. Problem definition 2.1. Data and constraints An instance of the SCSPC (Soft Car Sequencing Problem with Colors) is defined by3: • C, the number of colors • B, the “batch limit” • R the number of ratio constraints, with H ⊂ R the subset of high-level ratios. • E the number of relevant vehicles of the previous day • T the number of cars to be produced on the considered day • ∀ j ∈[0,R-1] two integers Nj and Pj with Pj > Nj > 0 • ∀ i ∈[-E, T-1], ci∈[0,C-1] is the color of car i and fi is a bitvector of length R (vector of features of car i). • A permutation of triplet (paint, high, low) where high is necessarily before low. A solution of the problem is a permutation σ of [0, T-1] such that, among cars from position 0 to T-1, the longest sequence of cars of identical color is smaller or equal to B. This batch constraint is the only imperative constraint of the problem. The objective of the problem is to find a permutation σ of minimum valuation. This valuation function is defined in the next section.
3
In the whole paper, notation [a,b] refers to a closed interval of integers (finite set)
Challenge Roadef 3 2.2. Valuation function Let ϕt be the vector of features of the vehicle in position t in permutation σ, and γt its color (for convenience these values are defined for any integer t):
ϕt = { fσ −1 ( t ) if t ∈[0,T-1], ft if t ∈[-E+1,-1], 0 otherwise}
(1)
γt = { cσ −1 ( t ) if t ∈[0,T-1], ct if t ∈[-E+1,-1], 0 otherwise}
(2)
When the considered ratio constraint is non ambiguous (say j) we will use notation
Φt when referring to ϕt[j].
Paint changes are defined as positions t ∈[0,T-1] such that the color of car in position t is different from the color of the car in position t (that is to say γt-1≠γt). The number of such positions in [0,T-1] is the color valuation Ωpaint. Violation penalties aim at measuring the violation of each ratio constraint Nj/Pj. For all w in [-Pj+1,T-1] we considerer window [w, w+Pj-1] and count the number of vehicle with option j in this window: each supernumerary vehicle (with respect to Nj) costs one point. In other words ratio valuations Ωhigh (penalties on high level constraints) and Ωlow (penalties on low level constraints) are defined as follows.
Ωhigh=
∑ω j∈H
j
, Ωlow=
∑ω j∉H
j
with
T −1
∑
ωj =
w = − P j +1
w + P j −1
max(0,
∑ϕ [ j ] − N t =w
t
j
)
(3)
The valuation function is a triplet (Ωpaint, Ωhigh, Ωlow) that should be minimized with respect to the lexicographical ordering defined by the given permutation of (paint, high, low). Notations: a car featuring option j (fi[j] = 1) will be called a j-car, and a car without option j (fi[j] = 0) will be called a j-blank. Besides a set of T cars including Q jcars (and T – Q j-blanks) will be denoted by (Q,T)j.
3. Polynomial sub-problems 3.1. The uncolored single ratio problem Let us consider the case of a problem restricted to a single ratio constraint Nj /Pj (R=1, C=1, B=T). We denote by Q the total number of cars featuring this option (Q = ∑i≥0 fi[0]). Any vector Φ of length T and weight Q (∑Φt=Q) is a valid solution. t + P −1 We define Yt = ∑ φi and Z t = max(0, Yt − N ) (counter and penalty, respectively). i =t
Property 1 : If Q>0 and (Q=T or
∑
−1 i = − P +1 i
φ < N ) then there is some optimal so-
lution such that : Φ0=1. Proof : The case Q=T is trivially true, so we will focus on the case Q < T. Let Φ be an optimal solution with Φ0=0. We have Y-P+1 < N. Let t1=min{t | t > 0 ∧ Φt=1} (exists since Q > 0). Since Y-P+1 < N and Φt=0 ∀ t ∈[0, t1-1], we have Yt1-P < N. Let Φ’
Challenge Roadef 4 be the solution which differs only from Φ by Φ’t1-1=1 and Φ’t1=0. This solution abides: Y’t1-P ≤ N (no penalty) and Y’t1=Yt1-1 (no other window is modified). Therefore the valuation of Φ’ is smaller or equal to that of Φ, that is to say that Φ’ is optimal too. Repeating this operation until Φ0=1 proves the property. ■ Property 2 : If Q=0 or (Q < T and ∑−1 φi ≥ N ) then there is some optimal solui = − P +1 tion such that : Φ0=0. Proof : The case Q=0 is trivially true, so we will focus on the case Q > 0. Let Φ be an optimal solution with Φ0=1. We have Y-P+1 > N hence Z-P+1>0. Let t1 = min{t | t > 0 ∧ Φt = 0} (exists since Q < T). Since Y-P+1 > N and Φt=1 ∀ t ∈[0,t1-1], we have Yt1-P > N. Let Φ’ be the solution which differs only from Φ by Φ’t1-1=0 and Φ’t1=1. This solution abides Y’t1-P = Yt1-P -1 and Y’t1=Yt1+1 (no other window is modified). Since Yt1-P > N, this swap decreases penalty associated to window [t1-P, t1-1] by one. On the other hand, the increase of the penalty associated to window [t1, t1+P-1] cannot exceed one. Therefore the valuation of Φ’ is smaller or equal to that of Φ, that is to say that Φ’ is optimal too. Repeating this operation until Φ0=0 proves the property. ■ The conclusion of these properties is that, when not trivially determined by Q = 0 or Q = T, an optimal choice for Φ0 is “1 if ∑−1 φi < N , and 0 otherwise”. Applyi =− P +1
ing this rule from left to right yields an optimal algorithm running in linear time. An interesting property of this algorithm is that as soon as a saturated pattern (Yt=N) is built, it will be repeated while possible4. This number of repetitions can be computed in O(1). Then an empty (Q = 0) or full (Q = T) state is reached in less than P iterations, and remaining penalties can be computed in O(1) in both cases. Finally the complexity of this improved algorithm is O(P). The special case E = 0, namely the no-trail case has remarkable properties. 1. A lower bound of ωj can be obtained by ignoring the max(0,x) operator in equation (3), and restricting the sum to indices w ∈[ N-P+1,T-N-1] (since no penalty can occur in windows with less than N+1 position included in [0,T-1]). Each Φt belongs to P windows unless t < N or t≥ T-N : in these cases Φt belongs to P-(N-t) windows or P-(N-(T-1-t)), respectively. Therefore the double sum ∑w∑tΦt in equation (3) admits PQ – N(N+1) as a lower bound. Since there are T+P-2N-1 terms in this sum, we conclude that PQ - N(N+1) - N(T+P-2N-1) is a lower bound for ωj, whose simplest expression is PQ – NT - N(P-N). 2. An exact analytical formula5 for ωj when E=0 can be is given (see. appendix). 3. The “no-penalty thresholds” have simple formulas:
Proof: if Yt=N we have: if φt=1 the rule enforces φt+P=1 (unless impossible) and if φt=0 the rule enforces φt+P=0 (unless impossible). 5 That is to say that the no-trail case can be solved in O(1) 4
Challenge Roadef 5 • Qmax(T) = max{Q | ωj = 0} = xN + min(N,T - xP) with x = T/P • Tmin(Q) = min{T | ωj = 0} = xP + Q – xN with x = Q/N –1 4. The optimal arrangement of a set (Q,T)j of cars, obtained with our algorithm is called the normal form for this set. 3.2. The paint changes minimization problem Minimizing the number of paint changes in absence of ratio constraint (R=0) is also a polynomial problem. With qc the number of cars with color c, sc = qc / B is a lower bound of the number of c strips6. Let c0 be one of the colors with max number of strips cardinality (∀ c sc ≤ sc0), and c-1= γ-1 (with γ defined in equation (2)). We choose c0 = c-1 if possible. In what follows we suppose that qc-1>0 (extension to the qc-1 = 0 case is straightforward). Two cases must be distinguished, depending on the value of ∑0 = ∑c≠c0 sc. • First case ∑0 ≥ sc0 : o Since a color change occurs just before each strip but the first one (provided that we chose color c-1 for the first one), a lower bound of the number of paint changes is ∑csc – 1. o This lower bound can be reached as follows. We insert one c-1 strip first, and one c0 strip just after (if c0 ≠ c-1). Then we have sc0 – 1 chinks between c0 strips. Since ∑0 ≥ sc0 enough other strips are available to fill these chinks. Besides since ∀ c sc ≤ sc0, we can avoid inserting two strips of identical colors in a single chink (when sc=sc0, one c strip can be inserted after the last c0 strip). •Second case ∑0 < sc0 : o Two color changes occurs around each c0 strip but the last one (and the first one if c0 = c-1). Therefore a lower bound of the number of paint changes is 2sc0 – 2 if c0 = c-1 and 2sc0 – 1 otherwise. o This lower bound can be reached as follows. We start and end with a c0 strip. We have sc0 – 1 chinks between these c0 strips. Since sc0 -1 ≥ ∑0, these chinks can be filled using a single color per chink provided that ∑c≠c0 qc ≥ sc0 – 1 (otherwise the problem is infeasible). When qc-1 = 0, the optimum is ∑csc in the first case and 2sc0 – 1 in the second case. Finally both feasibility and minimum number of paint changes can be determined in O(C).
4. Lower bounds In the benchmark provided by Renault, made of real world instances7 issued of various factories, three families of instances are defined. Here are the (slightly different) categories that we use: 1. PAINT instances are those whose first optimization criteria is the minimization of color changes 6 7
A “c strip” denotes a strip of color c, namely a sequence of cars of color c Involving up to 1500 vehicles and 26 ratio constraints (averages are 760 and 11 respectively)
Challenge Roadef 6 2. 3.
EASY instances are those whose best known solution satisfies all ratio constraints (zero penalty) whose importance is greater than color changes minimization Other instances are said to be HARD
In the following sections, each case is considered separately; lower bounds are presented and compared with best known solutions. 4.1. Paint first, ratios second When the first optimization criterion is paint changes minimization, better lower bounds that those of section 3.1 can be obtained for penalties attached to each ratio constraint. Indeed the known optimality of Ωpaint provides upper bounds on the number of strips of each color: in most cases (when ∑c≠c0 sc ≥ sc0) these upper bounds τc equal lower bounds sc = qc / B exposed in section 3.2. Then considering penalties within strips of a color can be judicious since features are not evenly dispatched among colors, what can make penalties unavoidable even for features whose global density is low. The client behavior can cause correlations between features and colors: expensive colors may be more frequent on cars with expensive features. Besides, some colors are only available for certain types of cars. A first lower bound can be derived from lower bound PQ – NT - N(P-N) defined in section 3.1. Let qc be the number of cars of color c and qcj be the number of such vehicles featuring option j. If these qc cars are split into τc strips this lower bound would apply to each of these strips and the sum of these terms is a lower bound of ωjc (the penalty for ratio constraint j within strips of color c). Finally we have ωjc ≥ Pqcj - Nqc - τc N(P-N). The following property can be used to take into account the trailing sequence, what is very important when using these bound as a guide for a greedy algorithm for instance, evaluating the consequences of the choice of the next color. Property 3 : When no batch limit is set, let (Q1,T1)j … (Qτ,Tτ)j be a dispatch of cars of color c into τ strips (∑Qi= qcj and ∑Ti= qc), minimizing penalties for ratio j within strips of color c, including penalties caused by inserting (Q1,T1) just after the trailing sequence. Then there is a sequence of equal cost such that ∀ i ≥ 2 (Qi,Ti)j=(x,x)j with x ≤ N. Proof. Each strip (x,y)j with x ≤ N can be turned into an (x,x)j pair just by moving all j-blanks from this strip to the first one. Otherwise, supposing (without loss of generality) that (x,y) is arranged in normal form (cf. section 3.1), then the whole sequence following the starting N consecutive jcars can be moved as is at the end of the first strip without adding a single penalty: • if y–x ≥ P–N, then this displaced sequence starts with P-N j-blanks and no penalty can occur on overlapping windows to the left of this sequence. • if y–x < P–N, then each displaced j-car cannot belong to a greater number of saturated windows in its new position. Indeed, with i' the start of the (x,y) strip and i" the position of the first displaced j-car: all windows starting before i' and including i" are saturated in their original position, and
Challenge Roadef 7 windows starting after i' cannot become saturated if they are not in their original position (since (x,y) starts with N consecutive j-cars). All cases are covered, hence the property is proven. ■ Therefore, if c is chosen as the next color we know that ωjc will be greater than the minimum cost of inserting qcj–(τc–1)N j-cars in a strip of length qc– (τc–1)N, just after the current trailing sequence. Another way of improving our lower bound is to take into account the trailing limit. It can be done solving the following MIP. Note that this last lower bound is computed in around one second for a problem and thus can only be used “offline” as opposed to previous formulas that can be computed during a branch and bound or greedy search. τc
Minimize
∑ PQ − NT − N ( P − N ) i
(4)
i
i =1
Subject to
∀i, 0 ≤ Qi ≤ Ti ≤ B τc
∑Q
i
= qcj
i =1
τc
∑T = q i
(5)
c
i =1
with Qi and Ti non negative integers The following table compares obtained lower bounds (each computed in less than one second) with best known results. For each instance the first letter A, B or X denotes the test set it belongs to in the considered benchmark8. The min number of paint changes (PCC) is only reported for information since its optimality is known (cf. section 3.2). Therefore the “first non trivial criterion” is the penalty associated to highpriority ratio constraints (HPRC): the average gap9 on this criterion is 3.7% with 50% of optimality proofs. Note that solving the above MIP improved the bound on 6 instances and that a “color-unaware” application of bounds of section 3.1 yields an average gap of 85%. The gap attached to low-priority ratio constraints is only reported when optimality on HPRC is proven.
A/022 A/039 A/064 A/064 B/022 B/023 B/024 B/025 8 9
instance 3 4 RAF EP ENP 38 4 RAF EP ch1 38 2 RAF EP ENP ch1 38 2 RAF EP ENP ch2 RAF EP ENP S22 J1 RAF EP ENP S23 J3 V2 RAF EP ENP S22 J1 RAF EP ENP S22 J3
Best known solution Lower bound PCC HPRC LPRC HPRC LPRC
11 68 63 27 13 50 132 126
1 39 0 155 423 782 52 367 22 148 31 1327 2022 1158 122 5589
39 131 413 367 22 1264 1817 122
Gaps HPRC
1 0.0% 0 15.5% 725 2.4% 49 0.0% 146 0.0% 15 4.7% 823 10.1% 5512 0.0%
Available at http://www.prism.uvsq.fr/~vdc/ROADEF/CHALLENGES/2005/ Gaps are computed as (Bestknown – lowerbound)/bestknown
LPRC
0.0% 5.8% 1.4%
Challenge Roadef 8 B/028 B/028 B/029 B/035 B/035 B/039 B/039 B/048 B/048 B/064 B/064 X/022 X/035 X/035
ch1 RAF EP ENP ch2 RAF EP ENP RAF EP ENP S21 ch1 RAF EP ENP ch2 RAF EP ENP ch1 RAF EP ENP ch3 RAF EP ENP ch1 RAF EP ENP ch2 RAF EP ENP ch1 RAF EP ENP ch2 RAF EP ENP RAF EP ENP S49 CH1 RAF EP S50 CH2 RAF EP S50
S22 S23 J6 S22 S22 S22 S22 S22 S22 S22 S22 J2 J4 J4
J2 J3 J3 J3 J4 J4 J3 J3 J3 J4
38 4 52 6 7 55 59 64 58 62 31 12 5 6
98 188 71 0 709 2171 90 156 651 671 96 45 214 671 115 670 282 1180 95 288 52 178 3 2 0 10 0 56
85 0 707 146 550 45 214 115 279 84 52 2 10 56
177 13.3% 70 0.0% 1.4% 2150 0.3% 84 6.4% 450 15.5% 83 0.0% 13.5% 663 0.0% 1.2% 643 0.0% 1170 1.1% 266 11.6% 178 0.0% 0.0% 3 0.0% 0.0% 0 0.0% 0 0.0%
Table 1. Lower bounds for PAINT instances
4.2. “Easy” ratios first, paint second For EASY instances the optimization of Ωpaint amounts to minimizing the number of paint changes with ratios10 considered as hard constraints. It is the opposite situation to that studied in section 4.1. This section describes lower bounds of Ωpaint in this case, based on improvements of the computation of the minimum number or strips of each color. For each color c and for each ratio constraints j we can consider the minimum number of strips of color c consistent with the no penalty constraint ωj = 0. The linear bound presented in section 4.1 reads ωj ≥ ωjc ≥ PQcj – NTc -τcN(P-N) and ωj = 0 requires τc ≥ (PQcj – NTc) / N(P-N). This first bound does not take into account the batch limit B, whereas it can have an important impact. For instance we have not only τc ≥ Tc / B but also τc ≥ Qcj / Qmax(B), since at most Qmax(B) j-cars can fit in each strip. Finally the exact τcmin can be computed as follows. Without loss of generality we can suppose that each strip will be in normal form (alternate sequence of blocks of j-cars separated by P-N consecutive j-blanks). Consequently the maximum number of j-cars that can fit in τc strips only depends on the number of available blank blocks X = (Tc-Qcj) / (P-N). In each strip, N j-cars can fit without any j-blank block11; any additional block (up to β = (B-N) / P) allows N additional j-cars; if a last additional block can be added, it allows α additional j-cars with α = max(0,B – (N + β P - (P-N)). Note that if no last additional block can be added then α=0. Finally the minimum possible τc must satisfy (6): in addition to the first Nτc j-cars, each of the X blank block allows either N or α additional j-cars. Nτ c + Ny + ( X − y )α ≥ Qcj
10 11
, y ≤ βτ c and y ≤ X
More precisely: ratios whose importance is greater than Ωpaint minimization. If N > B, then the basic bound Tc/B is optimal.
(6)
Challenge Roadef 9 Maximizing the number of acceptable j-cars (in order to exceed Qcj), the number of “fully used j-blank blocks” y is either equal to βτc or to X. Therefore the minimum possible τc with respect to ratio j is the maximum of three12 terms: (7)
Tc Q − αX Q − NX , , N ( ) B N + N − β α
τ cmin = max
The above property gives for each color a better lower bound of the number of strips it should be divides into (compared to that of section 3.2). Interestingly the same procedure applies on any set of colors, determining the minimum total number of strips that will be necessary for these colors. If this lower bound is larger than the sum of lower bounds of each color of this set, then the total bound is improved. For each ratio constraint, sets of colors with high density in this feature are the most likely to provide such an improvement. Computing this improvement for each ratio constraint, the largest one can be added to refine our lower bound on the number of paint changes. In the table below, the average gap is 2.1% (with 50% of optimality proofs) whereas without the search of such sets of colors we obtain 12.6%. As in section 4.1, each bound is computed in less than one second.
A/022 A/025 A/048 A/064 A/064 B/022 B/025 B/028 B/039 B/039 B/039 B/048 B/048 B/064 B/064 B/064 X/023 X/024 X/028 X/029 X/034 X/039 X/039 X/048 X/064 X/655
12
instance 3 4 EP RAF ENP 38 1 EP RAF ENP 39 1 EP RAF ENP 38 2 EP RAF ENP ch1 38 2 EP RAF ENP ch2 EP RAF ENP S22 J1 EP RAF ENP S22 J3 ch2 EP RAF ENP S23 J3 ch1 EP RAF ENP S22 J4 ch3 EP ENP RAF S22 J4 ch3 EP RAF ENP S22 J4 ch1 EP ENP RAF S22 J3 ch1 EP RAF ENP S22 J3 ch1 EP ENP RAF S22 J3 ch1 EP RAF ENP S22 J3 ch2 EP RAF ENP S22 J4 EP RAF ENP S49 J2 EP RAF ENP S49 J2 CH2 EP ENP RAF S51 J1 EP RAF ENP S49 J5 VP EP RAF ENP S51 J1 J2 J3 CH1 EP RAF ENP S49 J1 CH3 EP RAF ENP S49 J1 CH1 EP RAF ENP S50 J4 CH2 EP RAF ENP S49 J4 CH1 EP RAF ENP S51 J2 J3 J4
Best known solution PCC HPRC LPRC
31 228 174 112 34 19 167 4 78 197 189 200 161 182 130 130 192 337 3 110 55 69 231 196 37 30
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1 3134 612 759 51 144 5180 71 89 0 103 0 378 0 187 69 66 6 0 98 794 239 30 1005 0 0
Lower bound PCC gap
29 219 171 112 34 19 157 4 78 194 189 193 161 173 130 127 176 298 3 109 54 69 231 192 37 30
6.5% 3.9% 1.7% 0.0% 0.0% 0.0% 6.0% 0.0% 0.0% 1.5% 0.0% 3.5% 0.0% 4.9% 0.0% 2.3% 8.3% 11.6% 0.0% 0.9% 1.8% 0.0% 0.0% 2.0% 0.0% 0.0%
The basic bound Tc/B is re-introduced here since the other two only consider the min number of strips needed to contain Qcj j-cars using less than Tc-Qcj blanks: if Tc is large, additional strips must be added to contain supernumerary blanks.
Challenge Roadef 10 Table 2. Lower bounds for EASY instances
4.3. “Hard” ratios In the typology defined page 5, HARD instances are those for which no known solution manages to strictly satisfy all ratios constraint of greater importance than Ωpaint. For these problems, section 3.1 provides a first lower bound, computed as the sum of minimal penalties for each single ratio constraint. This simple sum proves the optimality of the best known Ωhigh (or Ωlow when best Ωhigh is 0) on 17 instances out of 32. Four additional optimality proofs (and three lower bounds improvements) can be obtained with a linear model of the problem. This classical model (Gravel et al. 2005, Estellon et al. 2005) is based on the identification of families of vehicles: two vehicles belong to the same family if they share exactly the same options (ignoring low priority ratio constraint when focusing on Ωhigh). Within this formalism, a solution is an assignment of a unique family to each position (binary variables), and the definition of penalty counters is straightforward, using intermediate13 binary variables detecting features on each position. We refer the reader to papers cited above for an exact formulation of this linear program. For large scale problems like those in this benchmark, only the continuous relaxation of this model can be solved (in a few seconds). Nonetheless, this relaxation is never smaller than the sum of minimal penalties because, as proven in appendix, for each single ratio it has the convex hull property. With this linear program, the strict feasibility of some problems remains undetermined that is to say that the obtained lower bound is 0. In this section we focus on pairs of ratio with a dynamic programming approach and finally prove that ratio constraints cannot be strictly satisfied for these instances. Let us define a simple ratio constraint as a ratio constraint N/P with N=1 or N=P-1, which is the case for 95% of ratio constraints in the considered benchmark. For a pair of such simple ratios N1/P1 and N2/P2, we consider the problem of placing n cars with both features, n1 cars with feature 1 and n2 cars with feature 2, in a strip of length T, without any penalty. This problem can be solved with a dynamic program based on a 5-dimensional state (ν,ν1,ν2,τ1,τ2) where ν,ν1,ν2 are counters initialized to (n,n1,n2) and τ1 ,τ2 code for the minimum number of blanks to be inserted before placing a car with the feature (for 1/P ratios) or for the maximum number of vehicles that can be inserted before placing a blank (for P-1/P ratios). Initial values t1, t2 of τ1 ,τ2 depend on vehicles of the previous day. With Λ recursively defined by equations (8), (9), (10), the minimum required length for placing (n,n1,n2) without penalty is Λ(n,n1,n2,t1,t2). Property 4 : The difference between Λ(n,n1,n2,t1,t2) and the available length (total number of vehicles) is a lower bound of the penalty for ratios N1/P1 and N2/P2. Proof. Given an optimal solution with a total penalty equal to x, there is necessarily a ratio Nj/Pj and a window of length smaller than Pj with at least N+1 j-cars, starting and ending with a j-car. Inserting a j-blank just before the rightmost car of this window decreases violation in this window without increasing penalties anywhere. In 13
Interestingly, (Estellon et al. 2005) point out that requiring the integrality of these intermediate variables is sufficient to ensure the integrality of all binary variables of the model.
Challenge Roadef 11 other words adding one j-blank can at least decrease penalty by one. Finally if the optimal solution with length T has a penalty equal to x, then the minimum length without violation is at least T+x.■ Condition for the insertion of a car with feature 1:
F (τ 1 ) = TRUE if ( N1 = 1 ∧ τ 1 = 0) ∨ ( N1 = P − 1 ∧ τ 1 > 0), FALSE otherwise
Transition rules for τ1:
if N1 = 1 P − 1, f (τ 1 ) = 1 max(0,τ 1 − 1), if N1 = P1 − 1
(insertion of a car with feature 1)
max(0, τ 1 − 1), if N1 = 1 b(τ 1 ) = if N1 = P1 − 1 P1 − 1,
(insertion of a car without feature 1)
(8)
F’,f’ and b’ are the equivalent functions for ratio N2/P2
∀τ 1 ,τ 2 , Λ(0,0,0,τ 1 ,τ 2 ) = 0 Λ(ν − 1,ν 1 ,ν 2 , f (τ 1 ), f ' (τ 2 ) ), provided ( Λ ν ,ν 1 − 1,ν 2 , f (τ 1 ), b' (τ 2 ) ), provided Λ(ν ,ν 1 ,ν 2 ,τ 1 ,τ 2 ) = 1 + min Λ(ν ,ν 1 ,ν 2 − 1, b(τ 1 ), f ' (τ 2 ) ), provided Λ(ν ,ν 1 ,ν 2 , b(τ 1 ), b' (τ 2 ) ), provided
(9) that :ν > 0 ∧ F (τ 1 ) ∧ F ' (τ 2 ) that : ν 1 > 0 ∧ F (τ 1 ) that :ν 2 > 0 ∧ F ' (τ 2 ) that : ¬( F (τ 1 ) ∧ F ' (τ 2 ))
(10)
The time complexity of this algorithm is 4nn1n2P1P2. As for space complexity it can be bounded by 2nn1n2P1P2/max(n,n1,n2) using an appropriate evaluation ordering, such that states (ν,.,.,.,.) can be garbage collected before reaching states (ν-2,.,.,.,.) for instance. In practice, when N1=1 we have n1P1 lbi(σ0, t) and a non empty set of transpositions τ = (t,t’) with t’>t (exchange of car in position t with a car in a position
Challenge Roadef 15 t’>t) such that lbi(τσ0, t+1) = lbi(σ0, t). We can select in this set the transposition minimizing ωi(τσ0). We call this exchange a repairing move for breaking point t. Scanning σ0 from left to right and applying all repairing moves leads to an optimal permutation for ratio i. Our selection function δi is based on this principle, with three improvements: 1. we stop this procedure as soon as the resulting permutation σ satisfies ωi(σ) < ωi(σ0) 2. we defined a maximum increase ε for the global objective and all transpositions leading to such an increase are ignored. However if ε is too small, many breaking points become non repairable, therefore we repeat this process with increasing values of ε, starting with ε=0 (in order to detect “pure” improvements if possible) and ending with ε=+∞ (in order to always find a permutation improving ωi) 3. the resulting permutation σ is improved by the local search descent defined in section 5.1, under the constraint ωi(σ) < ωi(σ0). As for the tabu list, since a solution is a tradeoff between different ratio constraints, it stores penalty vectors of permutation ω(σ) instead of storing permutation themselves in order to ensure better diversification. The detailed results of this star relinking local search can be found on http://www.prism.uvsq.fr/~vdc/ROADEF/CHALLENGES/2005/final_results.html. Obtained solutions are in average 7% above best known values and this algorithm ranked 12 among 55 in the Roadef Challenge. In other words it produces good solution but cannot compete with fast local search approaches like those developed by (Estellon et al. 2005) or (Ribeiro & et al. 2005). It may suggest that in this problem the choice of the next movement is not worth spending too much time, even with a polynomial algorithm. However we are still convinced that this Star Relinking metaheuristic could be appropriate for other problems.
6. Conclusion In this paper we have studied Soft Car Sequencing With Colors. After having identified polynomial algorithms for the minimization of each sub-objective (color changes or penalties of a single ratio constraints), we have computed lower bounds for three families of instances. • When paint changes minimization is the first criteria, we used the dispatch of car features among colors to obtain lower bounds of penalties attached to each ratio constraint. • On the contrary when only “easy” ratio constraints are more important than colors, we found three simple lower bounds for the minimum number of strips for each color. • Finally when the first criteria is made of “hard” ratios constraints, we reused the classical LP formulation of the problem, explained the quality of its relaxation by a polyhedral argument (see appendix) and detected infeasibility of some pairs of ratio constraints by dynamic programming.
Challenge Roadef 16 In summary we have proven that more than 50% of the instances of the considered benchmark are closed with respect to their first non trivial criteria. In addition to this lower bounds we have proposed a new meta heuristic named Star Relinking, yielding interesting results on this problem and which may apply on others problems whose objective is an aggregation of polynomial sub-objectives.
Appendix Analytical solution for the single ratio problem when E=0 (no-trail case) With η = (T-Q)/(P –N), Q’=Q-ηN, T’=T-ηP , the minimum penalty is: • When T’ ≤ P : (Q’-N)(P-T’+1) + (Q’- N)(Q’-N - 1) + (T’- Q’)max(0, Q’- 2N) • When Q’ = T’ : (H - N)(|Q’- P|+1) + (H - N)(H – N - 1) with H = min(P,Q’) • When Q’ < P + N : o When P < T’ < P + N : (T – P + 1)(P - (T’- Q’) - N) + (T’- Q’) max(0, Q’ - 2N) + (P - (T’- Q’) - N)(P - (T’- Q’) – N -1) o When T’ = P + N : (T’- Q’+ 1 + N)(Q’- 2N) + (Q’- 2N) (Q’- 2N - 1) o When P+N < T’ : (T’- Q’+ 1)(Q’- 2N) + N(P - (T’ - Q’) - N) + (Q’- 2N) (Q’- 2N - 1) • Otherwise : PQ’ – NT’ - N(P-N)
The classical LP formulation is totally unimodular for the single ratio problem For the single ratio problem, the linear program evoked in 4.3 takes a simple form (11), with Xt=1 if and only if the car in position t has the feature. For t∉[1,T], Xt is not a variable but a data, determined by the previous day for tT. The change of variable leading to system (12), similar to that of (Bartholdi et. Al 1980), shows that the matrix is totally unimodular (dual of a flow problem16). T +P
min
∑
t =−P
t
Z t such that ∀t , Z t ≥
∑
T
X i and
i =t − P +1
∑
Xt = q
t =−P
Z t ≥ Yt − Yt − P With Yt = X i constraints can be rewritten as YT = q and ∀t Yt − Yt −1 ≤ 1 Y −Y ≤ 0 i =−P t −1 t t
∑
16
(11)
(12)
Notice that once transposed, Z columns become unary constraints (capacities in the flow)
Challenge Roadef 17
References J.J. Bartholdi, J.B. Orlin, and H.D. Ratliff (1980), Cyclic scheduling via integer programs with circular ones. Operations Research, 28:110–118. T. Benoist and B. Rottembourg (2004), Upper bounds for revenue maximization in a satellite scheduling problem, 4OR: Quarterly Journal of the Belgian, French and Italian Operations Research Societies, Volume 2, Issue 3, Oct 2004, Pages 235 - 249 B. Estellon, F. Gardi, K. Nouioua (2005), Ordonnancement de véhicules: une approche par recherche locale à grand voisinage. In Journées Françaises de Programmation par Contraintes, Angers. I. Gent (1998), Two Results on Car-sequencing Problems. APES Report APES-02-1998: April 1998. Available from http://www.dcs.st-and.ac.uk/~apes/apesreports.html F. Glover (1986), Future paths for integer programming and links to artificial intelligence. Computers and Operations Research, 13, 533-549. F. Glover, M. Laguna, and R. Martl (2000), Fundamentals of scatter search and path relinking. Control and Cybernetics, 39:653-684. M. Gravel, C. Gagné et W.L. Price (2005), Review and comparison of three methods for the solution of the car sequencing problem. To appear in Journal of the Operational Research. P. J. M. Laarhoven and E. H. L. Aarts (1987), Simulated annealing: theory and applications Kluwer Academic Publishers, ISBN 9-027-72513-6. C. Ribeiro, D. Aloise, T. Noronha,C. Rocha, S. Urrutia (2005), A heuristic for a real-life car sequencing problem with multiple requirements. In MIC 2005, Vienna.
INFORMS
TRANSPORTATION SCIENCE Vol. 00, No. 0, Xxxxx 0000, pp. 000–000 issn 0041-1655 | eissn 1526-5447 | 00 | 0000 | 0001
doi 10.1287/xxxx.0000.0000 c 0000 INFORMS ⃝
Randomized local search for real-life inventory routing Thierry Benoist, Fr´ed´eric Gardi, Antoine Jeanjean Bouygues e-lab, 40 rue Washington, 75008 Paris, {tbenoist,fgardi,ajeanjean}@bouygues.com
Bertrand Estellon Laboratoire d’Informatique Fondamentale - CNRS UMR 6166, Facult´ e des Sciences de Luminy - Universit´ e Aix-Marseille II, 163 avenue de Luminy - case 901, 13288 Marseille cedex 9,
[email protected]
In this paper, a new practical solution approach based on randomized local search is presented for the optimization of a real-life inventory routing problem. Inventory routing refers to the optimization of transportation costs for the replenishment of customers’ inventories: based on consumption forecasts, the vendor organizes delivery routes. Our model takes into account pickups, time windows, drivers’ safety regulations, orders and many other real-life constraints. An important characteristic of our local-search heuristic is the absence of decomposition, made possible by a highly optimized volume assignment algorithm. Indeed, this generalization of the vehicle routing problem was often handled in two stages in the past: inventory first, routing second. Thanks to a large set of small neighborhoods, we can use a simple first-improvement descent instead of tuning complex metaheuristics. The problem being re-optimized every day with a rolling horizon, the short-term objective needs to be carefully designed in order to ensure long term savings. To achieve this goal we propose a new surrogate objective function for the short-term model, based on long-term lower bounds. An extensive computational study shows that our solution is effective, efficient and robust, providing long-term savings exceeding 20 % on average compared to solutions built by expert planners or even a classical urgency-based constructive algorithm. Confirming the promised gains in operations, the resulting decision support system is progressively deployed worldwide. Key words : logistics; inventory routing; decision support system; randomized local search; high-performance algorithm engineering. History :
The inventory routing problem (IRP) consists in optimizing the distribution of fluids by tank trucks in the long run. It is a generalization of the vehicle routing problem with vendor managed inventory replenishment. The particularity of this problem is that the vendor monitors the customers’ inventories, deciding when and how much each inventory should be replenished by routing trucks. Based on consumption forecasts for each customer, a solution is a set of routes visiting customers and delivering a certain amount of product at each of these stops. In addition to routing constraints, stock-outs must be avoided, which means that the quantity of product stored at each customer should stay above a certain safety level. The economic function is the costs of the routes. In this paper, a real-life IRP is addressed, very close to the one treated by operational planners (Section 1). To our acquaintance, such broad inventory routing problems have been rarely addressed in the operations research literature, as explained in our review of related works (Section 2). Indeed, many real-life features described here have not been treated in past studies, allowing a more global and accurate optimization of the replenishment logistics. Some of these features have been reported as important practical issues in the survey by Campbell et al. (1998). This problem need to be solved every day in less than five minutes, with a rolling horizon of 15 days. In order to minimize the costs on the long run, we propose a new surrogate objective for the short-term problem, based on lower bounds on delivery costs. We show that this objective, detailed in Section 3, significantly improves long-term optimization. 1
Benoist et al.: Real-life inventory routing c 0000 INFORMS Transportation Science 00(0), pp. 000–000, ⃝
2
To solve this problem, we propose a local-search heuristic whose originality is to be pure (no metaheuristic, no hybridization) and direct (no decomposition of the problem). The absence of decomposition is a strength of our approach. Indeed, most previous works on the subject proceed in two stages: inventory management first and vehicle routing second. On the contrary, the localsearch heuristic described in Section 5 handles the whole problem and performs transformations on the solution impacting both deliveries (dates and volumes) and routes (paths, resources, etc.). What makes it possible without overwhelming the local search is the incremental approximation algorithm that we designed for computing volumes, which is 2000 times faster than an exact flow algorithm. Following the methodology applied by some of the authors for solving other real-life problems, we use a large variety of small neighborhoods with highly-optimized underlying routines, but no metaheuristic; a first-improvement descent is sufficient provided than non deteriorating moves are accepted. The results reported in Section 6 show that our solution provides long-term savings exceeding 20 % on average compared to solutions built by expert planners or even to a classical urgency-based constructive algorithm described in Section 4.
1.
The inventory routing model
For the sake of readability, we first introduce the core model of Inventory Routing, then we focus on the real-life aspects taken into account in our model. Comparisons with previous works will be developed in Section 2. 1.1. Basic model The IRP can be informally described as follows. A product is consumed at customers’ sites and produced by the vendor’s plants . Both customers and plants store the product in tanks. Reliable forecasts of consumption (resp. production) at customers (resp. plants) are available over a shortterm horizon. The inventory of each customer must be replenished by tank trucks so as to never fall under its safety level. The transportation is performed by vehicles, formed by associating one driver, one tractor and one trailer. Scheduling a shift consists in defining a vehicle starting from a depot and performing a set of operations each one defined by a triplet (site, date, quantity) corresponding to the pickups or deliveries performed along the tour. The inventory dynamics, which can be modeled by flow equations, must be respected at each time step, for each site inventory. The objective of the planning is to minimize over the long term a logistic ratio defined as the sum of the costs of shifts divided by the sum of the quantities delivered to customers. In other words, this logistic ratio corresponds to the cost per unit of delivered product. The input data for this problem consists of: • A time horizon T , split in H time steps of size U . Any instant is given by a point in the interval [0, T ]. Thus, all dates defined in the model can be expressed with the desired precision. In effect, the value of T is equal to 15 days and the time unit is the minute. • Three sets of points (depots, plants and customers), between which a distance matrix and a time matrix are given. Both matrices are not necessarily symmetric, but are assumed to satisfy the triangular inequality. For each site p (plant or customer), the capacity of the storage and the initial quantity of product in this storage are referred to as capacity(p) and initialQuantity(p). The opening hours of these site are given as a set of intervals in [0,T [ (except contrary mention, any interval of time is such that the starting date is included and the ending date is excluded). The time needed to perform a loading or delivery operation at site p is setupTime(p). For each time step in the horizon, forecast(p, h) gives the consumption forecast for time step h (or production forecast if p is a plant). For each customer p, safetyLevel (p) is the quantity of product which must be maintained in the inventory. • Three sets of resources: drivers, tractors and trailers. Each resource is attached to a unique depot and has a set of availability time-windows. Time-windows of drivers are defined by their
Benoist et al.: Real-life inventory routing c 0000 INFORMS Transportation Science 00(0), pp. 000–000, ⃝
3
contracts, while for tractors and trailers they depend on maintenance periods. Costs are attached to drivers and tractors: a cost per unit of working time for drivers and a cost per unit of traveled distance for tractors. The maximal quantity that can be loaded in a trailer tl is capacity(tl) and the quantity of product in the trailer at the beginning of the horizon is initialQuantity(tl). Finally the duration of a shift performed by a driver d is bounded by maxAmplitude(d). The size of the problem is essentially defined by the number of points, the number of resources and the number of time steps for which are defined consumptions/productions over the horizon. Solving this problem amounts to building a set of shifts. A shift s is defined by: its driver (s), its tractor (s), its trailer (s), its depot(s), its starting date start(s) from the depot, its ending date end (s), and the chronological-ordered list operations(s) of performed operations. Then, an operation o is defined by the site point(o) where the operation takes place, the quantity(o) delivered or loaded (positive for delivery, negative for loading), its starting date arrival (o) and its ending date departure(o). The inventory levels (for customers, plants, trailers) can be computed from the quantities delivered or loaded in shifts. We denote by tankQuantity(p, h) the quantity of product in the tank of site p at time step h, and by trailerQuantity(tl, o) the quantity of product in the trailer tl at the end of operation o. The constraints on shifts are called routing constraints. First of all, any shift starts from a depot and must return to this depot. The interval [start(s), end (s)[ induced by any shift s must be contained into an availability time window for each resource assigned to s and the duration of the shift (end (s) − start(s)) must be smaller or equal to maxAmplitude(d) (where d is the driver of the shift). The shifts performed by a resource cannot overlap in time (that is, time intervals induced by the shifts are pairwise disjoint). The three resources (driver, tractor,trailer) assigned to the shift must belong to the depot of the shift. The elapsed time between the end of an operation and the start of the next operation must be greater or equal to the travel time between these two points (given by the time matrix). Note that this inequality allows for waiting time during the shift, for example between the end of the travel and the opening of the site. Finally for any operation o taking place on site p, the interval [arrival (o), departure(o)[ must belong to an open hours interval of p and its width must be equal to the operating time of the site (setupTime(p)). Two kinds of inventories have to be managed: tanks of sites (customers and plants) and trailers. In any case the quantity in a storage must remain between zero and its capacity. For customers, the tank quantity at each time step h is equal to the tank quantity at the previous time step h − 1, minus the forecasted consumption over h, plus all the deliveries performed over h. Note that the quantities delivered to customers must be positive (loading is forbidden at customers). More formally, the inventory dynamics for customers are expressed as follows: tankQuantity(p, −1) = initialTankQuantity(p) and for all time step h ∈ {0, . . . , H − 1}, ∑ { tankQuantity(p, h) = tankQuantity(p, h − 1) − forecast(p, h) + quantity(o) o∈operations(p,h)
if tankQuantity(p, h) < 0, then tankQuantity(p, h) = 0 with operations(p, h) corresponding to the set of operations performed at site p whose starting date belongs to time step h. The same formula applies for plants, since the forecasted productions and loading quantities have negative values (delivery is forbidden at plants). However, for plants, when the above formula yields a quantity larger than capacity(p), the result is limited to capacity(p). These overflows are not penalized, because production aspects are assumed not to be managed in this model. For trailers, the inventory dynamics are much simpler since operations performed by a trailer cannot overlap. Hence the quantity in a trailer tl is not defined for each time step but after each of its operations (and referred to as trailerQuantity(tl, o)). Initially equal to initialQuantity(tl), this level is merely increased by loadings and decreased by deliveries. More formally, we have: trailerQuantity(tl, o) = initialQuantity(tl) − quantity(o)
(1)
Benoist et al.: Real-life inventory routing c 0000 INFORMS Transportation Science 00(0), pp. 000–000, ⃝
4
when o is the first operation of the trailer tl, and trailerQuantity(tl, o) = quantity(prev (o)) − quantity(o)
(2)
otherwise, with prev (o) the previous operation performed by tl. Finally, forbidding stockouts at each customer p is achieved by setting for all time step h the constraint tankQuantity(p, h) ≥ safetyLevel (p). The objective of the vendor over the long term (more than 90 days), is to minimize the total cost of shifts. This cost is usually divided by the total delivered quantity in order to increase the readability of this economic indicator. This cost per ton ratio (or miles per ton when costs are approximated by distances) is widely used in the industry and in the academic literature. This ratio will be named the logistic ratio LR = SC /DQ, with SC the total shift cost and DQ the total delivered quantity over the considered horizon (with the exception that if DQ = 0, then LR = 0). The latter is simply computed as the sum of delivered quantities (that is, positive quantities) for all shifts. As for shift costs they include costs relative to traveled distance and to worked hours. We will show in the next section that many other costs are taken into account in our real-life model. 1.2. Real-life constraints 1.2.1. Compatibility matrices. In practice a driver is only allowed to use a restricted list of tractors and trailers, depending on its driving license for instance. Similarly, the possibility to hitch a trailer to a tractor is governed by technical constraints. Also the configuration of a site may not make it accessible to all kind of trailers or tractors (for instance in case of narrow gates or inadequate equipments) and special accreditations may be required from drivers to enter some sites. These binary relationships (resource/resource or resource/site) are represented by boolean matrices. 1.2.2. Legal regulations. As pointed out in Archetti and Savelsbergh (2007) legal regulations can not be ignored in an operational IRP model. Indeed, for safety reasons, drivers cannot work for more than a certain duration before a mandatory layover. More precisely, a maximum driving duration maxDrivingDuration(d) and a maximum working duration maxWorkingDuration(d) are defined for each driver d, after which a layover is required whose duration must be larger or equal to a given minLayoverDuration(d) (depending on countries, these durations usually take values close to 10 or 15 hours). For any driver d, cumulatedDrivingTime(d, t) at time t corresponds to the driving time cumulated since the end of the last layover or the start of the shift. In the same way, cumulatedWorkingTime(d, t) corresponds to the elapsed time since the end of the last layover or the start of the shift. At any time t of a shift, cumulatedDrivingTime(d, t) (resp. cumulatedWorkingTime(d)) cannot exceed maxDrivingDuration(d) (resp. maxWorkingDuration(d)). In other words, one layover must be set once one of the two maximal durations is reached. An operation cannot be stopped for resting (operations are not preemptive).Two consecutive shifts assigned to d must be separated by at least minLayoverDuration(d) as well. Layover times are not counted as working time that is to say that the working duration for a shift s is its width (end (s) − start(s)) minus the duration of layovers in this shift. It means that possible waiting times are counted as working time. 1.2.3. Time and cost refinements. Instead of using a single time matrix, we have one matrix per tractor kind (10 different tractor speeds are defined). Besides, checking operations must be performed at the start and at the end of any shift, as well as before and after any layover; these fixed durations are respectively denoted by preTripTime and postTripTime. Like operations, these checking tasks cannot be stopped for resting. Figure 1 gives two graphical views of a shift including these durations.
Benoist et al.: Real-life inventory routing c 0000 INFORMS Transportation Science 00(0), pp. 000–000, ⃝
5
p0 c1 preTripTime b0
setupTime(c0 ) postTripTime preTripTime
timeMatrix (b0 , c0 ) c0
start(s)
delivery
p0 layover
arrival (c1 )
c0
c1 c2
departure(p0 )
loading arrival (c2 )
timeMatrix (c1 , c2 )
departure(c1 )
setupTime(p0 )
c2 waiting
postTripTime b0 end (s)
b0 Figure 1
Two views of the shift s = (b0 , c0 , p0 , c1 , c2 , b0 ): the route and the schedule. Some of the notions and definitions described as real-life aspects are illustrated on the figure.
The cost of shifts is not proportional to working durations and traveled distances. Various fix costs must be accounted for. In particular, loadingCost(d) and deliveryCost(d) are defined for each driver d, representing the fix cost of loading and delivery operations respectively. A fix cost is also paid each time a layover is taken. 1.2.4. Orders. The “forecasting-based resupply” model described in the previous section is often combined in practice with “order-based resupply” that is to say the possibility for customers of issuing an order (to deal with an unexpected increase of their consumption, for example), specifying the desired quantity and the time window in which the delivery must be done. Some customers may use this possibility occasionally while others choose to work in pure order-based resupply mode (without forecasting). An order r is characterized by the quantity(r) asked by the customer and the specified time-window [earliestTime(r), latestTime(r)[ for delivery. An order r is considered as satisfied if an operation o is scheduled satisfying quantity(o) ≥ quantity(r) and arrival (o) ∈ [earliestTime(r), latestTime(r)[. For the sake of concision, order management will not be deeply discussed in this paper. Our local-search strategy for this feature is only sketched out in Section 5.1.3. 1.2.5. Problem size and allocated CPU time. Large-scale instances have to be tackled. A geographic area can contain up to 1500 customers, 50 sources, 50 depots, 100 drivers, 100 tractors, 100 trailers. All temporal data have to be managed in continuous time, except for consumptions of customers (resp. productions of plants) which are discretely represented. Concretely, all dates and durations are expressed in minutes (on the whole, the short-term planning horizon counts 21600 minutes); the inventory dynamics for plants and customers are computed with time steps of one hour (because forecasts are computed with this accuracy). The execution time for computing a short-term planning is limited to 5 minutes on standard computers. Shifts are planned deterministically day after day with a rolling horizon of 15 days. It means that each day, a distribution plan is built for the next 15 days, but only shifts starting at the current day are fixed. Note that other real-life constraints are also taken into account by our software but cannot be unveiled here for the sake of concision.
2.
Related works and contributions
Since the seminal work of Bell et al. (1983) on a real-life inventory routing problem, a vast literature has emerged on the subject. In particular, a long series of papers was published by Campbell et al. (1998, 2002), Campbell and Savelsbergh (2004a), Savelsbergh and Song (2007a,b, 2008), motivated by a real-life problematic encountered in the industry. However, in many companies, inventory routing is still done by hand or supported by basic softwares, with rules like: serve “emergency”
6
Benoist et al.: Real-life inventory routing c 0000 INFORMS Transportation Science 00(0), pp. 000–000, ⃝
customers (that is, customers whose inventory is near to run out) using as many “full deliveries” as possible (that is, deliveries with quantity equal to the trailer capacity or, if not possible, to the customer tank capacity). For more references, the interested reader is referred to the recent papers by Savelsbergh and Song (2007a, 2008), which give a comprehensive survey of the research done on the IRP over the past 25 years. Below are presented the three contributions of this paper, with respect to related works: • Our model is very realistic in terms of constraints, costs and sizes. • A new surrogate objective function is proposed for dealing with the rolling horizon process. • No decomposition of the problem is used in the local-search solution approach, thanks to an innovative volume assignment algorithm. 2.1. A real-life model The problem addressed here is very close to the one treated by operational planners. To our acquaintance, such broad inventory routing problems have been rarely addressed in the operations research literature. Indeed, many real-life features described here have not been treated in past studies, allowing a more global and accurate optimization of the replenishment logistics. Some of these features have been reported as important practical issues in the survey by Campbell et al. (1998). First, our inventory routing model integrates both kinds of resupply: forecasting-based and order-based. Besides, several subproblems related to the scheduling of shifts and the allocation of resources to shifts become computationally hard in the present case. Another interesting feature, enabling to go further in logistic optimization while making the problem harder, is what is called “continuous moves” in Savelsbergh and Song (2007a, 2008) or “satellite facilities” in Bard et al. (1998). The vehicles can arbitrarily load or deliver some product along their routes, and loadings can be done at multiple plants. Moreover, when a driver reaches its working or driving time limit, he can continue his route after a layover. This allows to design shifts spanning several days and covering huge geographic areas. Finally, the expected forecasts of consumption for customers and of production for plants are given for each hour on a 15-days horizon, allowing nonlinear consumptions/productions; here forecasts are assumed to be reliable, inducing a deterministic optimization problem (contingencies on the customer consumption are considered to be covered by the defined safety level). Customers (resp. plants) may have different consumption (resp. production) profile, asking several deliveries (resp. pickups) per day or only one per month. Note that one feature generally addressed in the IRP literature (e.g. Campbell et al. 1998, 2002, Savelsbergh and Song 2007a, 2008) is not included in our IRP model: loading or delivery duration depending on the quantity. Indeed, fixed-duration loadings and deliveries depending on sites were judged sufficient to approximate reality (full loadings/deliveries are performed in almost half an hour), because several other approximations making this detail negligible are done about temporal aspects due to real-life uncertainties (in particular about traveled times). Nevertheless, we shall see later that our solution could be modified to manage this feature without significantly affecting its performance. A popular and sensible economic function, used by Campbell et al. (1998, 2002), Savelsbergh and Song (2007a, 2008), is to maximize the volume per mile over the long term, obtained by dividing the total quantity delivered to all customers by the total distance traveled. Instead of the sole traveled distance, we take into account the actual cost of the routes, thanks to a precise modeling of the cost of each shift in function of its traveled distance, its traveled time, its number of loadings, its number of deliveries, and its number of rests. The resulting generalized objective is the minimization of the cost per unit of delivered product, called logistic ratio throughout the paper. This was made possible by modeling the cost of a shift in function of its traveled distance, its traveled time, its number of loadings, its number of deliveries, and its number of rests.
Benoist et al.: Real-life inventory routing c 0000 INFORMS Transportation Science 00(0), pp. 000–000, ⃝
7
2.2. A new surrogate objective function While the IRP goal is to optimize distribution costs over the long term, forecasts are usually available for a short horizon and continuously updated. Therefore the problem is usually solved in a rolling horizon framework. A short term planning is build for 15 days for instance and only shifts starting the first day are fixed. The next day, a new planning is built including one more day in the horizon. As mentioned by Campbell et al. (1998) and Campbell et al. (2002) and also by Bell et al. (1983), the first difficulty arising in modeling IRP is to define appropriate short-term objectives leading to good long-term solutions. In fact, a direct minimization of costs would lead to deferring as many deliveries as possible to later planning periods. This rolling horizon issue has been studied in Dror and Ball (1987), where incentives are introduced for the amount delivered, based on an estimation of the long term savings incurred by anticipated deliveries. Our contribution on this topic is to introduce a new surrogate objective for short-term optimization (here done over a 15days horizon) ensuring long-term improvements. This surrogate objective, which shall be detailed later in the paper, is based on lower bounds for the logistic ratio (this extends observations made by Savelsbergh and Song (2007b) on performance measurement). Computational experiments with real-life data show that significant gains are obtained in the long run by optimizing this short-term surrogate objective, compared to a direct short-term minimization of the logistic ratio. 2.3. A direct local-search approach To our knowledge, the sole papers describing practical solutions for similar problems are the ones described by Campbell et al. (2002), Campbell and Savelsbergh (2004a), Savelsbergh and Song (2007a, 2008). Before presenting our solution approach, we outline the ones implemented by Campbell et al. (2002), Campbell and Savelsbergh (2004a) for solving the single-plant IRP, and by Savelsbergh and Song (2007a, 2008) for solving the multiple-plant IRP. The solution approaches described by Campbell et al. (2002) and Campbell and Savelsbergh (2004a) are the same in essence; because integrating additional realistic constraints, the single-plant IRP addressed by Campbell and Savelsbergh (2004a) is more complex than the one by Campbell et al. (2002). The methodology developed by the authors is deterministic and proceeds in two phases. In the first phase, it is decided which customers are visited in the next few days, and a target amount of product to be delivered to these customers is set. In the second phase, vehicle routes are determined taking into account vehicle capacities, customer delivery windows, drivers restrictions, etc. The first phase is solved heuristically by integer programming techniques, whereas the second phase is solved with specific insertion heuristics (Campbell and Savelsbergh 2004c), as done for vehicle routing problems with time windows by Solomon (1987). In Campbell et al. (2002), a planning is constructed on a rolling horizon by considering 5 days in full details plus 4 weeks in aggregated form beyond this. Computational experiments are made on two instances with 50 customers and 87 customers respectively, with 4 vehicles as resources. The authors compare their short-term solutions to the ones obtained by a greedy algorithm based on the rules of thumb commonly used in practice (like the one cited at the beginning of this section). They obtain an average gain of 8.2 % for the volume per mile (running times are not reported). In Campbell and Savelsbergh (2004a), the authors simulate the use of a rolling-horizon approach covering one month. At each iteration of the rollinghorizon framework, they solve the first-phase integer program on 3 days in full details plus 1 week in aggregated form beyond this, and run the second-phase insertion heuristic with the information from the solution of the integer program for the first two days. Then, the resulting routes are fixed and the clock is moved forward two days in time. The running time to perform one iteration is limited to 10 minutes (with a 366 MHz processor). The authors compare their approach to a greedy algorithm similar to the one described in Campbell et al. (2002). The benchmarks are composed of two instances with almost 100 customers and 50 customers respectively (the available resources
8
Benoist et al.: Real-life inventory routing c 0000 INFORMS Transportation Science 00(0), pp. 000–000, ⃝
are not detailed). The average gain over one month is of 2.7 % for the volume per mile, but a better utilization of resources is observed (larger average percentage of trailer capacity delivered on routes, shorter average length of shifts). In Savelsbergh and Song (2007a, 2008), the authors develop two approaches for solving the multiple-plant IRP. Many realistic features taken into account in Campbell and Savelsbergh (2004a) are relaxed in the model addressed by the authors. In particular, simple resources are considered (that is, a vehicle is reduced to a trailer) allowing an integer multi-commodity flow formulation of the problem. The first approach (Savelsbergh and Song 2007a) is based on an insertion heuristic which delivers customers ordered by urgency (that is, the time remaining before the first stockout) while minimizing stockout and transportation costs. This approach is declined into three greedy algorithms: a basic one (called BGH) where insertions are only performed at the end of shifts, a enhanced one (EGH) where insertions can be performed at any point in the shift after the last pickup, and a randomized enhanced one (RGH) where the EGH algorithm is embedded into a greedy randomized adaptive search procedure (Feo and Resende 1995). Then, a postprocessing is performed using linear programming for maximizing delivered quantities on the resulting shifts (in order to maximize the volume per mile). The authors present computational results made on 20 benchmarks derived from an instance with 200 customers, 7 plants, 7 vehicles (with a 2.4 GHz processor). On a 10-days horizon, the average improvement for stockout and transportation costs from BGH to EGH (resp. from EGH to RGH) is of 15.2 % (resp. 6.8 %); the average running time is about a few seconds for BGH and EGH, and about 12 minutes for RGH. The postprocessing optimization increases the total delivered quantity by 2.8 % on average on the same benchmarks (with a running time lower than one second). Other experiments made on a rolling horizon of 5 months (with 10 days planned, 5 days fixed) show that the delivery volume post optimization helps to reduce costs of about 3 % (using RGH as reference algorithm). The second approach (Savelsbergh and Song 2008) consists in solving heuristically the integer multi-commodity flow program (by using customized integer programming techniques). The authors present computational results made on 25 benchmarks derived from the instance with 200 customers used as basis in Savelsbergh and Song (2007a). The average improvement over RGH for stockout and transportation costs is of 4.1 %, whereas the average running time is greater than 31 hours (with a 900 MHz processor). Since such computational requirements are too large for a practical use, the authors use the integer program for exploring large neighborhoods in a local search scheme (see Estellon et al. (2006, 2008) for an application of this technique to car sequencing problems). This consists in re-optimizing the schedules of two vehicles in the planning by solving the integer program with the other schedules fixed. In this way, all pairs of vehicles are re-optimized iteratively. The authors report an average improvement over RGH of 3.1 %, with an average running time lower than 3 minutes and an average number of improving iterations of 3. Unfortunately, no precise statistic is given in Savelsbergh and Song (2007a, 2008) about the resulting volume per mile over a long term. For the resolution of the short-term planning problem with the surrogate objective, we describe in this paper a pure and direct local-search heuristic, whose design and engineering follows the three-layers methodology recently formalized by Estellon et al. (2009) and successfully implemented for solving other large-scale business optimization problems (car sequencing with paint colors at Renault by Estellon et al. (2006, 2008), task scheduling with human resource allocation at France ´le ´com by Estellon et al. (2009)). A local-search approach is outlined by Lau et al. (2002) Te for solving an inventory routing problem with time windows, but their solution remains based on a decomposition of the problem (distribution and then routing). We insist on the fact that no decomposition is done here: the 15-days planning is directly optimized by local search. We explain in Section 5.3.2 that the key component of the local search is the assignment of quantities. An extensive computational study demonstrates that our solution is both effective, efficient and robust, providing long-term savings exceeding 20 % on average, compared to solutions computed
Benoist et al.: Real-life inventory routing c 0000 INFORMS Transportation Science 00(0), pp. 000–000, ⃝
9
by expert planners or even to a classical urgency-based constructive heuristic. An abstract of this work appears in Benoist et al. (2009).
3.
The short-term surrogate objective
One of the main difficulties encountered in IRP problems is to take short-term decisions ensuring long-term improvements. This is the case with most problems handled with a rolling horizon approach. In other words, a surrogate short term objective needs to be defined, in order to optimize the economic function over the long term. Obviously focusing on the minimization of total costs would lead to delivering only customers for which a shortage is forecasted over the short-term horizon. Optimizing the logistic ratio allows better anticipations but does not lead necessarily to long-term optimal solutions. For example, assume that a faraway customer has no stockout over the next days. Scheduling a delivery for this customer would probably increase the logistic ratio, and will be discarded. But such short-term decisions may be highly suboptimal in the long run, especially if some near-optimal deliveries are possible over these next days due to the availability of resources. This lack of anticipation motivates the proposal of a new surrogate objective function that can be summarized into the following rule: “never put off until tomorrow what you can do optimally today”. This short-term goal shall be to minimize the global extra cost per unit of delivered product, compared to the optimal logistic ratio LR ∗ . Denote by LR ∗ (p) the optimal logistic ratio for delivering the customer p and then by ∑ SC ∗ (s) = LR ∗ (p) × quantity(p) customer p delivered over s
the optimal cost of the shift s according to the quantities delivered at each customer over s. Then, the surrogate logistic ratio LR ′ is defined as: ∑ (SC (s) − SC ∗ (s)) ′ LR = s DQ Unfortunately, it requires to tackle another problem: the computation of lower bounds of LR ∗ (p) for each customer p. Such lower bounds are computed below. A trip is defined as a subpart of a tour (see Figure 2): it is a sequence of visits starting at a plant (or a depot), delivering one or more customers, and finishing at a plant (or a depot). In other words, a trip t in the shift s corresponds to an interval [start(t), end (t)[ with start(t) (resp. end (t)) the starting date from the plant or the depot (resp. the starting date from the plant or the depot visited in the next trip). Then, the cost of a shift can be decomposed according to its trips, in such a way that the cost of a trip corresponds to the costs (distance, time, deliveries, loadings, layovers) accumulated over [start(t), end (t)[. Besides, the cost of each trip can be dispatched to visited customers proportionally to the delivered quantities. For each customer p, a lower bound LR min (p) is obtained by dividing the cost of the cheapest trip visiting p by the maximum capacity of a trailer able to perform this trip. Since the distance matrix satisfies the triangular inequality, the cheapest trip consists in visiting solely the customer p. Consequently, LR min (p) is computed in O((B + P )2 ) time for each customer p, with B the number of depots and P the number of plants. base
Figure 2
delivery
delivery
trip t0 The trips of a shift.
loading
delivery
delivery
trip t1
delivery
loading
trip t2
base
10
Benoist et al.: Real-life inventory routing c 0000 INFORMS Transportation Science 00(0), pp. 000–000, ⃝
These lower bounds LR min (p) are the one that we use in the definition of our surrogate objective function LR ′ . A global lower bound of the logistic ratio LR ∗ can be derived from these lower bounds LR min (p) but this topic is outside of the scope of the present paper.
4.
Urgency-based constructive heuristic
In order to quickly build an initial solution, a constructive heuristic was designed, based on a classical urgency approach. The goal of this algorithm is to avoid stockouts. Basically, it repeatedly picks the next stockout and tries to create a new delivery for this customer. The deadline of a demand (stockout) is defined as the latest start of a shift that would reach the customer on time to perform the desired delivery, taking travel time and opening hours into account. Algorithm Greedy; Input: an instance of the IRP; Output: a solution S to the IRP (namely a set of shifts); Begin; S ← ∅; initialize the set D of demands with stockouts for each customer; while D is not empty do pick the demand d with the earliest deadline in D; create the cheapest delivery o to satisfy d (inside a new shift, possibly); if o exists then add o to S (with the new shift, if any); compute the next stockout after start(o) and update the deadline of d accordingly; else remove d from D; return S; End;
At each step of the algorithm, the newly created delivery can be either appended at the end of an existing shift or included in a new shift. In the first case, the extension of a shift can be made impossible due to accessibility or resources constraints (for example, the resulting duration of this shift may extend the maximum allowed amplitude). For each existing shift, this feasibility is tested in constant time. However, inserting a loading operation can be required for refilling the trailer before performing the delivery, in which case all plants are tested. Therefore, this stage runs in O(|S |P ) time, with |S | the number of shifts returned by the greedy algorithm and P the number of plants. In the second case, all depots and all possible triplets of resources are considered. Here again, all plants are considered if a loading is needed. The worst-case time complexity of this enumeration is in O(BRP ), with B the number of depots and R the number of triplets of resources (drivers, tractors, trailers). But in effect, this running time can be reduced by cutting strongly the search tree, in particular once a feasible shift has been found. The choice of the delivery date impacts the delivered volume since the available space in the customer tank increases with time (possibly reaching the capacity of the considered trailer before the safety level is hit). On the other hand, packing the shifts to the left tends to optimize resources utilization. Our tradeoff consists in favoring large deliveries as a first criterion, breaking ties by preferring early dates. In other words we prefer to deliver later (but before the stockout date) if it allows increasing the delivered quantity, but between two dates allowing a full drop we choose the earliest one. All considered deliveries are compared by dividing the cost of the shift (or the increase of the cost of the existing shift) by the quantity of the delivery. Each time a delivery is created, the inventory levels for this customer are updated and its next stockout date is computed. By construction, this urgency-based insertion heuristic never backtracks on decisions taken on dates and quantities. Practically, the running time of this greedy algorithm is about a dozen of
Benoist et al.: Real-life inventory routing c 0000 INFORMS Transportation Science 00(0), pp. 000–000, ⃝
11
seconds (on standard computers), even for the largest instances of our benchmarks. Even if the local-search heuristic described in the next section is able to start from an empty set of shifts, the use of the initial solution obtained by this constructive algorithm yields a significant speed-up in the convergence toward high-quality solutions (in particular, when finding a solution without stockout is hard).
5.
High-performance local search
In this section, the main ingredients of the local-search heuristic are detailed. The exposition follows the three-layers methodology by Estellon et al. (2009) for designing and engineering highperformance local-search algorithms: heuristic & search strategy, transformations, algorithms & implementation. 5.1. Heuristic & search strategy The heuristic is divided into two optimization phases: first we reach a feasible solution, then we optimize the cost of this solution. 5.1.1. Feasibility measure. When finding a feasible solution is not trivial, local-search heuristics often relax some constraints (introducing appropriate penalties) in order to allow the search to visit infeasible solutions and in particular to start with an infeasible solution. In our case we relax the no-stockout constraint as detailed below. In the first phase, the only objective is the maximization of our feasibility measure, regardless of costs. As soon as a feasible solution is found, we switch to the second phase (optimization of the economic function) during which only feasible solutions are visited. The no-stockout constraint was introduced as tankQuantity(p, h) ≥ safetyLevel (p) in Section 1. During the feasibility stage, these constraints are removed and a penalty SO is introduced, counting for each customer the number of time steps during which the above inequality is violated (quantity in tank is smaller than the required level). In other words, we count the number of violated nostockout constraints. The stockout stage is necessary for finding feasible solutions, since the constructive heuristic of Section 4 may not fix all stockouts. It also ensure that the software always returns a (possibly infeasible) solution. Indeed, presenting an infeasible solution to the user allows him to analyze the causes for this infeasibility. For instance, if stockouts are avoided for all customers but one, he can focus on this customer and detect that no available trailer is allowed to visit this site. 5.1.2. Heuristic. Below is outlined the skeleton of the whole heuristic, which is a simple firstimprovement randomized descent. We insist on the fact that no metaheuristic is used, thus avoiding the need for many tuning parameters. For more details on metaheuristics and their applications in combinatorial optimization, the reader is referred to the book edited by Aarts and Lenstra (1997). Algorithm Randomized-Descent; Input: an instance I of the IRP; Output: a solution S to the IRP; Begin; S ← Greedy(I); Stockout optimization: while SO > 0 and timeLimit is not reached do choose randomly a transformation T in the pool TSO ; evaluate the result (SO new ) of the application of T to S; if SO new ≤ SO then commit T ; else rollback T ; Logistic ratio optimization: while timeLimit is not reached do
12
Benoist et al.: Real-life inventory routing c 0000 INFORMS Transportation Science 00(0), pp. 000–000, ⃝
choose randomly a transformation T in the pool TLR ; evaluate the result (SO new , LR ′new ) of the application of T to S; if SO new = 0 and LR ′new ≤ LR ′ then commit T ; else rollback T ; return S; End;
The heuristic is divided into two optimization phases: the first one (SO) consists in minimizing the number of stockout timesteps regardless of costs, and the second one (LR) consists in optimizing the objective related to logistic ratio while preserving SO = 0. Note that accepting solutions with equal cost at each optimization phase is crucial for ensuring the diversification of the search and thus the convergence toward high-quality solutions. In our implementation, the sign of LR ′new − LR ′ is obtained by evaluating the expression SC − SC ∗ SC new − SC ∗new − DQ DQ new or equivalently DQ new (SC − SC ∗ ) − DQ(SC new − SC ∗new ) which avoids imprecisions due to floatingpoint arithmetic when the expression tends toward zero. Finally the random selection of transformation is performed with a uniform distribution. 5.1.3. Order management. In presence of orders, the above heuristic needs to be enriched with a preliminary phase devoted to orders (as an explicit request of a customer, order satisfaction have the highest priority). Hence our objective is lexicographic: order satisfaction, stockout constraints satisfaction and finally logistic ratio minimization. Once again we insist on the importance of ignoring impacts on subsequent stages in order to maximize the diversification in each phase (see Estellon et al. (2008) for another local search using this lexicographic rule). Our measure of order satisfaction is not directly the count of satisfied orders. Introducing for each order an intermediate state called “unsatisfied” between the states “missed” and “satisfied” was found to facilitate the convergence of the local search. An order is unsatisfied if an operation exists satisfying the time window of the order, but not its quantity. In this way, an order is satisfied (resp. missed) when both the dates and the quantity are respected by at least one operation (resp. by no operation). A transformation is accepted when it increases the number of satisfied orders or when it leaves this number unchanged, without increasing the number of unsatisfied orders. Together with specialized transformations focused on orders, this phase allows to handle problems where “forecasting-based resupply” and “order-based resupply” are mixed. This important variant of the problem will not be evoked in the remaining of this paper nor in experimental results. 5.2. The transformations The transformations are classified into two categories: the first ones work on operations, the second ones work on shifts. Having introduced the different transformations, their main instantiation shall be described. An instantiation corresponds to the way the objects modified by the transformation are selected. While defining orthogonal transformations (that is, transformations inducing disjoint neighborhoods) enables to diversify the search and then reach better-quality solutions, specializing transformations according to specificities of the problem (because random choices are not the most appropriate in all situations) enables to intensify the search and then speed up the convergence of the heuristic. The transformations on operations are grouped into the following types: insertion, deletion, ejection, move, swap (see Figure 3). Two kinds of insertion are defined: the first kind consists in inserting an operation (pickup or delivery) into an existing shift; the second consists in inserting a pickup followed by a delivery into a shift (the inserted plant is chosen to be one of the nearest from the inserted customer). The deletion consists in deleting a block of operations (that is, a set of
Benoist et al.: Real-life inventory routing c 0000 INFORMS Transportation Science 00(0), pp. 000–000, ⃝
13
consecutive operations) in a shift. An ejection consists in replacing an existing operation by a new one on a different site. The move transformation consists in extracting a block of operations from a shift and reinserting it at another position. Two kinds of moves are defined: moving operations from a shift to another one, or moving operations inside a shift. A swap exchanges two different blocks of operations. As for moves, several kinds of swaps are defined: the swap of blocks between shifts, the swap of blocks inside a shift, or the “mirror” which consists in a chronological reversal of a block of operations in a shift. The mirror transformation corresponds to the well-known 2-opt improvement used for solving traveling salesman problems (see Aarts and Lenstra (1997) for more details). insertion
deletion
ejection
move inside shift
move between shifts
swap between shifts
block
swap inside shift
mirror
Figure 3 The transformations on operations. Note. Original tours are given by straight arcs, dashed arcs are removed by the transformation, curved and vertical arcs are added by the transformation.
The transformations on shifts are grouped into the following types: insertion, deletion, rolling, move, swap. As for operations, two kinds of insertion are defined: insertion of a shift containing one operation (pickup or delivery), insertion of a shift with a pickup followed by a delivery. Deletion consists in removing an existing shift. The rolling transformation translates a shift over time. The move consists in extracting a shift from the planning of some of its resources and reinserting it into the planning of other ones (such a transformation allows to change some of the resources of the shift and its starting date). The swap is defined similarly: the resources of the shifts are exchanged and their starting dates can be translated over time. The fusion of two consecutive shifts into one new shift as well as the separation of one shift into two new ones are also available. Now, these transformations are declined from different ways. The first option concerns the maximal size of blocks for transformations where blocks of operations are involved. In this way, more generic transformations are defined allowing a larger diversification if needed: the (k, l)-ejection which consists in replacing k existing operations by l new ones on different sites, the k-move which consists in moving a block of k operations, the (k, l)-swap which consists in exchanging a block of k operations with a block of l operations, or the k-mirror which consists in reversing a block of k operations.
14
Benoist et al.: Real-life inventory routing c 0000 INFORMS Transportation Science 00(0), pp. 000–000, ⃝
Then, the second option allows to specialize some transformations. These derivations involve the choice of the sites affected by the transformations. For example, inserting a delivery serving a customer without expected stockout in the considered horizon is not interesting when minimizing the number of stockouts. In the same way, exchanging two operations which are performed on sites which are very distant is unlikely to succeed when optimizing the logistic ratio. Several derivations have been designed, which differ slightly from one transformation to another. Here are given the two main derivations, essentially used when inserting/ejecting operations or inserting/rolling shifts: “stockout” which places the delivery so as to solve a stockout, “nearest” where the customers to be inserted or exchanged are chosen among the nearest ones. The third option corresponds to the direction used to recompute all the dates of the modified shifts: backward over time by considering the ending date of the shift as fixed, or forward over time by considering its starting date as fixed. This option is available for all transformations, except the deletion of shifts. For the transformations modifying two shifts at once (for example, move operations between shifts), this results in four possible instantiations: backward/backward, backward/forward, forward/backward, forward/forward. Finally, the fourth option allows to augment the number of operations whose quantities are modified during the volume assignment. Recomputing operation quantities during the volume assignment increases its running time but allows repairing stockouts possibly introduced by the transformation, increasing the acceptation rate of the transformations (more details are given in the next section about volume assignment). The reader shall note that no very large-scale neighborhood is employed. Roughly speaking, the neighborhood explored here has a size O(n2 ) with n the number of operations and shifts in the current solution, but the constant hidden by the O notation is large. The number of transformations in TSO and TLR used respectively in optimization phases SO and LR are of 49 and 71. For each optimization phase, the transformation to apply is chosen randomly with equal probability over all transformations of the pool (improvements being not really significant, further tunings with non-uniform distribution have been abandoned to facilitate maintenance and evolutions). 5.3. Algorithms & implementation Finally, the kernel of the local search is outlined. Playing a central role in the efficiency of the local-search heuristic, only the evaluation procedure is detailed here. For each transformation, this procedure follows the same process: 1. Transforming the current solution. The transformation modifies shifts and operations. Resource/resource and resource/site compatibility is checked. 2. Scheduling shifts. Modified shifts are rescheduled in order to compute the new dates. Timewindows, shift overlapping constraints and driver regulations are taken into account. 3. Assigning volumes. Delivered or pickup quantities are recomputed for a limited number of sites including the modified ones. Inventories are updated and the number of stockouts SO is computed. Roughly speaking, the objective of the scheduling routine is to build shifts with smallest costs, whereas the volume assignment tends to maximize the quantity delivered to customers. Even approximately, this leads to minimize the surrogate logistic ratio. Although conceptually simple, the practical implementation of these routines are considerably complicated by incremental aspects. First, the evaluation is implemented so as to work only on objects (operations, shifts, sites, resources) impacted by the transformation. Besides, all dynamic data associated to these objects are duplicated into backup ones, which correspond to the solution before transformation, and current ones, which correspond to the solution after transformation. This duplication allows to have simpler and faster rollback/commit procedures, whose efficiency is also of importance in the present context.
Benoist et al.: Real-life inventory routing c 0000 INFORMS Transportation Science 00(0), pp. 000–000, ⃝
15
5.3.1. Scheduling shifts. The transformations modify some shifts in the current solution (at most two actually). When a shift is impacted by a transformation (for example, an operation is inserted into the shift), the starting and ending dates of its operations must be computed anew. Consider the shift s = (o1 , . . . , on ) and assume that an operation o¯ is inserted into s between operations i and j. The resulting shift s¯ is now composed of operations (o1 , . . . , oi , o¯, oj , . . . , on ). Then, we have two possibilities: rescheduling dates forward or rescheduling dates backward. The forward (resp. backward) scheduling consists in fixing the ending date of oi (resp. the starting date of oj ) in order to recompute the starting (resp. ending) dates of (¯ o, . . . , on ) (resp. (o1 , . . . , o¯)). Here computing dates can be done without assigning volumes to operations, because the durations of operations do not depend on delivered/loaded quantities. Since computing dates backward or forward is made completely symmetric by representing shifts with doubly-linked lists, the discussion shall be reduced to the forward case. More formally, we have to solve the following decision problem, called Shift-Scheduling: given a starting date for the shift s = (o1 , . . . , on ), determine the dates of each operation such that the shift is admissible. Two equivalent optimization problems are: having fixed its starting date, build a shift with the earliest ending date or with the minimum cost. A similar problem, called Truckload-Trip-Scheduling, has been recently studied by Archetti and Savelsbergh (2007). This latter problem is more restricted in the sense that only one opening time window is considered for each location to visit and that the rest time must be equal to (not greater than) the legal duration. Archetti and Savelsbergh (2007) sketch a O(n2 )-time algorithm for solving the truckload trip scheduling problem, with n the number of locations to visit. For the sake of efficiency, a linear-time and space algorithm has been designed for solving heuristically the Shift-Scheduling problem. Algorithm Schedule-Shift-Greedy; Input: an instance of Shift-Scheduling; Output: an admissible shift if any, null otherwise; Begin; define an empty shift; for each location to visit do drive to next location (by taking rests as late as possible if needed); if waiting time is needed (due to opening time windows) then if rest time has been taken on current arc then lengthen one of the rests to absorb waiting time; else if a rest is needed (due to waiting time) or waiting time is larger than rest time then take a rest (absorbing additional waiting time if any); else wait for the opening of location; perform operation at next location and add it to the shift; if maximal amplitude of the shift is exceeded then return null (infeasibility); return the shift (feasibility); End;
This algorithm is greedy in the sense that operations are chronologically set without backtracking. Each loop is performed in constant time and space (if rests are not stored explicitly) and the whole algorithm runs in O(n) time and space. The correctness of the algorithm is ensured by construction. The key of the Shift-Scheduling problem is to minimize unproductive time over the shift. Thereby, the main idea behind the algorithm is to take rests as late as possible during the trip and to avoid waiting time due to opening time windows of locations as much as possible. Here we try to remove waiting time by converting it into rest time (see Figure 4), but only on the current arc, which is suboptimal. Indeed, the algorithm could be reinforced by trying to convert waiting time into rest time on previous arcs (as done by Archetti and Savelsbergh (2007)). But
Benoist et al.: Real-life inventory routing c 0000 INFORMS Transportation Science 00(0), pp. 000–000, ⃝
16
such a modification would lead to a quadratic-time algorithm, which is not desired here, while not guaranteeing optimality because of multiple opening time windows. On the other hand, we have observed that waiting time is rarely generated in practice since many trips are completed in a day or even half a day, ensuring optimality of the algorithm Schedule-Shift-Greedy in most cases. Note that to our knowledge, the complexity of the Shift-Scheduling problem remains unknown. opening hours of cj preTripTime
postTripTime
ci
cj
delivery
layover preTripTime
waiting postTripTime
ci delivery Figure 4
delivery
cj layover
delivery
An example with waiting time converted into rest time.
5.3.2. Assigning volumes. Having rescheduled modified shifts, we have to reassign quantities to impacted operations. Having fixed the dates of all operations, the problem consists in assigning volumes such that inventory constraints are respected, while maximizing the total delivered quantity over all shifts. A similar problem, called Delivery-Volume-Optimization, has been addressed by Campbell and Savelsbergh (2004b). In this problem, the authors consider only deliveries on routes and not loadings, but this one is complicated by the fact that the duration of an operation depends on the quantity delivered. From the theoretical point of view, the present problem, called Volume-Assigning, is not so hard once observed that it can be formulated as a maximum flow problem (in a directed acyclic network). Then, this one can be solved in O(n3 ) time by using a classical maximum flow algorithm (Cormen et al. 2004, pp. 625–675), with n the number of operations. As mentioned previously, such a time complexity is not desirable here, even if guaranteeing an optimal volume assignment. Practically, naive implementations having a time complexity depending on the number H of time steps (360 in practice) are prohibited too; indeed, when the granularity becomes smaller than one day, the number of time steps exceeds largely the number of operations at a site (two per day in the worst case). Thus, a O(n log n)-time greedy algorithm has been designed to solve approximately the VolumeAssigning problem. The main idea behind the algorithm is simple: having ordered operations chronologically (that is, according to increasing starting dates), quantities are assigned to operations in this order following a greedy rule. Here we use the basic rule consisting in maximizing the quantity delivered/loaded at each operation, which is a good policy for minimizing the surrogate logistic ratio (this joins the ideas developed by Campbell and Savelsbergh (2004b)). Note that the chronological ordering is crucial for ensuring the respect of constraints related to inventory dynamics (flow conservation, capacity constraints). In graph-theoretical terms, the algorithm consists in pushing flow in the induced directed acyclic network following a topological order of the nodes (ensuring that no node is visited twice). Because the number of operations may be large (as worst case in practice, one can imagine that the 1500 customers must be delivered two times per day, leading to n = 45 000), a tradeoff must be found between the time complexity (even linear) and the quality of the volumes assignment. To introduce flexibility on this point, the greedy algorithm has been designed for computing partial reassignments, from the minimal one to the complete one. The minimal reassignment consists in changing only the volumes on impacted operations (that is, operations whose starting dates are
Benoist et al.: Real-life inventory routing c 0000 INFORMS Transportation Science 00(0), pp. 000–000, ⃝
v
P p0
17
L
l l
c0 c1
L
l C
c2 L tl0
tl1
U H Figure 5 An example of flow network for assigning volumes. Note. Operations are represented by nodes, input flows L correspond to initial levels for each inventory (trailer, customer, plant), input flow C (resp. P ) corresponds to consumption of customer c1 (resp. production of plant p0 ) over the time steps between the current operation and the previous one, flows l correspond to inventory levels (trailer, customer, plant) between two operations, flow v allows an overflow at plant (venting). Flows on arcs representing inventory levels are upper bounded by the capacity of the inventory; for customers, flows are also lower bounded by safety levels. Note that if some consecutive operations appear over the same time step (like the ones dotted around), input flows corresponding to consumption or production are cumulated at the last operation of this time step.
modified by the transformation); then, it suffices to tag as impacted some additional operations to expand the reassignment. This complicates notably the practical implementation of the greedy algorithm. Indeed, changing the quantity delivered at an operation is delicate since increasing (resp. decreasing) the quantity may imply overflows (resp. stockouts) at future operations. Then, determining the (maximum) quantity to deliver/load at each operation is not straightforward. For each site p, denote by n ¯ p the number of operations between the first impacted operation (that is, whose quantity can be modified by the transformation) in the chronological ordering and the last ¯ p = 0. Hence, we define ∑ one over the horizon. If no operation is impacted at site p, then n n ¯ = pn ¯ p . When the set of impacted operations consist only in operations whose dates are modified by the transformation, one can observe in practice that n ¯ ≪ n, since each transformation modify at most two shifts (the number of sites visited by one shift is generally small). Consequently, it is important to provide algorithms whose running time is linear in O(¯ n), and not only in O(n). Below is outlined an O(¯ n log n ¯ )-time algorithm for assigning volumes. But before, more explanations are given on how the maximum deliverable quantity is computed (the maximum loadable quantity can be obtained in a symmetric way). Denote by customerLevel (c, i) (resp. trailerLevel (r, i)) the level of customer c (resp. trailer r) before starting the operation i and by avoidOverflow (c, i) the maximum quantity that can be delivered to customer c at operation i without inducing overflows until the end of the horizon. In this way, the deliverable quantity at operation i, denoted by deliverable(i), is upper bounded by min{trailerLevel (r, i), avoidOverflow (c, i)}. Then, this bound is reinforced in such a way that the quantity remaining in the trailer after a delivery is sufficient to avoid stockouts at customers visited by the shift until the next loading. Denote by avoidStockout(c, i) the minimum quantity to deliver at operation i to avoid stockout until the end of the horizon. Now, the minimum quantity neededAfter (r, i) which must remain in the trailer r after operation i to avoid stockout later is obtained by summing avoidStockout(c, i) for all operations between the current one and the next loading. Then, we have deliverable(i) ≤ min{trailerLevel (r, i) − neededAfter (r, i), avoidOverflow (c, i)}
Benoist et al.: Real-life inventory routing c 0000 INFORMS Transportation Science 00(0), pp. 000–000, ⃝
18
Given the chronological-ordered list of operations for each trailer, customer and plant, all the data structures mentioned above can be computed in O(¯ n) time. Updating customerLevel (c, i) (resp. trailerLevel (r, i)) for any operation i is done by sweeping forward the operations delivering customer c (resp. performed by the trailer r). Then, updating avoidOverflow (c, i) and avoidStockout(c, i) for any operation i is done by sweeping backward the operations performed at customer c (note that the consumption between two operations is obtained in constant time by storing cumulated consumptions over the horizon). Finally, computing neededAfter (r, i) for any operation i is done by sweeping backward the operations of shifts performed by r. Below is given a sketch of algorithm. Algorithm Assign-Volumes-Greedy; Input: the set E of n ¯ impacted operations; Begin; sort the set E chronologically; update customerLevel , trailerLevel , avoidOverflow , avoidStockout, neededAfter ; for each operation in E do assign the maximum deliverable/loadable quantity to the operation; End;
A basic example is given for illustrating the reset of delivered quantities and the update of data structures. A customer has 4 scheduled operations A = (4, 2), B = (10, 5), C = (14, 8), D = (18, 12) with the first number denoting the time step to which the operation occurs and the second number denoting the delivered quantity. Here the horizon is composed of 24 time steps. The capacity of the tank is 14 and the safety level is 2. Table 1 gives for each time step h the forecasted consumption (second line) and the resulting tank level (fourth line). Then, values in data structures avoidStockout and avoidOverflow are detailed. These values are computed backward over the horizon by applying the following recurrence: avoidStockout(h) = max{avoidStockout(h + 1), safetyLevel − customerLevel (h) + consumption(h)} avoidOverflow (h) = min{avoidOverflow (h + 1), capacity − customerLevel (h) + consumption(h)} Now, let us consider that operation B is impacted by a transformation: only the quantity of operation B can be modified. The delivered quantity of operation B is reset to zero. Then, for assigning a new quantity to operation B, only the values of column 10 have to be updated: customerLevel (10) is decreased by 5, while avoidStockout(10) and avoidOverflow (10) are increased by 5. In this way, the new (temporary) values are: customerLevel (10) = 2, avoidStockout(10) = 4 and avoidOverflow (10) = 6. It means that a minimal quantity of 4 has to be delivered to avoid stockouts over the horizon (here time step 17 is critical) and a maximal quantity of 6 can be delivered without implying overflows (here time step 18 is critical). We insist on the fact that the other columns will only be updated if the transformation is eventually committed. Table 1 h
Data structures for assigning volumes. 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23
consumption delivery customerLevel avoidStockout avoidOverflow
0 1 0 1 1 1 - 2 13 12 12 11 12 11 0 0 0 0 0 0 1 1 1 1 1 1
2 9 0 1
3 6 0 1
2 4 0 1
2 2 0 1
0 5 7 -1 1
1 6 -1 1
1 5 -1 1
1 2 - 8 4 10 -1 -1 1 1
1 9 -1 1
3 6 -1 1
3 2 2 1 - 12 3 13 11 10 -1 -3 -3 -3 1 1 3 4
2 8 -3 6
3 5 -3 9
0 5 -3 9
According to the previous discussion, the five data structures which serve to the calculation of the maximum deliverable/loadable quantity are updated in O(¯ n) time (recall that barn is the number
Benoist et al.: Real-life inventory routing c 0000 INFORMS Transportation Science 00(0), pp. 000–000, ⃝
19
of impacted operations). Then, sorting the set E is done in O(¯ n log n ¯ ) time in the worst case; in effect, the heapsort algorithm is used (see Cormen et al. (2004, pp. 121–137)). Finally, the loop is done in linear time, since the calculation of the maximum deliverable/loadable quantity requires only constant time by using the adequate data structures. Consequently, the whole algorithm runs in O(¯ n log n ¯ ) time. In theory, the greedy algorithm is far from being optimal. Figure 6 gives the smallest configuration for which the greedy algorithm fails to find an optimal assignment. On the other hand, two sufficient conditions hold for which the greedy assignment is optimal. The proofs are not detailed here because easy to establish. The first condition corresponds to the case where each customer is served at most once over the planning horizon. This condition is interesting because likely to be met in practice. The second condition corresponds to the case where each shift visits only one customer. For example, this condition is satisfied when customers have infinite storage capacity. Experiments have been made for evaluating the practical performance of this critical routine. In practice, its running time is shown to be constant with respect of the total number of operations: it is 100 times faster than the full application of the greedy algorithm (that is, considering that all operations are impacted, implying that n ¯ = n) and 2000 times faster than exact algorithms (tests conducted with the simplex algorithm of the linear programming library GLPK 4.24). On the other hand, the total volume delivered by the routine is close to the optimal assignment, in particular when no stockout appears (the average gap between the greedy assignment and an optimal one is lower than 2 %). o1 c1 o2
o0
c0
tl0
tl1 U
Figure 6
H
Bad configuration for the greedy volume assignment.
Finally, having assigned volumes, computing the gain of the transformation is done efficiently. The (variation of) cost of shifts is computed during the scheduling, and the (variation of) total delivered quantity is obtained during the assignment of volumes, without increasing the complexity of the algorithms. The (variation of) stockouts costs are also computed during the assignment of volumes. Note that computing the number of time steps in stockout between two consecutive operations requires O(log H ) time, with H the number of time steps over the horizon, since it is equivalent to the problem of searching the zero of a discrete non-increasing function. 5.3.3. Implementation details. All sets (unordered or ordered, fixed or dynamic) are implemented as arrays, in order to improve the cache memory locality. Memory allocation is avoided as much as possible during local-search iterations: all the data structures are allocated before starting the local search; an array of capacity n representing a dynamic list is extended if necessary by reallocating a larger block of memory of size n + k (with k ≈ 10). Since the success rate of transformations is low on average (a few percents), the rollback routine must be very efficient. In this way, the decision variables of the problem (for example, the starting and ending dates of an operation) are duplicated in such a way that only temporary data are modified by a transformation. In this way, the rollback routine consists simply in overwriting temporary data by current ones (that is, corresponding to the current solution). But this is complicated by the fact that during one transformation, several objects (in particular operations or shifts) are likely
Benoist et al.: Real-life inventory routing c 0000 INFORMS Transportation Science 00(0), pp. 000–000, ⃝
20
to move in the arrays in which they are stored. In order to ensure the (temporary) insertion or deletion of one object in O(1) time, the objects of the array are doubly linked (see Figure 7 which illustrates the exchange of operations between shifts). oi,0
oi,1
oi,2
oi,3
oi,4
oi,5
oi,6
oi,7
si
sj oj,0 oj,1 oj,2 oj,3 oj,4 oj,5 oj,6 oj,7 Figure 7 Representation of shifts and operations. Note. Operations oi,3 , oi,4 of the shift si are swapped with operations oj,3 , oj,4 of the shift sj : the current links (before transformation) are plain, the temporary links (after transformation) are dashed.
The main data structures are designed to support basic routines (find, insert, delete, clear) in O(1) time, even if they are implemented as arrays. An example is the classical data structure used to implement an unordered list of objects. For example, this one is used to store the customers experiencing stockouts in the current solution. The unordered list is implemented as an array L, with L.size the current number of elements in L and L.capacity the capacity of L (that is, the maximum number of elements which can be stored in the list without exceeding allocated memory). Any element e stored in L has a pointer e.indexL to its position in the array L. If the maximal number of elements e stored in L is known a priori and is not too large (a few thousand), then L can be allocated with a capacity equal to this number (to avoid frequent memory allocations), otherwise the extension of L is done by increasing its capacity by L.increase elements when needed. Classically, the routines Find, Insert, Delete, and Clear are implemented as follows to run in O(1) time (note that the elements in L are indexed from 0): Algorithm Find; Input: the array L, the element e to find; Output: true if e belongs to L, false otherwise; Begin; i = e.indexL; if i ≥ 0 and i < L.size and L[i] = e then return true; return false; End; Algorithm Delete; Input: the array L, the element e to delete; Begin; if not Find(L,e) then return; i = e.indexL, e′ = L[L.size − 1]; L[i] = e′ , e′ .indexL = i, L.size = L.size − 1; End;
Algorithm Insert; Input: the array L, the element e to insert; Begin; if Find(L,e) then return; if L.size = L.capacity then; L.capacity = L.capacity + L.increase; reallocate L with the new L.capacity; L[L.size] = e, e.indexL = L.size, L.size = L.size + 1; End; Algorithm Clear; Input: the array L; Begin; L.size = 0; End;
To end the section, we focus on a data structure which is particularly critical for efficiency. Operations or shifts correspond to intervals over the horizon, for which we have the following need: given a date over the horizon, find the previous, current, or next operation performed at a site if any. The same problem arises for situating shifts performed by a resource. For this, the following data structure is employed. Assume that the n operations are stored into an ordered list L. The horizon is divided into m intervals U0 , . . . , Um−1 of given length u (with u dividing T ). Then, an array I is defined such that Ii refers to the first operation whose starting date is larger than the
Benoist et al.: Real-life inventory routing c 0000 INFORMS Transportation Science 00(0), pp. 000–000, ⃝
21
left endpoint of Ui . The next operation after date d is found by searching the operations between the one pointed by Ii with i = ⌊d/u⌋ and the one pointed by Ii+1 . In this way, the search is done in O(k) time in the worst case, with k the number of operations contained in the interval Ui . If u corresponds to the entire horizon (m = 1), then k = n; on the other hand, if u corresponds to the smallest granularity for expressing time (here the minute, leading to m = 21600), then k = 1. Assuming that starting dates of operations performed at a site are uniformly distributed over the horizon, the number k is equal to n/m. In this case, searching takes O(n/m) time (when evaluating the transformation), but the array I requires O(m) space to be stored and O(m) time to be updated (when committing the transformation). This implies two compromises: time to evaluate vs. time to commit, time to evaluate vs. space. Theoretically, the best value m∗ for solving the compromise on running time corresponds to the minimum of the function T (m) = E(N/m) + Cm, with N the average number of operations per customer and E (resp. C) a coefficient relative to the proportion of calls of the evaluate routine (resp. commit routine) per customer. A simple calculation using differentiation yields m∗ = √ (EN )/C. Table 2 shows the values of m∗ for different realistic configurations of parameters N, E, C. In practice, we have chosen m∗ = 15, which corresponds to interval Ui of one day: such a value of m offers a good compromise for running time (even in worst-case situations) and leads to a small memory footprint.
Table N E C m∗
6.
2 2 90 10 4.2
Theoretical values of m∗ . 2 2 10 10 10 30 30 30 95 99 90 95 99 90 95 99 5 1 10 5 1 10 5 1 6.2 14.1 9.5 13.8 31.5 16.4 23.9 54.5
Computational experiments
The whole algorithm was implemented in C# 2.0 programming language (for running on Microsoft .NET 2.0 framework). The resulting program includes nearly 30 000 lines of code, whose 6 000 lines (20 %) are dedicated to check the validity of all incremental data structures at each iteration (only active in debug mode). The whole project (specifications, implementation, tests), realized during the year 2008, required nearly 300 man-days. All statistics and results presented here have been obtained (without parallelization) on a computer equipped with a Windows Vista operating system and a chipset Intel Xeon X5365 64 bits (CPU 3 GHz, L1 cache 64 Kio, L2 cache 4 Mio, RAM 8 Go). The interested reader is invited to contact the authors to obtain some benchmarks to work on this problem. Note that the urgency-based constructive heuristic used to compute an initial solution is also called “greedy algorithm” below. Since the local-search heuristic is randomized, 5 runs have been performed with different seeds for each benchmark. All results are presented in terms of cost (or cost per kilo) but it shall be noted that around 80 to 90% of the cost is proportional to the traveled distance, which means that our algorithm is likely to obtain similar gains in absence of fix costs (with a miles per ton objective). Except contrary mention, all the statistics presented below correspond to average results obtained for these 5 runs. Note results requiring particular explanations are marked with asterisks (∗ ) in figures presenting numerical experiments; these explanations could be found in the text below.
22
Benoist et al.: Real-life inventory routing c 0000 INFORMS Transportation Science 00(0), pp. 000–000, ⃝
6.1. Short-term benchmarks The local-search algorithm has been extensively tested on short-term benchmarks (15 days) with different characteristics: realistic (that is, matching the operational conditions), pathological (for example, with plants whose production is stopped several days), large-scale (for example, with 1 500 sites and 300 resources). Some aggregated results are presented here for 17 short-term benchmarks involving from 46 to 500 customers. Table 3 gives the characteristics of these instances: the number of customers, the number of plants, the number of depots, the number of drivers, the number of tractors, the number of trailers. For these instances, our greedy algorithm finds a solution without stockout. Note that it is not always the case in production (see results on long-term benchmarks). The results obtained by the local-search heuristic are presented in Table 4 using the results of the greedy algorithm as a reference. Two kinds of results are presented on this table: the results obtained by optimizing directly the logistic ratio LR (denoted by LS-LR) and the ones obtained by optimizing the surrogate ratio LR ′ (denoted by LS-LR ′ ). In both cases (LS-LR or LS-LR ′ ), the local-search heuristic improves drastically the quality of solutions provided by the greedy algorithm. The average gain obtained by LS-LR (resp. LS-LR ′ ) is of 29.2 % (resp. 22.6 %). Table 5 gives more statistics on the solutions found by local search. The column “nb shift” (resp. “nb oper”) of the table reports the number of shifts (resp. operations) of the solution. The column “avg oper” (resp. “avg deliv”, “avg load”, “avg layov”) reports the average number of operations (resp. deliveries, loadings, layovers) per shift. Finally, the column “avg dur” (resp. “avg dist”) reports the average traveled distance (resp. duration) per shift. One can observe that more shifts and much more operations are included in both LS-LR and LS-LR ′ solutions (compared to solutions produced by the greedy). On average, the number of shifts (resp. operations) is increased of nearly 25 % (resp. 50 %). In this way, the average number of operations per shift is increased from almost 4 to more than 6. The average distance and duration of shifts are decreased slightly in the case of LS-LR, whereas these ones are increased slightly in the case of LS-LR ′ . The greedy algorithm takes a few seconds even for large-scale instances (12 seconds for a test case with 1500 customers). Statistics about the performance of the local search are given on Table 6. The column “attempt” corresponds to the number of transformations attempted by the localsearch heuristic. The columns “accept” (resp. “improve”) corresponds to the number of accepted (resp. strictly improving) transformations; in addition, the corresponding rate for 100 (resp. 10 000) attempted transformations is specified. The local-search algorithm attempts more than 10 000 transformations per second, even for large-scale instances. On average, our algorithm visits more than 10 million solutions in the search space during 5 minutes of running time (which is the desired time limit in operational conditions). When planning over a 15-days horizon, the memory allocated by the program does not exceed 30 Mo for medium-size instances (hundred sites, ten resources), and 300 Mo for large-scale instances (thousand sites, hundred resources). The acceptance rate, which corresponds to the number of accepted transformations (that is, transformations not strictly improving the current solution) over the number of attempted ones, varies essentially between 1 and 10 %, with an average value close to 5 % over all the instances. Note that this rate is quasi constant all along the search (that is, during the 5 minutes of running time), allowing a large diversification of the search (without the use of metaheuristics). On the other hand, the number of strictly improving transformations is of several hundreds, which corresponds to a rate of nearly 2 improvements for 10 000 attempts. One can observe that the choice of objective (LR or LR ′ ) does not affect the performance of the local-search heuristic. 6.2. Long-term benchmarks The local-search algorithm has been also tested on long-term benchmarks, in particular for verifying that optimizing the surrogate objective leads to better solutions on the long run. Some results are presented for 5 real-life benchmarks, each one with 105 days. The operational planning process
Benoist et al.: Real-life inventory routing c 0000 INFORMS Transportation Science 00(0), pp. 000–000, ⃝
23
is simulated as follows. The simulator starts at day 0 by computing a planning over the next 15 days, with 5 minutes as time limit. Then, only the shifts starting at the first day of this shortterm planning are fixed (the levels of plants or customers visited by these shifts are updated, the resources operating on these shifts become unavailable) and the process is iterated the following day. The characteristics of these 5 benchmarks are presented on Table 8. The complete statistics are given for each heuristic on Tables 9, 10, and 11. The main remark is that the average number of operations per shift is increased in local-search solutions. Indeed, the number of shifts in localsearch solutions is slightly smaller than in greedy solutions, whereas the number of operations is increased. Besides, local-search solutions are characterized by a larger average traveled duration per shift, thanks to an increased use of layovers. The average logistic ratios marked by an asterisk are computed as the sum of shift costs for the 5 benchmarks divided by the sum of all delivered quantities. The gains obtained by LS-LR ′ are reported on the right part of Table 8. The column “wst 1 mn” reports the worst LR gain in % obtained over the 5 runs for 1 minute of running time per planning iteration. The column “avg 1 mn” (resp. “avg 5 mn”, “avg 1 h”) reports the average gain in % for LR obtained by local search limited to 1 minute (resp. 5 minutes, 1 hour) of computation per planning iteration. Note that the solutions found by the greedy algorithm include some stockouts. On average, the LR gain obtained by LS-LR ′ with only 1 minute of running time per planning iteration is of nearly 20 % on average. More than providing high-quality solutions, these statistics demonstrate that our local-search heuristic is robust and fast (with an exponentialinverse convergence). Solutions provided by logistic experts are reported on Table 13. Note that the comparison between the experts and the three heuristics is not completely fair. Indeed, because finding solutions with no stockout (with actual safety levels) was difficult and fastidious, experts were allowed to modify the initial long-term benchmarks in order to provide solutions without stockout. This could explain the negative gain of greedy algorithm on instances L1, L2, L4. Moreover, the solution provided by experts for instance L2 is considered as a “best-effort” solution, in the sense that many more time has been spent to optimize carefully the solution. 6.3. Impact of the surrogate objective The key figures for comparing LS-LR and LS-LR ′ are given on Table 7 (for short-term benchmarks) and on the right part of Table 12 (for long-term benchmarks). “avg DQ” corresponds to the average total delivered quantity, and “avg delivq” to the average delivered quantity (per operation). On short-term benchmarks, the total delivered quantity in both LS-LR and LS-LR ′ solutions is increased by more than 50 % on average. But note that the average quantity per delivery is increased by almost 5 % in LS-LR ′ solutions compared to LS-LR solutions. On long-term benchmarks, one shall observe that LS-LR ′ aims at increasing the average quantity per delivery, which results in better long-term solutions. On instances L1 (resp. L2), the augmentation is of 21 % (resp. 13 %), leading to logistic ratio savings of 10 % (resp. 7 %) compared to LS-LR. Moreover, LS-LR ′ is able to produce solutions without stockout on the instance L4, contrary to LS-LR. The values marked by an asterisk on Tables 12 and 13 are computed globally, for the 5 benchmarks (as done for logistic ratios on Tables 10 and 11).
7.
Conclusion
Three contributions have been presented in this paper. First a real-life IRP problem encountered in a worldwide industry has been introduced and modeled. Then, a surrogate objective based on local lower bounds was defined for ensuring a long-term optimization when building a planning over the short term. Our experiments show that using this objective decreases the final logistic cost by 6% on average, compared to a direct minimization of the logistic ratio. Finally, a local-search heuristic
24
Benoist et al.: Real-life inventory routing c 0000 INFORMS Transportation Science 00(0), pp. 000–000, ⃝
has been described for solving effectively and efficiently the real-life IRP over the short term (15 days in full details), even when some large-scale instances (thousand sites, hundred resources) are considered. By assigning volumes approximately but thousands times faster than with a classical flow algorithm, we are able to handle the problem as a whole, without decomposition. Using a large large variety of neighborhoods, our first-improvement descent visits millions of solutions during the allocated execution time. In 5 minutes, we obtain long-term savings of 20 % on average compared to urgency based strategies used by expert planners or implemented in classical chronological heuristics. The resulting decision support system is progressively deployed worldwide, confirming the promised gains in the field. New researches are still conducted in several directions: • further enlarging the scope of the IRP problem addressed in the paper (in particular, refining costs and managing drivers’ desiderata); • improving the existing local-search heuristic (adding transformations with larger neighborhoods for speeding up convergence); • reinforcing the global lower bound by integrating tours visiting several sites and constraints on resources. Another prospective, but promising, line of research is to proceed step by step toward a global optimization of the supply chain, by tackling jointly the production and distribution problems and finally by integrating purchasing issues. Indeed, we think that local-search approaches like the one developed presently are best suited for solving such very large-scale problems.
References Aarts, E., J. Lenstra, eds. 1997. Local Search in Combinatorial Optimization. Wiley-Interscience Series in Discrete Mathematics and Optimization, John Wiley & Sons, Chichester, England. Archetti, C., M. Savelsbergh. 2007. The truckload trip scheduling problem. TRISTAN VI, the 6th Triennial Symposium on Transportation Analysis. Phuket Island, Thailand. Bard, J.F., F. Huang, M. Dror, P. Jaillet. 1998. A branch and cut algorithm for the vrp with satellite facilities. IIE Transactions 30(9) 831–834. Bell, W., L. Dalberto, M. Fisher, A. Greenfield, R. Jaikumar, P. Kedia, R. Mack, P. Prutzman. 1983. Improving the distribution of industrial gases with an on-line computerized routing and scheduling optimizer. Interfaces 13(6) 4–23. Benoist, T., B. Estellon, F. Gardi, A. Jeanjean. 2009. High-performance local search for solving inventory routing problems. H. Hoos T. St¨ utzle, M. Birattari, ed., SLS 2009, the 2nd International Workshop on Engineering Stochastic Local Search Algorithms, Lecture Notes in Computer Science, vol. 5752. Springer, 105–109. Campbell, A., L. Clarke, A. Kleywegt, M. Savelsbergh. 1998. The inventory routing problem. T. Crainic, G. Laporte, eds., Fleet Management and Logistics. Kluwer Academic Publishers, Norwell, MA, 95–113. Campbell, A., L. Clarke, M. Savelsbergh. 2002. Inventory routing in practice. P. Toth, D. Viego, eds., The Vehicle Routing Problem. SIAM Monographs on Discrete Mathematics and Applications 9, SIAM, Philadelphia, PA, 309–330. Campbell, A., M. Savelsbergh. 2004a. A decomposition approach for the inventory-routing problem. Transportation Sci. 38(4) 488–502. Campbell, A., M. Savelsbergh. 2004b. Delivery volume optimization. Transportation Sci. 38(2) 210–223. Campbell, A., M. Savelsbergh. 2004c. Efficient insertion heuristics for vehicle routing and scheduling problems. Transportation Sci. 38(3) 369–378. Cormen, T., C. Leiserson, R. Rivest, C. Stein. 2004. Introduction ` a l’Algorithmique. Dunod, Paris, France. French 2nd edition. Dror, M., M. Ball. 1987. Inventory/routing: reduction from an annual to a short-period problem. Naval Research Logistics 34(6) 891–905.
Benoist et al.: Real-life inventory routing c 0000 INFORMS Transportation Science 00(0), pp. 000–000, ⃝
25
Estellon, B., F. Gardi, K. Nouioua. 2006. Large neighborhood improvements for solving car sequencing problems. RAIRO Operations Research 40(4) 355–379. Estellon, B., F. Gardi, K. Nouioua. 2008. Two local search approaches for solving real-life car sequencing problems. Eur. J. Oper. Res. 191(3) 928–944. Estellon, B., F. Gardi, K. Nouioua. 2009. High-performance local search for task scheduling with human resource allocation. H. Hoos T. St¨ utzle, M. Birattari, ed., SLS 2009, the 2nd International Workshop on Engineering Stochastic Local Search Algorithms, Lecture Notes in Computer Science, vol. 5752. Springer, 1–15. Feo, T., G. Resende. 1995. Greedy randomized adaptive search procedures. Journal of Global Optimization 6(2) 109–133. Lau, H., Q. Liu, H. Ono. 2002. Integrating local search and network flow to solve the inventory routing problem. AAAI 2002, the 18th National Conference on Artificial Intelligence. AAAI Press, Menlo Park, CA, 9–14. Savelsbergh, M., J.-H. Song. 2007a. Inventory routing with continuous moves. Computers and Operations Research 34(6) 1744–1763. Savelsbergh, M., J.-H. Song. 2007b. Performance measurement for inventory routing. Transportation Sci. 41(1) 44–54. Savelsbergh, M., J.-H. Song. 2008. An optimization algorithm for the inventory routing with continuous moves. Computers and Operations Research 35(7) 2266–2282. Solomon, M. 1987. Algorithms for the vehicle routing and scheduling problems with time window constraints. Oper. Res. 35(2) 254–265.
Appendix Table 3
Short-term benchmarks characteristics (17 test cases). customers plants depots drivers tractors trailers minimum 46 1 1 10 5 10 maximum 500 5 2 50 50 50 average 138 1.9 1.2 28 19 25
Table 4
Short-term benchmarks: local search results. LS-LR LS-LR ′ minimum gain over greedy 20.8 % 28.5 % maximum gain over greedy 39.1 % 65.6 % average gain over greedy 29.2 % 45.4 %
Table 5 Short-term benchmarks: statistics on shifts (average over all test cases). algorithm nb shift nb oper avg oper avg deliv avg load avg layov avg dist avg dur greedy 68.6 473.6 4.9 2.8 2.2 0.2 481.8 676.8 LS-LR 91.8 689.6 5.9 3.3 2.6 0.2 399.7 617.5 LS-LR ′ 86.7 692.2 6.4 3.5 2.9 0.2 487.9 708.4
Benoist et al.: Real-life inventory routing c 0000 INFORMS Transportation Science 00(0), pp. 000–000, ⃝
26 attempt accept improve minimum 4.867 M 141 962 2.6 % 497 0.4 h% maximum 16.167 M 705 213 6.6 % 2 067 4.2 h% average 8.596 M 377 169 4.5 % 937 1.3 h%
attempt accept improve minimum 3.706 M 117 333 2.4 % 389 0.5 h% maximum 15.184 M 536 327 6.8 % 2 218 5.2 h% average 7.830 M 303 620 4.1 % 946 1.5 h%
Short-term benchmarks: statistics on transformations for LS-LR (left) and LS-LR ′ (right) optimization. M = million, h% = one-hundredths percent.
Table 6
Table 7
Short-term benchmarks: statistics on volumes.
avg DQ greedy avg DQ LS-LR avg DQ LS-LR ′ avg delivq greedy avg delivq LS-LR avg delivq LS-LR ′ 3 031 400 4 565 518 4 861 465 15 992 16 066 17 073
Table 8 data L1 L2 L3 L4 L5 average
Table 9 data L1 L2 L3 L4 L5 average
Table 10 data L1 L2 L3 L4 L5 average
Table 11 data L1 L2 L3 L4 L5 average
Table 12 data L1 L2 L3 L4 L5
Long-term benchmarks: characteristics and LR gains with different time limits. customers plants depots drivers tractors trailers callins orders 75 6 1 35 21 5 19 56 75 6 1 35 21 5 20 55 175 8 1 35 21 12 36 189 165 4 1 24 11 7 33 167 198 8 7 12 12 12 3 40 138 6 2 28 17 8 22 101
wst 1 mn avg 1 mn avg 5 mn avg 1 h 23.8 % 24.6 % 26.3 % 26.5 % 22.3 % 23.5 % 24.9 % 25.2 % 5.2 % 5.8 % 8.3 % 11.2 % 9.9 % 11.2 % 14.0 % 18.9 % 32.5 % 34.2 % 35.7 % 35.9 % 18.7 % 19.9 % 21.8 % 23.5 %
Long-term benchmarks: greedy results. SO SC 652 406 443 3 146 407 379 3 86 1 092 976 31 257 808 887 18 85 145 339 8 245 572 205 13
DQ 767 868 827 560 989 357 433 289 830 708 369 756
LR 0.107 871 0.106 433 0.034 167 0.043 882 0.016 458 ∗ 0.042 798
nb shift nb oper avg oper avg deliv avg load avg layov avg dist avg dur 189 503 2.7 1.6 1.0 0.6 640 1 320 196 506 2.6 1.6 1.0 0.5 619 1 235 790 3 584 4.5 2.7 1.8 0.2 366 954 590 2 249 3.8 2.4 1.4 0.2 395 844 295 1 020 3.5 1.9 1.5 1.2 598 1 760 412 1 572 3.4 2.0 1.3 0.5 524 1 223
Long-term benchmarks: LS-LR results. SO SC 0 340 767 3 0 335 661 3 0 1 019 292 32 17 697 009 18 0 106 326 9 3 499 811 13
DQ 840 502 899 780 079 238 694 845 475 562 597 985
LR 0.088 730 0.086 072 0.031 774 0.037 283 0.011 221 ∗ 0.036 756
nb shift nb oper avg oper avg deliv avg load avg layov avg dist avg dur 137 590 4.3 3.0 1.3 0.8 721 1 618 148 570 3.9 2.7 1.2 0.7 660 1 445 839 3 570 4.3 2.6 1.7 0.2 317 873 605 2 400 4.0 2.6 1.4 0.2 321 735 110 1 324 12.0 7.8 4.3 3.2 1 256 4 286 368 1 691 5.7 3.7 2.0 1.0 655 1 792
Long-term benchmarks: LS-LR ′ results. SO SC 0 321 449 4 0 321 207 4 0 1 012 191 32 0 701 139 18 0 101 913 9 0 491 580 13
DQ 045 989 016 621 320 180 587 949 630 979 720 344
LR 0.079 449 0.079 969 0.031 318 0.037 720 0.010 582 ∗ 0.035 829
nb shift nb oper avg oper avg deliv avg load avg layov avg dist avg dur 148 542 3.7 2.4 1.3 0.7 632 1 403 140 541 3.9 2.6 1.3 0.7 669 1 471 807 3 583 4.4 2.7 1.8 0.2 327 890 602 2 396 4.0 2.6 1.4 0.2 325 744 138 1 352 9.8 6.3 3.5 2.2 945 3 159 367 1 683 5.2 3.3 1.9 0.8 580 1 533
Long-term benchmarks: gains of LS-LR ′ against LS-LR (left) and gains obtained by local search against greedy (right).
LS-LR ′ against LS-LR 10 % 7% 1% ∗ -1 % 6%
data L1 L2 L3 L4 L5 average
gain LS-LR gain LS-LR ′ 17.7 % 26.3 % 19.1 % 24.9 % 7.0 % 8.3 % 15.0 % 14.0 % 31.8 % 35.7 % ∗ ∗ 14.1 % 16.3 %
avg delivq greedy avg delivq LS-LR avg delivq LS-LR ′ 12 460 9 344 11 391 12 205 9 759 11 035 14 997 14 706 14 833 13 018 11 885 11 876 15 755 11 044 11 078 ∗ ∗ ∗ 14 146 12 537 12 864
Benoist et al.: Real-life inventory routing c 0000 INFORMS Transportation Science 00(0), pp. 000–000, ⃝
Table 13 data L1 L2 L3 L4 L5 average
Long-term benchmarks: gains obtained by local search against logistic experts. SO SC DQ LR gain greedy gain LS-LR gain LS-LR ′ 0 378 778 3 725 847 0.101 662 -6.1 % 12.7 % 21.9 % 0 328 364 3 567 370 0.092 047 -15.6 % 6.5 % 13.1 % 0 1 257 354 32 667 576 0.038 489 11.2 % 17.4 % 18.6 % 0 788 893 18 683 473 0.042 224 -3.9 % 11.7 % 10.7 % 0 290 921 10 398 050 0.027 978 41.2 % 59.9 % 62.2 % ∗ ∗ ∗ 0 608 862 13 808 463 ∗ 0.044 093 2.9 % 16.6 % 18.7 %
27