View
214
Download
0
Tags:
Embed Size (px)
Citation preview
Lecture 7: Linear Programming in Excel
AGEC 352Spring 2011 – February 9, 2011
R. Keeney
Linear Programming on the ComputerTwo things to know:
◦1) Setting up the spreadsheet and directing Solver to run This is what lab is for and we will learn
this through repetition
◦2) Understanding what happens between starting Solver and it giving you a solution We are covering this in lecture
Computer algorithmsStep by step approach: often
called a routine or procedure
List of directions to be carried out and a series of checks◦The checks indicate which direction
is to be done next
Simplex method as an algorithmStep 1: Identify the pivot columnStep 2: Identify the pivot cellStep 3: Convert the pivot cell to
a value of 1Step 4: Convert the remaining
cells of the pivot column to a value of 0
Step 1: Direction to the comp.
Ask the computer to search over the row labeled ‘obj’ and find the most negative value
In Excel:◦Min function: = min(B17:F17)◦Small function: = small(B17:F17,1)
Initial TableauC B s1 s2 s3 P RHS
land 1 1 1 0 0 0 320cash 50 100 0 1 0 0 20000stor 100 40 0 0 1 0 19200obj -60 -90 0 0 0 1 0
Step 2: Direction to the comp.
Working in the Beans column (In Excel this is labeled as C)
Have Excel calculate a column =RHS/BHave Excel identify the minimum value
in that column (min or small functions)
Initial TableauC B s1 s2 s3 P RHS
land 1 1 1 0 0 0 320cash 50 100 0 1 0 0 20000stor 100 40 0 0 1 0 19200obj -60 -90 0 0 0 1 0
Step 3: Direction to the comp.
Working in the cash rowHave Excel recalculate the cash row
by dividing through by 100=B15/$C$15An absolute cell reference
◦Copying to other cells will change the numerator but not the denominator
Initial TableauC B s1 s2 s3 P RHS
land 1 1 1 0 0 0 320cash 50 100 0 1 0 0 20000stor 100 40 0 0 1 0 19200obj -60 -90 0 0 0 1 0
Step 4: Direction to the comp.
Calculate a factor for each row◦E.g. Land factor = -1◦Old land row + {land factor x cash row} =
new land rowRun a check for negative values in the
obj rowIf statement: =if(condition, true, false)
Initial TableauC B s1 s2 s3 P RHS
land 1 1 1 0 0 0 0cash 0.5 1 0 0.01 0 0 200stor 100 40 0 0 1 0 0obj -60 -90 0 0 0 1 0
The example is simplifiedThe steps discussed above would
require a considerable amount of user input
Solver and other computer programs are typically designed to take user input only at the beginning and then return completed output
Spreadsheet does not have the capacity, to do this efficiently, need a more robust programming language
Excel LP Model Setup
Corn SoybeansActivity Levels 0 0Profit per acre 60 90 0<-Objective Cell Measuring Total Profits
Constraints LHS Sign RHSLand 1 1 0<= 320Cash 50 100 0<= 20000Storage 100 40 0<= 19200
*Decision variables are listed at the top of each column.
*First value underneath is the current value of the variable.
*Always set to zero before running Solver.
DECISION VARIABLES
Excel LP Model Setup
Corn SoybeansActivity Levels 0 0Profit per acre 60 90 0<-Objective Cell Measuring Total Profits
Constraints LHS Sign RHSLand 1 1 0<= 320Cash 50 100 0<= 20000Storage 100 40 0<= 19200
*Every other row in the model is an equation and the cells are equation coefficients.
*Place the objective equation directly under the decision variables. Read as 60*Corn + 90*Soybeans =
*Objective Cell holds the value of the objective equation.
Excel LP Model Setup
Corn SoybeansActivity Levels 0 0Profit per acre 60 90 0<-Objective Cell Measuring Total Profits
Constraints LHS Sign RHSLand 1 1 0<= 320Cash 50 100 0<= 20000Storage 100 40 0<= 19200
*Constraint equations work the same way as the objective equation. We calculate their values in a column called LHS.
*E.g. Land constraint is 1*Corn + 1*Soybeans.
*RHS column is the upper limit for each resource. Comparing the LHS to the RHS checks feasibility.
Excel LP Model Setup*More variables? Add more columns to the right of Soybeans.
*More constraints? Add more rows beneath Storage.
*The cells in orange below are the only ones that Solver actually uses. It adjusts activity levels to maximize the objective cell formula result while ensuring that no LHS value exceeds the RHS value.
Corn SoybeansActivity Levels 0 0Profit per acre 60 90 0<-Objective Cell Measuring Total Profits
Constraints LHS Sign RHSLand 1 1 0<= 320Cash 50 100 0<= 20000Storage 100 40 0<= 19200
SolverScreen capture are from Excel 2010
Reference to objective cell
Reference to decision variables
Input the constraints (i.e. LHS <= RHS)
Solver
Solving Method:
For linear programs, we use Simplex LP. (This is automatic when you click ‘assume linear model’ in previous versions of Excel.)
We’ll discuss Options later.