You are on page 1of 42

1

Linear Programming Solution


with Excel
by Art Ismail Yagci

Supplemental Doc.
2

Optimization
• Major field within the discipline of Data Analytics,
Operations Research and Management Science.
• Linear programming (also called linear
optimization problem) is a mathematical method
for finding the maximum or minimum value of a
multivariable function that is constrained by a
system of equalities or inequalities.
• Linear programming problems (linear
optimization) is not a programming language like
C++, Java, or Visual Basic.
Supplemental Doc.
3

Linear Programming: Basic Ideas


Linear optimization problems can be expressed in matrix or
mathematical equations. Mathematical equation format is
usual and most intuitive form of describing a linear
programming problem.
f(!", !$) = '"!" + '$!$
Subject to
(""!" + ("$!$ ≤ )"
($"!" + ($$!$ ≤ )$
(*"!" + (*$!$ ≤ )*
!" ≥ 0, !$ ≥ 0

Supplemental Doc.
4

Linear Programming: Basic Ideas


Linear Optimization Problem Components
• Decision Variables – a mathematical symbols f(!", !$ ) = '" !" + '$ !$
representing levels of activity (e.g., x1, x2)
• Objective Function– a linear mathematical Subject to
relationship describing an objective of the problem
(to maximize or minimize). 1"" !" + 1"$ !$ ≤ 2"
• Constraints - logical conditions (requirements or 1$" !" + 1$$ !$ ≤ 2$
limitations) that a solution to the problem must 13" !" + 13$ !$ ≤ 23
satisfy. They reflect real-world limits on
production/storage capacity, market demand, !" ≥ 0, !$ ≥ 0
available funds, and so on.
• Parameters - usually the given constant numerical
values.

Basic Idea
• Find the values of the decision variables that
maximize (minimize) the objective function value,
while staying within the constraints
5

Linear Programming (LP)


Real-world LPs which contain from hundreds of variables to
millions of variables are solved with specialized software
(e.g., www.solver.com). The problems (we will discuss in
class) are obviously much smaller, but the basic concepts
are much the same.

Supplemental Doc.
6

Linear Programming Problems


Many practical problems in operations research and
management science can be expressed as linear programming
problems. Such as
• Dynamic and Customized Pricing
• Blending/Product Mix
• Scheduling/Allocation
• Routing/Logistics
• Supply Chain Optimization
• Facility Location
• Financial Planning/Asset Management
• Diet Problem
• Etc.

Supplemental Doc.
7

Example of Linear Programming


• Product Mix Problem
• A manufacturer has fixed amounts of different resources such as
raw material, labor, and equipment.

• These resources can be combined to produce any one of several


different products.

• The quantity of the ith resource required to produce one unit of the
jth product is known.

• The decision maker wishes to produce the combination of products


that will maximize total income.

Supplemental Doc.
8

Example of Linear Programming


• Blending Problem
• Company wants to determine the optimum amounts of three
ingredients to include in an animal feed mix. The final product must
satisfy several nutrient restrictions. The mixture must meet the
following restrictions:
• Calcium — at least 0.8% but not more than 1.2%.
• Protein — at least 22%.
• Fiber — at most 5%.
• The problem is to find the composition of the feed mix that satisfies
these constraints while minimizing cost.

Supplemental Doc.
9

Example of Linear Programming


• Production Scheduling Problem
• A manufacturer knows that he must supply a given number of items
of a certain product each month for the next N months.
• They can be produced either in regular time, subject to a maximum
each month, or in overtime. The cost of producing an item during
overtime is greater than during regular time. A storage cost is
associated with each item not sold at the end of the month.
• The problem is to determine the production schedule that
minimizes the sum of production and storage costs.

Supplemental Doc.
10

Example of Linear Programming


• Transportation Problem
• Company has m warehouses and n retail outlets. Each warehouse
has given level of supply, and each outlet has given level of
demand. Company is also know the transportation cost between
every pair of warehouse and outlet.

• The problem is to determine the amount to be shipped from each


warehouse to each outlet such that the total cost of transportation
is a minimum.

Supplemental Doc.
11

Example of Linear Programming


• Flow Capacity Problem
• One example, traffic engineers may want to know the maximum
flow rate of vehicles from downtown car park to freeway on-ramp
because this will influence their decisions on whether to widen the
roads.

• Another example, might be maximum number of simultaneous


telephone calls between two cities via various land-lines, satellites,
and microwave towers operated by telephone company.

• The problem is to determine the maximum flow, or capacity of the


network.

Supplemental Doc.
12

LP Problem Formulation Process


In formulating a given decision problem in mathematical form, you should practice
understanding the problem by carefully reading and re-reading the problem
statement. While trying to understand the problem, ask yourself the following
general questions:
• What are the decision variables? That is, what are controllable inputs? Define the
decision variables precisely, using descriptive names.

• What are the parameters? That is, what are the uncontrollable inputs? These are
usually the given constant numerical values.

• What is the objective? What is the objective function? Also, what does the owner
of the problem want? How the objective is related to his decision variables? Is it a
maximization or minimization problem? The objective represents the goal of the
decision-maker.

• What are the constraints? That is, what requirements must be met? Should I use
inequality or equality type of constraint? What are the connections among
variables? Write them out in words before putting them in mathematical form.

Supplemental Doc.
13

Linear Programming Steps


• Understand the problem; draw a diagram
• Identify and label the decision variables
• Determine the objective and use the decision variables to write
an expression for the objective function as a linear function of
the decision variables.
• Determine the explicit constraints and write a functional
expression for each of them as either a linear equation or a
linear inequality in the decision variables.
• Determine the implicit constraints, and write each as either a
linear equation or a linear inequality in the decision variables.
E.g., non negativity constraint
• Do the analysis which should lead to the selection of values for
the decision variables that optimize the criterion function while
satisfying all the constraints imposed on the problem.

Supplemental Doc.
14

Example of LP: Product Mix Problem


• DJJ Enterprises makes automotive parts: Camshafts and
Gears
• Unit Profit: Camshafts $25/unit, Gears $18/unit
• Resources needed: Steel, Labor, Machine-Time. In total,
5000 pounds steel available, 1500 hours labor, and 1000
hours machine-time.
• Camshafts need 5 pounds steel, 1 hour labor, 3 hours
machine-time.
• Gears need 8 pounds steel, 4 hours labor, 2 hours
machine time.
• How many camshafts & gears to make in order to
maximize profit?

Supplemental Doc.
15

Example of LP: Product Mix Problem


• Diagram helps to
structure the problem
and use communication
tool.

• Text-based formulation
• Decision Variables:
Number of camshafts,
number of gears

• Objective Function:
Maximize profit

• Constraints: Don’t exceed


amounts available of steel,
labor, and machine time.

Supplemental Doc.
16

Example: Product Mix Problem


• Decision Variables
C = number of camshafts to make
G = number of gears to make
• Objective Function
Maximize 25C + 18G (profit in $)
• Constraints
5C + 8G <= 5000 (steel in pounds)
1C + 4G <= 1500 (labor in hours)
3C + 2G <= 1000 (machine time in hours) Max available steel, labor and
machine-time given in the problem
C >= 0, G >= 0 (non-negativity) definition

Supplemental Doc.
17

Example of LP: Product Mix Problem


• The key to solving an LP on a
spreadsheet is:
• Set up a spreadsheet that tracks
everything of interest (e.g., costs,
profits, resource usage)
• Identify the decision variables that
can be varied. These are called
Changing Cells (green color cells)
• Identify the cell that contains your
objective function as the Target
Cell (blue color cell)
• Identify the constraints and tell
SOLVER to solve the problem
• At this point, the optimal solution
to our problem will be placed on
the spreadsheet
18

How to Install SOLVER


The SOLVER Add-in is a Microsoft Office Excel add-in
program that is available when you install Microsoft Office
or Excel.

Supplemental Doc.
19

How to Install SOLVER


• Click the Microsoft Office • Open Excel for Mac 2016
Button (or Click the File tab), and • Go to the Tools menu
then click Excel Options. • Select "Add-ins"
• Click Add-Ins, and then in
the Manage box, select Excel Add- • Check "Solver Add-in" and
ins. "Analysis ToolPak" then click OK
• Click Go.
• In the Add-Ins available box, select
the Solver Add-in check box, and
then click OK.
• Tip If Solver Add-in is not listed in
the Add-Ins available box,
click Browse to locate the add-in.
• If you get prompted that the Solver Add-
in is not currently installed on your
computer, click Yes to install it.
• After you load the Solver Add-in,
the Solver command is available in
the Analysis group on the Data tab.
20

LP Example #1 (Product Mix)


The Quality Furniture Corporation produces benches and
picnic tables. The firm has two main resources: its labor
force and a supply of redwood for use in the furniture.
During the next production period, 1200 labor hours are
available under a union agreement. The firm also has a
stock of 5000 pounds of quality redwood. Each bench, that
Quality Furniture produces, requires 4 labor hours and 10
pounds of redwood; each picnic table takes 7 labor hours
and 35 pounds of redwood. Completed benches yield a
profit of $9 each, and tables a profit of $20 each. What
product mix will maximize the total profit?

Formulate this problem as a linear programming model.

Copyright © 2015 Pearson Education, Inc. Supplemental Doc.


Copyright © 2015 Pearson Education, Inc. 21

LP Example #1 (Product Mix)


B = number of benches to produce • Completed benches yield a
T = number of tables to produce profit of $9 each, and tables a
profit of $20 each.
• 1200 labor hours are available
Maximize Profit in $= ($9)B +($20)T
under a union agreement.
subject to • The firm also has a stock of
Labor: 4B + 7T ≤ 1200 hours 5000 pounds of quality redwood.
Wood: 10B + 35T ≤ 5000 pounds • Each bench requires 4 labor
and B ≥ 0, T ≥ 0 hours and 10 pounds of
redwood;
• Each picnic table takes 7 labor
We will now solve this LP model using hours and 35 pounds of
the Excel Solver.
redwood.
• What product mix will maximize
the total profit?
Copyright © 2015 Pearson Education, Inc. 22

Spreadsheet Solution of LP Example #1


2

4
Copyright © 2015 Pearson Education, Inc. 23

Spreadsheet Solution of LP Example #1


24

LP Example #2 (Diet Problem)


A prison is trying to decide what to feed its prisoners. They would like to
offer some combination of milk, beans, and oranges. Their goal is to
minimize cost, subject to meeting the minimum nutritional requirements
imposed by law. The cost and nutritional content of each food, along
with the minimum nutritional requirements are shown below.

Navy Oranges Minimum


Milk Beans (large Calif. Daily
(gallons) (cups) Va lencia) Requirement
Niacin (mg) 3.2 4.9 0.8 13.0
Thiamin (mg) 1.12 1.3 0.19 1.5
Vitamin C (mg) 32.0 0.0 93.0 45.0
Cost ($) 2.00 0.20 0.25

Supplemental Doc.
25

Spreadsheet Solution of LP Example #2


M = gallon of milk
B = cups of beans
O= number of oranges

Minimize Cost = ($2.00)M +($0.20)B+($0.25)O


subject to
Niacin: 3.2M + 4.9B + 0.8O ≥ 13 mg
Thiamin: 1.12M + 1.3B + 0.19O ≥ 1.5 mg
Vitamin C: 32M + 0B + 93O ≥ 45 mg
and M ≥ 0, B ≥ 0, O ≥ 0 Navy Oranges Minimum
Milk Beans (large Calif. Daily
(gallons) (cups) Valencia) Requirement
Niacin (mg) 3.2 4.9 0.8 13.0
Thiamin (mg) 1.12 1.3 0.19 1.5
VitaminC (mg) 32.0 0.0 93.0 45.0
Cost($) 2.00 0.20 0.25

Supplemental Doc.
26

Spreadsheet Solution of LP Example #2

Supplemental Doc.
27

Spreadsheet Solution of LP Example #2

Supplemental Doc.
28

LP Example #3 (Scheduling Problem)


An airline reservations office is open to take reservations by telephone
24 hours per day, Monday through Friday. The airline schedules agents
for six 8-hour shifts starting at 12 am, 4 am, 8 am 12 pm, 4 pm, 8 pm.
The demand for officers varies depending on the time-period (see
table). The airline wants to determine the minimal number of agents to
be employed so that there will be a sufficient number of agents
available for each period. Formulate this as a linear programming
problem by setting up appropriate constraints and objective function.
Number of
Time Period Officers Needed
12a.m. - 4 a.m. 11
4 a.m. - 8 a.m. 15
8 a.m. - 12p.m. 31
12p.m. - 4 p.m. 17
4 p.m. - 8 p.m. 25
8 p.m. - 12 a.m. 19

Supplemental Doc.
29

LP Example #3 (Scheduling Problem)


• The objective is to schedule agents is to minimize the
number of agents on each shift, so as to minimize cost.
• The problem is that agents work 8 hour shifts, yet the
demand comes in 4 hour chunks. That is the service
system scheduling dilemma, and that is why agencies
such as airlines have gone to flex time for agents.

Supplemental Doc.
30

LP Example #3 (Scheduling Problem)


• To formulate this problem, let's begin identifying and defining
decision variables
• Let x1,x2,x3,x4,x5,x6 be the number of agents joining duty at
the beginning of periods 1, 2, 3, 4, 5 and 6 respectively
• Objective function
Min f(x) = x1 + x2 + x3 + x4+ x5+ x6
• Subjected to following constraints
x1 +x6 >= 11
x2 + x1 >= 15
x3 + x2 >= 31
x4 + x3 >= 17
x5 + x4 >= 25
x6 + x5 >= 19
x1,x2,x3,x4,x5,x6 >= 0

Supplemental Doc.
31

Spreadsheet Solution of LP Example #3

Supplemental Doc.
32

Spreadsheet Solution of LP Example #3

Supplemental Doc.
33

LP Example #4 (Transportation Problem)


• A company wants to minimize the cost of shipping
a product from 2 different factories to 3 different
customers.
• Each factory has a limited supply and each
customer a certain demand.
Cost of shipping ($ per product) Capacity
Destinations Factory 1 50,000
Customer 1 Customer 2 Customer 3 Factory 2 50,000
Factory 1 $1.75 $2.25 $1.50
Factory 2 $2.00 $2.50 $1.00 Customer 1 Customer 2 Customer 3

Demand 30,000 23,000 16,000

• How should the company distribute the product?

Supplemental Doc.
34

Spreadsheet Solution of LP Example #4


• The variables are the number of products to ship from
each factory to the customers.
• Products-shipped
• The other two constraints are
• Total-shipped <= Capacity
• Total-received >= Demand

• The objective is to minimize cost.

Supplemental Doc.
35

Spreadsheet Solution of LP Example #4


Customer Customer 2 Customer
1 3
Factory 1 !"" !"# !"$
Factory 2 !#" !## !#$

Minimize Cost = ($1.75) !"" + ($2.25) !"# + ($1.50) !"$ + ($2.00) !#" +
($2.50) !## + ($1.00) !#$
subject to
Factory 1 to customers: !"" + !"# + !"$ ≤ 50000
Factory 2 to customers: !#" + !## + !#$ ≤ 50000
Customer 1 demand: !"" + !#" ≥ 30000
Customer 2 demand: !"# + !## ≥ 23000
Customer 3 demand: !"$ + !#$ ≥ 16000
and !"" , !"# , !"$ , !#" , !## , !#$ ≥ 0

Supplemental Doc.
36

Spreadsheet Solution of LP Example #4

Supplemental Doc.
37

Spreadsheet Solution of LP Example #4

Supplemental Doc.
38

LP Example #5 (Transportation Problem)


• A company wants to minimize the cost of shipping
a product from 2 different factories to 4 different
customers.
• Each factory has a limited supply and each
customer a certain demand.
Cost of shipping ($ per product)
Destinations Customer 1 Customer 2 Customer 3 Customer 4
Custom Customer Deman
er 1 Customer 2 Customer 3 4 d 30,000 23,000 15,000 16,000
Factory 1 $1.75 $2.25 $1.50 $1.50
Capacity
Factory 2 $2.00 $2.50 $2.50 $1.00
Factory 1 50,000
Factory 2 50,000

• How should the company distribute the product?

Supplemental Doc.
39

Spreadsheet Solution of LP Example #5


• The variables are the number of products to ship from
each factory to the customers.
• Products-shipped
• The other two constraints are
• Total-shipped <= Capacity
• Total-received >= Demand

• The objective is to minimize cost.

Supplemental Doc.
40

Spreadsheet Solution of LP Example #5


Customer Customer Customer
1 Customer 2 3 4
Factory 1 !"" !"# !"$ !"%
Factory 2 !#" !## !#$ !#%
Minimize Cost = ($1.75) !"" + ($2.25) !"# + ($1.50) !"$ + ($1.50) !"% + ($2.00) !#" +
($2.50) !## + ($2.50) !#$ + ($1.00) !#%
subject to
Factory 1 to customers: !"" + !"# + !"$ + !"% ≤ 50000
Factory 2 to customers: !#" + !## + !#$ + !#% ≤ 50000
Customer 1 demand: !"" + !#" ≥ 30000
Customer 2 demand: !"# + !## ≥ 23000
Customer 3 demand: !"$ + !#$ ≥ 15000
Customer 4 demand: !"% + !#% ≥ 16000

and !"" , !"# , !"$ , !"% , !#" , !## , !#$ , !"% ≥ 0

Supplemental Doc.
41

Spreadsheet Solution of LP Example #5

Supplemental Doc.
42

Spreadsheet Solution of LP Example #5

Supplemental Doc.

You might also like