Optimization_Part7
Optimization_Part7
• This is not always possible – e.g. we cannot hire or fire 10.75 people. We need to restrict
the decision variables to integer values only.
• We may sometimes need to restrict them to binary values (0 or 1) – e.g. assigning tasks to
workers.
• The key advantage of integer programming in these applications is its ability to handle
"yes/no" decisions and whole-number requirements that are common in real-world
problems.
2
Applications – Production Planning
• Deciding how many units of each product to manufacture
• Allocating limited resources (machines, raw materials) to different product lines
• Determining batch sizes when there are setup costs
• Example
• A factory must decide how many washing machines and dryers to produce with limited steel,
labour hours, and assembly line capacity.
• Each product must be made in whole units.
3
Applications – Facility Planning
• Facility location • Facility layout
• Choosing which warehouses or stores to • Arranging machines on a factory floor
open from potential locations • Designing assembly lines
• Optimizing distribution network design • Organizing warehouse storage
• Determining service coverage areas • Example
• Example • Determining the placement of machines
• A retail chain deciding which of 20 in a factory to minimize material handling
potential locations to open stores in, distances while ensuring required space
ensuring each neighbourhood has a store between equipment.
within 5 kilometres while minimizing total
costs.
4
Applications – Staff Scheduling
• Creating work shifts that meet minimum staffing requirements
• Assigning employees to shifts while respecting labor rules
• Managing full-time vs part-time employee mix
• Example
• A hospital scheduling nurses where each shift needs minimum coverage, nurses can't work
consecutive shifts, and must have at least 12 hours between shifts.
5
Applications – Transportation and Logistics
• Vehicle routing for delivery fleets
• Airline crew scheduling
• Container loading optimization
• Example
• Planning routes for a fleet of delivery trucks to serve 100 customers, where each truck has
limited capacity and must return to the depot.
6
Applications – Project Selection
• Choosing which projects to fund with a limited budget
• Selecting portfolio of investments
• Research & Development project prioritization
• Example
• A company choosing which IT projects to implement given budget constraints and project
interdependencies (some projects require others to be completed first).
7
Applications – Cutting Stock Problems
• Minimizing waste in cutting materials
• Paper roll cutting
• Sheet metal cutting
• Example
• Determining how to cut standard-sized steel sheets into smaller pieces of various sizes to fulfill
orders while minimizing waste.
8
Solving IPs – Branch and Bound
• Algorithm
• Start with linear relaxation (allow fractional values)
• Create decision tree by branching on integer variables
• Set upper and lower bounds on solution
• Prune branches that can't improve best solution
• Explore promising branches
9
368 Chapter 9 Integer Linear Programming
Illustration 8
x2 FIgure 9.2
Solution space for ILP (lattice p
(shaded area) of Example 9.2-1
6
maximize 𝑧 = 5𝑥! + 4𝑥"
5
subject to:
Feasible integer points
𝑥! + 𝑥" ≤ 5 4
x1
0 1 2 3 4 5 6
x2 FIgure 9.3
10
Solution Spaces of LP2 and LP3
6 Example 9.2-1
5
x1 # 3 x1 $ 4
4
Step 1: Solve the Relaxed Linear Program (LP)
• First, we ignore the integer constraint and solve the problem as a regular LP.
• This involves maximizing 𝑧 = 5𝑥! + 4𝑥" under the given constraints without
requiring 𝑥! and 𝑥" to be integers.
• Let's denote the solution to this relaxed problem as (𝑥!∗, 𝑥"∗).
• If 𝑥!∗ and 𝑥"∗ turn out to be integers, then this solution is optimal for the original problem,
and we're done.
• If not, we proceed with branching.
11
368 Chapter 9 Integer Linear Programming
6
In this case, the solution of the LP
relaxation is 𝑥! = 3.75 and 𝑥" = 1.25 5
Feasible integer points
and 𝑧 = 23.75.
4
3 Optimum (continuous):
x1 5 3.75, x2 5 1.25
The solution is non-integer. We LP1 z 5 23.75
2
proceed to the branching step.
1
x1
0 1 2 3 4 5 6
x2 FIgure 9.3
12
Solution Spaces of LP2 and LP3
6 Example 9.2-1
5
x1 # 3 x1 $ 4
4
Step 2: Branch on the Non-integer Variable
• Because the optimum LP1 solution does not satisfy the integer restrictions, the solution
space is subdivided in a systematic manner that eventually locates the ILP optimum.
• First, B&B selects an integer variable whose optimum value at LP1 is not integer. In this
example, both 𝑥! and 𝑥" qualify.
• Selecting 𝑥! = 3.75 arbitrarily, the region 3 < 𝑥! < 4 of the LP1 solution space contains no
integer values of 𝑥!, and thus it can be deleted.
• This is equivalent to replacing the original LP1 with two new LPs:
• LP2 space = LP1 space + 𝑥! <= 3
• LP3 space = LP1 space + 𝑥! >= 4
13
3 Optimum (continuous):
x1 5 3.75, x2 5 1.25
LP1 z 5 23.75
2
x1
0 1 2 3 4 5 6
5
The two spaces combined contain x1 # 3 x1 $ 4
the same feasible integer points as 4
the original ILP — meaning that no
information is lost when LP1 is 3
x1
0 1 2 3 4 5
15
Branching 9.2 Integer Programming Algorithms 369
LP1
x1 5 3.75, x2 5 1.25, z 5 23.75
x1 # 3 x1 $ 4
2 3
LP2 LP3
x1 5 3, x2 5 2, z 5 23 x1 5 4, x2 5 .83, z 5 23.33
Lower bound (optimum)
FIgure 9.4
Using branching variable x1 to create LP2 and LP3 for Example 9.2-1
16
gives rise to the concept of branching in the B&B algorithm. In this case, x1 is called the
branching variable.
The optimum ILP lies in either LP2 or LP3. Hence, both subproblems must be examined.
We arbitrarily examine LP2 (associated with x1 … 3) first:
Branch and Bound
• We arbitrarily examine LP2 (associated with 𝑥! <= 3 ) first.
• The solution of LP2 is 𝑥! = 3 and 𝑥" = 2 and 𝑧 = 23.
• The LP2 solution satisfies the integer requirements for 𝑥! and 𝑥".
• Hence, LP2 is said to be fathomed — meaning it cannot yield any better ILP solution and no further
branching from node 2 is required.
• We cannot say at this point that the integer solution obtained from LP2 is optimum for the original
problem, because LP3 may yield a better integer solution.
• All we can say is that 𝑧 = 23 is a lower bound on the optimum (maximum) objective value of the original
ILP.
• This means that any unexamined subproblem that cannot yield a better objective value than the lower bound
must be discarded as nonpromising.
• If an unexamined subproblem produces a better integer solution, then the lower bound must be
updated accordingly.
17
Branch and Bound
• Given the lower bound 𝑧 = 23, we examine LP3.
• LP3 does not (cannot) yield a result that is better than LP2.
• Because optimum 𝑧 = 23.75 at LP1 and all the coefficients of the objective function happen to
be integers, it is impossible that LP3 can produce a better integer solution (with 𝑧 > 23).
• As a result, we discard LP3 and conclude that it has been fathomed
• The B&B algorithm is now complete because both LP2 and LP3 have been examined and
fathomed, the first for producing an integer solution and the second for failing to
produce a better integer solution.
• We thus conclude that the optimum ILP solution is the one associated with the lower
bound — namely, 𝑥! = 3 and 𝑥" = 2 and 𝑧 = 23.
18
Concerns
1. At LP1, could we have selected 𝑥" as the branching variable in place of 𝑥!?
2. When selecting the next subproblem to be examined, could we have solved LP3 first
instead of LP2?
The answer to both questions is “yes,” but ensuing computations may differ dramatically.
This is the principal weakness of the branch and bound algorithm.
19
stead of LP2?
The answer to both questions is “yes,” but ensuing computations may differ dramatically. Figure 9.5
demonstrates this point. Suppose that we examine LP3 first (instead of LP2 as we did in Figure 9.4).
The solution is x1 = 4, x2 = .83, and z = 23.33 (verify!). Because x2 1 = .832 is noninteger, LP3
is examined further by creating subproblems LP4 and LP5 using the branches x2 … 0 and x2 Ú 1,
respectively. This means that
LP4 space = LP3 space + 1x2 … 02
= LP1 space + 1x1 Ú 42 + 1x2 … 02
LP5 space = LP3 space + 1x2 Ú 12
= LP1 space + 1x1 Ú 42 + 1x2 Ú 12
FIgure 9.5
Alternative B&B tree for Example 9.2-1
LP1
Bound Path
x1 # 3 x1 $ 4
7 2
LP2 LP3
x1 5 3, x2 5 2, z 5 23 x1 5 4, x2 5 0.83, z 5 23.33
Lower bound (optimum)
This path leads to a substantially higher
x2 # 0 x2 $ 1
computational effort.
4 3
LP4 LP5
x1 5 4.5, x2 5 0, z 5 22.5 No feasible solution
x1 # 4 x1 $ 5
6 5
LP6 LP7
x1 5 4, x2 5 0, z 5 20 No feasible solution
Lower bound
20
How to handle integer variables in AMPL?
• Earlier, we declared variables in the following manner:
var x1 >= 0;
or
var x1 integer >= 0;
21
Modeling with Binary Variables
• Do/don’t do decisions
• Logical conditions
• Choice among several possibilities
• Simple implications (if-then)
• Implications with three variables
22
Do/don’t do decisions
• Modelling activities that either have to be done in their entirety or not done at all – there
are just two options from which we must select only one.
• For instance, we might want to model whether we drive a particular truck between city A and
city B on a particular day.
• Typically we model the option of doing something by having a binary variable being equal to
1, and the option of not doing the thing with the binary variable being equal to 0.
23
Do/don’t do decisions
• Suppose for instance we are considering what we do with the three trucks that we own. Truck
1 has a capacity of 20 tonnes, truck 2 has a capacity of 25 tonnes and truck 3 has a capacity of
30 tonnes. If on a particular day we decide to send truck 1 to a customer then we either send
the entire truck or we do not send the entire truck.
• So we might have a decision variable (a binary variable) send1 taking the value 1 if we send
truck 1 out or 0 if we do not send truck 1. Similarly we will have another binary variable send2
which is 1 if truck 2 goes out and 0 otherwise; and variable send3 taking on the value 1 if
truck 3 goes out, and 0 otherwise.
• Elsewhere in the model we will probably be interested in the total tonnage that goes out on
that particular day and we can see that this is:
20·send1 +25·send2 +30·send3 >= total_out
24
Logical conditions
• Take as an example a set of projects that we may or may not decide to do.
• We shall call the projects A, B, C, D, E, F, G and H and with each of these projects we will
associate a decision variable (a binary variable) which is 1 if we decide to do the project
and 0 if we decide not to do the project.
• We call the corresponding variables a, b, c, d, e, f, g and h. So decision variable a taking
on the value 1 means that we do project A, whilst a taking on the value of 0 means that
we do not do project A.
25
Logical conditions – Choice among several possibilities
• The first constraint that we might impose is ‘we must choose no more than one project to do’.
We can easily see that this can be expressed by the constraint
a+b+c+d+e+f+g+h≤1
• Now suppose that the constraint is that we must choose exactly two of the projects. Then the
constraint we can use to model this is
a+b+c+d+e+f+g+h=2
• Since the binary variables can take only the values 0 or 1, we must have exactly two of them
being 1 and all the rest of them being 0, and that is the only way that we can satisfy that
constraint.
26
Simple implications (if-then)
Condition Constraint
27
Implications with three variables
Condition Constraint
28
Implications with three variables
Condition Constraint
29
Table 3.2: Formulation of logical conditions using binary variables
We move on to modeling the product of binary variables. Suppose we have three binary variables b1 ,
and b3 and we want to model the equation
b3 = b1 · b2
Dichotomies: either/or constraints
• All the constraints we have seen so far have had to be satisfied simultaneously, but
sometimes we need to model that either Constraint 1 or Constraint 2 has to be satisfied,
not necessarily both of them. Consider the problem:
31
Semi-continuous variables
• Suppose we have a semi-continuous variable s which can take on either the value 0 or
any value between some lower limit L and some upper limit U.
• e.g. s either has to take on the value 0 or it has to take on a real value in the range between 5
and 10.
32
Common IP/MIP
33
The Knapsack Problem
• You have a set of items, each with a weight and a
value.
• You have a knapsack with a maximum weight
capacity.
• The goal is to select a subset of items to put into
the knapsack such that the total value of the
selected items is maximized, while ensuring that
the total weight of the selected items does not
exceed the knapsack's capacity.
34
Illustration
A logistics company manages a truck fleet. Each truck has a weight capacity of 10 tons, and they
need to load the trucks with high-value products for delivery. Due to weight limitations, the goal is to
maximize the total value of the items loaded onto the truck without exceeding its weight limit.
Value
Product Weight (tons)
(in thousands)
A 2 10
B 5 15
C 4 12
D 3 8
35
Formulation
• Let 𝑣) = value of each item, 𝑤) = weight of each item and 𝑥) = a binary variable taking on
the value 1 if item 𝑖 is selected and 0 otherwise.
Maximize F 𝑣# 𝑥#
#
Subject to:
F 𝑤# 𝑥# ≤ 𝑊
#
𝑥# are binary.
36
Formulate an integer program and solve it using AMPL
• What is the total value of items loaded onto the truck.
• Items A and C are complementary items and are sold together. How will the solution
change?
• If any two items can be carried, how will the solution change?
• Items A and D are hazardous and cannot be carried together. How will the solution
change?
37
38