Indr 460 Operations Research Applications: Integer Programming
Indr 460 Operations Research Applications: Integer Programming
Indr 460 Operations Research Applications: Integer Programming
Operations Research
Applications
Integer Programming
2
Types of Integer Programming
Models
p A linear program in which all the variables are
restricted to be integers is called an integer linear
program (ILP) or pure integer program (IP) in
short.
p If only a subset of the variables are restricted to
be integers, the problem is called a mixed integer
linear program (MILP) or MIP in short.
p Binary variables are variables whose values are
restricted to be 0 or 1. If all variables are
restricted to be 0 or 1, the problem is called a 0-1
or binary integer program, 0-1 IP in short.
3
Example: All-Integer LP
p Consider the following all-integer linear
program (IP):
4
Example: All-Integer LP
p LP Relaxation
Solving the problem as a linear
program ignoring the integer constraints,
the optimal solution to the linear program
gives fractional values for both x1 and x2.
2 LP Optimal (2.5,1.5)
1 x1 + 3x2 < 7
x1
1 2 3 4 5 6 7 6
Example: All-Integer LP
p Rounding Up
If we round up the fractional solution
(x1 = 2.5, x2 = 1.5) to the LP relaxation
problem, we get x1 = 3 and x2 = 2.
7
Example: All-Integer LP
Rounded Up Solution
x2
5 3x1 + x2 < 9
3
IP Infeasible (3,2)
2
LP Optimal (2.5,1.5)
1 x1 + 3x2 < 7
x1
1 2 3 4 5 6 7
8
Example: All-Integer LP
p Rounding Down
By rounding the optimal solution down
to x1 = 2, x2 = 1, we see that this solution
indeed is an integer solution within the
feasible region, and substituting in the
objective function, it gives z = 8.
9
Example: All-Integer LP
p Complete Enumeration of Feasible IP
Solutions
There are eight feasible integer solutions to
this problem:
x1 x2 z
1. 0 0 0
2. 1 0 3
3. 2 0 6
4. 3 0 9 optimal solution
5. 0 1 2
6. 1 1 5
7. 2 1 8
8. 1 2 7
10
Example: All-Integer LP
x2
5
2
IP Optimal (3,0)
x1
1 2 3 4 5 6 7 11
Example: Mixed Integer LP
(x
x 1 integer, x 2 continuous)
2
4
Max 3x1 + 2x2
3
2
MILP Optimal (2,5/3)
x1
1 2 3 4 5 6 7 12
LP Relaxation of an IP
p When the integer requirements in an
integer programming problem (IP) are
“relaxed” (not enforced), we obtain the LP
relaxation of the IP.
14
Solving Integer Programs
p The branch-and-bound algorithm theoretically
allows us to solve any IP/MIP problem by solving
a series of LP relaxation problems.
p Finding the optimal solution may require the
solution of thousands/millions/billions of LPs.
p Finding the optimal solution to “some” IP
problems can be immensely time-consuming
even for the fastest computers.
n Problem size, model structure
p Other solution methods: cutting planes,
branch&cut, branch and price
15
Sensitivity Analysis in Integer
Programming
p Sensitivity analysis is often crucial for IPs
since a very small change in one of the
coefficients can cause a relatively large
change in the optimal values.
16
Modeling Integer Programs
p Much of the flexibility provided by linear
integer programming is due to the use of 0-1
variables.
18
Modeling Dependent Decisions
p We can also use binary variables to enforce the condition
that a certain action can only be taken if some other
action is also taken.
19
Example: Facility Location Problem
p We are given n potential facility locations and
m customers that must be serviced from
those locations.
p There is a fixed cost cj of opening facility j.
p There is a cost dij associated with serving
customer i from facility j.
p We have two sets of
binary variables.
yj is 1 if facility j is opened,
0 otherwise.
xij is 1 if customer i is served
by facility j, 0 otherwise.
20
Modeling Fixed Costs
p In many applications, the cost of production
has two components:
n A setup cost (fixed cost)
n A variable cost (related to the production quantity)
21
Example: Gandhi Clothing
(Fixed Cost Model)
p Gandhi clothing company manufactures
shirts, shorts and pants.
p They need to rent special machinery for the
production of each product line, if they decide
to produce any of that line.
p Rental costs are:
n shirt machinery - $200/week,
n shorts machinery - $150/week and
n pants machinery - $100/week.
22
Example: Gandhi Clothing
(Fixed Cost Model)
Requirements
Labor (hr) Cloth (sq. yard) Profit ($)
Shirts 3 4 6
Shorts 2 3 4
Pants 6 4 7
Available 150/week 160/week
23
Gandhi Clothing Formulation
p Decision Variables :
n Continues variables
p ! is the amount of shirts to produce
p " is the amount of shorts to produce
p # is the amount of pants to produce
n Binary variables
1, ./ 0ℎ.23 $45ℎ.672" .0 276378
p $%&'()% = +
0, :3ℎ72;.07
1, ./ 0ℎ:230 $45ℎ.672" .0 276378
p $%&<()% = +
0, :3ℎ72;.07
1, ./ @4630 $45ℎ.672" .0 276378
p $=>?)% = +
0, :3ℎ72;.07
p Objective Function:
n max: 6! + 4" + 7# − 200$%&'()% − 150$%&<()% − 100$=>?)%
24
Gandhi Clothing Formulation
p Constraints :
n Labor
p 3" + 2% + 6' ≤ 150
n Cloth
p 4" + 3% + 4' ≤ 160
n Machinery
p " ≤ -./012. 3./012.
p y≤ -./412. 3./412.
p z≤ -56272. 35672.
25
Example: Fixed-charge Network
Flow Problem
p We are given a directed graph G = (N, A).
n There is a fixed cost cij associated with “opening” arc (i, j)
(think of this as the cost to “build” the link).
n There is also a variable cost dij associated with each unit of
flow along arc (i, j).
n Each node i has supply/demand quantity bi.
n Minimizing the fixed cost by itself is a minimum spanning tree
problem (easy).
n Minimizing the variable cost by itself is a minimum cost
network flow problem (easy).
n We want to minimize the sum of these two costs (difficult).
26
Modeling the Fixed-charge Network
Flow Problem
p To model the FCNFP, we associate two variables with each arc.
n xij (fixed-charge variable) indicates whether arc (i,j) is open.
n fij (flow variable) represents the flow on arc (i, j).
n Note that we have to ensure that fij > 0 ⇒ xij = 1.
27
Special 0-1 Constraints
p When xi and xj represent binary variables
designating whether projects i and j have been
completed, the following special constraints may
be formulated:
n At most k out of n projects will be completed:
Sj xj < k
n Project j can be completed only if project i has
been completed:
xj - xi < 0
n Project i can be completed if and only if project j
is:
xj - xi = 0
n Projects i and j are mutually exclusive:
xi + xj < 1 28
Using 0-1 Variables to Model Special
Conditions
p Example 1 (Capital Budgeting):
Perry Construction is faced with the problem of
determining which projects it should undertake
over the next three years.
29
Perry Construction
Estimated Capital Requirements
Project Present Value Year1 Year2 Year3
A 180 000 30 000 40 000 40 000
B 20 000 12 000 8 000 0
C 72 000 30 000 20 000 20 000
D 25 000 15 000 10 000 24 000
E 80 000 20 000 40 000 40 000
Funds Available 70 000 90 000 100 000
30
Perry Construction
Let ! = {$, &, ', (, )} be the set of projects and + = 1,2,3 be
the set of years in the planning horizon. We define /0 as
the present value of a project 1 ∈ !, and 304 is the capital
requirement for the project 1 at year 5 ∈ +. The available
funds in a year 5 ∈ + is denoted by 7 4 .
p Decision Variables :
1, :; 1<=>?35 1 ∈ ! :@ ABC?<5DE?B
80 9
0, =5ℎ?<H:@?
p Objective Function :
max L /0 80
0∈M
31
Perry Construction
p Constraints :
n Capital requirement
32
Perry Construction Example (cont’d)
The Management has decided that the following restrictions
must also be enforced:
p At most three projects can be undertaken.
! %" ≤ 3
"∈$
p Projects A and D cannot be undertaken at the same
time.
%( + %* ≤ 1
p If project C is undertaken, then project E must also be
undertaken.
%, ≤ %-
33
Example (cont’d)
4) If projects B or E are undertaken, then project A cannot
be undertaken.
!" ≤ 2 − (!' + !) )
34
Production Scheduling Problem
Example 2 (Fixed-Charge Problem):
p A product can be assembled on any of the five
assembly lines.
p For each line, the table below gives the cost of
assembling a product, the assembly time
required per product, the start up cost, and the
maximum number of hours the line can be
operated during the next month.
p At least 350 units of the product must be
assembled next month.
35
Production Scheduling Problem
Start-up Prod. Prod. Maximum
Line Cost Cost Time(hrs.) Prod.hrs.
A $ 6,000 $ 80 5 510
B $10,000 $ 60 6 480
C $ 2,000 $110 10 600
D $ 7,500 $ 75 4 440
E $15,000 $ 40 3 480
36
Production Scheduling Problem
Let ! = {$, &, ', (, )} be the set of alternative assemply
lines. For each line ℓ ∈ L, we define .ℓ as the cost of
building, /ℓ is the unit production cost and 0ℓ is the unit
production time. The maximum productions hours of a
line ℓ ∈ ! is denoted by 1ℓ .
p Decision Variables :
n 3ℓ is the number of products assembled in line ℓ ∈ !
1, 78 97:; ℓ ∈ ! 7< =>790
n 4ℓ = 5
0, @0ℎ;BC7<;
p Objective Function :
min ∑ℓ∈H /ℓ 3ℓ + ∑ℓ∈H .ℓ 4ℓ
37
Production Scheduling Problem
p Constraints :
n ∑ℓ∈$ %ℓ ≥ 350
n *ℓ%ℓ ≤ ,ℓ-ℓ, ∀ ℓ ∈ 0
38
Production Scheduling Problem
The management decided to enforce the following additional
restrictions:
p If line A is operated, then lines D and E can not be operated.
+$ ≤ 1 − +,
+0 ≤ 1 − +,
p If line C is operated, then no more than 150 units may be
produced on lines B and D combined.
!" + !$ ≤ 150 + (1 − +, ).
p If line B is operated, then at least 50 units must be produced on
that line.
!" ≥ 50 +"
p If line E is operated, then line B must also be operated
+0 ≤ +"
39
Selecting from a Set
p We can use constraints of the form to
represent that at least one item should be chosen
from a set T.
p Similarly, we can also model that at most one or
exactly one item should be chosen.
n Examples?
40
Set Covering Problem
a
C 1
S
b c
2 d
e
3 f
4 g
p Covers:
n {1,2,3,4}, {1,2,3}, {1,2,4}, {1,3}, {1,4}
p Each cover (subset) has an associated cost
p The objective is to find the cover with the minimum cost
p Special case:
n Cost of a subset is the sum of the costs of each item in it. 41
Set Covering IP formulation
42
Set Covering, Packing and Partitioning
n Each row of A represents an item from the set S.
n Each column Aj represents the items covered by the subset Cj.
n Each variable xj represents selecting subset Cj.
n The constraints say that each item must be covered
p at least one subset (set covering)
p at most one subset (set packing)
p exactly one subset (set partitioning)
selected subset.
43
Set Covering, Packing and Partitioning
p Set covering formulation is of the form
min cTx
s:t: Ax ≥ 1
xj є {0,1} ∀j
where A is a 0-1 matrix.
p Objective Function :
n 7'8 ∑<":; =" !"
46
Covering Problem
p Constraints :
n Cover city A: !" + !$ + !% + !& ≥ 1
n Cover city B: !% + !) + !* + !& + !+ ≥ 1
n Cover city C: !" + !) + !, + !+ ≥ 1
n Cover city D: !" + !$ + !* + !, + !- ≥ 1
n Cover city E: !$ + !% + !) + !* + !, + !- ≥ 1
n Nonnegativity and binary: !. ∈ 0,1 , for all
2 ∈ {1, … , 9}
47
Set Partitioning Example
p Used in airline crew scheduling
p Next to fuel costs, personnel costs are the
largest cost an airline faces
p A tremendous number of restrictions on how
airline personnel are used
n regulations and union contracts
n determining a feasible crew schedule is a very
difficult problem
48
Set Partitioning Example
p In formulating this problem, a variable is created
for each feasible schedule for a single crew.
p For instance, a schedule where the crew leaves
Pittsburgh at 7:15AM on Tuesday, arrives in NY
at 8:30, leaves NY at 9:00, arrives in Atlanta at
11:00, leaves Atlanta at 12:00 and arrives in
Pittsburgh at 14:30 would correspond to a single
variable, say x1.
p The cost of setting that variable to 1 (meaning to
have a crew fly that schedule) would be based on
the union contract and other regulations.
49
Set Partitioning Example
p Number of variables is huge.
p For each flight (called a leg), it is necessary to
choose a schedule that includes that flight.
p For example, suppose schedules 1, 5, 46, 1534
and 2133 contain the 7:15 Tuesday flight from
Pittsburgh to NY.
Then we add the constraint:
x1 + x5 + x46 + x1534 + x2133 = 1
50
Set Packing Example
p Suppose your kitchen contains a collection of
different food ingredients and you have a
cookbook with a collection of recipes
p Each recipe requires a subset of the food
ingredients
p You want to prepare the largest possible
collection of recipes from the cookbook
p You are actually looking for a set-packing - a
collection of recipes whose sets of ingredients are
pairwise disjoint
51
Production Planning Problems
p Demand in each period can be met by
production in the same period and inventory
carried over from the previous period
(assuming no backorder is allowed)
p A production run incurs a fixed setup cost per
run and a variable production cost (function
of production quantity)
p Inventory holding cost
p Minimize sum of these three costs
52
Capacitated Lot Sizing
p Find an optimal lot size (quantity of a production
run) for each time period so that demand in each
period is satisfied
p Minimize total cost of production and inventory
holding
p dt: demand in each period t=1,…,T
p ft: setup cost in each period t
p ct: unit production cost in each period t
p ht: unit holding cost in each period t
p ut: maximum production quantity in each period t
p Assume beginning inventory is zero
53
Capacitated Lot Sizing Problem
p Formulation
%
Min:
! &" '" + )" *" + +" ,"
"#$
st: -. = -.01 + 2. − 4. ∀6 = 1, … , :
-; = 0 ∀6 = 1, … , :
2. =. ≤ ?. ∀6 = 1, … , :
2. , -. ≥ 0 ∀6 = 1, … , :
?. ∈ {0,1} ∀6 = 1, … , :
54
Workforce/Staff Scheduling Problems
p Many companies such as hospitals, restaurants,
call centers and police departments divide the
daily schedule to discrete time windows, say T of
them
p The number of staff required typically varies
among time windows
p Staff members are scheduled to n different work
shifts, each covering m consecutive time windows
p Staff members assigned to different shifts may
be paid differently
n those working overnight are usually paid at a
higher rate
55
Workforce/Staff Scheduling Problems
p The problem is to determine the number of staff
members to be assigned to each shift so that the
company meets the demand in each time window
p It is assumed that personnel works full-time
56
Workforce/Staff Scheduling Problems
Time Shift 1 Shift 2 Shift 3 Shift 4 Workers
window required
6am-9am X X 55
9am-12 X 46
12-3pm X X 59
3pm-6pm X 23
6pm-9pm X X 60
9pm-12am X 38
12am-3am X X 20
3am-6am X 30
Wage per $135 $140 $190 $188
shift
57
Workforce/Staff Scheduling Problems
p Parameters:
n ": number of shifts
n #: number of time windows
n $%: number of workers required per time
window % = 1, … , #
n *+: wage rate for shift +
p Objective: minimize total wages paid to all
workers
p Constraint: demand (requirement) within each
time window must be satisfied
58
Formulation
p Let !"# = 1, if shift " covers time window #; and 0,
otherwise
Min: *
& +' ,'
'()
/
st:
& !01 20 ≥ 41 ∀# = 1, … , 8
-(.
21 ≥ 0 and integer ∀# = 1, … , 8
59
Scheduling Full-time and Part-time
Workers (Exercise)
p Now, in addition to before, let us assume part-
time workers may be hired per time window with
wage of !"
p At least one full-time worker must be present
when part-time workers are hired
p Update your formulation Determine how many
full-time
Min: ' and part-time workers need to be hired
to minimize
# ( )the total workforce cost
$ $
$%&
,
st:
# -./ 0. ≥ 2/ ∀" = 1, … , 8
*%+
31 ≥ 0 and integer ∀j = 1, … , 4
42 ≥ 0 and integer ∀t = 1, … , T
61
Modeling Disjunctive Constraints
p We are given two constraints !"# ≥ % and &"# ≥ ' with
nonnegative coefficients.
p Instead of insisting both constraints be satisfied, we want at least
one of the two constraints to be satisfied.
p To model this, we define a binary variable y and impose
()* ≥ +,
-)* ≥ (/ – +)2
+ ,34(5+
p More generally, we can impose
that exactly k out of m constraints
be satisfied with
62
Disjunctive constraints
p Either or constraints : !" ≤ $ %& '" ≥ )
n Convert to the form:
!" – $ ≤ 0 %& – '" + ) ≤ 0
n Let y be a binary variable
!" – $ ≤ -. !/)
– '" + ) ≤ -(1 − .)
63
Modeling a Restricted Set of Values
p We may want variable x to take on values only in the set a1, a2, …,am
p We introduce m binary variables yj, j=1,…,m and the constraints
64
Example
p Building a warehouse
p Select size (capacity) from possible choices
Size Cost
15 300
20 450
25 600
30 1000
50 2500
75 3500
100 4000
65
Example
p Define binary variables !1, … , !7 to indicate the
ith choice, & = 1, … , 7.
p Size = ∑,)*+ -) !)
p Cost = ∑,)*+ .) !)
/ !) = 1
)*+ 66
Modeling Arbitrary Piecewise Linear
Cost Functions
f (x)
x
0 a1 a2 a3 a4
67
Piecewise Linear Cost Functions
p We can use binary variables to model arbitrary piecewise linear cost
functions.
p The function is specified by ordered pairs ("# , %("&)) and we wish to
evaluate it at a point (.
p We have a binary variable )&, which indicates whether
"& ≤ ( ≤ "& + 1
p To evaluate the function, we will take linear combinations
∑0#./ 1# % "# of the given function values.
p This only works if the only two nonzero 12# 3 are the ones
corresponding to the endpoints of the interval in which x lies.
68
Modeling Arbitrary Piecewise Linear
Cost Functions
p The function !(#) defined by %& , !(%& ) for ' =
1, … . , - where %1 < %2 < ⋯ … < %- on the interval
[%1, %- ], can be expressed by letting # = ∑6&45 7& %& ,
where ∑6&45 7& = 1, %89 7& ≥ 0 !<= %>> '.
69
Modeling Arbitrary Piecewise Linear
Cost Functions
p To represent the condition, we need binary
variables
ì1, if x Î [ai , ai +1 ]
yi = í
î0, o.w.
p We should express: !" can be positive only if # is
in the (i-1)st or ith interval. That is, !" can be
positive only if y%&' = 1 or *" = 1.
70
Minimizing Piecewise Linear Cost Functions
Min: %
! &' ((*' )
"#$
st: ,- ≤ y-
,0 ≤ y12- + 40 ∀i = 2, … , k − 1
,> ≤ y?2-
?2-
! y1 = 1
1#-
,0 ≥ 0 ∀i = 1, … , k
40 ∈ {0,1} ∀i = 1, … , k − 1
71
Minimizing Piecewise Linear Cost Functions
p The following formulation minimizes the function for !" ≤ $
)
Min:
% *+ ,(.+ )
&'(
st: 01 ≤ y1
03 ≤ y451 + 73 ∀i = 2, … , k − 1
0A ≤ yB51
B51
% y4 = 1
4'1
C
" = % D3 03
4'1
!" ≤ $
03 ≥ 0 ∀i = 1, … , k 72
73 ∈ {0,1} ∀i = 1, … , k − 1
Specially Ordered Constraints
p Note that at most two of the λi variables can
be 1 and they should be adjacent.
73
Exercise
p Consider the following price structure offered by
a seller for a certain commodity
p The price is $10 per unit for the first 100 units,
$9 per unit for the next 200 units and $6 per unit
for the next 200 units
p Suppose at most 500 units can be purchased
p let x denote the number of units purchased and
let f(x) represent the total cost associated with
the purchase of x units
74
Exercise
p Represent the cost function f(x) for this example
as a mathematical expression first
p Plot this function graphically
p Where are the breakpoints?
p Notice that the individual segments are linear but
the entire function is nonlinear
p Convert the nonlinear function to an equivalent
formulation involving only linear functions so that
the resulting model can be solved by an MIP
algorithm
75
Concave Piecewise Linear Cost
Functions
p Economy of scale
p Discounts in unit prices
p Unit costs decrease as the quantity increases
p The function defined in our previous example is
concave
p We can take advantage of this and write a
simpler formulation
76
Concave Piecewise Linear Cost
Functions
p Three line segments exist in the example with
slopes s1 =10, s2 = 9 and s3 = 6
80
Linearization of 0-1 Polynomial
Functions
p Linear constraints are added for every j,k pair
!"# ≤ !"
!"# ≤ !#
!"# ≥ !" + !# −1
81
Exercise
p Maximize 2!" !# !$ # + !" # !#
s.t.
12!" +7!# # !$ − 3!" !$ ≤16
!" , !# , !$ binary