2a.modeling Linear and Integer Programs-2
2a.modeling Linear and Integer Programs-2
Summer 2024
Modeling Linear and Integer Programs
IE 311 2
Recall: Types of Linear Optimization Models
IE 311 3
A First Example: Farmer LP
• A farmer must determine how many acres of corn and wheat to plant.
• An acre of corn yields 10 bushels of corn and requires 4 hours of labor per
week.
• An acre of wheat yields 25 bushels of wheat and requires 10 hours of labor
per week.
• All corn can be sold at $3 a bushel and all wheat can be sold at $4 a bushel.
• 7 acres of land and 40 hours per week of labor are available.
• Government regulations require that at least 30 bushels of corn be
produced.
• How can the farmer maximize the total revenue?
IE 311 4
Farmer LP: Components (I)
IE 311 5
Farmer LP: Components (II)
IE 311 6
Farmer LP: Components (III)
• Labor availability
• Government regulations
• Nonnegativity
IE 311 7
Assumptions in Linear Programming
IE 311 8
Assumptions in Linear Programming
IE 311 9
Giapetto LP (Winston, page 49)
• Giapetto’s, Inc., manufactures two types of wooden toys: soldiers and trains.
• Each soldier built:
• sells for $27 and uses $10 worth of raw materials.
• increases Giapetto’s variable labor/overhead costs by $14.
• requires 2 hours of finishing labor and 1 hour of carpentry labor.
• Each train built:
• sells for $21 and uses $9 worth of raw materials.
• increases Giapetto’s variable labor/overhead costs by $10.
• requires 1 hour of finishing labor and 1 hour of carpentry labor.
• Each week Giapetto has only 100 finishing hours and 80 carpentry hours available.
• Demand for trains is unlimited, but at most 40 soldiers are bought each week.
• Giapetto wants to maximize weekly profit (revenues - costs).
IE 311 10
Giapetto LP: Model (I)
IE 311 11
Giapetto LP: Model (II)
• Nonnegativity
IE 311 12
Graphical Solution Method
• Notice that both examples considered so far (Farmer and Giapetto) have
only two variables.
• It is possible to solve LPs with two variables by the “Graphical Solution
Method”.
• This method gives valuable intuition as to the possible outcomes of LPs:
• LP is infeasible (no feasible solution exists)
• LP is feasible (feasible solution exists)
• LP has unbounded objective (the “optimal value” is unbounded)
• LP has bounded objective (the optimal value is bounded)
• Unique optimal solution
• Multiple optimal solution
• We will see later in the course that the Simplex Method is based on the
intuition obtained from the Graphical Solution Method.
IE 311 13
Graphical Solution Method: Giapetto LP
(1)
(3)
(1)
(2)
(3)
(2)
IE 311 14
Post Office (Winston, page 72)
IE 311 15
Post Office: Key Observations
IE 311 16
Post Office LP vs. IP
• My diet requires that all the food I eat come from one of the four “basic food groups” (chocolate
cake, ice cream, soda, and cheesecake).
• At present, the following four foods are available: brownies, chocolate ice cream, cola, and pineapple
cheesecake.
• Each brownie costs 50¢, each scoop of chocolate ice cream costs 20¢, each bottle of cola costs 30¢,
and each piece of pineapple cheesecake costs 80¢.
• Each day, I must ingest at least 500 calories, 6 oz of chocolate, 10 oz of sugar, and 8 oz of fat.
• The nutritional content per unit of each food is shown in the following table:
Ingredients Brownie Chocolate ice cream Cola Pineapple cheesecake Daily Requirement
Calories 400 200 150 500 500
Chocolate (oz) 3 2 0 0 6
Sugar (oz) 2 2 4 4 10
Fat (oz) 2 4 1 5 8
• Formulate a linear programming model that can be used to satisfy my daily nutritional requirements
at minimum cost. How can you generalize the model with m ingredients and n food types?
IE 311 18
Diet LP – Specific Formulation
IE 311 19
Diet LP – Specific Formulation
• Chocolate requirement
• Sugar requirement
• Fat requirement
• Nonnegativity
IE 311 20
Diet LP – Generic Formulation
IE 311 21
Transportation LP
• A decision now needs to be made about the shipping plan for how many units to
ship from each factory to each customer.
• Formulate this problem as an LP.
IE 311 22
Transportation LP: Key Observations
C1
F1
C2
F2
C3
IE 311 23
Transportation LP: Key Observations
C1 C1
F1 F1
C2 C2
F2 F2
C3 C3
IE 311 24
Transportation LP
IE 311 25
Transportation LP: General Model
IE 311 26
Blending LP (Winston, page 86)
• Sunco Oil manufactures three types of gasoline. Each type is produced by blending three types of crude oil.
• The sales price of gasoline, the purchase price of crude oil and their octane and sulfur content are given below:
Gas Price($) Oil Cost($) Octane Sulfur(%)
1 70 1 45 12 0.5
2 60 2 35 6 2.0
3 50 3 25 8 3.0
• Sunco can purchase up to 5,000 barrels of each type of crude oil daily. The three types of gasoline differ in their octane and
sulfur content as follows:
• The crude oil blended to form gas 1 must have an average octane rating of at least 10 and contain at most 1% sulfur.
• The crude oil blended to form gas 2 must have an average octane rating of at least 8 and contain at most 2% sulfur.
• The crude oil blended to form gas 3 must have an average octane rating of at least 6 and contain at most 1% sulfur.
• It costs $4 to transform one barrel of oil into one barrel of gasoline, Sunco’s refinery can produce up to 14,000 barrels of
gasoline daily.
• Sunco’s customers require the following amounts of each gasoline daily: gas 1—3,000 barrels; gas 2—2,000 barrels; gas 3—
1,000 barrels.
• Sunco also has the option of advertising to stimulate demand for its products. Each dollar spent daily in advertising a particular
type of gas increases the daily demand for that type of gas by 10 barrels.
• Formulate an LP that will enable Sunco to maximize daily profits (revenues - costs).
IE 311 27
Blending LP: Key Observations
O2 G2
O3 G3
IE 311 28
Blending LP: Key Observations
O1 G1 O1 G1
O2 G2 O2 G2
O3 G3 O3 G3
IE 311 29
Blending LP: Key Observations
6
O2 G2
8
O3 G3
IE 311 30
Blending LP: Decision Variables and Objective Function
• Decision variables:
• Objective:
31
Blending LP: Constraints
• Oil availability:
• Gas demand:
• Total capacity:
• Octane rating:
• Sulfur content:
• Nonnegativity:
32
Production Planning
IE 311 34
Production Planning
IE 311 35
A Few “Tricks” to Linearize Special Nonlinear Expressions
IE 311 36
Machine Balancing Example
• A machine shop has a drill press and a milling machine which are used to
produce two parts A and B.
• The required time (in minutes) per unit part on each machine is shown in the
table below.
Part Drill Press Milling Machine
A 3 4
B 5 3
• The shop must produce at least 50 units in total (both A and B) and at least 30
units of part A, and it can make at most 100 units of part A and 100 units of
part B.
• Formulate an LP to minimize the absolute difference between the total
running time of the drill press and that of the milling machine.
IE 311 37
Machine Balancing Example
IE 311 38
Piecewise Linear Example
• A farm grows two types of mangoes. This year the yield of mangoes of type 1 is 1000
units and that of type 2 is 700 units. The farm sells all its mangoes.
• The mangoes can be sold to a retail company and can also be sold in a local market
directly. The contract with the retail company has the following details:
• At least 60% of the total amount of mangoes sold to the retail company must be type 2.
• The retail company has a demand of 1000 units of mangoes and pays $3 per unit for both types.
The demand does NOT need to be satisfied exactly.
• If the total amount of mangoes sold to the retail company is less than 1000 units, then there is a
penalty of $0.05 per unit shortfall from 1000 units.
• If the number of units of mangoes is more than 1200, then each unit over the first 1200 units is
purchased by the retail store at the rate of $2.5 per unit.
• Mangoes of type 1 sell at $2.2 per unit in the local market and mangoes of type 2
sell for $3.1 per unit in the local market.
• Any amount of mangoes can be sold in the local market.
• Formulate a linear program to maximize the net revenue of the farm.
IE 311 39
Piecewise Linear Example
• Decision variables:
• Constraints:
• Objective function:
• We need to understand the details of the retailer contract.
IE 311 40
Piecewise Linear Example: Retailer Contract
• The retail company has a demand of 1000 units of mangoes and pays $3 per unit
for both types.
• If the total amount of mangoes sold to the retail company is less than 1000 units,
then there is a penalty of $0.05 per unit shortfall from 1000 units.
• If the number of units of mangoes is more than 1200, then each unit over the
first 1200 units is purchased by the retail store at the rate of $2.5 per unit.
IE 311 41
Piecewise Linear Example: Retailer Contract
IE 311 42
Piecewise Linear Example: Retailer Contract
• This is an LP!
IE 311 43
Piecewise Linear Example: Complete Model
IE 311 44
Single Facility Rectilinear Distance Location Problem
• We are given the location of 6 plants in 2D space and their raw material demand.
x-Coordinate y-Coordinate Demand
1 1 50
5 12 60
2 8 19
4 4 20
8 6 32
10 7 23
• The raw material will be provided from a warehouse to be located.
• The transportation cost between the warehouse located at (x,y) and a plant located at (a,b) is equal
to demand times the rectilinear distance, that is, 𝑥 − 𝑎 + |𝑦 − 𝑏|.
• Provide a linear program which minimizes the total transportation cost.
• What if our aim is to minimize the largest distance between the warehouse and plants?
IE 311 45
Single Facility Rectilinear Distance Location Problem
𝑥 ≥ 0, 𝑦 ≥ 0
IE 311 46
Sailco Inventory (Winston, page 101)
• Sailco must determine how many sailboats should be produced during next four quarters.
• The demand during each of the next four quarters is 40, 60, 75, 25, respectively.
• Sailco must meet demands on time. At the beginning of the first quarter, Sailco has an inventory of 10
sailboats.
• At the beginning of each quarter, Sailco must decide how many sailboats should be produced during that
quarter. For simplicity, we assume that sailboats manufactured during a quarter can be used to meet
demand for that quarter.
• During each quarter, Sailco can produce up to 40 sailboats with regular-time labor at a total cost of $400
per sailboat. By having employees work overtime during a quarter, Sailco can produce additional sailboats
with overtime labor at a total cost of $450 per sailboat.
• At the end of each quarter (after production has occurred and the current quarter’s demand has been
satisfied), a carrying or holding cost of $20 per sailboat is incurred.
• Use linear programming to determine a production schedule to minimize the sum of production and
inventory costs during the next four quarters.
IE 311 47
Sailco Inventory (Winston, page 101)
IE 311 48
Powerco Electric Company (Winston, page 360)
• Powerco has three electric power plants that supply electricity to four cities.
• The table below shows
• the cost of sending 1 kwh of electricity from each plant to each city
• the capacity of each plant
• the exact demand of each city.
City 1 City 2 City 3 City 4 Capacity
Plant 1 $8/kwh $6/kwh $10/kwh $9/kwh ≤ 35 Mwh
Plant 2 $9/kwh $12/kwh $13/kwh $7/kwh ≤ 50 Mwh
Plant 3 $14/kwh $9/kwh $16/kwh $5/kwh ≤ 45 Mwh
Demand = 45 Mwh = 20 Mwh = 30 Mwh = 30 Mwh
• A decision now needs to be made about the dispatch of electricity regarding
how many Mwh to send from each plant to each city.
• Formulate this problem as an LP, implement and solve in the Python-Gurobi
interface.
IE 311 49
Powerco Electric Company (Winston, page 360)
• Decision Variables:
𝑥𝑖𝑗 : # of (million) kwh produced at plant i and sent to city j
• The model:
• Decision Variables:
• Objective Function:
• Constraints:
IE 311 53
Giapetto LP: Python-Gurobi Implementation
IE 311 55