Learning Objectives
• Identify decision-making situations which that
may benefit from optimization
• Formulate algebraic models for linear and
nonlinear programming problems.
• Develop spreadsheet models for linear
programming problems.
• Use Excel’s Solver Add-In to solve optimization
problems.
• Interpret the results of models and perform basic
sensitivity analysis.
Linear Programming
“Linear programming (LP, or linear optimization) is a method to
obtain the best outcome (such as maximum profit or lowest cost) in
a mathematical model whose requirements are expressed by linear
relationships
It is a technique for the optimization of a linear objective function, subject
to linear equality and linear inequality constraints
Let´s see this with an example…
From Wikipedia
• A Farmer owns 45 hectares of arable land. He would like to produce Wheat and Corn.
• Each Ton of Wheat and Corn can be sold at 200 euros and 300 euros respectively
• Each ha of Wheat requires 2 Tons of fertilizer, and 3 hours of labor. Each ha of Corn, in turns, demand 4
LP Example 1 •
Tons of fertilizer, and 2 hours of labor.
The labor unit cost per worker is 10 euros, and the fertilizer costs 50 euros/Kg.
• Each hectare of Wheat can produce 4 Tons, and each hectare of Corn can produce 4 Tons
• The farmer would like to know which amount of land to assign to the production of each product, to obtain
the greatest possible benefit.
• However, there are some limitations:
• The number of total labor hours available are 100
• The amount of fertilizer available is 120 Tons
• Given this information, what would you suggest him?
Definitions
• Objective Function: is a performance metric we want to maximize or
minimize. In this example, profit is the objective function to be maximized:
• Profit = Sales – Costs
• Sales= Tons of Wheat x Price of Wheat +
• Tons of Corn x Price of Corn
• Costs= Labor Costs + Fertilizer Costs
• Labor Costs = (Hours of labor for Wheat + Hours of Labor for Corn) x Labor
unit cost
• For example, if we arbitrarely set the number of ha for Wheat and Corn to
20 and 25, and replace all the values in the equations, we have that:
• Sales= 20 x 4 x 200 + 25 x 4 x 300 =46.000 euros
• Costs= (20 x 3 + 25 x 2)x 10 + (20 x 2 + 25 x 4)x 50= 8.100 euros
• Profits= 46,000 – 8.100 = 37.900 euros
• In terms of W and C
• Profits = W x 200 x 4 + C x 300 x 4 – (W x 3 + C x 2)x10 -(W x 2 + C x
4)X50
• Profits = W x 670 + C x 980
Decision variables: These are the variables we can decide upon. In our example:
W= The number of Ha. to be allocated to Wheat
C= The number of Ha. to be allocated to Corn
Constraints: These are the limitations/requirements, etc, that we must
meet. In our case:
. The area allocated to Wheat plus the area allocated to Corn
must be at most equal to 45 Ha
. The total hours available is 100 hrs
. The available quantity of fertilizer is 120 Kg
In “algebraic” terms:
W + C <= 45
3 x W+2 x C<=100 hours
2 x W + 4 x C <=120 Kg
Please, verify if these constraints are met, with our initial values of W
and C (20 and 25)
Solution:
. W+C=45 ➔ OK (<= 45)
. 3 x 20+ 2 x 25= 110 ➔ NOT OK (should be <=100 hours)
. 2 x 20 + 4 x 25= 140 ➔ NOT OK (should be<=120 Kg)
We have to iterate, setting new pairs of values (W;C), see if the constraints
are met, and if the Objective Function is maximized.
This can be solved algebraically, and with Excel Solver add-in
Sensitivity Analysis – Shadow Prices
Allowable Increase/Decrease:
Maximum amount that the
objective coefficients (70, 80)
can increase or decrease,
without changing the present
Solution given by solution (W=20, C=20).
Solver (The obj.function will change,
but not the solution)
Slack represents the difference between the available
resource and the amount of that resource that is actually
utilized in the solution. Slack represents the difference
between the available resource and the amount of that
Shadow Price: The amount that
the objective function would
resource that is actually utilized in the solution.
increase, if the constraint limit
increases one unit (e.g. Labor
from 100 to 101)
Multiple Changes – the 100% Rule
Example: Increase Labor
Constraint, from 100 to 110,
and decrease Fertilizer´s
from 120 to 100
Multiple Changes – the 100% Rule
Example: Increase Labor Labor max allowable increase: 20
Constraint, from 100 to 110, Suggested increase=10, i.e. 50% of
and decrease Fertilizer´s the max allowable
from 120 to 100
Multiple Changes – the 100% Rule
Example: Increase Labor Labor max allowable increase: 20 Fertilizer max allowable decrease: 53.3
Constraint, from 100 to 110, Suggested increase=10, i.e. 50% of Suggested decrease=20, i.e. 38% of the
and decrease Fertilizer´s the max allowable max allowable
from 120 to 100
50% + 38% = 88% <= 100% ➔OK
Definitions
Objective Function: is a performance metric we want to maximize or minimize.
In this example, profit is the objective function to be maximized:
Profit = Sales – Costs
Sales= Tons of Wheat x Price of Wheat +
Tons of Corn x Price of Corn
Costs= Labor Costs + Fertilizer Costs
Labor Costs = (Hours of labor for Wheat + Hours of Labor for Corn) x Labor unit cost
For example, if we arbitrarely set the number of ha for Wheat and Corn to 20 and
25, and replace all the values in the equations, we have that:
Sales= 20 x 4 x 200 + 25 x 4 x 300 = 46,000 euros
Costs= (20 x 3 + 25 x 2)x 10 + (20 x 2 + 25 x 4)x 50= 8.100 euros
Profits= 46,000 – 8.100 = 39.700 euros
In terms of W and C
Profits = W x 200 x 4+ C x 300 x 4 – (W x 3 + C x 2)x10 -(W x 2 + C x 4)X50
Profits = W x 670 + C x 980
If instead of maximizing Profits, we
wanted to maximize SALES…..
Definitions
Objective Function: is a performance metric we want to maximize or minimize.
In this example, profit is the objective function to be maximized:
Profit = Sales – Costs
Sales= Tons of Wheat x Price of Wheat +
Tons of Corn x Price of Corn
Costs= Labor Costs + Fertilizer Costs
Labor Costs = (Hours of labor for Wheat + Hours of Labor for Corn) x Labor unit cost
For example, if we arbitrarely set the number of ha for Wheat and Corn to 20 and
25, and replace all the values in the equations, we have that:
Sales= 20 x 200 + 25 x 300 = 11.500 euros
In terms of W and C
Sales = W x 200 + C x 300
This would be our new OBJECTIVE
FUNCTION…Let´s solve it…
In this particular case, the
objective coefficients represent
the Prices of Wheat and Corn.
Now, the Allowable increase and
decrease, mean the máximum
change in Price (upwards, or
downwards) of these products
Linear Programming – Integer variables
Company XYZ manufactures two products:
Product A, and Product B.
Product B has a higher profit margin, but also requires more resources, in terms of Labor and Quality control
hours.
The demand for these two products excedes the present production capacity.
Given that there is no limitations regarding the number of units that can be sold, but that the number of
hours available for manufacturing and quality control are indeed limited, the Manager would like to
determine the best combination of production of each Product.
The goal is to have the highest profit posible, within the present restrictions.
Product A Product B
Price 800 1100
Variable Costs 600 850
Gross Margin 200 250
Manufacturing Hours req. Per unit 10 14
Quality Control Hours req. Per unit 2 2.5
Total Gross Margin = PA x 200 + PB x 250
PA = Number units of Product A manufactured
PB = Number units of Product A manufactured
Please, define the Objective Function, the Constraints, and Solve this
problem, with Excel SOLVER
Product A Product B
Price 800 1100
Variable Costs 600 850
Gross Margin 200 250
Manufacturing Hours req. Per unit 10 14
Quality Control Hours req. Per unit 2 2.5
Objective Function:
Total Gross Margin = PA x 200 + PB x 250 (Maximize)
PA = Number units of Product A manufactured
PB = Number units of Product A manufactured
Problem: Fractions of Units?
How do we fix that?
Optimizing - Non Linear cases
The XYZ2 Company manufactures and sells two products: A,
and B.
Product A sells for 500 euros, and B for 600.
The variable costs (which are the costs of the consumable
needed to produce the units) follow a Discount scheme such
as the one in this Table :
The first two columns represent the range of the purchase of the materials. For instance,
for Product A, the cost of purchase of one unit, when buying 50 or less units, is 300
euros.
If the compamy buys 120 units, for example, the unit cost will be 270 euros, and so
forth…
THIS IS NOT A LINEAR FUNCTION!!!!
How do we handle these cases?
Let´s first formulate our problem in Excel…
Sales = A x 500 + B x 600
where A and B are the production/sales of each
product
Costs =? This Item Will depend on how much the company
purchases from the supplier (following the volumen
discount table). The Excel VLOOKUP function will help.
Profit= Sales – Costs : This Will be our OBJECTIVE FUNCTION, to
maximize
Let´s first formulate our problema in Excel…
Sales = A x 500 + B x 600
where A and B are the production/sales of each
product
Costs =? This Item Will depend on how much the company
purchases from the supplier (following the volumen
discount table). The Excel VLOOKUP function will help.
Profit= Sales – Costs : This Will be our OBJECTIVE FUNCTION, to
maximize
Let´s first formulate our problema in Excel…
Sales = A x 500 + B x 600
where A and B are the production/sales of each
product
Costs =?
Profit= Sales – Costs : This Will be our OBJECTIVE FUNCTION, to
maximize
With the following Production Constraints:
The production of A has to be less (or equal) than 200 units
The production of B has to be less (or equal) than 150 units
The production of A + B has to be less (or equal) than 300 units
Matching Demand and
Supply - Distribution
Matching Demand and Supply - Distribution
◆ G-Mart Inc. is a retail company.
◆ It has 3 Warehouses, in City A, City B and City C (from now on, WA, WB, WC)
◆ G-Mart has to send the products to 5 Retail Stores (R1, R2, R3, R4 and R5)
◆ WA, WB and WC have at this moment, the following Inventory, that must be shipped
100% this month:
Warehouse To Be Shipped Out (tons)
WA 25
WB 30
WC 45
◆ The Retail must receive a MINIMUM quantity each, as specified in the following Table:
Minimum To Be Shipped
Retail Center In (tons)
R1 15
R2 20
R3 25
R4 15
R5 30
R1 Decision Variables:
≥ 15 R5
≥ 30
25 WA
R2
30
≥ 20
WB
R3
45
≥ 25
WC R4
Tons to be shipped
From / To R1 R2 R3 R4 R5 TOTAL ≥ 15
WA XA1 XA2 XA3 XA4 XA5 25
WB XB1 XB2 XB3 XB4 XB5 30
WC XC1 XC2 XC3 XC4 XC5 45
TOTAL >= 15 17 20 15 10
R1 Decision Variables:
≥ 15 R5
≥ 30
25 WA
R2
30
≥ 20
WB
R3
45
≥ 25
WC R4
Tons to be shipped
From / To R1 R2 R3 R4 R5 TOTAL ≥ 15
WA XA1 XA2 XA3 XA4 XA5 25
WB XB1 XB2 XB3 XB4 XB5 30
WC XC1 XC2 XC3 XC4 XC5 45
TOTAL >= 15 17 20 15 10
R1 Decision Variables:
≥ 15 R5
≥ 30
25 WA
R2
30
≥ 20
WB
R3
45
≥ 25
WC R4
Tons to be shipped
From / To R1 R2 R3 R4 R5 TOTAL ≥ 15
X
WA XA1 XA2 XA3 XA4 XA5 25
WB XB1 XB2 XB3 XB4 XB5 30
WC XC1 XC2 XC3 XC4 XC5 45
TOTAL >= 15 17 20 15 10
Objective Function
• Minimize transportation Costs
• Transportation Costs
• WAR1 x XA1 + WAR2 x XA2+ WAR3 x XA3+ WAR4 x XA4+ WAR5 x XA5 +
• WBR1 x XB1 + WBR2 x XB2+ WBR3 x XB3+ WBR4 x XB4+ WBR5 x XA5 +
• WCR1 x XC1 + WCR2 x XC2+ WBC3 x XC3+ WCR4 x XC4+ WCR5 x XA5
Transportation costs
From / To R1 R2 R3 R4 R5
WA 95 130 160 145 170
WB 100 135 140 160 180
WC 120 125 120 130 135
Constraints:
Minimum Tons to be shipped in to:
Tons to be shipped from:
Minimum To Be
Retail Center Shipped In (tons)
Tons to be
Warehouse shipped R1 15
R2 17
A 25
R3 20
B 30
R4 15
C 45 R5 10
WA1+WA2+WA3+WA4+WA5= 25 WA1+WB1+WC1 >= 15
WB1+WB2+WB3+WB4+WB5= 30 WA2+WB2+WC1 >= 17
WC1+WC2+WC3+WC4+WC5= 45 WA3+WB3+WC3 >= 20
WA4+WB1+WC4 >= 15
WA5+WB5+WC5 >= 10