0% found this document useful (0 votes)
5 views

Optimization_Part7

Uploaded by

Kathan Raval
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

Optimization_Part7

Uploaded by

Kathan Raval
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 38

Integer Programming

What is integer programming?


• Linear programming assumes that the decision variables are fractional.
• E.g. a decision variable can take on a value 𝑥! = 10.75

• 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

• Complexity: Exponential in worst case


• Best for: Small to medium-sized problems

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

• Consider the following problem: 7

6
maximize 𝑧 = 5𝑥! + 4𝑥"
5
subject to:
Feasible integer points
𝑥! + 𝑥" ≤ 5 4

10𝑥! + 6𝑥" ≤ 45 3 Optimum (continuous):


x1 5 3.75, x2 5 1.25
LP1 z 5 23.75
𝑥! , 𝑥" ≥ 0 2
𝑥! , 𝑥" are integers
1

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

The LP Relaxation x2 FIgure 9.2


Solution space for ILP (lattice p
8
(shaded area) of Example 9.2-1

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

Solution Space of LP2 x2 FIgure 9.3


Solution Spaces of LP2 an
and LP3 6 Example 9.2-1

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

replaced with LP2 and LP3.


2
LP2
LP3
1

x1
0 1 2 3 4 5

If we intelligently impose sequential constraints


14 that exclude the
(e.g., 3 6 x1 6 4 in LP1), we will be reducing the continuous solution
number of LP subproblems whose optimum extreme points satisfy the
The best of these subproblems is the optimum solution of ILP.
The new restrictions, x1 … 3 and x1 Ú 4, are mutually exclusive, so
nodes 2 and 3 must be dealt with as separate LPs, as Figure 9.4 shows. T
Branching
• The new restrictions, 𝑥! <= 3 and 𝑥! >= 4 , are mutually exclusive, so that LP2 and LP3 at
nodes 2 and 3 must be dealt with as separate LPs.
• The optimum ILP lies in either LP2 or LP3. Hence, both subproblems must be examined.
• This gives rise to the concept of branching in the B&B algorithm.
• In this case, 𝑥! is called the branching variable.
• If we intelligently impose sequential constraints that exclude the integer-free regions, we
will be reducing the continuous solution space of LP1 into a number of LP subproblems
whose optimum extreme points satisfy the integer restrictions.
• The best of these subproblems is the optimum solution of ILP.

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

Alternative Branch and x1 5 3.75, x2 5 1.25, z 5 23.75

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;

• The declaration will change to:


var x1 >= 0 integer;

or
var x1 integer >= 0;

• In the case of binary (0 or 1) variables, the declaration will change to:


var x1 binary >= 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

• Dichotomies: either/or constraints


• Semi-continuous 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

if we do project A then we must do project B b≥a

if we do project A then we must not do project B a+b≤1

if we do not do A then we must do B a+b≥1

if we do project A we must do project B, and if we do


a=b
project B we must do project A

27
Implications with three variables

Condition Constraint

if we do project A then we must do project B and


b ≥ a and c ≥ a
project C
if we do project A then we must do project B or project
b+c≥a
C

if we do Project B or project C then we must do A a ≥ b and a ≥ c

28
Implications with three variables

Condition Constraint

if we do both B and C then we must do A


this can be written as:
if we do both B and C then we must not do not-A b + c + (1 - a) ≤ 2
or
we can do at most two of B, C or not-A

29
Table 3.2: Formulation of logical conditions using binary variables

Summary At most one of A, B,...,H


Exactly two of A, B,...,H
a+b+c+d+e+f +g+h1
a+b+c+d+e+f +g+h=2
If A then B b a
Not B b=1 b
If A then not B a+b1
If not A then B a+b 1
If A then B, and if B then A a=b
If A then B and C b a and c a
If A then B or C b+c a
If B or C then A a b and a c
1
or alternatively: a 2
· (b + c)
If B and C then A a b+c 1
1
If two or more of B, C, D or E then A a 3
· (b + c + d + e 1)
b+c+d+... M+1
If M or more of N projects (B, C, D, ...) then A a N M+1

3.3.3 Products of binary variables 30

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:

minimize 𝑍 = 𝑥! + 𝑥" We can model this with one additional binary


subject to either variable 𝑏.
2𝑥! + 𝑥" ≥ 6 (Constraint1) 2𝑥! + 𝑥" ≥ 6 · 𝑏
or 𝑥! + 2𝑥" ≥ 7 · (1 − 𝑏)
𝑥! + 2𝑥" ≥ 7 (Constraint2)

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.

• Introduce a binary variable b then we can represent the semi-continuity of s by the


following pair of constraints:
L·b ≤ s
S ≤ U·b

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.

Each product has an associated weight and monetary value:

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

You might also like