Lab 8

advertisement

Lab 8 - Math 2355

(13pts)

The purpose of Lab 8 is to use: the Solver Add-in feature in to learn how to solve linear programming problems

The Solver add-in is a Microsoft Excel add-in program that is available when you install Microsoft Office or Excel. To use it in Excel, however, you need to load it first.

To activate it take the following steps: Click the File tab, and then click Options . Click Add-Ins , and then in the Manage box, select Excel Add-ins . Click Go . In the Add-Ins available box, select the Solver

Add-in and the Analysis ToolPak (We’ll use the Analysis ToolPak in another lab) check boxes, and then click OK . 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.

Consider the following problem:

A firm manufactures 2 types of jackets, wool and cotton. The wool jacket costs $150 to make and sells for

$250. The cotton jacket costs $100 to make and sells for $125. The manufacturer can budget no more than

$2,000 per day to produce the coats and can handle no more than 100 coats per day. How many coats of each type should be made in order to MAXIMIZE PROFIT?

You formulate the problem:

Let x = number of wool jackets

y = number of cotton jackets

Then x + y

100

150x + 100y

2000

x

0 y

0 and you maximize profit, P = 100x + 25y.

Now, you must re-formulate this problem in Excel, so that Solver can find its solution.

- First, add a new sheet to the end of your file and name it “L8 Ex1”. Next define the coefficient matrix and limits in Excel according to the following layout:

A B C D E

1 Number: Wool Coats Cotton

2

3

4

Total #

Cost x

1

150 y

1

100

Limits

100

2000

- Note that column D was left blank. This is intentional, since in column D you must formulate the parts of the inequalities that correspond to the rows in the coefficient matrix, namely:

1x + 1y (to go in D3) and

150x + 100y (to go in D4)

- In order to do this and use Solver, you must first assign specific locations to the x and y variables. These locations will later reveal the solution (after using Solver ). But initially you must assign the locations and enter an initial guess at the solution. The initial guess really can be anything, but the closer it is to the actual solution, the less time will be needed in finding the solution.

2

In cells B6 and C6, you enter your initial guess (say 50 in B6 and 50 in C6), and associate the x-variable with B6 and the y-variable with C6. To identify these entries, in A6 enter: x, y values .

A B C D E

1

2

Number: Wool Coats Cotton x y Limits

3

4

5

Total #

Cost

1

150

1

100

100

2000

6

3

4

5 x, y Values 50

1

150

50

1

100

100

12500

100

2000

-Now that you have defined the x-variable by B6 and the y-variable by C6, you can enter the left-hand

sides of the inequalities, x + y and 150x + 100y, in D3 and D4, respectively. To do this you will use the sumproduct function. This function multiplies corresponding components in a range and returns the

sum of those products. For example, the value of cell D3 below will be found by multiplying the value in

B3 by the value in B6 and that will be added to the product of the value in C3 and C6.

in D3, enter: =SUMPRODUCT(B3:C3,B6:C6)

in D4, enter: =SUMPRODUCT(B4:C4,B6:C6)

It is necessary to create this information in these cells because in Solver… ,

you will define x + y

100 by D3

E3,

and 150x + 100y

2000 by D4

E4

When you start Solver , you will also define the locations B6 and C6 as Changing Cells , which in essence defines them as variables.

- Finally, you must define the objective function and locations to put the results. Although, you do not have to do this, it is often convenient to look at the profit generated by wool coats and cotton coats independently and then together, especially if a complete analysis of the problem is necessary.

In A8, enter: Profit*Coat

In B8, enter: =100*B6 (which is $100*x, the profit for wool coats)

In C8, enter : =25*C6 (which is $25*y, the profit for cotton coats)

In A9, enter: Max Profit

In B9, enter: =B8+C8 (which represents the total profit)

At this time, you should observe the following worksheet:

A B C D E

1

2

Number: Wool Coats Cotton x y Limits

Total #

Cost

6

7

8 x, y Values 50 50

5000 1250

9

Profit*Coat

Max Profit 6250

- Now that the problem is defined in terms of Excel and what Solver needs to know, you can activate the

Solver feature:

Go to the Data tab on the ribbon and in the Analysis group click on Solver .

- In the Solver Parameters box, the following information should be entered. It is easier to enter the information by clicking on the locations (white boxes) in the Solver Parameters box where information

3 must be entered, then highlighting the cells in the worksheet. Excel will automatically enter the cell location(s):

Set Objective : $B$9

To : Max

By Changing Variable Cells : $B$6:$C$6

Subject to the Constraints:

Note: When entering constraints, click on the Add button, then in the Add Constraint box , click in the Cell

Reference box if the cursor is not already there, then highlight the location on the worksheet for the cells that need to be referenced , then choose <=, or >=, or =, and finally in the Constraint box enter the cells in the worksheet (highlight them) that define the limits or enter numbers (such as in the case when you define the variables to be >= 0)

Enter: $D$3:$D$4<=$E$3:$E$4 then click on OK (You would click on Add if you had multiple constraints to enter but, since this was the only constraint to enter, OK is the better choice.)

You are now back at the Solver Parameters box. Be sure the Make Unconstrained Variables Non-

Negative box is checked and choose Simplex LP as a Solving Method . Finish the problem by clicking on

Solve .

The following worksheet will result:

A B C D E

1

2

Number: Wool Coats Cotton x y Limits

3

4

5

Total #

Cost

1

150

1 13.33333

100 2000 2000

100

6

7

8 x, y Values 13.3333333

1333.33333

0

0

9

Profit*Coat

Max Profit 1333.33333

A Solver Results box appears, and you are given three options: Keep Solver Solution, Restore Original

Values or Return to Solver Parameters Dialog . You should have a solution so you want to generate a report by clicking on Answer from the Reports list. Then click on OK. The solution appears on your worksheet and a report is generated on a separate worksheet. To see the report click on the Answer Report

1 tab. Since the answer report sheet is generated in front of your initial work, you should drag it so it follows the initial work. To move the sheet you click on it and while holding the left mouse button down, drag and drop it on the other side of your initial work sheet. A small sheet icon will show so you can tell where the sheet is being inserted.

The Answer Report shows cell locations and names with original (guessed) values and the final (optimal) values. In addition, the constraints portion shows the slack variable values.

What’s really nice about Solver is that you can easily change some values in the worksheet and re-run

Solver to examine different solutions under different constraints and/or limits.

In the above worksheet, the following solution is observed:

Make 13.33 wool coats and 0 cotton coats for a maximum profit of $1333.33

(Of course, making 13.33 wool coats is a theoretical answer. In practice, a decision would need to be made.)

4

Lab 8 – Math 2355 – Spring 2016 (13pts)

Name: ______________________________________ Discussion Section: ____________

Due Date: April 8 th by 8:30am

Insert a new sheet at the end of your file and rename it “L8 #1”. Use this page for the following problem:

You are the traffic manager for Fly-by-Night Airlines, which flies airplanes from five cities: Los Angeles,

Chicago, Atlanta, New York, and Boston. Due to a strike, you have not had sufficient crews to fly your planes, so some of your planes have been stranded in Chicago and in Atlanta. In fact, 15 extra planes are in

Chicago and 30 extra planes are in Atlanta. Los Angeles needs at least 10 planes to get back on schedule,

New York needs at least 20, and Boston needs at least 10. It costs $50,000 to fly a plane from Chicago to

Los Angeles, $10,000 to fly from Chicago to New York, and $20,000 to fly from Chicago to Boston. It costs $70,000 to fly a plane from Atlanta to Los Angeles, $20,000 to fly from Atlanta to New York, and

$50,000 to fly from Atlanta to Boston. How should you rearrange your planes to get back on schedule at the lowest cost? What is the minimum cost?

Remember to start by identifying the unknowns. You need to decide how many planes you will fly from each of Chicago and Atlanta to each of Los Angeles, New York, and Boston. This gives you six unknowns: a) Let a = ____________________________________________________________________

b = ____________________________________________________________________

c = ____________________________________________________________________

d = ____________________________________________________________________

e = ____________________________________________________________________

f = ____________________________________________________________________

Formulate the problem as a linear programming problem with an objective function and constraints.

Problem Constraint 1: _______________________________________________________

(Los Angeles needs)

Problem Constraint 2: _______________________________________________________

(New York needs)

Problem Constraint 3: _______________________________________________________

(Boston needs)

Problem Constraint 4: _______________________________________________________

(Chicago can provide)

Problem Constraint 5: _______________________________________________________

(Atlanta can provide)

Nonnegative Constraints: __________________________________________________

Objective function: __________________________________________________(A max or a min?)

(related to costs)

Use Excel and Solver… to find the solution. REMEMBER that you will now be working with six variables and five constraints. Format all numerical cells as a number with 0 decimal places. Label appropriately as

Solver will use the labeling on the answer report sheet.

On the Answer report sheet, type your name in cell F1, your student ID number in cell F2. Do not change any other information on the page. Print this sheet. Be sure to attach it to your lab as it is worth points. b) Write one or two sentences stating the final solution. Be careful to address the questions being asked.

5

Download