0% found this document useful (0 votes)
273 views42 pages

2b.modeling Linear and Integer Programs

The document describes an integer programming problem involving single-machine job scheduling. It introduces the following key elements: 1) There are n jobs that must be processed on a single machine. 2) The objective is to determine the order of jobs to minimize total completion time. 3) Decision variables indicate whether job i is completed before job j, with constraints to ensure a valid schedule without overlaps.

Uploaded by

Esra Tanyıldız
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)
273 views42 pages

2b.modeling Linear and Integer Programs

The document describes an integer programming problem involving single-machine job scheduling. It introduces the following key elements: 1) There are n jobs that must be processed on a single machine. 2) The objective is to determine the order of jobs to minimize total completion time. 3) Decision variables indicate whether job i is completed before job j, with constraints to ensure a valid schedule without overlaps.

Uploaded by

Esra Tanyıldız
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/ 42

IE 311 – Operations Research I

Part 2: Modeling Linear and Integer Programs


2b. Integer Programs

Spring 2021
Recall: Types of Linear Optimization Models

• An optimization problem with linear relations between


continuous variables is called a Linear Program:

• An optimization problem with linear relations between integer


variables is called a (Pure) Integer (Linear) Program:

• An optimization problem with linear relations between


continuous and integer variables is called a Mixed-Integer
Linear Program:

IE 311 2
Is Integer Programming Really Needed?

IE 311 3
Integer Programming Preliminaries

• Integer Programming is needed when


• the continuity assumption on the decision variables is not valid, or
• following type of decisions are to modeled:
• "yes/no",
• logical statements such as "either-or", "if-then", "and", "exclusive-or".
• We will see examples of IP Formulations, and how to implement
and solve such models in Python-Gurobi.
• The solution methods for the IP Models will be covered in IE 312.

IE 311 4
A First Example: Knapsack IP

• Suppose that there is a knapsack of capacity 14 units.


• There are four items, each with a size and a value given as
below:
Item 1 Item 2 Item 3 Item 4
Value 5 7 4 3
Size 8 11 6 4

• Determine the items to pick so as to maximize the value of the


knapsack while respecting its capacity.

IE 311 5
Knapsack capacity is 14 units.
Item Item Item Item
Knapsack IP: Components (I) 1 2 3 4
Value 5 7 4 3
Size 8 11 6 4
• Parameters (what are given?)
• Number of items (4)
• Value of each item (5, 7, 4, 3)
• Size of each item (8, 11, 6, 4)
• Capacity of the knapsack (14)

• Decision variables (what can be decided/changed?)


• 𝑥𝑖 =1 if item 𝑖 picked, and 0 otherwise (such variables are called
BINARY), 𝑖 = 1, … , 4.

IE 311 6
Knapsack capacity is 14 units.
Item Item Item Item
Knapsack IP: Components (II) 1 2 3 4
Value 5 7 4 3
Size 8 11 6 4
• Objective function (what is the aim?)
• Maximize the total value of the knapsack

• Constraints (what should be obeyed/respected?)


• Knapsack capacity constraint

• Binary requirements

IE 311 7
Knapsack IP: Simplest (but Dirty)
Python-Gurobi Implementation s.t.

from gurobipy import GRB,Model

m = Model('Knapsack')

x1 = m.addVar(vtype=GRB.BINARY) # define binary variable x1

x2 = m.addVar(vtype=GRB.BINARY) # define binary variable x2

x3 = m.addVar(vtype=GRB.BINARY) # define binary variable x3

x4 = m.addVar(vtype=GRB.BINARY) # define binary variable x4

m.setObjective(5*x1+7*x2+4*x3+3*x4, GRB.MAXIMIZE) # maximize the value

m.addConstr(8*x1+11*x2+6*x3+4*x4 <= 14) # Constraint on capacity

m.optimize() # Optimize the model


IE 311 8
Capital Budgeting (Winston, Page 478)

• Stockco is considering four investments.


• Investment 1 will yield a net present value (NPV) of $16,000; investment 2, an NPV of $22,000;
investment 3, an NPV of $12,000; and investment 4, an NPV of $8,000.
• Each investment requires a certain cash outflow at the present time: investment 1, $5,000;
investment 2, $7,000; investment 3, $4,000; and investment 4, $3,000.
• Currently, $14,000 is available for investment.
• Formulate an IP whose solution will tell Stockco how to maximize the NPV obtained from
investments 1–4.
• Modify the Stockco formulation to account for each of the following requirements separately:
• Stockco can invest in at most two investments.
• If Stockco invests in investment 2, it must also invest in investment 1.
• If Stockco invests in investment 2, it cannot invest in investment 4.

IE 311 9
Capital Budgeting (Winston, Page 478)

• Let 𝑥𝑖 =1 if investment 𝑖 if picked, and 0 otherwise, 𝑖 =


1, … , 4.
• Then, we have the following base model:

IE 311 10
Capital Budgeting (Winston, Page 478)

• Additional constraints:
• Stockco can invest in at most two investments.

• If Stockco invests in investment 2, it must also invest in


investment 1.

• If Stockco invests in investment 2, it cannot invest in


investment 4.

IE 311 11
Distribution Problem

• A company is operating 𝑚 supply stations to satisfy the demand of 𝑛


demand centers.
• Each supply station has a capacity of at most 𝑠𝑖 tons of products and
each demand center requires at least 𝑑𝑗 tons of products (you can model
the amount of product as a continuous variable).
• The products are shipped by using trucks. Each truck can carry at most 𝑏
tons of products (you need to model the number of trucks as an integer
variable).
• The cost of sending a truck from supply station 𝑖 to demand center 𝑗 is
𝑐𝑖𝑗, regardless of the amount of product carried by the truck.
• Write a mixed integer linear program to minimize the total cost.
IE 311 12
Distribution Problem: Key Observations

• Decision variables (what can be decided/changed?)


• We need to know how many tons of products are sent from each supply
station 𝑖 to each demand center 𝑗.
tons of
𝑖 products 𝑗
• We also need to know how many trucks are sent from each supply
station 𝑖 to each demand center 𝑗.
#trucks
𝑖 𝑗
• Note the following relationship:
𝐭𝐨𝐧𝐬 𝐨𝐟 𝐩𝐫𝐨𝐝𝐮𝐜𝐭𝐬
#𝐭𝐫𝐮𝐜𝐤𝐬 =
truck capacity
IE 311 13
Distribution Problem

IE 311 14
Machine Allocation Problem

• A machine tool plant owns 𝑚 different machines on which it can process


𝑛 types of jobs.
• A job 𝑗 takes 𝑡𝑖𝑗 time units if processed on machine 𝑖.
• A job cannot be divided between machines, that is, each job must be
processed by exactly one machine.
• Each machine can process more than one job.
• If a machine is used at all, then a setup time of 𝑠𝑖 units is needed.
• Formulate an IP to minimize the sum of total processing and setup
times.

IE 311 15
Machine Allocation Problem: Key Observations

• Decision variables (what can be decided/changed?)


• We need to know job 𝒋 is processed on which machine 𝒊.

• We also need to know which machine 𝒊 is used at all.

• Note the following relationship:


• If a machine 𝒊 is NOT used at all, then machine 𝒊 CANNOT process
job 𝒋.

IE 311 16
Machine Allocation Problem

IE 311 17
Modeling Conditional Statements

• Let 𝑥, 𝑦, 𝑧 be binary variables. Let us see how to model some


logical relationships:
• 𝑧 = 𝑥 and 𝑦 can be modelled as
𝑥 + 𝑦 − 1 ≤ 𝑧, 𝑧 ≤ 𝑥, 𝑧 ≤ 𝑦.
• 𝑧 = 𝑥 or 𝑦 can be modelled as
𝑥 + 𝑦 ≥ 𝑧, 𝑧 ≥ 𝑥, 𝑧 ≥ 𝑦.
• 𝑧 = 𝑥 xor 𝑦 can be modelled as
𝑥 + 𝑦 = 𝑧 + 2𝑤, 𝑤 ∈ 0,1 .

IE 311 18
Modeling Conditional Statements: Continued

• Let 𝑥, 𝑦, 𝑧 be binary variables. Let us see how to model some


logical relationships:
• y = not 𝑥 can be modelled as
𝑦 = 1 − 𝑥.
•𝑥 → 𝑦 can be modelled as
𝑥 ≤ 𝑦.
• 𝑥 → not 𝑦 can be modelled as
𝑥 ≤ 1 − 𝑦.

IE 311 19
Modeling Conditional Statements: Continued

• Let 𝑓1 𝑥1 , … , 𝑥𝑛 , 𝑓2 𝑥1 , … , 𝑥𝑛 be functions of decision variables


𝑥1 , … , 𝑥𝑛 .
• We will assume that there exist two constants 𝑀1 , 𝑀2 which upper
bound 𝑓1 , 𝑓2 for every value of 𝑥1 , … , 𝑥𝑛 .
• Let 𝑦 be a binary variable. Let us see how to model some logical
relationships:
• 𝑓1 𝑥1 , … , 𝑥𝑛 ≤ 0 or 𝑓2 𝑥1 , … , 𝑥𝑛 ≤ 0 can be modelled as
𝑓1 𝑥1 , … , 𝑥𝑛 ≤ 𝑀1 y, 𝑓2 𝑥1 , … , 𝑥𝑛 ≤ 𝑀2 1 − 𝑦 .
• 𝑓1 𝑥1 , … , 𝑥𝑛 > 0 → 𝑓2 𝑥1 , … , 𝑥𝑛 ≤ 0 can be modelled as
𝑓1 𝑥1 , … , 𝑥𝑛 ≤ 𝑀1 y, 𝑓2 𝑥1 , … , 𝑥𝑛 ≤ 𝑀2 1 − 𝑦 .

IE 311 20
Single-Machine Job Scheduling

• Jobs 1, … , 𝑛 must be processed on a single machine.


• Each job is available for processing after a certain time, called
release time.
• For each job 𝑖, we are given
• its release time 𝑟𝑖 ,
• its processing time 𝑝𝑖 and
• its weight 𝑤𝑖 .
• Formulate as a mixed-integer linear program the problem of
sequencing the jobs without overlap or interruption so that the
sum of the weighted completion times is minimized.

IE 311 21
Single-Machine Job Scheduling: Key Observations
• Decision variables (what can be decided/changed?)
• We need to know the completion time of each job 𝒊.
• We also need to know whether job 𝒊 is processed before job 𝒋 or not.
• If job 𝒊 is processed before job 𝒋, then we must have
job 𝑖 job 𝑗

𝐜𝐨𝐦𝐩𝐥. 𝐭𝐢𝐦𝐞 proc. time 𝐜𝐨𝐦𝐩𝐥. 𝐭𝐢𝐦𝐞


𝐨𝐟 𝐣𝐨𝐛 𝒊 + of job 𝑗
≤ 𝐨𝐟 𝐣𝐨𝐛 𝒋
• If job 𝒋 is processed before job 𝒊, then we must have
job 𝑗 job 𝑖
𝐜𝐨𝐦𝐩𝐥. 𝐭𝐢𝐦𝐞 proc. time 𝐜𝐨𝐦𝐩𝐥. 𝐭𝐢𝐦𝐞
IE 311 𝐨𝐟 𝐣𝐨𝐛 𝒋
+ of job 𝑖 ≤ 𝐨𝐟 𝐣𝐨𝐛 𝒊
22
Single-Machine Job Scheduling

IE 311 23
Set Covering (Winston, Page 486)

• There are six cities in Kilroy County.


• The county wants to determine the minimum number of fire stations needed to ensure
that at least one fire station is within 15 minutes (driving time) of each city.
• The times (in min) required to drive between the cities in Kilroy County are shown below:
City 1 City 2 City 3 City 4 City 5 City 6
City 1 0 10 20 30 30 20
City 2 10 0 25 35 20 10
City 3 20 25 0 15 30 20
City 4 30 35 15 0 15 25
City 5 30 20 30 15 0 14
City 6 20 10 20 25 14 0
• Formulate an IP that will tell Kilroy how many fire stations should be built and where they
should be located.
IE 311 24
Set Covering (Winston, Page 486)

• Example: By building a fire station in City 1, we cover cities 1 and 2.


• Parameters:

• Decision Variables:

• Model:

IE 311 25
Fixed Charge (Winston, Page 480)

• Gandhi Cloth Co. is capable of manufacturing three types of clothing: shirts, shorts, and pants.
• The manufacture of each type of clothing requires Gandhi to have the appropriate machinery
available.
• The machinery needed to manufacture each type of clothing must be rented at the following
rates: shirt machinery, $200/week; shorts machinery, $150/week; pants machinery, $100/week.
• The amounts of cloth and labor required in the manufacturing together with the variable unit
cost and selling price for each type of clothing are as follows:
Clothing Labor(hrs) Cloth (yards) Price($) Cost($)
Shirt 3 4 12 6
Shorts 2 3 8 4
Pants 6 4 15 8
• Each week, 150 hours of labor and 160 sq yd of cloth are available.
• Formulate an IP to maximize Gandhi’s profit (assume that production amounts are integer).

IE 311 26
Fixed Charge (Winston, Page 480)

• Decision variables:

• Objective:
• Labor Availability:
• Cloth Availability:
• Big-M Constraint:
• Variable Domains:

• NOTE: We need to choose Mj in such a way that 𝑥𝑗 ≤ 𝑀𝑗 is redundant when 𝑦𝑗 = 1.


For instance, 𝑀1 = 𝑀2 = 𝑀3 = 1000 work (best values: 𝑀1 = 40, 𝑀2 = 53, 𝑀3 = 25).
Fixed Charge-General Model
• Let us define the following parameters:

• Model:

IE 311 28
IP with Piecewise Linear Functions (Winston, Page 492)

• Euing Gas produces two types of gasoline (gas 1 and gas 2) from two types
of oil (oil 1 and oil 2).
• Each gallon of gas 1 must contain at least 50 percent oil 1, and each gallon
of gas 2 must contain at least 60 percent oil 1.
• Each gallon of gas 1 can be sold for 12¢, and each gallon of gas 2 can be
sold for 14¢.
• Currently, 500 gallons of oil 1 and 1,000 gallons of oil 2 are available.
• As many as 1,500 more gallons of oil 1 can be purchased at the following
prices: first 500 gallons, 25¢ per gallon; next 500 gallons, 20¢ per gallon;
next 500 gallons, 15¢ per gallon.
• Formulate an IP that will maximize Euing’s profits.

IE 311 29
IP with Piecewise Linear Functions

• Decision variables:

• Constraints:

• Objective function:
• We need to understand the details of the purchasing cost.

IE 311 30
IP with Piecewise Linear Functions: Purchasing Cost

• As many as 1,500 more gallons of oil 1 can be purchased at the following prices:
• First 500 gallons, 25¢ per gallon;
• Next 500 gallons, 20¢ per gallon;
• Next 500 gallons, 15¢ per gallon.

• The purchasing cost of oil 1 as a function of 𝑧 is given by the following piecewise


linear function:

IE 311 31
IP with Piecewise Linear Functions: Purchasing Cost

• Observe that the purchasing cost is a nonconvex function.


• Minimizing a nonconvex piecewise linear function is
“difficult”.
IE 311 32
IP with Piecewise Linear Functions: Purchasing Cost

• Minimizing a nonconvex piecewise linear function is “difficult”:

• However, if we knew in which piece 𝑧 lies in, then the resulting problem
would be “easy”.
• We create three copies of 𝑧 variable as 𝑧1, 𝑧2, 𝑧3 corresponding to each
piece and control them via three binary variables 𝑤1, 𝑤2, 𝑤3.

IE 311 33
IP with Piecewise Linear Functions: Complete Model

• Linearized Objective Function:

• Piecewise Linearization Constraints:

• Oil 1 requirement in Gas 1 and Gas 2:

• Availability of Oil 1 and Oil 2:

• Nonnegativity:

IE 311 34
Dinner Seating

• You are asked to determine the seating arrangement of 8 diners,


4 girls (A, B, C, D) and 4 boys (E, F, G, H) on a circular table.
• No boy must be seated next to a boy.
• A and E should not be seated next to each other.
• C and H should be seated next to each other.
• If A and F are seated next to each other, then D and F must be seated
next to each other.
• Formulate an integer linear program to determine if a feasible seating
arrangement exists.

IE 311 35
Dinner Seating

• Let 𝑖 = 𝐴, … , 𝐻 denote the girls and boys.


• Let 𝑗 = 1, … , 8 denote the seats.
• Decision Variables:

• This is a FEASIBILITY problem, therefore, there is no objective.


• Assignment Constraints:

IE 311 36
Dinner Seating
• No boy must be seated next to a boy.

• A and E should not be seated next to each other.

• C and H should be seated next to each other.

• If A and F are seated next to each other, then D and F must be seated
next to each other.

IE 311 37
Dorian Auto: “Either-Or” (Winston, Page 488)

• Dorian Auto is considering manufacturing three types of autos: compact, midsize,


and large.
• The resources required for, and the profits yielded by, each type of car is shown
below: Resource Compact Midsize Large
Steel required 1.5 tons 3 tons 5 tons
Labor required 30 hours 25 hours 40 hours
Profit yielded $2,000 $3,000 $4,000

• Currently, 6,000 tons of steel and 60,000 hours of labor are available.
• For production of a type of car to be economically feasible, at least 1,000 cars of
that type must be produced.
• Formulate an IP to maximize Dorian’s profit.

IE 311 38
Dorian Auto: Either-Or (Winston, Page 488)

• Decision variables:

• Objective:
• Labor Availability:
• Steel Availability:
• Big-M Constraint:

• Variable Domains:
• NOTE: We need to choose Mj in such a way that 𝑥𝑗 ≤ 𝑀𝑗 is redundant when 𝑦𝑗 = 1,
e.g., 𝑀1 = 𝑀2 = 𝑀3 = 100000 work (best values: 𝑀1 = 𝑀2 = 2000, 𝑀3 = 1200).
IE 311 39
Box Problem: “And”

• A company sells seven types of boxes, ranging in volume from 17 to 33 cubic feet. The
demand and size of each box type are given as follows:
Box 1 Box 2 Box 3 Box 4 Box 5 Box 6 Box 7
Size 33 30 26 24 19 18 17
Demand 400 300 500 700 200 400 200
• The cost (in dollars) of producing each box is equal to the box's volume. Moreover, a fixed
cost of $1000 is incurred to produce any of a box type.
• All demand should be met. If the company desires, a demand for a box may be satisfied by
a box of larger size.
• If both box type 5 and 7 are manufactured, then the total fixed cost is $1500 instead of
$2000.
• The company must manufacture at least 5 types of boxes.
• Formulate a mixed-integer linear program to minimize the cost of meeting the demand of
the boxes.

IE 311 40
Box Problem: “And”

• Parameters:

• Decision Variables:

• Objective Function:

IE 311 41
Box Problem: “And”

• Relation between 𝑥 and 𝑧 variables:

• Demand constraint:

• Fixed charge constraint (what is a reasonable value for 𝑀?):

• Relation between y and w variables:

• At least 5 box types to be produced:

• Variable Domains:

IE 311 42

You might also like