15
–1– c Samuel K. Eldersveld – OM301 – April 23, 2007 1. Linear Programming Quick Review 2. More formulations 3. Solution Techniques 4. Using the Excel Solver Add-In 5. Interpretation of Output. 6. Sensitivity Analysis OM301 - L9 – p. 1/2 –2– c Samuel K. Eldersveld – OM301 – April 23, 2007 Linear Programming: Linear programming uses a mathematical model to nd the best allocation of scarce resources to various activities so as to maximize prot or minimize cost A linear program is a “plan” modeled using linear equations and solved using a computer. OM301 - L9 – p. 2/2

Excel_Solver_Example

Embed Size (px)

DESCRIPTION

Alinearprogramisa“plan”modeledusinglinearequationsandsolvedusingacomputer. –2– c SamuelK.Eldersveld–OM301–April23,2007 SamuelK.Eldersveld–OM301–April23,2007 OM301-L9–p.1/2 OM301-L9–p.2/2 c –1–

Citation preview

Page 1: Excel_Solver_Example

–1– c©Samuel K. Eldersveld – OM301 – April 23, 2007

1. Linear Programming Quick Review

2. More formulations

3. Solution Techniques

4. Using the Excel Solver Add-In

5. Interpretation of Output.

6. Sensitivity Analysis

OM301 - L9 – p. 1/2

–2– c©Samuel K. Eldersveld – OM301 – April 23, 2007

Linear Programming:

Linear programming uses a mathematical model to find thebest allocation of scarce resources to various activities so asto maximize profit or minimize cost

A linear program is a “plan” modeled using linear equations and solved using a computer.

OM301 - L9 – p. 2/2

Page 2: Excel_Solver_Example

–3– c©Samuel K. Eldersveld – OM301 – April 23, 2007

1. Decision Variables

x1, x2, . . . , xn.

2. Objective Function

Z = c1x1 + c2x2 + · · · + cnxn,

3. Constraints

ai1x1 + ai2x2 + · · · + ainxn

8<:

=

9=; bi, for i = 1, . . . ,m.

4. Model parameters.cj, bi, aij

OM301 - L9 – p. 3/2

–4– c©Samuel K. Eldersveld – OM301 – April 23, 2007

Chose the values of decisions variables x1, x2, . . . , xn to:

maximize{x1,x2,...,xn}

Z = c1x1 + c2x2 + · · · + cnxn

subject to a11x1 + a12x2 + · · · + a1nxn

n≤≥=

ob1

a21x1 + a22x2 + · · · + a2nxn

n≤≥=

ob2

......

am1x1 + am2x2 + · · · + amnxn

n≤≥=

obm

and xj ≥ 0, for j = 1, 2, . . . , n.

For known parameters: cj , for j = 1, 2, . . . , n,bi, for i = 1, 2, . . . , m,aij , for i = 1, 2, . . . , m, and j = 1, 2, . . . , n.

OM301 - L9 – p. 4/2

Page 3: Excel_Solver_Example

–5– c©Samuel K. Eldersveld – OM301 – April 23, 2007

1. Define your decisions variables (what decisions need to be made?)As a manager, what decisions do you have available to you? Which of these decisions involve quantitative

values?

2. Explicitly define your objective functionDetermine your overall objective (e.g. maximize profit, minimize cost, etc.) Then construct an equation using

your decision variables multiplied by the contribution to the objective given by the unit change in each

decision variable.

3. Determine your constraints:

(a) Determine what resources are required.

(b) Determine what resources might be in short supply.

(c) Determine what other requirements must be met (e.g. demand).

(d) Write down your objective, constraints and variable bounds.

4. Do not forget to include bounds on variables (e.g. xi ≥ 0 and/orxi ≤ ui) as necessary.

OM301 - L9 – p. 5/2

–6– c©Samuel K. Eldersveld – OM301 – April 23, 2007

Minimum number of

Period Time officers on duty

1 12a–04a 5

2 04a–08a 7

3 08a–12p 15

4 12p–04p 8

5 04p–08p 12

6 08p–12a 9

Union contracts stipulate that all employees work 8 consecutive hours.

Objective: Hire the minimum number of officers need to cover all shifts.

Part (b): If the officers who work consecutively from 12a–08a are paid 50% more, andthe objective is to minimize total wage cost, how should the model be changed?

OM301 - L9 – p. 6/2

Page 4: Excel_Solver_Example

–7– c©Samuel K. Eldersveld – OM301 – April 23, 2007

A company has two plants (A and B) producing a certain product that is to be

shipped to three warehouses (1,2, and 3). Unit production cost at each plant unit

shipping cost from each plant to each warehouse, and unit sales price at each

warehouse are all given below (costs and prices are in dollars)

Shipping Warehouse

Cost 1 2 3

Plant A 4 6 4

Plant B 6 5 6

Production Cost

Plant A 3

Plant B 4

Sales Warehouse

Price 1 2 3

18 17 9

Shipments are made once per week. During each week, each plant produces at

most 65 units and each warehouse needs at least 40 units. How many units should

be shipped from each plant to each warehouse, so as to maximize profit?

OM301 - L9 – p. 7/2

–8– c©Samuel K. Eldersveld – OM301 – April 23, 2007

1. A prison is trying to decide what to feed its prisoners. They would like to offer somecombination of milk, beans and oranges in the next meal. Their goal is to minimize costwhile satisfying a set of minimum nutritional requirements. The cost and nutritionalcontent of each food-stuff is given in the table along with minimum nutritional guidelines.

Food stuff

Milk Beans Oranges MDR

Nutrient (gallons) (cups) (large) (micrograms)

Niacin (mg) 3.20 4.90 0.80 13.00

Thiamin (mg) 1.12 1.30 0.19 1.50

Vitamin C (mg) 32.00 0.00 93.0 45.00

Cost ($) 2.00 0.20 0.25

2. Suppose we want to ensure that the cost of Milk and Beans should not account for morethan 60% of the total cost. Can we also model this restriction? (Hint: formulate a newconstraint.)

OM301 - L9 – p. 8/2

Page 5: Excel_Solver_Example

–9– c©Samuel K. Eldersveld – OM301 – April 23, 2007

You have a weekly supply of 6 large bricks and 8 small bricks. The objective is tomaximize total profit. You need 2 large bricks and two small bricks to make a tableand one large brick and two small bricks to make a chair. You obtain $20 profit fromeach finished table and $15 from each finished chair.

maximize{T,C}

Z = 15C + 20T (objective)

subject to 1C + 2T ≤ 6 (Large Blocks)

2C + 2T ≤ 8 (Small Blocks)

and C ≥ 0, T ≥ 0 (non-negativity)

Lego.xls download from uwbs.blackboard.com

OM301 - L9 – p. 9/2

–10– c©Samuel K. Eldersveld – OM301 – April 23, 2007

A full description of how to set up, solve and eval-uate the LPs formulated in class is given in thecourse pack article CP5.

Step 1: Set up spreadsheet.Invoke solver from the “tools”menu.

Step 2: Click Solver “Options”. Step 3: Click “Assume LinearModel” (and “Assumenon-negative” if applicable). Click“OK” to return to solver menu theclick “Solve” and obtain sensitivityreport.

OM301 - L9 – p. 10/2

Page 6: Excel_Solver_Example

–11– c©Samuel K. Eldersveld – OM301 – April 23, 2007

OM301 - L9 – p. 11/2

–12– c©Samuel K. Eldersveld – OM301 – April 23, 2007

Messages:

1. Optimal solution found

2. Did not converge

3. No feasible solution

4. Not linear

Reports

1. Answer report

2. Sensitivity Report (“what if”).

3. Limits Report (contribution to profit).

OM301 - L9 – p. 12/2

Page 7: Excel_Solver_Example

–13– c©Samuel K. Eldersveld – OM301 – April 23, 2007

Target Cell: The objective value, Z.

Adjustable Cells: Decision variables, x1, x2, . . . , xn.

Constraints: Cell Value, ai1x1 + ai2x2 + · · · + ainxn.

Constraints: Status: (Binding or slack)

1. Binding: ai1x1 + ai2x2 + · · · + ainxn = bi.

2. Slack: ai1x1 + ai2x2 + · · · + ainxn < bi.

A slack resource constraint exhibits a positive amount ofunused resource (slack).

OM301 - L9 – p. 13/2

–14– c©Samuel K. Eldersveld – OM301 – April 23, 2007

Rationale:

Math problem is an approximation.

Constraints are often “artificial”.

Situations are often “probabilistic”.Prices changeNeed to assess riskResources may change.

OM301 - L9 – p. 14/2

Page 8: Excel_Solver_Example

–15– c©Samuel K. Eldersveld – OM301 – April 23, 2007

This sensitivity report provides us with information relating to:

1. Changing the objective function coefficient for a variable.

2. Changing the right-hand side of a constraint (Shadow Price)

3. Forcing a variable which is currently zero to be non-zero (Reduced Cost).

OM301 - L9 – p. 15/2

–16– c©Samuel K. Eldersveld – OM301 – April 23, 2007

Changing Objective Function coefficientsAllowable Increase/Decrease (adjustable cells):

This defines the range of the cost coefficients in the objective function for which the

current solution (the value of the decision variables in the optimal solution) will not

change.

Example: If a chair’s contribution to profit increases by less than $5 (to$19.99 or less) we will still make 2 chairs and 2 tables. When the profitfor a chair drops by less than $5 the same result holds.

If a chair’s contribution to profit increases by $5 or more we will makemore chairs.

If a chair’s contribution to profit decreases by $5 or more, we will makefewer chairs.

OM301 - L9 – p. 16/2

Page 9: Excel_Solver_Example

–17– c©Samuel K. Eldersveld – OM301 – April 23, 2007

Changing the right-hand side of a constraint:

For each constraint the column headed Shadow Price tells us the marginal change in

the objective function by increasing the right-hand side of the corresponding

constraint within the limits given in the Allowable Increase/Decrease columns

Optimal solution moves from (2,2) to (3,1), objective Z increases from $70 to $75Difference in objective of $5 = Shadow Price of the large-block constraint.

OM301 - L9 – p. 17/2

–18– c©Samuel K. Eldersveld – OM301 – April 23, 2007

Shadow Price =change in objective Z

unit change in constraint

Use of Shadow Prices:

Identify constraints with high Shadow Prices

Can we change the RHS? (add or borrow resources).

Use for planning (capacity).

If Shadow price is 0 then it is not worth increasing the correspondingresource.

Allowable Increase/Decrease (constraints):

This defines the range of the constraint RHS for which the shadow price will not

change. Changing the constraint may change the optimal values of the decision

variables.

OM301 - L9 – p. 18/2

Page 10: Excel_Solver_Example

–19– c©Samuel K. Eldersveld – OM301 – April 23, 2007

Suppose we add a new product “The Stool", profit=$5 each, and it usesonly two small blocks:

Optimal solution is unchanged: (Chairs=2, Tables=2, Stools= 0).What would happen to the objective if we had one stool produced?

OM301 - L9 – p. 19/2

–20– c©Samuel K. Eldersveld – OM301 – April 23, 2007

The solution is unchanged. Reduced cost for stools variable is -$5,implying that if we wanted to produce one stool, the optimal objectivewould be reduced by $5, from $70 to $65.

Reduced cost is the value of the objective that arises from forcing avariable that is currently zero to a non-zero value.

OM301 - L9 – p. 20/2

Page 11: Excel_Solver_Example

–21– c©Samuel K. Eldersveld – OM301 – April 23, 2007

OM301 - L9 – p. 21/2

–22– c©Samuel K. Eldersveld – OM301 – April 23, 2007

1. Solution Techniques

2. Using the Excel Solver Add-In

3. Interpretation of Output.

4. Sensitivity Analysis

OM301 - L9 – p. 22/2

Page 12: Excel_Solver_Example

–23– c©Samuel K. Eldersveld – OM301 – April 23, 2007

1. Spreadsheet Modeling:

2. Algebraic Modeling Languages (MPL, OPL-STUDIO, GAMS):DEFINE i=(1..4) {Workers}

DEFINE j=(1..6) {Tasks}

Minimize Cost = SUM(i,j:C[i,j]*X[i,j])

SUBJECT TO

SUM(j:X[i,j])<= RESOURCE[i]

SUM(i:A[i,j]*X[i,j]) >= DEMAND[j]

END

3. User-generated call routines (C, C++, Fortran) interfacing tooptimization packages (e.g. CPLEX, MINOS, MINLP etc.)

OM301 - L9 – p. 23/2

–24– c©Samuel K. Eldersveld – OM301 – April 23, 2007

Equations are less visible.

Problem is not scalable (size is fixed).

Difficult with many problem dimensions.

Adding a data element to the dimension corresponds to adding a rowor column.

Restricted to “small” problems...

...“Solver” (basic) is limited to 200 decision variables and constraints.

Limited algorithmic options (e.g. “Simplex” primal LP algorithm)

Difficult to tune optimization algorithm parameters.

OM301 - L9 – p. 24/2

Page 13: Excel_Solver_Example

–25– c©Samuel K. Eldersveld – OM301 – April 23, 2007

Excel product is ubiquitous (“Solver” is included with Excel).

Basic problems are easy to set up.

Problem data is easily visible.

Model and resulting analysis is easier to demonstrate to management.

OM301 - L9 – p. 25/2

–26– c©Samuel K. Eldersveld – OM301 – April 23, 2007

1. Multiple optimal solutions sometimes exist.

2. Solver does not identify all optimal solutions.

3. Solver stops at the first optimal solution encountered

4. Solver will sometimes “iterate” from one optimal solution to the next byperturbing the current solution (try this with the Resource AllocationExample).

5. The optimal solution obtained will often depend on the starting point.

OM301 - L9 – p. 26/2

Page 14: Excel_Solver_Example

–27– c©Samuel K. Eldersveld – OM301 – April 23, 2007

Keep initial models as simple as possible.

Start with your data. Build your model around the data.

If you don’t yet have all your data, build your model around yourdecision variables.

Create formulas distinct from data cells.

Use both intermediate calculations (subtotals) and intermediateformulas for simplicity and to aid in debugging.

Use relative addressing in Excel ($’s) to minimize the number of uniqueformulas and to make copying formulas easier.

OM301 - L9 – p. 27/2

–28– c©Samuel K. Eldersveld – OM301 – April 23, 2007

Use the formula bar to determine if your formula is correct.

If it is difficult to determine whether your formula is correct by viewing it, then it isprobably too complicated and you should use more intermediate calculations.

Display formulas for clarity

From the “tools” and then ”options” menus in Excel, check "Windows options: Formulas"

OM301 - L9 – p. 28/2

Page 15: Excel_Solver_Example

–29– c©Samuel K. Eldersveld – OM301 – April 23, 2007

Use a standardized form when possible. For example:

Cells Status Shade Color

Data Fixed Light Green

Decision variables Changing Bright Yellow

Objective function Changing Orange

Constraint Formulas (LHS) Changing Light Yellow

It should be obvious which cells contain data, formulas, variables etc.

OM301 - L9 – p. 29/2