IP Referece guide for iteger programmig formulatios. by James B. Orli for 15.053 ad 15.058 This documet is iteded as a compact (or relatively compact) guide to the formulatio of iteger programs. For more detailed explaatios, see the PowerPoit tutorial o iteger programmig. The followig are techiques for trasformig a problem described logically or i words ito a iteger program. I most cases, the trasformatio is the simplest to describe. Ufortuately, simplest is ot the same as "best." It is widely accepted that the best iteger programmig formulatios are those that result i fast solutios by iteger programmig solvers. I geeral, these are the iteger programs for which the liear programmig relaxatio provides a good boud. Sectio 1. Subset selectio problems. Ofte, models are based o selectig a subset of elemets. For example, i the kapsack problem, oe wats to select a subset of items to put ito a kapsack so as to maximize the value while ot goig over a specified weight. Or oe wats to select a subset of potetial products i which to ivest. Or, oe has a set of differet itegers, ad oe wats to select a subset that sums to a value K. I these cases, it is typical for the iteger variables to be as follows: 1 if elemet i is selected 0 otherwise. Example: kapsack/capital budgetig. I this example, there are sitems to select from. Item 1 2 3 4 5 6 Cost 5 7 4 3 4 6 Value 16 22 12 8 11 19 Problem: choose items whose cost sums to at most 14 so as to maximize the utility. maximize 16x 1 + 22x 2 +12x 3 + 8x 4 +11x 5 +19x 6 Formulatio: subject to 5x 1 + 7x 2 + 4x 3 + 3x 4 + 4x 5 + 6x 6 14 {0,1} for i = 1 to 6. I geeral: Maximize the value of the selected items such that the weight is at most b. C i = value of item i for i = 1 to. a i = weight of item i for i = 1 to. b = boud o total weight. maximize c i subject to a i b {0,1} for i = 1 to.
Coverig ad packig problems. I some selectio problems, each item is associated with a subset of a larger set. The larger set is usually referred to as the groud set. For example, suppose that there is a collectio of sets 5 1, ", 5 where for i = 1 to 5 i is a subset of the groud set {1, 2, 3, ", m}. Associated with each set 5 i is a cost C i. 1 if i S j 1 if set S j is selected Let a ij Let x j 0 otherwise. 0 otherwise. The set packig problem is the problem of selectig the maximum cost subcollectio of sets, o two of which share a commo elemet. The set Coverig problem is the problem of selectig the miimum cost subcollectio of sets, so that each elemet i E {1, 2, ", m} is i oe of the sets. Maximize c j x j=1 j subject to a x 1 for each i {1,...,m} Set Packig Problem j=1 ij j x j {0,1} for each j {1,...,}. Miimize c j x j=1 j subject to a x 1 for each i {1,...,m} Set Coverig Problem j=1 ij j x j {0,1} for each j {1,...,}. For example, cosider the followig map of the couties of Colorado. Figure 1. The couties of Colorado. Suppose that we wat to select a miimum cardiality subset C of couties such that each couty either was i C or shared a commo boudary with a couty i C. I this case, we would let
5 j = {j} U {i: couty i shares a boudary with couty j}. We let C j = 1 for each j. We would the solve the mi cost coverig problem. Here is a related problem. Select the largest subset CC of couties such that o two couties of CC share a commo border. We refer to this problem as P1. Although P1 is a set packig problem (as you shall soo see) it is ot the set packig problem defied o the sets S 1, S 2, ", S. To see why ot, cosider the followig example. Suppose that couty 1 bordered o couty 2, which bordered o couty 3, but that couties 1 ad 3 had o commo border. The oe ca iclude both couty 1 ad couty 3 i CC. But 2 E S 1 S 3, ad so it would ot be possible to select S 1 ad S 3 for the set packig problem. Problem P1 ca be formulated as follows: Maximize x j=1 j subject to + x j 1 wheever a ij = 1 (i.e., i S j ) Problem P1 x j {0,1} for each j {1,...,}. Sectio 2. Modular arithmetic. I this very brief sectio, we show how to costrai a variable x to be odd or eve, ad we show how to costrait x to be a mod(b). (That is, there is a iteger q such that a + qb = x.) I each case, we eed to add a ew variable w, where w 0 ad iteger. Costrait. IP Costrait s odd. x - 2w = 1. s eve. x - 2w = 0. x = a (mod b) x - bw = a. Table 1. Modular arithmetic formulatios. Sectio 3. Simple logical costraits. Here we address differet logical costraits that ca be trasformed ito iteger programmig costraits. I the first set, we describe the logical costraits i terms of selectio of items from a subset.
Logical Costrait. IP Costrait If item i is selected, the item j is also selected. - x j : 0 Either item i is selected or item j is selected, but ot both. + x j = 1 Item i is selected or item j is selected or both. If item i is selected, the item j is ot selected. + x j 1 + x j : 1 If item i is ot selected, the item j is ot selected. - +x j : 0 At most oe of items i, j, ad k are selected. + x j + x k : 1 At most two of items i, j, ad k are selected. + x j + x k : 2 Exactly oe of items i, j, ad k are selected. + x j + x k = 1 At least oe of items i, j ad k are selected. + x j + x k 1 Table 2. Simple costraits ivolvig two or three biary variables. Restrictig a variable to take o oe of several values. Suppose that we wated to restrict x to be oe of the elemets {4, 8, 13}. This is accomplished as follows. x = 4 w 1 + 8 w 2 + 13 w 3 w 1 + w 2 + w 3 = 1 w i E {0, 1} for i = 1 to 4. If we wated to restrict x to be oe of the elemets {0, 4, 8, 13}, it suffices to use the above formulatio with the equality costrait chaged to "w 1 + w 2 + w 3 : 1." Sectio 4. Other logical costraits, ad the big M method. Biary variables that are 1 whe a costrait is satisfied. We ext cosider biary variables that are defied to be 1 if a costrait is satisfied, ad 0 otherwise. I each case, we eed bouds o how much the costrait could be violated i a solutio that satisfies every other costrait of the problem. 1 if x 1 Example 1. w 0 if x = 0. I this example, s a iteger variable. Ad suppose that we kow s bouded above by 100. (We may kow the boud o x because it is oe of the costraits of the problem. We may also kow the boud of 100 o x because it is implied by oe or more of the other costraits. For example, suppose that oe of the costraits was "3x + 4y + w : 300." We could ifer from this costrait that 3x : 300 ad thus x : 100.
Equivalet costrait: w : x : 100w. w E {0,1}. I ay feasible solutio, the defiitio of w is correct. If x 1, the the first costrait is satisfied whether w = 0 or w = 1, ad the secod costrait forces w to be 1. If x = 0, the the first costrait forces w to be 0, ad the secod costrait is satisfied. Example 2. w = 1 if x 7 0 otherwise. Agai, we assume here that s a iteger variable, ad that s bouded above by 100. Equivalet costraits: x : 7-7(1-w) x : 6 + 94 w w E {0,1}. I ay feasible solutio, the defiitio of w is correct. If x 7, the the first costrait is satisfied whether w = 0 or w = 1, ad the secod costrait forces w to be 1. If x : 6, the the first costrait forces w to be 0, ad the secod costrait is satisfied. Big M: example 1. w = 1 if x 7 0 otherwise. Here we assume that s a iteger variable that is bouded from above, but we doct specify the boud. Equivalet costraits: x : 7 - M(1-w) x : 6 + Mw w E {0,1}, where M is chose sufficietly large. I this way, we doct cocer ourselves with the value of the boud. We just write M. I fact, we could have writte 7 istead of M i the first costrait, ad it would have also bee valid. But writig big M meas ot havig to thik about the best boud. The disadvatage of this approach is that the ruig time of the iteger programmig algorithm may deped o the choice of M. Choosig M very large (e.g., M = 1 trillio) will lead to valid formulatios, but the overly large value of M may slow dow the solutio procedure. Big M: example 2. w = 1 if x a 0 otherwise. Here we assume that s a iteger variable that is bouded from above, but we doct specify the boud. Equivalet costraits: x : a - M(1-w) x : (a-1) + Mw w E {0,1},
where M is chose sufficietly large. I ay feasible solutio, the defiitio of w is correct. If x a, the the first costrait is satisfied whether w = 0 or w = 1, ad the secod costrait forces w to be 1. If x : a-1, the the first costrait forces w to be 0, ad the secod costrait is satisfied. 1 if x a Big M: example 3. w 0 otherwise. Here we assume that s a iteger variable that is bouded from above, but we doct specify the boud. Equivalet costraits: x 5 a - M(1-w) x (a+1) + Mw w E {0,1}, where M is chose sufficietly large. I the case that w depeds o a iequality costrait ivolvig more tha oe variable, the previous two trasformatios ca modified i a straightforward maer. 1 if a i b Big M: example 4. w = 0 otherwise. Here we assume that a i is iteger valued ad is bouded from above, but we doct specify the boud. Equivalet costraits: a i b + M (1 w). a i b +1 Mw. w {0,1}. I ay feasible solutio, the defiitio of w is correct. If a b,, the the first costrait is =1 i i satisfied whether w = 0 or w = 1, ad the secod costrait forces w to be 1. If a i b +1,, the the first costrait forces w to be 0, ad the secod costrait is satisfied. At least oe of three iequalities is satisfied. Suppose that we wated to model the logical costrait that at least oe of three iequalities is satisfied. For example,
x 1 + 4 x2 + 2 x 4 7 or 3 x1-5 x 2 12 or 2 x 2 + x 3 6. We the create three ew biary variables w1, w2, ad w3 ad reformulate the above costrait as the followig system of logical, liear, ad iteger costraits. x 1 If w 1 = 1, the + 4x 2 + 2x 4 7. If w2 = 1, the 3x1-5x2 12. If w3 = 1, the 2x2 + x3 6. w1 + w2 + w3 1. w {0,1} for i = 1 to 3. i This above system of costraits is equivalet to the followig. x1 + 4x2 + 2x 4 7 - M(1- w1) 3x 1-5x2 12 + M (1- w2) 2x2 + x3 6 - M(1- w3) w + w2 + w3 1. (Usig a equality would also be valid.) w i 1 {0,1} for i = 1 to 3. At least oe of two iequalities is satisfied. I the case of two iequalities, it suffices to create a sigle ew variable w. For example, suppose that we wat to satisfy the followig logical coditio. At least oe of the followig two costraits is satisfied: x1 + 4x 2 + 2x 4 7 or 3x 1-5x 12. This logical coditio is equivalet to: x1 + 4x 2 + 2 x 4 7 - Mw 3x1-5x2 12 + M(1- w) w {0, 1} 2 Sectio 5. Fixed costs Here we cosider a iteger program i which there are fixed costs o variables. For example, cosider the followig iteger program: Maximize f (x 1 ) + f 2 (x 2 ) + f 3 (x 3 ) subject to 2x 1 + 4x 2 + 5x 3 100 x 1 + x 2 + x 3 30 10x 1 + 5x 2 + 2x 3 204 0 ad iteger for i = 1 to 3. where 52x 1 500 if x 1 if x 1 30x 2 400 1 2 20x 3 300 if x3 f 1 ( x 1 ) f (x ) f (x ) 1 0 if x = 0, 2 2 1 0 if x = 0, 3 3 2 0 if x = 0 3.
The IP formulatio is as follows: Maximize 52x 1 500w 1 + 30x 2 400w 2 + 20x 3 300w 3 subject to 2x 1 + 4x 2 + 5x 3 100 x 1 + x 2 + x 3 30 10x 1 + 5x 2 + 2x 3 204 Mw i for i = 1 to 3 0 ad iteger for i = 1 to 3. The costrait : Mw i forces w i = 1 wheever > 0. The model may look icorrect because it permits the possibility that = 0 ad w i = 1. It is true that the IP model allows more feasible solutios tha it should. However, if = 0 i a optimal solutio, the w i = 0 as well because its objective value coefficiet is less tha 0. Because the iteger program gives optimal solutios, if = 0, the w i = 0. Sectio 6. Piecewise liear fuctios. Iteger programmig ca be used to model fuctios that are piecewise liear. For example, cosider the followig fuctio. 2f 0 x 3 y 9 f 4 x 7 5+ f 8 x 9. Oe ca model y i several differet ways. Here is oe of them. We first defie two ew variables for every piece of the curve. 1 if 0 x 3 f 0 x 3 w 1 x 1 0 otherwise. 0 otherwise. 1 if 4 x 7 f 4 x 7 w 2 x 2 0 otherwise. 0 otherwise. 1 if 8 x 9 f 8 x 9 w 3 x 3 0 otherwise. 0 otherwise.
We complete the model as follows. IP formulatio y = 2x 1 + 9w 2 - x 2-5w 3 + x 3 0 : x 1 : 3w 1 4w 2 : x 2 : 7w 2 8w 3 : x 3 : 9w 3 w 1 + w 2 + w 3 = 1 x = x 1 + x 2 + x 3 w i E {0, 1} for i = 1 to 3. For ay choice of w 1, w 2, ad w 3, the variables x ad y are correctly defied. Sectio 7. The travelig salesma problem I this sectio, we give the stadard model for the travelig salesma problem. It has a expoetial umber of costraits, which may seem quite uusual for a iteger programmig model. We explai how it ca be implemeted so as to be practical. We assume that there are cities, ad that C ij deotes the distace from city i to city j. I this model, the followig are the variables: j 1 if city i is immediately followed by city j o the tour 0 otherwise. The formulatio is as follows: Miimize c ij j j=1 subject to j = 1 for all i = 1 to j=1 j = 1 for all j = 1 to j 1 for all S {1,2,...,} with 1 S 1 i S, j N \S j {0,1}, for all i, j = 1 to. The first set of costraits esures that there is some city that follows city i i the solutio. The secod set of costraits esures that there is some city that precedes city j i the solutio.
Ufortuately, there are ot eough costraits to esure that the solutio is a tour. For example, a feasible solutio to the first two sets of costraits for the six city problem cosists of x 12 = x 23 = x 31 = 1, ad x 45 = x 56 = x 64 = 1. This "solutio" to the first two sets of costraits correspods to the cycles 1-2-3-1 ad 4-5-6-4. A tour should be oe cycle oly. The third set of costraits guaratees the followig. For ay o-empty subset 5 of cities with S, there must be some city ot i 5 that follows some city that is i 5. This set of costraits is kow as the subtour elimiatio Costraits. With all of the costraits listed above, every feasible solutio correspods to a tour. Implemetatio details. Suppose that oe wated to solve the liear programmig relaxatio of the TSP that is, we solve the problem obtaied from the above costraits if we drop the itegrality costraits, ad merely require that j 0 for each i ad j. (We woct deal with solvig the iteger program here.) We refer to this liear program as LP. At first it appears that there is o way of solvig LP for ay large values of, say > 100. For ay TSP istace with more tha 100 cities, there are more tha 2 100 differet subtour elimiatio costraits. Listig all of the costraits would take more tha all of the computer memory i the etire world. Istead, LP is solved usig a "costrait geeratio approach." LP(0) is obtaied from LP by droppig all of the subtour elimiatio costraits. A optimal solutio x 0 is obtaied for LP(0). If x 0 is feasible for LP, the it is also optimal for LP. If ot, the some subtour elimiatio costrait that x 0 violates is idetified ad added to LP(0), resultig i LP(1). ItCs ot obvious how oe ca determie a subtour elimiatio costrait that is violated, but there are efficiet approaches for fidig a violated subtour elimiatio costrait. A optimal solutio x 1 is obtaied for LP(1). If x 1 is feasible for LP, the it is also optimal for LP. If ot, the some subtour elimiatio costrait that x 1 violates is idetified ad added to LP(1), resultig i LP(2). This process cotiues util there is a optimal solutio for LP(k) for some k that is feasible for LP ad hece optimal for LP. Or else, the solver takes so much time, that it is stopped before reachig optimality. I practice, the techique works quite well, ad fids a optimal solutio for LP i a short amout of time.
MIT OpeCourseWare http://ocw.mit.edu 15.053 Optimizatio Methods i Maagemet Sciece Sprig 2013 For iformatio about citig these materials or our Terms of Use, visit: http://ocw.mit.edu/terms.