Welcome to Highline BI 348 class video number 60. If you want to download this Excel workbook, BI 348 Chapter 8, and follow along, click on the link below in the video.
We're talking about linear programming and using Excel Solver to find an optimal solution. In this video, we're going to do a transportation problem. This is represented by a network graph that gives us all the information we need to figure out the minimum cost to ship from these locations to these locations.
Here is our graph. The production plants are the supply side, and these are called origin nodes. We have a plant in Oakland, Portland, and Seattle. If we're producing items in these three locations, we need to look at the supply constraints, meaning the maximum amount each location can produce. In Oakland, the maximum they can produce is 5,075. Portland is 6,150, and Seattle is 2,725. The arrows are called arcs, and the numbers on them are the transportation cost per unit to ship, for example from Oakland to Rapid City or from Oakland to Spokane. So we have our transportation costs and our arcs. Over here is the demand side. These are distribution centers in Spokane, Las Vegas, Coeur d'Alene, and Rapid City, and this side shows the demand constraints. This is the exact amount each has ordered: Spokane ordered 6,150, Las Vegas ordered 4,125, Coeur d'Alene ordered 2,050, and Rapid City ordered 1,625.
The question is how we pick the right route to get the right number of items to each location. That's where linear programming and Excel Solver come in handy. The trick is to build a cross-tabulated table, as we have done many times already in this class. Oakland, Portland, and Seattle will be the row headers. Spokane, Las Vegas, Coeur d'Alene, and Rapid City will be the column headers. I put origin, or production cities, as row headers and distribution, or destination, cities as column headers.
We define the decision variable as the number of units shipped, where the origin is the row and the destination is the column. I put in x11, x21, x31, and so on. Any particular x represents the number of units from one origin to one destination. For example, the number of units from Portland to Coeur d'Alene is in row 2, column 3. I copy this, paste it, and put dummy data in the active cell. I type the number one and then press Control Enter to populate everything through the highlighted range. These will be the number of units shipped from each location. Right now we're shipping one from Seattle to Coeur d'Alene. These are the decision variables that Excel Solver will determine for us.
Next we put in the shipping costs. I highlight the same range, copy it, and paste it below with the label "Shipping Cost Per Unit." I remove the red color and the bold formatting. Then, carefully reading from the chart, I enter the correct values. I use the Tab key to move across the row, and when I reach the end it moves to the next row. For Oakland, the costs along the first row are 3.5, 2.5, 6.75, and 7. For Portland, the shipping cost per unit is 6, 5.5, 2.25, and 3.25. For Seattle, it is 2.5, 5, 3.75, and 5.25.
Notice that this problem is set up differently than in earlier videos. Previously we had a separate section for constraints. Here, the constraints all relate to the units on the supply and demand sides. For Oakland, the total units shipped must be less than or equal to 5,075. Similarly, on the demand side, the total for each destination must be exactly equal to its ordered amount. I highlight the dummy data of units to ship, with empty cells to the right and below, and use Alt equals to add them up. This is a quick way to place the SUM function in all the right places. Then I add labels and formatting.
Now that I have the supply-side totals and demand-side totals, I enter the actual constraints. For supply, Oakland's maximum is 5,075, Portland's is 6,150, and Seattle's is 2,725. For demand, I compare each destination total to its required amount: 6,150 for Spokane, 4,125 for Las Vegas, 2,050 for Coeur d'Alene, and 1,625 for Rapid City.
Before going further, let's look at the structure. The objective function is each number of units multiplied by its shipping cost per unit, summed together. That total is the cost we are trying to minimize. For the constraints, we use the SUM function to add up all items delivered from each origin, with a comparison operator. On the demand side, we add the individual decision variables and set them equal to the demanded amount.
To be explicit, as in earlier videos, we enter each constraint function in the sheet and compare it to its limit. In the active cell I type a leading apostrophe and an equal sign, because each demand total must equal exactly the demanded amount. Without the leading apostrophe, Excel would treat it as a formula. I press Control Enter to populate those cells. For the supply side, each total must be less than or equal to the maximum that location can produce, so I enter the less-than-or-equal operator in the same way and populate those cells.
We still need the objective function. It is a long formula, but earlier videos showed how the SUMPRODUCT function can take one range of values, multiply it by a second range with the exact same dimensions, and add the results. I place the objective function in a cell and note the goal, which is to minimize. I enter SUMPRODUCT with the decision variable array first. These are the values Solver will determine to minimize cost. That array has 3 rows and 4 columns. Then I enter the shipping cost array, which also has 3 rows and 4 columns. SUMPRODUCT requires the arrays to have the exact same dimensions. Multiplying each number of units by its shipping cost per unit and summing gives the total cost. I label this total cost.
Now we set up Solver. I click the cell with the objective function, then go to Data and Solver. Under Set Objective, I select the objective cell. The goal is to minimize. Under By Changing Variable Cells, I select the decision variables. I check "Make Unconstrained Variables Non-Negative," which is our non-negativity requirement for decision variables. I select Simplex LP as the solving method, which handles the linear programming.
Next I add constraints. Since the supply-side and demand-side constraints each use the same operator across a group, I can enter the entire range at once. I add the four demand constraints using the equal sign, and the three supply constraints using the less-than-or-equal operator. The equal signs in the spreadsheet cells are only there for visual reference; they do not affect the solution. I also add a constraint requiring the decision variables to be integers. This ensures we get whole units, since partial units cannot be shipped from one place to another.
I click OK, confirm the objective function, goal, decision variables, and constraints, and then click Solve. Solver finds a solution. I click OK, and the optimal solution appears in the sheet.
In this video, we saw how to use a network graph to organize the information for a transportation problem where the goal is to minimize costs. In the next video, we'll look at a finance example where we want to maximize portfolio returns. We'll see you in the next video.
