2b.modeling Linear and Integer Programs
2b.modeling Linear and Integer Programs
Spring 2021
Recall: Types of Linear Optimization Models
IE 311 2
Is Integer Programming Really Needed?
IE 311 3
Integer Programming Preliminaries
IE 311 4
A First Example: Knapsack IP
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)
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
• Binary requirements
IE 311 7
Knapsack IP: Simplest (but Dirty)
Python-Gurobi Implementation s.t.
m = Model('Knapsack')
IE 311 9
Capital Budgeting (Winston, Page 478)
IE 311 10
Capital Budgeting (Winston, Page 478)
• Additional constraints:
• Stockco can invest in at most two investments.
IE 311 11
Distribution Problem
IE 311 14
Machine Allocation Problem
IE 311 15
Machine Allocation Problem: Key Observations
IE 311 16
Machine Allocation Problem
IE 311 17
Modeling Conditional Statements
IE 311 18
Modeling Conditional Statements: Continued
IE 311 19
Modeling Conditional Statements: Continued
IE 311 20
Single-Machine Job Scheduling
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 𝑗
IE 311 23
Set Covering (Winston, Page 486)
• 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:
• 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.
IE 311 31
IP with Piecewise Linear Functions: Purchasing Cost
• 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
• Nonnegativity:
IE 311 34
Dinner Seating
IE 311 35
Dinner Seating
IE 311 36
Dinner Seating
• No boy must be seated next to a boy.
• 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)
• 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”
• Demand constraint:
• Variable Domains:
IE 311 42