1 chapter 2: linear programming problems: basic ideas 2.1 introduction to linear programming 2.2...

Post on 03-Jan-2016

278 Views

Category:

Documents

7 Downloads

Preview:

Click to see full reader

TRANSCRIPT

1

Chapter 2: Linear Programming Problems: Basic Ideas

2.1 Introduction to Linear Programming

2.2 Formulating and Solving Linear Programming Problems Using the OPTMODEL Procedure

2.3 Reading Data from SAS Data Sets

2.4 Writing Output from the OPTMODEL Procedure

2.5 Dual Values, Reduced Costs, and Pricing in the Simplex Method

2

2.1 Introduction to Linear Programming2.1 Introduction to Linear Programming

2.2 Formulating and Solving Linear Programming Problems Using the OPTMODEL Procedure

2.3 Reading Data from SAS Data Sets

2.4 Writing Output from the OPTMODEL Procedure

2.5 Dual Values, Reduced Costs, and Pricing in the Simplex Method

Chapter 2: Linear Programming Problems: Basic Ideas

3

Objectives Understand how, geometrically, the primal simplex,

dual simplex, and interior point methods solve linear programming problems.

Enter and solve simple linear programming problems using the OPTMODEL procedure.

4

A Linear Programming Problem

Each of the linear constraints can be either an inequality or an equation.

The bounds can be ±∞, so that xj can be restricted to be non-negative (lj=0 and uj=+∞) or free (lj=-∞ and uj=+∞).

{ , , }

( )

1 1 n n

j j j

min | max c x +...+c x

subject to

l x u j 1,2,...,n

Ax b

5

Implicit Assumptions of Linear Programming Proportionality Additivity Divisibility Certainty

6

Two-Dimensional ExampleThe following LP has decision variables x and y:

maximize 12x +19y

subject to x + 3y ≤ 225x + y ≤ 1173x + 4y ≤ 420x ≥ 0, y ≥ 0

The constraints of the LP determine a feasible region in two dimensions.

7

Feasible Region

x axis

y ax

is

8

Feasible Region

[63, 54]

[0, 75]

[0, 0] [117, 0]

extreme point solutions

optimal solution

y ax

is

x axis

An extreme point is a corner of the feasible region

14

This demonstration illustrates the solution of a linear programming problem using PROC OPTMODEL with the default, primal simplex and iterative interior point solvers.

Solving a Linear Programming Problem Using PROC OPTMODEL 2dimensional.sas

15

[63, 54]

Primal Simplex Trajectory

[0, 75]

[0, 0] [117, 0]

extreme point solutions

optimal solution

y ax

is

x axis

16

[63, 54]

Dual Simplex Trajectory

[0, 75]

[0, 0] [117, 0]

extreme point solutions

optimal solution

y ax

is

x axis

17

[63, 54]

Iterative Interior Trajectory

[0, 75]

[0, 0] [117, 0]

extreme point solutions

optimal solution

y ax

is

x axis

18

These exercises reinforce the concepts discussed previously.

Exercises 1 and 2

19

2.1 Introduction to Linear Programming

2.2 Formulating and Solving Linear Programming 2.2 Formulating and Solving Linear Programming Problems Using the OPTMODEL ProcedureProblems Using the OPTMODEL Procedure

2.3 Reading Data from SAS Data Sets

2.4 Writing Output from the OPTMODEL Procedure

2.5 Dual Values, Reduced Costs, and Pricing in the Simplex Method

Chapter 2: Linear Programming Problems: Basic Ideas

20

Objectives Formulate linear programming problems using

array indexing or index sets, name constraints, and store values in arrays and matrices.

Use the EXPAND statement to verify that a formulation is correct.

21

A Furniture-Making ProblemA furniture-making company can manufacture desks, chairs, bookcases, and bedframes, all of which require various person-hours of labor and units of metal and wood, given in the table below:

Labor

(hrs)

Metal

(lbs)

Wood

(ft3)

Selling

Price ($)

Desks 2 1 3 52

Chairs 1 1 3 44

Bookcases 3 1 4 70

Bedframes 2 1 4 61

22

A Furniture-Making ProblemThe cost and availability of labor, metal, and wood are as follows:

Assuming that all furniture can be sold, how many desks, chairs, bookcases, and bedframes should the company produce per day in order to make its profit as large as possible?

Labor

(hrs)

Metal

(lbs)

Wood

(ft3)

Cost ($) 7 10 5

Availability 225 117 420

23

Three Distinct Formulation Approaches

Variable Names explicit enter data intuitive

Array Indices compact read data abstract

Index Sets compact read

data intuitive flexible

24

A Furniture-Making ProblemThe cost and availability of labor, metal, and wood are as follows:

Assuming that all furniture can be sold, how many desks, chairs, bookcases, and bedframes should the company produce per day in order to make its profit as large as possible?

What should the decision variables be?

Labor

(hrs)

Metal

(lbs)

Wood

(ft3)

Cost ($) 7 10 5

Availability 225 117 420

25

A Furniture-Making ProblemThe cost and availability of labor, metal, and wood are as follows:

Assuming that all furniture can be sold, how many desks, chairs, bookcases, and bedframes should the company produce per day in order to make its profit as large as possible?

What should the decision variables be?

Labor

(hrs)

Metal

(lbs)

Wood

(ft3)

Cost ($) 7 10 5

Availability 225 117 420

26

Furniture-Making Problem Data

What should the objective be?

Labor

(hrs)

Metal

(lbs)

Wood

(ft3)

Selling

Price ($)

Desks 2 1 3 52

Chairs 1 1 3 44

Bookcases 3 1 4 70

Bedframes 2 1 4 61

Cost ($) 7 10 5

Availability 225 117 420

27

Furniture-Making Problem Data

What should the objective be?

Maximize profit = revenue - cost

Labor

(hrs)

Metal

(lbs)

Wood

(ft3)

Selling

Price ($)

Desks 2 1 3 52

Chairs 1 1 3 44

Bookcases 3 1 4 70

Bedframes 2 1 4 61

Cost ($) 7 10 5

Availability 225 117 420

28

Mathematical Optimization FormulationsThe basic structure of the formulation of a mathematical optimization problem is shown here:

min|max objective function

subject to constraints

variable bounds

The formulation should be followed by a description of the decision variables, sets, and parameters in the formulation.

29

PROC OPTMODEL FormulationsThe basic structure of a PROC OPTMODEL formulation of a mathematical optimization problem is shown here:

proc optmodel;

/* declare sets and parameters */

/* declare variables */

/* declare constraints */

/* declare objective */

solve;

/* print solution */

quit;

30

Formulation Using Variable Names proc optmodel;

/* declare variables */ desks, chairs, bookcases, bedframes

/* declare constraints */ availability of labor, metal, wood

/* declare objective */ maximize profit = revenue - cost

solve;

/* print solution */

quit;

31

This demonstration illustrates using the interactive nature of PROC OPTMODEL to expand and then solve a linear programming problem formulated using variable names.

Using PROC OPTMODEL to Solve the Variable Names Formulation of the Furniture-Making Problem furniture_names.sas

32

The EXPAND StatementThe EXPAND statement has options to print only a part of the linear programming formulation. This is the statement’s syntax:

Identifier-expression is the name of a variable, objective, or constraint. Options include the following:

VAR outputs variables.

OBJECTIVE|OBJ outputs objectives.

CONSTRAINT|CON outputs constraints.

EXPAND [ identifier-expression ] [ / options ] ;EXPAND [ identifier-expression ] [ / options ] ;

33

Arrays versus Names in PROC OPTMODELAn LP is compactly represented by arrays and matrices:

Advantages of arrays and matrices in PROC OPTMODEL: enter objective/constraint coefficients compactly read data from SAS data files make formulations portable/scalable/adaptable

PROC OPTMODEL syntax for matrix and array entries is A[i,j] and b[i].

{ , , }

min | max

subject to

cx

Ax b

l x u

34

Example: Transportation ProblemGiven supply values at a set of origins and demand values at a set of destinations, the transportation problem is to determine the amount to transport from each origin to each destination to meet the demand at a minimum cost.

A linear programming model of a transportation problem with two origins and three destinations is

( )

( )

( )

2 3

ij iji=1 j=1

3

ij ij=1

2

ij ji=1

ij

minimize c x

subject to x s i =1,2

x d j =1,2,3

x 0 i =1,2; j =1,2,33

2

11

2Ori

gin

s

De

stination

s

35

The SUM Aggregation OperatorThe SUM aggregation operator can be used to add numeric or variable expressions:

PROC OPTMODEL Output

In this sum, k is a local dummy parameter.

print (sum{k in 1..24} k**2);

4900

36

The SUM Aggregation OperatorThe SUM aggregation operator can be used to add numeric or variable expressions:

In these sums, i, j, and k are local dummy parameters.

print (sum{k in 1..24} k**2);

min Cost = sum{i in 1..2, j in 1..3} c[i,j] * x[i,j];

con s1: sum{j in 1..3} x[1,j] <= s[1]; con s2: sum{j in 1..3} x[2,j] <= s[2]; con d1: sum{i in 1..2} x[i,1] >= d[1]; con d2: sum{i in 1..2} x[i,2] >= d[2]; con d3: sum{i in 1..2} x[i,3] >= d[3];

37

Expanding a Transportation ProblemThe EXPAND statement also expands summations:

( )

( )

( )

2 3

ij iji=1 j=1

3

ij ij=1

2

ij ji=1

ij

minimize c x

subject to x s i =1,2

x d j =1,2,3

x 0 i =1,2; j =1,2,33

2

11

2

Minimize Cost=c11*x[1,1]+c12*x[1,2]+c13*x[1,3]+c21*x[2,1]+ c22*x[2,2]+c23*x[2,3]Constraint s1: x[1,1]+x[1,2]+x[1,3] <= s1

Constraint s2: x[2,1]+x[2,2]+x[2,3] <= s2

Constraint d1: x[1,1]+x[2,1] >= d1

Constraint d2: x[1,2]+x[2,2] >= d2

Constraint d3: x[1,3]+x[2,3] >= d3

Ori

gin

s

De

stination

s

38

Declaring Parameters in PROC OPTMODELParameters (other than local dummy parameters) must be declared in PROC OPTMODEL before they are used. number or num declares numeric parameters

num n; num pi = constant('pi'); num M{1..n,1..n};

39

Declaring Parameters in PROC OPTMODELParameters (other than local dummy parameters) must be declared in PROC OPTMODEL before they are used. number or num declares numeric parameters:

string or str declares character-valued parameters:

str name; str wkday{1..5}=[Mon Tue Wed Thu Fri];

num n; num pi = constant('pi'); num M{1..n,1..n};

40

Declaring Parameters in PROC OPTMODELParameters (other than local dummy parameters) must be declared in PROC OPTMODEL before they are used. number or num declares numeric parameters. string or str declares character-valued parameters. set <number> or set <num> declares a set of

numbers. set <string> or set <str> declares a set of

strings. set <type-1,…,type-n> declares a set of n-tuples

(types can be number (num) or string (str)).

set <num> Sixties = 1960..1969; set <str> Cities = /Cary 'New York'/; set <str,num> Parts = /<R 1> <C 2>/;

41

Declaring Parameters in PROC OPTMODELParameters (other than local dummy parameters) must be declared in PROC OPTMODEL before they are used. number or num declares numeric parameters. string or str declares character-valued parameters. set <number> or set <num> declares a set of

numbers. set <string> or set <str> declares a set of

strings. set <type-1,…,type-n> declares a set of n-tuples

(types can be number (num) or string (str)).

set Sixties = 1960..1969; set Cities = /Cary 'New York'/; set Parts = /<R 1> <C 2>/;

42

This demonstration illustrates the use of arrays and matrices in PROC OPTMODEL to solve a linear programming problem.

Using Arrays in PROC OPTMODEL to Solve the Furniture-Making Problem furniture_arrays.sas

43

Array Indexing versus Index Sets

set Products = /desks chairs bookcases bedframes/; set Resources = /labor metal wood/;

num A{Resources,Products} = [2 1 3 2 1 1 1 1 3 3 4 4]; num s{Products} = [52 44 70 61]; num c{Resources} = [7 10 5]; num b{Resources} = [225 117 420];

The indices used in arrays and matrices often correspond to index sets that are more meaningful than 1,2,…,n:

num A{1..3,1..4} = [2 1 3 2 1 1 1 1 3 3 4 4]; num s{1..4} = [52 44 70 61]; num c{1..3} = [7 10 5]; num b{1..3} = [225 117 420];

Array Indexing

versus Mnemonic Index Sets

44

Array Indexing versus Index Sets

set Products = /desks chairs bookcases bedframes/; set Resources = /labor metal wood/;

num Requirements{Resources,Products} = [2 1 3 2 1 1 1 1 3 3 4 4]; num Selling_Price{Products} = [52 44 70 61]; num Cost{Resources} = [7 10 5]; num Availability{Resources} = [225 117 420];

The indices used in arrays and matrices often correspond to index sets that are more meaningful than 1,2,…,n:

num A{1..3,1..4} = [2 1 3 2 1 1 1 1 3 3 4 4]; num s{1..4} = [52 44 70 61]; num c{1..3} = [7 10 5]; num b{1..3} = [225 117 420];

Array Indexing

versus Mnemonic Index Sets (and Names)

45

The SUM Aggregation OperatorThe SUM aggregation operator can be used with index sets. This is the statement’s syntax:

If the index-set is a set of tuples, the dummy parameter must match the number of terms in the tuple:

SUM{ index-set } expression SUM{ index-set } expression

set Cities = /Cary 'New York'/; num Total, Population{Cities}; Total = sum{c in Cities} Population[c];

set Parts = /<R 1> <C 2>/; num Inv, Stock{Parts}; Inv = sum{<p,n> in Parts} Stock[p,n];

46

This demonstration illustrates the use of index sets in PROC OPTMODEL to solve a linear programming problem.

Using Index Sets in PROC OPTMODEL to Solve the Furniture-Making Problem furniture_indices.sas

47

This exercise reinforces the concepts discussed previously.

Exercise 3

48

2.1 Introduction to Linear Programming

2.2 Formulating and Solving Linear Programming Problems Using the OPTMODEL Procedure

2.3 Reading Data from SAS Data Sets2.3 Reading Data from SAS Data Sets

2.4 Writing Output from the OPTMODEL Procedure

2.5 Dual Values, Reduced Costs, and Pricing in the Simplex Method

Chapter 2: Linear Programming Problems: Basic Ideas

49

Objectives Read data from multiple SAS data sets to formulate

linear programming problems.

50

Reading Data from SAS Data Sets: Example

Name Height Weight Age

1 Alfred 69 112.5 14

2 Alice 56.5 84 13

3 Barbara 65.3 98 13

4 Carol 62.8 102.5 14

How can you read the height, weight, and age of students into the arrays Height, Weight, and Age?

SAS Data Set: Opt.Class (just the first four columns)

51

Reading Data from SAS Data Sets: Example

Name Height Weight Age

1 Alfred 69 112.5 14

2 Alice 56.5 84 13

3 Barbara 65.3 98 13

4 Carol 62.8 102.5 14

SAS Data Set: Opt.Class (just the first four rows)

read data Opt.Class into Students=[Name] Height Weight Age;

How can you read the height, weight, and age of students into the arrays Height, Weight, and Age?

52

Reading Data from SAS Data Sets: Example

Name Height Weight Age

1 Alfred 69 112.5 14

2 Alice 56.5 84 13

3 Barbara 65.3 98 13

4 Carol 62.8 102.5 14

SAS Data Set: Opt.Class (just the first four rows)

Can you read just the first four rows (observations)?

53

Reading Data from SAS Data Sets: Example

Name Height Weight Age

1 Alfred 69 112.5 14

2 Alice 56.5 84 13

3 Barbara 65.3 98 13

4 Carol 62.8 102.5 14

SAS Data Set: Opt.Class (just the first four rows)

read data Opt.Class(obs=4) into Students=[Name] Height Weight Age;

Can you read just the first four rows (observations)?

54

data Resource_Data; input Resource $ Cost Amount_Available; datalines;labor 7 225metal 10 117wood 5 420run;

data Product_Data; length Product $9; input Product $ Selling_Price labor metal wood; datalines;desks 52 2 1 3chairs 44 1 1 3bookcases 70 3 1 4bedframes 61 2 1 4run;

Furniture-Making Problem SAS Data Sets

55

Furniture-Making Problem SAS Data Sets

Resource Cost Amount_Available

1 labor 7 225

2 metal 10 117

3 wood 5 420

Product Selling_Price labor metal wood

1 desks 52 2 1 3

2 chairs 44 1 1 3

3 bookcases 70 3 1 4

4 bedframes 61 2 1 4

SAS Data Set: Work.Resource_Data

SAS Data Set: Work.Product_Data

56

Reading Data: The READ Statement

SAS-data-set specifies the input data set. read-key-column(s) provide the index values for array

destinations. The optional set-name saves index values as a set. read-column(s) specify the data values to read and

destination locations. The optional NOMISS keyword suppresses the

assignment of missing values.

READ DATA SAS-data-set [ NOMISS ] INTO [set-name=] [ read-key-column(s) ] [ read-column(s)] ;

READ DATA SAS-data-set [ NOMISS ] INTO [set-name=] [ read-key-column(s) ] [ read-column(s)] ;

58

proc optmodel; /* declare sets and parameters */ set <str> Products, Resources; num Cost{Resources}, Availability{Resources}; num Selling_Price{Products}; num Requirements{Resources,Products};

read data Resource_Data into Resources=[Resource] Cost Availability=Amount_Available;

read data Product_Data into Products=[Product] Selling_Price {r in Resources} <Requirements[r,Product]=col(r)>;

Reading the Furniture-Making Data Sets

59

Declare index-sets (with no initialization expression, <str> is necessary because the default is <num>).

proc optmodel; /* declare sets and parameters */ set <str> Products, Resources; num Cost{Resources}, Availability{Resources}; num Selling_Price{Products}; num Requirements{Resources,Products};

read data Resource_Data into Resources=[Resource] Cost Availability=Amount_Available;

read data Product_Data into Products=[Product] Selling_Price {r in Resources} <Requirements[r,Product]=col(r)>;

Reading the Furniture-Making Data Sets

60

Declare parameter arrays, which are indexed by the (unpopulated) index-sets Products and Resources.

proc optmodel; /* declare sets and parameters */ set <str> Products, Resources; num Cost{Resources}, Availability{Resources}; num Selling_Price{Products}; num Requirements{Resources,Products};

read data Resource_Data into Resources=[Resource] Cost Availability=Amount_Available;

read data Product_Data into Products=[Product] Selling_Price {r in Resources} <Requirements[r,Product]=col(r)>;

Reading the Furniture-Making Data Sets

61

data Resource_Data; input Resource $ Cost Amount_Available; datalines;labor 7 225metal 10 117wood 5 420run;

Reading the Furniture-Making Data Sets

read-key-column(SAS data set variable name)

set <str> Products, Resources; num Cost{Resources}, Availability{Resources}; read data Resource_Data into Resources=[Resource] Cost Availability=Amount_Available;

62

data Resource_Data; input Resource $ Cost Amount_Available; datalines;labor 7 225metal 10 117wood 5 420run;

set <str> Products, Resources; num Cost{Resources}, Availability{Resources}; read data Resource_Data into Resources=[Resource] Cost Availability=Amount_Available;

Reading the Furniture-Making Data Sets

set-name(OPTMODEL index-set)

63

data Resource_Data; input Resource $ Cost Amount_Available; datalines;labor 7 225metal 10 117wood 5 420run;

set <str> Products, Resources; num Cost{Resources}, Availability{Resources}; read data Resource_Data into Resources=[Resource] Cost Availability=Amount_Available;

Reading the Furniture-Making Data Sets

read-columns (OPTMODEL array name [=SAS data set variable name] )

64

set <str> Products, Resources; num Selling_Price{Products}; num Requirements{Resources,Products}; read data Product_Data into Products=[Product] Selling_Price {r in Resources} <Requirements[r,Product]=col(r)>;

Reading the Furniture-Making Data Sets

read-key-column (SAS data set variable name)

data Product_Data; length Product $9; input Product $ Selling_Price labor metal wood; datalines;desks 52 2 1 3chairs 44 1 1 3bookcases 70 3 1 4bedframes 61 2 1 4run;

65

set <str> Products, Resources; num Selling_Price{Products}; num Requirements{Resources,Products}; read data Product_Data into Products=[Product] Selling_Price {r in Resources} <Requirements[r,Product]=col(r)>;

Reading the Furniture-Making Data Sets

set-name (OPTMODEL index-set)

data Product_Data; length Product $9; input Product $ Selling_Price labor metal wood; datalines;desks 52 2 1 3chairs 44 1 1 3bookcases 70 3 1 4bedframes 61 2 1 4run;

66

set <str> Products, Resources; num Selling_Price{Products}; num Requirements{Resources,Products}; read data Product_Data into Products=[Product] Selling_Price {r in Resources} <Requirements[r,Product]=col(r)>;

Reading the Furniture-Making Data Sets

read-column (OPTMODEL array name)

data Product_Data; length Product $9; input Product $ Selling_Price labor metal wood; datalines;desks 52 2 1 3chairs 44 1 1 3bookcases 70 3 1 4bedframes 61 2 1 4run;

67

set <str> Products, Resources; num Selling_Price{Products}; num Requirements{Resources,Products}; read data Product_Data into Products=[Product] Selling_Price {r in Resources} <Requirements[r,Product]=col(r)>;

Reading the Furniture-Making Data Sets

iterated read-column (array destination=COL expression)

data Product_Data; length Product $9; input Product $ Selling_Price labor metal wood; datalines;desks 52 2 1 3chairs 44 1 1 3bookcases 70 3 1 4bedframes 61 2 1 4run;

68

This demonstration reads data from SAS data sets for the formulation of the furniture-making problem using index sets in PROC OPTMODEL.

Reading Data Sets in PROC OPTMODEL for the Furniture-Making Problem furniture_read.sas

69

data Break_Points; input a @@; datalines;0 1 2 5 10 20run;

Reading Data with No Read-Key-ColumnHow can you read break point values into an array a?

read data SAS-DATA-SET into [ SET-NAME=] [READ-KEY-COLUMNS] READ-COLUMN;

70

data Break_Points; input a @@; datalines;0 1 2 5 10 20run;

Reading Data with No Read-Key-ColumnHow can you read break point values into an array a?

read data Break_Points into [ SET-NAME=] [READ-KEY-COLUMNS] READ-COLUMN;

71

data Break_Points; input a @@; datalines;0 1 2 5 10 20run;

Reading Data with No Read-Key-ColumnHow can you read break point values into an array a?

read data Break_Points into [ SET-NAME=] [READ-KEY-COLUMNS] a;

72

data Break_Points; input a @@; datalines;0 1 2 5 10 20run;

Reading Data with No Read-Key-ColumnHow can you read break point values into an array a?

a

1 0

2 1

3 2

4 5

5 10

6 20

SA

S D

ata

Set

: Work.Break_Points

read data Break_Points into [ SET-NAME=] [READ-KEY-COLUMNS] a;

73

data Break_Points; input a @@; datalines;0 1 2 5 10 20run;

Reading Data with No Read-Key-ColumnHow can you read break point values into an array a?

_N_ a

1 0

2 1

3 2

4 5

5 10

6 20

read data Break_Points into [ SET-NAME=] [_N_] a;

SA

S D

ata

Set

: Work.Break_Points

74

data Break_Points; input a @@; datalines;0 1 2 5 10 20run;

Reading Data with No Read-Key-ColumnHow can you read break point values into an array a?

_N_ a

1 0

2 1

3 2

4 5

5 10

6 20

read data Break_Points into [ SET-NAME=] [_N_] a;

Why would you need the set name?

SA

S D

ata

Set

: Work.Break_Points

75

data Break_Points; input a @@; datalines;0 1 2 5 10 20run;

Reading Data with No Read-Key-ColumnHow can you read break point values into an array a?

_N_ a

1 0

2 1

3 2

4 5

5 10

6 20

read data Break_Points into domain= [_N_] a;

Why would you need the set name?

SA

S D

ata

Set

: Work.Break_Points

76

Reading Data with Read-Key-Columns

Plant Part_No Init_Inventory

1 Denver WD12X300 340

2 Denver WD18X213 456

3 Boulder WD12X300 120

4 Boulder WD1X1097 1203

SAS Data Set: Colorado.Inventory_by_Plant

read data SAS-DATA-SET into [ SET-NAME=] [READ-KEY-COLUMNS] READ-COLUMN;

How can you read the starting inventory levels into the matrix Start[p,n] indexed by Plant and Part_No?

77

Reading Data with Read-Key-Columns

Plant Part_No Init_Inventory

1 Denver WD12X300 340

2 Denver WD18X213 456

3 Boulder WD12X300 120

4 Boulder WD1X1097 1203

SAS Data Set: Colorado.Inventory_by_Plant

read data Colorado.Inventory_by_Plant into [READ-KEY-COLUMNS] READ-COLUMN;

How can you read the starting inventory levels into the matrix Start[p,n] indexed by Plant and Part_No?

78

Reading Data with Read-Key-Columns

Plant Part_No Init_Inventory

1 Denver WD12X300 340

2 Denver WD18X213 456

3 Boulder WD12X300 120

4 Boulder WD1X1097 1203

SAS Data Set: Colorado.Inventory_by_Plant

read data Colorado.Inventory_by_Plant into [Plant Part_No] READ-COLUMN;

How can you read the starting inventory levels into the matrix Start[p,n] indexed by Plant and Part_No?

79

Reading Data with Read-Key-Columns

Plant Part_No Init_Inventory

1 Denver WD12X300 340

2 Denver WD18X213 456

3 Boulder WD12X300 120

4 Boulder WD1X1097 1203

SAS Data Set: Colorado.Inventory_by_Plant

read data Colorado.Inventory_by_Plant into [Plant Part_No] Start=Init_Inventory;

How can you read the starting inventory levels into the matrix Start[p,n] indexed by Plant and Part_No?

80

Example: Oil Refinery Blending ProblemHow much of each raw gasoline should be blended into each aviation gasoline to maximize profit while meeting limits on performance (PN) and vapor pressure (RVP)?

Raw Gasolines

B

ACat

Str

Iso

Alk

Aviation Gasolines

PN ≥ 100RVP ≤ 7

PN ≥ 91RVP ≤ 7

PN RVP

107 5

93 8

87 4

108 21

81

This class participation exercise includes the use of index sets and reading data from SAS data sets in PROC OPTMODEL to solve a linear programming problem.

Reading Data Sets in PROC OPTMODEL for the Oil Refinery Blending Problemblending_partial.sas

82

These exercises reinforce the concepts discussed previously.

Exercises 4–6

83

2.1 Introduction to Linear Programming

2.2 Formulating and Solving Linear Programming Problems Using the OPTMODEL Procedure

2.3 Reading Data from SAS Data Sets

2.4 Writing Output from the OPTMODEL 2.4 Writing Output from the OPTMODEL Procedure Procedure

2.5 Dual Values, Reduced Costs, and Pricing in the Simplex Method

Chapter 2: Linear Programming Problems: Basic Ideas

84

Objectives Interpret PROC OPTMODEL output and write

formatted output. Write linear programming problems to Math

Programming System (MPS) format.

85

PROC OPTMODEL Output: Suffixes Decision Variables.init (initial value) .lb (lower bound).ub (upper bound).sol (solution value) .rc or .dual (reduced cost)

Objective Function

.sol (objective value) Constraints.body (body value) .lb (lower bound).ub (upper bound) .dual (dual value)

86

Writing Output: The CREATE StatementThe CREATE statement mimics the READ statement:

SAS-data-set specifies the output data set. key-column(s) specify data set variable names whose

values index array locations in column(s). The optional key-set specifies a set of index values

for key-column(s). column(s) specify data set variable names and

PROC OPTMODEL source data.

CREATE DATA SAS-data-set FROM [ key-column(s) ] [ = key-set ] column(s) ;

CREATE DATA SAS-data-set FROM [ key-column(s) ] [ = key-set ] column(s) ;

88

Writing Output from the Furniture-Making LP

Product Solution_Value

1 desks 0

2 chairs 48

3 bookcases 39

4 bedframes 30

SAS Data Set: Work.Optimal_Solution

create data Optimal_Solution from [Product]=Products Solution_Value=x;

89

Writing Output from the Furniture-Making LP

Product Solution_Value

1 desks 0

2 chairs 48

3 bookcases 39

4 bedframes 30

SAS Data Set: Work.Optimal_Solution

create data Optimal_Solution from [Product]=Products Solution_Value=x;

Reminder:

Products is the set of products that can be made (an index-set).

90

Writing Output from the Furniture-Making LP

Product Solution_Value

1 desks 0

2 chairs 48

3 bookcases 39

4 bedframes 30

SAS Data Set: Work.Optimal_Solution

create data Optimal_Solution from [Product]=Products Solution_Value=x;

Reminder:

x=x.sol is an array that holds the optimal production levels.

91

Writing Output from the Furniture-Making LP

Product Solution_Value

1 desks 0

2 chairs 48

3 bookcases 39

4 bedframes 30

SAS Data Set: Work.Optimal_Solution

The key-column declares index values and their data set variables.

create data Optimal_Solution from [Product]=Products Solution_Value=x;

92

Writing Output from the Furniture-Making LP

Product Solution_Value

1 desks 0

2 chairs 48

3 bookcases 39

4 bedframes 30

SAS Data Set: Work.Optimal_Solution

The key-set specifies a set of index values for the key-column(s).

create data Optimal_Solution from [Product]=Products Solution_Value=x;

93

Writing Output from the Furniture-Making LP

Product Solution_Value

1 desks 0

2 chairs 48

3 bookcases 39

4 bedframes 30

SAS Data Set: Work.Optimal_Solution

The column specifies data set variables and OPTMODEL source data.

create data Optimal_Solution from [Product]=Products Solution_Value=x;

94

Writing Output from the Furniture-Making LPHow could you write just the variables that occur (are nonzero) in the optimal solution?

95

Writing Output from the Furniture-Making LPHow could you write just the variables that occur (are nonzero) in the optimal solution? Two approaches:

Data set option where=

Optimal_Solution(where=(Solution_Value>0))

96

Writing Output from the Furniture-Making LPHow could you write just the variables that occur (are nonzero) in the optimal solution? Two approaches:

Data set option where=

Restrict the key-set by a selection expression

Optimal_Solution(where=(Solution_Value>0))

[Product]={p in Products: x[p]>0}

97

Writing Output with Multiple Key ColumnsHow can we write only those transportation links that occur in the optimal solution to a SAS data set Shipping_Links?

create data Shipping_Links from [Origin Destination]={i in Origins, j in Destinations: x[i,j]>0} Amount=x;

create data Shipping_Links(where=(Amount>0)) [Origin Destination] Amount=x;

98

Writing Output Using Dummy ParametersDummy parameters in the key-set can also be used to specify the columns:

create data Excess(where=(Amount>0)) from [Supplier]={i in Origins} Amount=(Supply[i]-Supply_Avail[i].body);

SAS Data Set: Work.ExcessSupplier Amount

1 Atlanta 175

2 Los_Angeles 150

3 Bozeman 25

99

Writing Output Using Dummy ParametersDummy parameters in the key-set can also be used to specify the columns:

create data Excess(where=(Amount>0)) from [Supplier]={i in Origins} Amount=(Supply[i]-Supply_Avail[i].body);

SAS Data Set: Work.ExcessSupplier Amount

1 Atlanta 175

2 Los_Angeles 150

3 Bozeman 25

Amount does not need to be declared.

100

Formatted Output Using the PRINT Statement print 'Profit:' (Profit.sol) DOLLAR.;

Profit: $1,827

PROC OPTMODEL Output

101

Formatted Output Using the PRINT Statement print 'Profit:' (Profit.sol) DOLLAR.; print 'Optimal Solution:'; print {p in Products: x[p]>0} x;

Profit: $1,827

Optimal Solution:

[1] x

bedframes 30 bookcases 39 chairs 48

PROC OPTMODEL Output

102

Formatted Output Using the PRINT Statement print 'Resource Usage:'; print Usage.body Usage.ub;

Resource Usage:

Usage. [1] BODY Usage.UB

labor 225 225 metal 117 117 wood 420 420

PROC OPTMODEL Output

103

Formatted Output Using the PUT StatementThe FILE statement selects the current output file for the PUT statement (the default is the SAS log).

file print; put / 'Products=' Products; put 'Resources=' Resources; file 'greeting.txt'; put 'hello, world'; closefile 'greeting.txt';

(The slash outputs the current line.)

104

Formatted Output Using the PUT StatementThe FILE statement selects the current output file for the PUT statement (the default is the SAS log).

PROC OPTMODEL Output

file print; put / 'Products=' Products; put 'Resources=' Resources; file 'greeting.txt'; put 'hello, world'; closefile 'greeting.txt';

Products={'desks','chairs','bookcases','bedframes'} Resources={'labor','metal','wood'}

(The slash outputs the current line.)

105

This demonstration illustrates the different methods of writing output from PROC OPTMODEL after solving a linear programming problem.

Writing PROC OPTMODEL Output for the Furniture-Making Problem furniture_output.sas

106

Sparsity in Linear Programming ProblemsMany practical linear programming problems are sparse: most coefficients in the constraint matrix A are zero.

An LP with Staircase Structure

388 rows

466 columns

1,534 nonzeros

107

Writing Problems to MPS FormatThe SAVE MPS statement saves the structure and coefficients for an LP model into a SAS data set, which can be used as input data for the OPTLP procedure.

A Supply Chain Problem

108,500 rows

1.7 million columns

4.2 million nonzeros

108

This demonstration illustrates writing a linear programming model to the (industry standard) MPS format, which preserves sparsity.

Writing an LP to MPS Format Using PROC OPTMODEL transportation.sas

109

These exercises reinforce the concepts discussed previously.

Exercises 7–9

110

2.1 Introduction to Linear Programming

2.2 Formulating and Solving Linear Programming Problems Using the OPTMODEL Procedure

2.3 Reading Data from SAS Data Sets

2.4 Writing Output from the OPTMODEL Procedure

2.5 Dual Values, Reduced Costs, and Pricing in 2.5 Dual Values, Reduced Costs, and Pricing in the Simplex Methodthe Simplex Method

Chapter 2: Linear Programming Problems: Basic Ideas

111

Objectives Explain the interpretation of dual values in linear

programming. Describe how dual values are used in the primal

simplex method and how pricing options influence the behavior of the simplex method.

112

Interpretation of Dual Values The dual value of a constraint is defined as

Dual Value = Change in optimal objective

Unit increase in constraint RHS

113

Interpretation of Dual Values The dual value of a constraint is defined as

This assumes that the extreme point determining the optimal solution is not over-determined:

Dual Value = Change in optimal objective

Unit increase in constraint RHS

114

Interpretation of Dual Values The dual value of a constraint is defined as

This assumes that the extreme point determining the optimal solution is not over-determined:

Dual Value = Change in optimal objective

Unit increase in constraint RHS

over-determined (degenerate)

115

[63, 54]

Feasible Region

y ax

is

x axis

optimal solution

116

[63, 54]

Feasible Region

dual value = 3.5

dual value = 8.5

dual value = 0

y ax

is

x axis

optimal solution

117

Feasible Region

y ax

is

x axis

optimal solution

[60.5, 56.5]

118

Feasible Region

y ax

is

x axis

optimal solution

[58, 59]

119

Feasible Region

y ax

is

x axis

optimal solution

[55.5, 61.5]

120

Feasible Region

y ax

is

x axis

optimal solution

[70.5, 51.5]

121

Feasible Region

y ax

is

x axis

optimal solution

[72, 51]

122

Dual Values for the Furniture-Making ProblemThe dual values can be written using the PRINT statement:

print Usage.dual;

123

Dual Values for the Furniture-Making ProblemThe dual values can be written using the PRINT statement:

Usage. [1] DUAL

labor 2 metal 1 wood 3

PROC OPTMODEL Output print Usage.dual;

124

Dual Values for the Furniture-Making ProblemThe dual values can be written using the PRINT statement:

If additional overtime hours are available for $10.50 (time-and-a-half), would they be used?

PROC OPTMODEL Output print Usage.dual;

Usage. [1] DUAL

labor 2 metal 1 wood 3

125

Dual Values for the Furniture-Making ProblemThe dual values can be written using the PRINT statement:

If additional overtime hours are available for $10.50 (time-and-a-half), would they be used?

No. For an additional hour at $7, the objective increases by at most $2; for overtime the cost is $10.50=$7+$3.50.

PROC OPTMODEL Output print Usage.dual;

Usage. [1] DUAL

labor 2 metal 1 wood 3

126

Making Tables: Pricing an ActivityTables require 3 hours of labor, 1 pound of metal, and 2 ft3 wood. Tables sell for $55. Should any be produced?

Profit for a table:

$55-3($7)-1($10)-2($5) = $14

127

Making Tables: Pricing an ActivityTables require 3 hours of labor, 1 pound of metal, and 2 ft3 wood. Tables sell for $55. Should any be produced?

Profit for a table:

$55-3($7)-1($10)-2($5) = $14

Cost of reduced availability:

3($2)+1($1)+2($3) = $13

128

Making Tables: Pricing an ActivityTables require 3 hours of labor, 1 pound of metal, and 2 ft3 wood. Tables sell for $55. Should any be produced?

$14-$13=$1 is the unit gain of making tables.

Profit for a table:

$55-3($7)-1($10)-2($5) = $14

Cost of reduced availability:

3($2)+1($1)+2($3) = $13

129

Making Tables: Pricing an ActivityTables require 3 hours of labor, 1 pound of metal, and 2 ft3 wood. Tables sell for $55. Should any be produced?

$14-$13=$1 is the unit gain of making tables.

Profit for a table:

$55-3($7)-1($10)-2($5) = $14

Cost of reduced availability:

3($2)+1($1)+2($3) = $13

The difference is called the reduced cost.

130

Pricing in the Primal and Dual Simplex Methods

Option Description

FULL Most negative* reduced cost

PARTIAL Maintain a candidate queue (of length QUEUESIZE=k)

STEEPESTEDGE Steepest edge pricing strategy (dual simplex default)

DEVEX Approximate steepest edge

HYBRID Hybrid of DEVEX and STEEPESTEDGE (primal simplex default)

SOLVE WITH LP / PRICETYPE = option ; SOLVE WITH LP / PRICETYPE = option ;

131

This demonstration introduces the linear programming problem on which the following exercise is based.

Solving the McDonald’s Diet Problem Using PROC OPTMODEL mcdonalds.sas

132

These exercises reinforce the concepts discussed previously.

Exercises 10–12

top related