ORSA TAC - Anvari.net

advertisement
US Army Logistics University
OPERATIONS RESEARCH SYSTEMS
ANALYSIS TECHNOLOGIES AND
APPLICATIONS COURSE (ORSA TAC)
Course Director: John Zauner
(804) 765-4256, DSN 539
john.zauner@us.army.mil
US Army Logistics University (ALU)
College of Professional & Continuing Education
Department of Systems Engineering (DSE)
Fort Lee, VA
ORSA Courses offered by ALU/CPCE/DSE
Spreadsheet Modeling - 1
US Army Logistics University
ORSA TAC Course Objectives
…to provide previously trained ORSA
analysts with an exposure to some of
the emerging technologies and
applications of operations research
related to military problem solving
Spreadsheet Modeling - 2
US Army Logistics University
Why focus on spreadsheet technology?
• Availability
• General knowledge by most analysts
• Greater understanding by decision makers
• Enhanced capability with add-in packages
• Great for quick analysis/small to mid-size
models
Spreadsheet Modeling - 3
US Army Logistics University
Course Materials
• Course based on material from textbooks Practical
Management Science and Managerial Statistics
(Winston, Albright, Zappe)
– Example based learning
– EXCEL workbooks included
– Covers more than we can cover in a one week class
• Use of Decision Tools Suite software
– @Risk, Stat Tools, PrecisionTree, TopRank plus others
– http://www.palisade.com/decisiontools_suite/default.asp
• Student CD contains:
– All course slides and spreadsheet examples used in class
– StatPro and Solver Table add-in packages plus others
Spreadsheet Modeling - 4
US Army Logistics University
ORSA TAC Schedule
• Contains daily schedule
• Contains instructor contact information
• Contains subject breakout, textbook reference
and examples
• Contains links to all slides and spreadsheet
examples
Spreadsheet Modeling - 5
US Army Logistics University
ORSA PROCESS
“Strategy for a successful study”
Define the problem
Develop the analysis plan
Gather / review data
Crunch the numbers
Analyze the results
Prove the answer
Package the results
STUDY
PLANNING
(40%)
ORSA TOOLS
(20%)
STUDY
EXECUTION
(40%)
Spreadsheet Modeling - 6
US Army Logistics University
Spreadsheet Modeling
Fundamentals
Finding a Breakeven Point
at Great Threads
Spreadsheet Modeling - 7
US Army Logistics University
Background Information
Breakeven Analysis at Great Threads
• The Great Threads Company sells hand-knit sweaters. They want
to print a product brochure for a direct mail campaign.
• The costs of printing, mailing, and materials are provided. The
average size of a customer order is $40, and the company’s
variable cost per order averages around 80% of the order’s value.
• The company plans to mail 100,000 catalogs. It wants to develop a
spreadsheet model to answer the following questions:
– How does a change in the response rate affect profit? (answer)
– For what response rate does a company break even? (answer)
– If the company estimates a response rate of 3%, should it
proceed with the mailing? (answer)
– How does the presence of uncertainty affect the usefulness of
the model? (answer)
Spreadsheet Modeling - 8
US Army Logistics University
Basic Modeling Tenants
Breakeven Analysis at Great Threads
• Note the clear layout of the model
– The input cells are outlined and shaded and separated
from the outputs
– Headings clearly define cells (bold, indented)
– Formulas use cell or range name reference (very few
numbers in formulas)
– Appropriate numeric formats
– Range names listed in text boxes to the right
Spreadsheet Modeling - 9
US Army Logistics University
Creating the Model
Breakeven Analysis at Great Threads
• To create this model, proceed through the
following steps:
– Enter heading and range names
– Enter input values
– Model the responses (enter an estimate in the
Response Rate cell – we’ll use 8%)
– Model the revenues, costs and profits
Spreadsheet Modeling - 10
US Army Logistics University
Answering the Questions
Breakeven Analysis at Great Threads
• Now that a basic model has been created, we can
answer the questions posed by the company.
• For question 1, we form a data table to show how
profit varies with the response rate. The table is
shown here.
Spreadsheet Modeling - 11
US Army Logistics University
Creating a Data Table
Breakeven Analysis at Great Threads
• Enter a series of response rates (1% to 10%) in col A,
and “link” them to the profit in cell B18 (=Profit)
• Highlight the entire range (A18:B28) and select the
Data Table option from the What If Analysis Icon
(Data Tools Group on Data Ribbon)
• Put cell $E$4 (ResponseRate) as the column input
cell
• The data table reports the change in profit as the
response rate changes
• Create a scatterplot (XY chart) of the values in the
data table to provide a visual of the results
Spreadsheet Modeling - 12
US Army Logistics University
Answering the Questions
Breakeven Analysis at Great Threads
• Profit increases in a linear manner as response
rate varies. A 1% increase in the response rate
always increased profit by $7800.
• Profit goes from negative to positive when the
response rate is between 5% and 6%.
• Use GoalSeek to answer Question 2 about the
exact breakeven point
• Goal Seek is useful for solving a single equation
in a single unknown
Spreadsheet Modeling - 13
US Army Logistics University
Answering the Questions
Breakeven Analysis at Great Threads
• To implement Goal Seek, select Goal Seek from the What If
Analysis Icon (set Profit to 0 by changing the Response Rate)
• If the response rate is 5.77%, Great Threads breaks even
• Question 3 asks if the company should proceed with the
mailing if the response rate is only 3%. The short term view
says “no”, but we may want to go ahead anyways.
– Many customers who respond to direct mail will reorder in the
future. If each of the respondents ordered two more times, the
company would earn (3000)($7.80)(2) = $46,800 more than
appears in the model, and profit would then be positive.
– The moral is to look at the long-term impact of our decisions
(which means a more complex model)
Spreadsheet Modeling - 14
US Army Logistics University
Answering the Questions
Breakeven Analysis at Great Threads
• Finally, question 4 asks about the impact of
uncertainty in the model (all inputs are not known
with certainty)
• For example, a high degree of uncertainty about
model inputs makes it difficult to talk about the profit
level or the breakeven response rate.
• It makes more sense to talk about the probability that
profit will have a certain value or the probability that
the company will break even.
Spreadsheet Modeling - 15
US Army Logistics University
Cleaning Input Data
Cleaning Customer Data
Spreadsheet Modeling - 16
US Army Logistics University
Data Cleaning
Cleaning Customer Data
• Lists data on 1500 customers of a company
• How much of this data set is usable? How much
needs to be cleaned?
• It is the analyst’s responsibility to correct data
problems before doing any serious analysis
(data cleaning)
Spreadsheet Modeling - 17
US Army Logistics University
Cleaning the Data
Cleaning Customer Data
• All of the problems in this data are typical of real
world data sets.
• In cleaning this data we will look at the following
variables:
– Social Security Number(SSN)
– Birthdate/Age
– Region
– CredCardUser
– Income
– Purchases and AmtSpent
Spreadsheet Modeling - 18
US Army Logistics University
Finding Duplicate Entries
Cleaning Customer Data
• For SSN, all 1500 customers are distinct people, so all
1500 SSNs should be different.
• One of the simplest ways to check this is to sort on
the SSN column
• To check whether two adjacent SSN are identical, add
formula IF(B5=B4,1,0) in cell J5 and copy down
• Then enter the formula =SUM(J5:J1503) in cell J4
(you should find two duplicates)
• Use Edit/Find menu item (set Look in: to “Values”) to
find the exact records with duplicate SSNs
Spreadsheet Modeling - 19
US Army Logistics University
Cleaning Up Dates
Cleaning Customer Data
• Sorting on birth date finds that the first 18 customers all
have birthdate 05/17/27
• Excel’s dates are stored internally as integers
• Select the 18 birth dates and use the Format/Cells
menu item with the number option(and zero decimals)
• The dates format to 9999, the “code” many analysts
use for missing values
• If the birth date is important for further analysis, these
18 customers should probably be deleted form the data
set.
Spreadsheet Modeling - 20
US Army Logistics University
Cleaning Up Dates
Cleaning Customer Data
• Sorting on age shows the first twelve customers with
negative ages (all were born before 1930)
• EXCEL assumes that any two-digit year from 00 to 29
is the 21st century; years from 30 to 99 are the 20th
century
• Fix by selecting the 12 birth dates , select
Edit/Replace, set find what: to /202, set replace with:
to /192 , click on “Replace All”
Spreadsheet Modeling - 21
US Army Logistics University
Fixing Text Labels
Cleaning Customer Data
• Sort on Region does not seem to work correctly
• After a close look we will find that the top labels in
these cells begin with a space (Fix with Edit/Replace)
• For the CredCard user column (1 means user, 0 is
non-user), taking an average gives a #DIV/0! Error
• The problem is that the numbers were somehow input
or transformed into text labels
• Two ways to convert to numbers:
• Put a 1 in an empty cell (make sure entered as number),
select Edit/Copy, select cells to convert, select Edit/Paste
Special and choose multiply operation (prior to Excel 2002)
• Highlight range, click on Error Indicator (exclamation point in
upper left corner of range), select convert to number
Spreadsheet Modeling - 22
US Army Logistics University
Examining Numeric Data
Cleaning Customer Data
• Sorting the Income column shows most values from
$20,000 to $160,000
• Some values are much smaller (may have entered
without 000)
• Some values are 9999 (many times a code for a
missing value)
• Sorting by Purchases also shows 9999 for the
records at the bottom for Purchases and Amount
Spent (again probably a missing value code)
• Put a blank row between records where 9999 starts
for Purchases to separate from other records
Spreadsheet Modeling - 23
US Army Logistics University
Examining Data Relationships
Cleaning Customer Data
• Presumably there is a relationship between Purchases
and Amount Spent
• A scatterplot shows an upward trend with some outliers
at the bottom of the plot
• The outliers could represent the average amount spent
per purchase instead of the total amount spent
• If this is true, sort on AmtSpent and Purchases and
multiply the AmtSpent by the number of purchases for
the outlier values
Spreadsheet Modeling - 24
US Army Logistics University
Using EXCEL’s AutoFilter
and Advanced Filter
Querying Customer Records
at Hytex
Spreadsheet Modeling - 25
US Army Logistics University
Background Information
Querying Customer Records at HyTex
• 1000 customers records of HyTex (direct marketing firm)
• Data collected:
–
–
–
–
–
–
–
–
Age: (1 = 30 or younger, 2 = 31 to 55, 3 = 56 and older)
Gender: (1= males, 2 = females)
OwnHome: (1 = customer owns a home, 2 = don’t own home)
Married: (1 = customer currently married, 2 = not married)
Close: (1 = lives near shops that sells similar items, 2 = not close)
Salary: combined annual salary of customer and spouse (if any)
Children: number of children living with customer
History: (“NA” = no dealings with company in prior years, 1 = low
spending customer, 2 = medium-spending, 3 = high-spending)
– Catalogs: Number of catalogs sent to the customer this year
– AmountSpent: Total amount of purchases by customer this year
Spreadsheet Modeling - 26
US Army Logistics University
Excel’s AutoFilter Tool
• Excel’s autofilter tool performs simple queries on
an existing Excel database easily
• Terms that we will be used:
- Database: a set of related data (each column is a
field, each row is a record)
- Top row contains field names
- No empty rows
- Query: a command that asks for the subset of a
database that satisfies specified conditions
Spreadsheet Modeling - 27
US Army Logistics University
Using AutoFilter
Querying Customer Records at HyTex
• To use the autofilter tool, make sure the cursor is
anywhere within the database, and select the Filter Icon
(on Data and Home Ribbons)
• Click on the dropdown arrows next to a field name to
view a list of choices
• Choices are available to sort and filter (text or number)
• Click on any value in any fields’ dropdown list to see
only the records where that field equals the selected
value
Spreadsheet Modeling - 28
US Army Logistics University
Using Autofilter
Querying Customer Records at HyTex
• Records are temporarily hidden (not deleted)
• Setting filter on multiple lists implies “and” condition
• Select “All” from list to remove filter for that field
• Select “Top Ten” to see top/bottom of items or
top/bottom percent
• To see the entire database: select clear option in Sort
and Filter group
Spreadsheet Modeling - 29
US Army Logistics University
Complex Queries with Autofilter
Querying Customer Records at HyTex
• The “Custom” item allows us to enter up to two
conditions for any field (can be “and” or “or” conditions)
• Choose from a number of types of conditions such as
“greater than some value,” “contains some value,”
“does not equal some value,” and others.
• Use “wildcard” characters ? and * (useful for text data)
- ? stands for any single character
- * stands for a series of characters
• Example: perform a query where Salary must be
between $40,000 and $80,000, History must not be
“NA” and Catalogs can either be 6 or 24
Spreadsheet Modeling - 30
US Army Logistics University
Performing Analysis on Query Results
Querying Customer Records at HyTex
• Once we obtain the results of a query we might want
to summarize these results in some way.
• If you use functions/add-ins, when you select the
result cells from a query, all hidden rows are included
• The trick is to copy and paste the results of the query
to a new location.
Spreadsheet Modeling - 31
US Army Logistics University
Excel’s Advanced Filter Tool
• Excel’s advanced filter tool can be used only after
creating a “criteria range”
• The “criteria range” consists of a top row of field
names and one or more rows of conditions.
• To use the advanced filter tool:
- Copy the row of field names to any unused area (this is the
top row of the criteria range)
- Manually enter conditions in the cells just below those field
names
- Conditions in a given row are “and” conditions
- Conditions across rows are treated in an “or” manner
Spreadsheet Modeling - 32
US Army Logistics University
Advanced Filter Example
Querying Customer Records at HyTex
• First row: all customers who are married and
have salary at least $80,000 and have at least 2
children.
• Second row: all customers who have salary
$100,000 and received at least 12 catalogs.
• Return all records that meet the first row or
second row conditions
Spreadsheet Modeling - 33
US Army Logistics University
Advanced Filter Example
Querying Customer Records at HyTex
• Once the criteria range is created, we run the query
by using the Data/Filter/Advanced Filter menu item.
• The associated dialog box is completed as follows.
Works like
Autofilter
Entire
database
Include field
names and
all conditions
Can specify
upper left corner
of range
Spreadsheet Modeling - 34
US Army Logistics University
Another Advanced Filter Example
Querying Customer Records at HyTex
• Suppose we want the customers who are either
(1) male with salary between $40,000 and
$50,000, or (2) female with salary over $70,000
• How should this condition be entered in the
criteria range? It is tempting to enter the label
”>40000,<50000” in a cell under Salary.
However, this doesn’t work.
• One solution is to enter two Salary fields in the
criteria range as shown on the next slide
Spreadsheet Modeling - 35
US Army Logistics University
Another Example
Querying Customer Records at HyTex
• There is no rule in Excel that every field name must
be included in the criteria range. Only those involved
in the query are required.
• Also the same field name can be included more than
once, evidently to deal with the situation we have
posed.
• The criteria range above will return exactly the
records we seek.
Spreadsheet Modeling - 36
US Army Logistics University
Importing External
Data from Access
Importing customer orders from a database
for the Fine Shirt Company
Spreadsheet Modeling - 37
US Army Logistics University
Background Information
Customer Orders for the Fine Shirt Company
• The Fine Shirt Company has a database of historical
customer retail shirt sales information that we want to
analyze
• There are three related tables in this database:
Customers, Orders, and Products
– Customer table (info on seven customers): CustomerNum,
Name, Street, City, State, Zip, Phone
– Products table (info on ten shirt types): ProductNum,
Description, Gender, UnitPrice
– Orders table (info on 2245 orders): OrderNum, CustomerNum,
ProductNum, OrderDate, UnitsOrdered, Discount
Spreadsheet Modeling - 38
US Army Logistics University
Introduction to Relational Databases
• Excel “databases” are flat files or lists
• They are also called single-table databases, where table is
the usual database terminology for a rectangular range of
data
• Flat files are fine for relatively simple database applications,
but are not powerful enough for more complex applications
• A relational database is a set of tables, where each table is
a rectangular arrangement of fields and records, and the
tables are linked explicitly.
• Microsoft Query (EXCEL add-in) allows import of data from
many database packages with very little work
Spreadsheet Modeling - 39
US Army Logistics University
Single Table Query Example
Customer Orders for the Fine Shirt Company
• Find all of the records from the Orders Table in the
Shirtorders database that meet the following conditions:
– Order date is during the years 1997 or 1998
– Product number is 3 or 5
– Number of units ordered is at least 100
• Return to Excel all fields in the Orders Table for these
records
Spreadsheet Modeling - 40
US Army Logistics University
Importing Data with Microsoft Query
Customer Orders for the Fine Shirt Company
• Import is a three step process done in Excel and Query,
not Access
• Step 1: Define a “data source”
– Select Data/Import External Data/New Database Query menu
item, then select “<New Data Source>” from Database tab of
Data Source dialog box
– In the Create New Data Source dialog box, give a name to the
data source, select appropriate driver (Microsoft Access), click
Connect, then Select and choose the database file & click OK a
couple of times to get back to the Data Source dialog box
– Make sure that the data source you defined is highlighted in the
Data Source dialog box, then click OK (should see Add Tables
dialog box)
Spreadsheet Modeling - 41
US Army Logistics University
Importing Data with Microsoft Query
Customer Orders for the Fine Shirt Company
• Step 2: Specify the data you want
– Select the appropriate table and click Add (click Close when
completed)
– The table should appear in the top part of the window
– Double click on fields you want returned to EXCEL (click on * to
return all fields)
– The data should appear on the bottom part of the window
– Click on the “Show/Hide Criteria” button on the toolbar to view
the criteria section in the middle of the window
Spreadsheet Modeling - 42
US Army Logistics University
Importing Data with Microsoft Query
Customer Orders for the Fine Shirt Company
• Step 3: Specify criteria and return data to EXCEL
– Entering criteria is similar to the Advanced Filter Tool
– Can type in criteria or use Criteria/Add Criteria menu item
– For Add Criteria dialog box, use pull-downs to select field and
operator, click on Values to select values from records (or can
type in values box)
– If you type anything in, be careful with syntax
– Can select more than one value in value box
– Records in bottom part of window are filtered each time a new
criteria is added
– Select File/Return Data to Microsoft Excel and select location of
data
Spreadsheet Modeling - 43
US Army Logistics University
Working with Imported Data
Customer Orders for the Fine Shirt Company
• You can now analyze the data using any EXCEL
features
• The imported data are still linked to the query
– With the cursor anywhere in the data, select the Data/Get
External Data/Edit Query menu item
– This takes you back into Microsoft Query, with your criteria
showing
– Any changes in criteria will be reflected in the Excel data
• You can also select File/Save in Microsoft Query to
save the query for later use (select Data/Get External
Data/Run Saved Query)
Spreadsheet Modeling - 44
US Army Logistics University
Creating a Complex Query
Customer Orders for the Fine Shirt Company
• Find all records that meet the following conditions:
– All orders for at least 80 units
– Order made by the customer “Shirts R Us” (customer
number 3)
– Product is Long sleeve Tunic (product number 6)
– Return the order date and units ordered for these orders.
• The main difference is that we now have to base the
query on all three tables in the database
Spreadsheet Modeling - 45
US Army Logistics University
Creating a Complex Query
Customer Orders for the Fine Shirt Company
• The trick is to use the links between the tables
• Create a new query by clicking on the data source
created from the previous example
• Inside the Query screen, first add all three tables by
using the Tables/Add Table menu item
• Double click the fields you want to return to EXCEL
• Create the appropriate criteria (fields will be
displayed as table.field)
Spreadsheet Modeling - 46
US Army Logistics University
Exploring Data with
Pivot Tables
Examining effects on elevator rail
diameters for Otis Elevator
Spreadsheet Modeling - 47
US Army Logistics University
Background Information
Rail diameters for Otis Elevator
• Spreadsheet contains the diameters (in inches) of
elevator rails produced by Otis Elevator’s two
machines and two operators
• Each diameter corresponds to a particular machine/
operator combination.
• What effects, if any, do the operator and machine
have on elevator rail diameters?
Spreadsheet Modeling - 48
US Army Logistics University
Pivot Tables
• Pivot tables provide an incredible amount of of
useful information about a data set
• Pivot tables allow us to break the data down into
subpopulations
• Statisticians often refer to the resulting tables as
contingency tables or crosstabs
Spreadsheet Modeling - 49
US Army Logistics University
Creating a Pivot Table
•
Position the cursor in the data range
•
Select PivotTable from Insert Ribbon
•
Select the data source and type of report (table or
chart/table)
•
Specify the range of the data set (should be set
properly if you placed the cursor in the data range)
•
Drag appropriate fields to the PivotTable Field List on
right side of workbook
Spreadsheet Modeling - 50
US Army Logistics University
Creating a Pivot Table
•
Click on any of the variable buttons and drag into the
appropriate areas
•
Row: shows field items as row labels
•
Column: shows field items as column labels
•
Report Filter: shows field items one at a time in the table
•
Values: summarizes values/statistics in the body of the
table
•
Double click on variables in data area to set
appropriate statistical calculation
•
Specify the location of the pivot table
Spreadsheet Modeling - 51
US Army Logistics University
Pivot Table and Chart Output
Rail diameters for Otis Elevator
Average of Diameter Machine
Operator
1
2 Grand Total
1
0.5190
0.5286
0.5231
2
0.5291
0.5412
0.5347
Drop
Page Fields Here
Grand Total
0.5243
0.5358
0.5294
Average of Diameter
0.60
0.55
0.50
0.45
0.40
0.35
Mac hine
0.30
1
2
0.25
0.20
0.15
0.10
0.05
0.00
1
2
Operator
Spreadsheet Modeling - 52
US Army Logistics University
Additional Pivot Table Options
• Can import data from an external database
• Can drag multiple field to any of the areas
• Can drag fields without going back to the wizard (table
updates automatically)
• Double click on any pivot table entry to see the source
data
• Use pull downs on table or chart to select/deselect
specific field values
• if the original data changes, the pivot table recalculates
automatically (click the exclamation point on the Pivot
Table toolbar to refresh the data)
Spreadsheet Modeling - 53
US Army Logistics University
Spreadsheet Modeling
and Analysis
Ordering with quantity discounts
at Sam’s Bookstore
Spreadsheet Modeling - 54
US Army Logistics University
Background Information
Ordering Books With Quantity Discounts
• Sam’s Bookstore needs a model to help it order the
appropriate number of hardback books of any title
• The unit costs for books depends on the quantity ordered
• The demand for books is uncertain (best estimate is a
range)
• Any hardback books not sold before the paperback book
comes out will be sold for $10
• Determine the company’s profit for a book’s sales for a
fixed demand and order quantity, then analyze the
demand uncertainty to choose an order quantity that
maximizes expected profit
Spreadsheet Modeling - 55
US Army Logistics University
Modeling Process
Ordering Books With Quantity Discounts
• Develop a model that will determine the profit
for any order quantity and any possible demand
• Perform a sensitivity analysis to see how profit
changes as order quantity and demand changes
• Estimate probabilities and determine the
expected profit for different order quantities
Spreadsheet Modeling - 56
US Army Logistics University
Building the model
Ordering Books With Quantity Discounts
• Use the MIN function with order quantity (Q) & demand
(D) to determine books sold at regular price (cell B15)
• Use the IF function to determine books sold at leftover
price (cell B16): IF(Q > D, Q – D, 0)
• Revenue = price * units sold (cell B17)
• Use VLOOKUP function to determine unit cost:
VLOOKUP(Q,CostLookup,2)*Q (cell B18)
• Profit = Revenue – Cost (cell B19)
Spreadsheet Modeling - 57
US Army Logistics University
Sensitivity Analysis
Ordering Books With Quantity Discounts
• Develop a two way data table to determine profit as the
demand and order quantity changes
– Create a demand row in row 22 (500 to 4500 in increments of
500)
– Create an order quantity column in column A (500 to 4500 in
increments of 500)
– Link cell A22 to the profit cell (=A19)
– Highlight table and Select Data Table from menu
» Row Input Cell: B12
» Column Input Cell: B9
• Table shows profit for varying levels of demand and order
quantity
Spreadsheet Modeling - 58
US Army Logistics University
Expected Profit
Ordering Books With Quantity Discounts
• Use probabilities of demand (row 35) to calculate
expected profit for different order quantities
• Use SUMPRODUCT function to calculate expected profit
– First range: profits for order quantity 500 (B23:J23)
– Second range: probabilities (B$35:J$35)
• Select order quantity with largest expected profit
(what does that number represent?)
Spreadsheet Modeling - 59
Download