Module Development Template

Download Report

Transcript Module Development Template

CS110: Introduction to Computer Science: Lab 9

Optimization and Linear Programming: Calzones vs. Mini-Pizzas

How can we optimize revenues in a pizza parlor by varying the production of one delicious attraction vs. another?

Core Quantitative concept Linear Programming Supporting Quantitative Skills and Concepts Algebra: Manipulating equations Linear functions; Linear equations Multivariable functions Inequalities XY scatter plot Modified by Fred Annexstein Univ. Cincinnati Prepared for SSAC by J. M. Pogodzinski – San Jose State University © The Washington Center for Improving the Quality of Undergraduate Education. All rights reserved. 2007 1

Overview of Module The optimal product mix (the optimal combination of goods produced by the firm) can be represented as the solution to a linear

programming problem (

End note 1

). Linear programming can also be used to represent a wide variety of decision-making situations.

Slide 3. A Typical Application and Glossary of Terms - Optimization, Choice (Endogenous) Variables, Parameters (Exogenous Variables), Objective function, feasible set

Slide 4. Background

Slides 5-8. The Objective Function - linear functions, level curves, slope of level curves, family of level curves Slides 9-14. The Feasible Set - feasible set defined by linear inequalities, linear inequalities, slope of the facets of the feasible set

Slide 15. Optimization

Maximization subject to constraint, an optimal solution illustrated, vertices and facets,

2

A Typical Application Consider a pizza parlor that makes mini-pizzas and calzones. Two resources (inputs) are used to make each: labor time and baking time. There is a limited amount of labor time available, denoted by C 1 and a limited amount of baking time available, denoted by C prices, (P 1 and P 2 calzones sell for $5.

2

, respectively). Say, mini-pizzas sell for $7 and . [Assume that the ingredients of mini-pizzas and calzones are the same.] Mini-pizzas (Good 1) and calzones (Good 2) sell for different Question What is the optimal (or highest-revenue) combination of mini pizzas and calzones (X 1 and X 2 ,respectively) for the pizza parlor to produce?

GLOSSARY OF TERMS Optimization: maximizing or minimizing a function subject to constraints Objective function: the function to be maximized or minimized Choice (endogenous) variables: the variables whose value is to be determined so as to maximize or minimize the objective function Parameters or exogenous variables: the variables whose value is given or fixed when finding the optimal solution of a particular problem Feasible set: the set of choice variables that satisfies all the constraints of the problem

3

Background

Linear Functions and Equations • Slope-intercept form: you are probably familiar with the slope-intercept form of a linear equation:

y

=m

x

+b.

• Another form of the same equation is: a

x

+b

y

=c • We can rewrite the equation above so that it has the same form (the slope-intercept form) as the first equation:

y

=(c/b)-[(a/b)

x

] • Another form of the same equation (with the variables

X

1 and

X

2 ) is : a 11

X

1 +a 12

X

2 =

k

. Can you put this equation into slope-intercept form?

HINT: Except for notation, the last equation is identical to the second equation on this slide.

4

The Objective Function The objective function – revenue in our pizza parlor example – is a function of the choice variables – the number of mini-pizzas and calzones the pizza parlor produces (

X 1

and X

2

) – which we seek to maximize. In a linear programming problem, the objective function is linear in the choice variables. For the pizza parlor application, the objective function is R(X 1 ,X 2 )=P 1

X

1 +P 2

X

2 . The value of the objective function is computed in Cell G4 in the spreadsheet below.

Recreate the spreadsheet to the right.

HINT: The expression in Cell G4 can be computed using the built-in Excel function SUMPRODUCT

9 10 11 12 2 3 4 5 6 7 8 B C Linear Programming Objective Function Parameters

P1

5

X1

10 D

P2

Choice variables 7

X2

15 E dollars F G H Value of the Objective Function R = 155 dollars 5

Level Curves of the Objective Function A level curve of the objective function is defined as the objective function set equal to a constant. In the pizza parlor example, the level curve is given by the equation R(X 1 ,X 2 )=P 1

X

1 +P 2

X

2 = k where k is an arbitrary constant.

Modify the spreadsheet you prepared for the previous slide to include two arbitrary values for k – k 1 and k 2 – and values of X 1 ranging from 0 to 10 (in Column C). Enter formulas in the corresponding cells in Column D so that the corresponding value of

X

2 gives a point on the level curve for k=10.

2 3 4 5 6 7 8 9 18 19 20 21 22 10 11 12 13 14 15 16 17 B C Linear Programming Objective Function Parameters

P1

5

X1

0 1 2 3 4 5 6 7 8 9 10 D

P2

Choice variables 7

X2 (for k1) X2 (for k2)

1.428571 2.857143

0.714286 2.142857

0 -0.714286 0.714286

-1.428571

E dollars 1.428571

0 -2.142857 -0.714286

-2.857143 -1.428571

-3.571429 -2.142857

-4.285714 -2.857143

-5 -3.571429

-5.714286 -4.285714

F G Arbitrary values

k1

10

k2

20 H 6

Level Curves of the Objective Function Changing the arbitrary constant causes a shift in the level curve.

Make a graph of the level curves in the previous slide (using the XY scatter graph).

Why are the level curves straight lines? (

End note 2

)

Level Curves of the Objective Function

2 1.5

1 0.5

0 0 4 3.5

3 2.5

2 4 6

X1

8 10 12 X2 (for k1) X2 (for k2) 7

4 3.5

1 0.5

0 0 3 2.5

2 1.5

Level Curves of the Objective Function Changing the parameters (prices) of the objective function will change the slope of the level curves. The left-hand graph illustrates the level curves for k 1 =10 and k 2 =20 with prices P 1 =5 and P 2 =7. The right-hand graph illustrates the same level curves with the prices reversed.

Level Curves of the Objective Function (P1=5 & P2=7)

X2 (for k1) X2 (for k2)

Level Curves of the Objective Function (P1=7 & P2=5)

X2 (for k1) X2 (for k2) 2 4 6

X1

8 10 12 4 3.5

1 0.5

0 0 3 2.5

2 1.5

2 4 6

X1

8 10 12 8

Feasible Set The feasible set is the set of admissible values of X 1 and X 2 . In a linear programming problem, the feasible set is specified in terms of linear inequalities. Consider the pizza parlor that produces mini-pizzas and calzones. Each of these goods requires labor time and baking time. Suppose that the calzones require less labor time than mini-pizzas (because the mini-pizzas must be artfully presented) but that the calzones require more baking time than the mini-pizzas (because they are thicker). Let’s say that each calzone requires 6 minutes of labor time to produce and each mini-pizza requires 10 minutes of labor time to produce. Suppose the pizza parlor employs only one production worker for an eight-hour shift, so 480 minutes of labor time are available. The total number of mini-pizzas (X 1 ) and calzones (X 2 ) produced must satisfy the following linear inequality: 10X 1 +6X 2 ≤480.

This expression is called a constraint and is of the form a 11

X

1 +a 12

X

2 ≤C 1 , where a 11 , a 12 ,and C 1 are constants (parameters).

9

Feasible Set Suppose the baking time for each mini-pizza is 4 minutes, while the baking time for each calzone is 6 minutes. Suppose the oven is available for a total of 400 minutes per eight-hour shift (because it requires 80 minutes of cleaning per shift).

In addition, the number of mini-pizzas (X 1 ) and the number of calzones (X 2 ) must be non-negative, i.e., X 1 ≥0 and X 2 ≥0.

NOTE: The subscript notation is purposeful. In the interpretation of the linear programming problem as determining the optimal output of two goods, a 11 is the units of Resource 1 used in producing each unit of Good 1, and a 12 is the units of Resource 1 used in producing each unit of Good 2. C 1 is the total amount of Resource 1 available.

In your worksheet, write down a linear inequality that represents a limit on Resource 2 (baking time) in a fashion that is consistent with the notational convention referred to above.

10

Inequality Constraints Modify your spreadsheet from Slide 5 to look like this. In Cells G23 and G24, enter logical statements that will return “feasible” when the respective inequalities are satisfied for the values of X 1 and X 2 contained in Cells C12 and D12, “infeasible” otherwise.

Be sure to account for the non negativity constraints, i.e., X 1 ≥0 and

X

2 ≥0.

11

Graphical Representation of Feasible Region The feasible set is the set of admissible values of X 1 and X 2 . It is the intersection of the inequality constraints and the non-negativity constraints. Modify the previous worksheet to look like this.

12

Inequality Constraints For each inequality constraint determine the slope of the associated equation (i.e., determine the slope of the straight line when you substitute an “= ” sign for the “≤” sign). Graph each of the equations associated with the inequality constraints. Taking the inequality constraints and non-negativity constraints together (satisfied simultaneously) defines a polyhedron with verticies and facets (nodes of interesection and flat surfaces). Identify the coordinates of all the verticies for the constraints in the pizza parlor problem (labeled A, B, C, and D in the next slide). Compare your answer with the figure in the following slide.

13

Graphical Representation of Feasible Region Constraints for Pizza Parlor Problem

100 90 80 70

A

60 50 40 30 20 10 0 0

D

10

B

20 30 40

C

50

X1

60 70 80 90 100

Verticies of the feasible region are A: (0,66.67) B: (13.33, 57.78) C: (48,0) D: (0,0)

14

Optimization Optimization refers to either the maximization or minimization of some function. In our Linear Programming example, we are concerned with maximizing the function R subject to the inequality constraints and the non-negativity constraints. This corresponds to finding the “highest” level curve which just touches the feasible region (the one for which the constant k is the greatest). In our example, this highest level curve is that level curve that is the furthest to the North-East the furthest from the origin.

Graphically, the maximum must occur at a vertex of the feasible region – either the point where the equations associated with the linear inequalities intersect, or at the intercepts on the X 1 the feasible region.

or X 2 axes of A simple (but usually inefficient) algorithm for solving a linear programming problem is to determine the value of the objective function at each vertex of the feasible set. For the pizza parlor problem, you can use the worksheet prepared for Slide 5 and substitute the coordinates of each vertex you determined in Slide 14 to determine the optimal solution to this linear programming problem.

Which vertex gives the optimal solution?

15

Optimization using Excel Solver

• Built into Excel is a program that automatically considers each vertex of the feasible polyhedron in order to determine the optimal solution. Recall that this is just the region defined by the set of constraint equations.

• You will now learn how to use the Excel Solver to find an optimal solution to a linear programming problem with three choice variables. In general, linear programming problems have many variables and constraints- the feasible polyhedron can be complex and near impossible to visualize • Open the following worksheet, copy it into your current worksheet, and follow the directions. 16

End-of-Module Assignment

1. You are to construct your own linear programming problem. Construct a spreadsheet representing an example of linear programming based on scheduling your own life (school, work, hobbies, social life). As in the first part, use two choice variables. Specify the choice variables and parameters of the objective function, and at least two inequality constraints. Base the parameter selection on your “best guess.” In a brief paragraph, explain your objective function and inequality constraints.

2. Graph the inequality constraints and identify the feasible set.

3. Graphically determine the optimal solution.

4. What changes in the parameters of the objective function will lead to a different vertex being optimal?

5. Extend the example you developed in #1 to more choice variables and more constraints. Solve the extended problem using the Excel Solver to produce an optimal solution. 17

End Notes

1. Linear programming is a mathematical technique that is widely used to solve optimization problems in business and engineering. According to Wikipedia (7/5/07), “Some industries that use linear programming models include transportation, energy, telecommunications, and manufacturing. It has proved useful in modeling diverse types of problems in planning, routing, scheduling, assignment, and design.” Examples of business applications, according to Wikipedia, are food blending, inventory management, portfolio and finance management, resource allocation for human and machine resources, and planning advertising campaigns. In the mathematics, linear programming can be found in many linear

algebra textbooks.

Return to Slide 2

.

2. Level curves are essentially contours of a function

z

(

x

,

y

) shown on a graph of

y

function)

z

vs.

x

. Think of the dependent variable (the objective as elevation, and the independent variables,

x

and

y

, as distances east and north, respectively. Then, the surface of

z

(

x,y

) is a plane, because

z

is a linear combination of

x

and

y

. The contours

of an inclined plane are straight lines.

Return to Slide 7

.

18