+ All Categories
Home > Documents > 1 Chapter 2: Linear Programming Problems: Basic Ideas 2.1 Introduction to Linear Programming 2.2...

1 Chapter 2: Linear Programming Problems: Basic Ideas 2.1 Introduction to Linear Programming 2.2...

Date post: 03-Jan-2016
Category:
Upload: leona-walker
View: 270 times
Download: 7 times
Share this document with a friend
Popular Tags:
125
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
Transcript
Page 1: 1 Chapter 2: Linear Programming Problems: Basic Ideas 2.1 Introduction to Linear Programming 2.2 Formulating and Solving Linear Programming Problems Using.

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

Page 2: 1 Chapter 2: Linear Programming Problems: Basic Ideas 2.1 Introduction to Linear Programming 2.2 Formulating and Solving Linear Programming Problems Using.

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

Page 3: 1 Chapter 2: Linear Programming Problems: Basic Ideas 2.1 Introduction to Linear Programming 2.2 Formulating and Solving Linear Programming Problems Using.

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.

Page 4: 1 Chapter 2: Linear Programming Problems: Basic Ideas 2.1 Introduction to Linear Programming 2.2 Formulating and Solving Linear Programming Problems Using.

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

Page 5: 1 Chapter 2: Linear Programming Problems: Basic Ideas 2.1 Introduction to Linear Programming 2.2 Formulating and Solving Linear Programming Problems Using.

5

Implicit Assumptions of Linear Programming Proportionality Additivity Divisibility Certainty

Page 6: 1 Chapter 2: Linear Programming Problems: Basic Ideas 2.1 Introduction to Linear Programming 2.2 Formulating and Solving Linear Programming Problems Using.

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.

Page 7: 1 Chapter 2: Linear Programming Problems: Basic Ideas 2.1 Introduction to Linear Programming 2.2 Formulating and Solving Linear Programming Problems Using.

7

Feasible Region

x axis

y ax

is

Page 8: 1 Chapter 2: Linear Programming Problems: Basic Ideas 2.1 Introduction to Linear Programming 2.2 Formulating and Solving Linear Programming Problems Using.

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

Page 9: 1 Chapter 2: Linear Programming Problems: Basic Ideas 2.1 Introduction to Linear Programming 2.2 Formulating and Solving Linear Programming Problems Using.

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

Page 10: 1 Chapter 2: Linear Programming Problems: Basic Ideas 2.1 Introduction to Linear Programming 2.2 Formulating and Solving Linear Programming Problems Using.

15

[63, 54]

Primal Simplex Trajectory

[0, 75]

[0, 0] [117, 0]

extreme point solutions

optimal solution

y ax

is

x axis

Page 11: 1 Chapter 2: Linear Programming Problems: Basic Ideas 2.1 Introduction to Linear Programming 2.2 Formulating and Solving Linear Programming Problems Using.

16

[63, 54]

Dual Simplex Trajectory

[0, 75]

[0, 0] [117, 0]

extreme point solutions

optimal solution

y ax

is

x axis

Page 12: 1 Chapter 2: Linear Programming Problems: Basic Ideas 2.1 Introduction to Linear Programming 2.2 Formulating and Solving Linear Programming Problems Using.

17

[63, 54]

Iterative Interior Trajectory

[0, 75]

[0, 0] [117, 0]

extreme point solutions

optimal solution

y ax

is

x axis

Page 13: 1 Chapter 2: Linear Programming Problems: Basic Ideas 2.1 Introduction to Linear Programming 2.2 Formulating and Solving Linear Programming Problems Using.

18

These exercises reinforce the concepts discussed previously.

Exercises 1 and 2

Page 14: 1 Chapter 2: Linear Programming Problems: Basic Ideas 2.1 Introduction to Linear Programming 2.2 Formulating and Solving Linear Programming Problems Using.

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

Page 15: 1 Chapter 2: Linear Programming Problems: Basic Ideas 2.1 Introduction to Linear Programming 2.2 Formulating and Solving Linear Programming Problems Using.

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.

Page 16: 1 Chapter 2: Linear Programming Problems: Basic Ideas 2.1 Introduction to Linear Programming 2.2 Formulating and Solving Linear Programming Problems Using.

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

Page 17: 1 Chapter 2: Linear Programming Problems: Basic Ideas 2.1 Introduction to Linear Programming 2.2 Formulating and Solving Linear Programming Problems Using.

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

Page 18: 1 Chapter 2: Linear Programming Problems: Basic Ideas 2.1 Introduction to Linear Programming 2.2 Formulating and Solving Linear Programming Problems Using.

23

Three Distinct Formulation Approaches

Variable Names explicit enter data intuitive

Array Indices compact read data abstract

Index Sets compact read

data intuitive flexible

Page 19: 1 Chapter 2: Linear Programming Problems: Basic Ideas 2.1 Introduction to Linear Programming 2.2 Formulating and Solving Linear Programming Problems Using.

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

Page 20: 1 Chapter 2: Linear Programming Problems: Basic Ideas 2.1 Introduction to Linear Programming 2.2 Formulating and Solving Linear Programming Problems Using.

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

Page 21: 1 Chapter 2: Linear Programming Problems: Basic Ideas 2.1 Introduction to Linear Programming 2.2 Formulating and Solving Linear Programming Problems Using.

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

Page 22: 1 Chapter 2: Linear Programming Problems: Basic Ideas 2.1 Introduction to Linear Programming 2.2 Formulating and Solving Linear Programming Problems Using.

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

Page 23: 1 Chapter 2: Linear Programming Problems: Basic Ideas 2.1 Introduction to Linear Programming 2.2 Formulating and Solving Linear Programming Problems Using.

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.

Page 24: 1 Chapter 2: Linear Programming Problems: Basic Ideas 2.1 Introduction to Linear Programming 2.2 Formulating and Solving Linear Programming Problems Using.

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;

Page 25: 1 Chapter 2: Linear Programming Problems: Basic Ideas 2.1 Introduction to Linear Programming 2.2 Formulating and Solving Linear Programming Problems Using.

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;

Page 26: 1 Chapter 2: Linear Programming Problems: Basic Ideas 2.1 Introduction to Linear Programming 2.2 Formulating and Solving Linear Programming Problems Using.

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

Page 27: 1 Chapter 2: Linear Programming Problems: Basic Ideas 2.1 Introduction to Linear Programming 2.2 Formulating and Solving Linear Programming Problems Using.

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 ] ;

Page 28: 1 Chapter 2: Linear Programming Problems: Basic Ideas 2.1 Introduction to Linear Programming 2.2 Formulating and Solving Linear Programming Problems Using.

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

Page 29: 1 Chapter 2: Linear Programming Problems: Basic Ideas 2.1 Introduction to Linear Programming 2.2 Formulating and Solving Linear Programming Problems Using.

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

Page 30: 1 Chapter 2: Linear Programming Problems: Basic Ideas 2.1 Introduction to Linear Programming 2.2 Formulating and Solving Linear Programming Problems Using.

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

Page 31: 1 Chapter 2: Linear Programming Problems: Basic Ideas 2.1 Introduction to Linear Programming 2.2 Formulating and Solving Linear Programming Problems Using.

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];

Page 32: 1 Chapter 2: Linear Programming Problems: Basic Ideas 2.1 Introduction to Linear Programming 2.2 Formulating and Solving Linear Programming Problems Using.

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

Page 33: 1 Chapter 2: Linear Programming Problems: Basic Ideas 2.1 Introduction to Linear Programming 2.2 Formulating and Solving Linear Programming Problems Using.

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};

Page 34: 1 Chapter 2: Linear Programming Problems: Basic Ideas 2.1 Introduction to Linear Programming 2.2 Formulating and Solving Linear Programming Problems Using.

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};

Page 35: 1 Chapter 2: Linear Programming Problems: Basic Ideas 2.1 Introduction to Linear Programming 2.2 Formulating and Solving Linear Programming Problems Using.

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>/;

Page 36: 1 Chapter 2: Linear Programming Problems: Basic Ideas 2.1 Introduction to Linear Programming 2.2 Formulating and Solving Linear Programming Problems Using.

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>/;

Page 37: 1 Chapter 2: Linear Programming Problems: Basic Ideas 2.1 Introduction to Linear Programming 2.2 Formulating and Solving Linear Programming Problems Using.

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

Page 38: 1 Chapter 2: Linear Programming Problems: Basic Ideas 2.1 Introduction to Linear Programming 2.2 Formulating and Solving Linear Programming Problems Using.

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

Page 39: 1 Chapter 2: Linear Programming Problems: Basic Ideas 2.1 Introduction to Linear Programming 2.2 Formulating and Solving Linear Programming Problems Using.

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)

Page 40: 1 Chapter 2: Linear Programming Problems: Basic Ideas 2.1 Introduction to Linear Programming 2.2 Formulating and Solving Linear Programming Problems Using.

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];

Page 41: 1 Chapter 2: Linear Programming Problems: Basic Ideas 2.1 Introduction to Linear Programming 2.2 Formulating and Solving Linear Programming Problems Using.

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

Page 42: 1 Chapter 2: Linear Programming Problems: Basic Ideas 2.1 Introduction to Linear Programming 2.2 Formulating and Solving Linear Programming Problems Using.

47

This exercise reinforces the concepts discussed previously.

Exercise 3

Page 43: 1 Chapter 2: Linear Programming Problems: Basic Ideas 2.1 Introduction to Linear Programming 2.2 Formulating and Solving Linear Programming Problems Using.

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

Page 44: 1 Chapter 2: Linear Programming Problems: Basic Ideas 2.1 Introduction to Linear Programming 2.2 Formulating and Solving Linear Programming Problems Using.

49

Objectives Read data from multiple SAS data sets to formulate

linear programming problems.

Page 45: 1 Chapter 2: Linear Programming Problems: Basic Ideas 2.1 Introduction to Linear Programming 2.2 Formulating and Solving Linear Programming Problems Using.

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)

Page 46: 1 Chapter 2: Linear Programming Problems: Basic Ideas 2.1 Introduction to Linear Programming 2.2 Formulating and Solving Linear Programming Problems Using.

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?

Page 47: 1 Chapter 2: Linear Programming Problems: Basic Ideas 2.1 Introduction to Linear Programming 2.2 Formulating and Solving Linear Programming Problems Using.

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)?

Page 48: 1 Chapter 2: Linear Programming Problems: Basic Ideas 2.1 Introduction to Linear Programming 2.2 Formulating and Solving Linear Programming Problems Using.

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)?

Page 49: 1 Chapter 2: Linear Programming Problems: Basic Ideas 2.1 Introduction to Linear Programming 2.2 Formulating and Solving Linear Programming Problems Using.

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

Page 50: 1 Chapter 2: Linear Programming Problems: Basic Ideas 2.1 Introduction to Linear Programming 2.2 Formulating and Solving Linear Programming Problems Using.

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

Page 51: 1 Chapter 2: Linear Programming Problems: Basic Ideas 2.1 Introduction to Linear Programming 2.2 Formulating and Solving Linear Programming Problems Using.

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)] ;

Page 52: 1 Chapter 2: Linear Programming Problems: Basic Ideas 2.1 Introduction to Linear Programming 2.2 Formulating and Solving Linear Programming Problems Using.

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

Page 53: 1 Chapter 2: Linear Programming Problems: Basic Ideas 2.1 Introduction to Linear Programming 2.2 Formulating and Solving Linear Programming Problems Using.

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

Page 54: 1 Chapter 2: Linear Programming Problems: Basic Ideas 2.1 Introduction to Linear Programming 2.2 Formulating and Solving Linear Programming Problems Using.

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

Page 55: 1 Chapter 2: Linear Programming Problems: Basic Ideas 2.1 Introduction to Linear Programming 2.2 Formulating and Solving Linear Programming Problems Using.

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;

Page 56: 1 Chapter 2: Linear Programming Problems: Basic Ideas 2.1 Introduction to Linear Programming 2.2 Formulating and Solving Linear Programming Problems Using.

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)

Page 57: 1 Chapter 2: Linear Programming Problems: Basic Ideas 2.1 Introduction to Linear Programming 2.2 Formulating and Solving Linear Programming Problems Using.

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] )

Page 58: 1 Chapter 2: Linear Programming Problems: Basic Ideas 2.1 Introduction to Linear Programming 2.2 Formulating and Solving Linear Programming Problems Using.

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;

Page 59: 1 Chapter 2: Linear Programming Problems: Basic Ideas 2.1 Introduction to Linear Programming 2.2 Formulating and Solving Linear Programming Problems Using.

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;

Page 60: 1 Chapter 2: Linear Programming Problems: Basic Ideas 2.1 Introduction to Linear Programming 2.2 Formulating and Solving Linear Programming Problems Using.

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;

Page 61: 1 Chapter 2: Linear Programming Problems: Basic Ideas 2.1 Introduction to Linear Programming 2.2 Formulating and Solving Linear Programming Problems Using.

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;

Page 62: 1 Chapter 2: Linear Programming Problems: Basic Ideas 2.1 Introduction to Linear Programming 2.2 Formulating and Solving Linear Programming Problems Using.

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

Page 63: 1 Chapter 2: Linear Programming Problems: Basic Ideas 2.1 Introduction to Linear Programming 2.2 Formulating and Solving Linear Programming Problems Using.

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;

Page 64: 1 Chapter 2: Linear Programming Problems: Basic Ideas 2.1 Introduction to Linear Programming 2.2 Formulating and Solving Linear Programming Problems Using.

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;

Page 65: 1 Chapter 2: Linear Programming Problems: Basic Ideas 2.1 Introduction to Linear Programming 2.2 Formulating and Solving Linear Programming Problems Using.

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;

Page 66: 1 Chapter 2: Linear Programming Problems: Basic Ideas 2.1 Introduction to Linear Programming 2.2 Formulating and Solving Linear Programming Problems Using.

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;

Page 67: 1 Chapter 2: Linear Programming Problems: Basic Ideas 2.1 Introduction to Linear Programming 2.2 Formulating and Solving Linear Programming Problems Using.

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

Page 68: 1 Chapter 2: Linear Programming Problems: Basic Ideas 2.1 Introduction to Linear Programming 2.2 Formulating and Solving Linear Programming Problems Using.

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

Page 69: 1 Chapter 2: Linear Programming Problems: Basic Ideas 2.1 Introduction to Linear Programming 2.2 Formulating and Solving Linear Programming Problems Using.

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

Page 70: 1 Chapter 2: Linear Programming Problems: Basic Ideas 2.1 Introduction to Linear Programming 2.2 Formulating and Solving Linear Programming Problems Using.

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?

Page 71: 1 Chapter 2: Linear Programming Problems: Basic Ideas 2.1 Introduction to Linear Programming 2.2 Formulating and Solving Linear Programming Problems Using.

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?

Page 72: 1 Chapter 2: Linear Programming Problems: Basic Ideas 2.1 Introduction to Linear Programming 2.2 Formulating and Solving Linear Programming Problems Using.

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?

Page 73: 1 Chapter 2: Linear Programming Problems: Basic Ideas 2.1 Introduction to Linear Programming 2.2 Formulating and Solving Linear Programming Problems Using.

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?

Page 74: 1 Chapter 2: Linear Programming Problems: Basic Ideas 2.1 Introduction to Linear Programming 2.2 Formulating and Solving Linear Programming Problems Using.

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

Page 75: 1 Chapter 2: Linear Programming Problems: Basic Ideas 2.1 Introduction to Linear Programming 2.2 Formulating and Solving Linear Programming Problems Using.

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

Page 76: 1 Chapter 2: Linear Programming Problems: Basic Ideas 2.1 Introduction to Linear Programming 2.2 Formulating and Solving Linear Programming Problems Using.

82

These exercises reinforce the concepts discussed previously.

Exercises 4–6

Page 77: 1 Chapter 2: Linear Programming Problems: Basic Ideas 2.1 Introduction to Linear Programming 2.2 Formulating and Solving Linear Programming Problems Using.

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

Page 78: 1 Chapter 2: Linear Programming Problems: Basic Ideas 2.1 Introduction to Linear Programming 2.2 Formulating and Solving Linear Programming Problems Using.

84

Objectives Interpret PROC OPTMODEL output and write

formatted output. Write linear programming problems to Math

Programming System (MPS) format.

Page 79: 1 Chapter 2: Linear Programming Problems: Basic Ideas 2.1 Introduction to Linear Programming 2.2 Formulating and Solving Linear Programming Problems Using.

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)

Page 80: 1 Chapter 2: Linear Programming Problems: Basic Ideas 2.1 Introduction to Linear Programming 2.2 Formulating and Solving Linear Programming Problems Using.

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) ;

Page 81: 1 Chapter 2: Linear Programming Problems: Basic Ideas 2.1 Introduction to Linear Programming 2.2 Formulating and Solving Linear Programming Problems Using.

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;

Page 82: 1 Chapter 2: Linear Programming Problems: Basic Ideas 2.1 Introduction to Linear Programming 2.2 Formulating and Solving Linear Programming Problems Using.

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).

Page 83: 1 Chapter 2: Linear Programming Problems: Basic Ideas 2.1 Introduction to Linear Programming 2.2 Formulating and Solving Linear Programming Problems Using.

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.

Page 84: 1 Chapter 2: Linear Programming Problems: Basic Ideas 2.1 Introduction to Linear Programming 2.2 Formulating and Solving Linear Programming Problems Using.

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;

Page 85: 1 Chapter 2: Linear Programming Problems: Basic Ideas 2.1 Introduction to Linear Programming 2.2 Formulating and Solving Linear Programming Problems Using.

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;

Page 86: 1 Chapter 2: Linear Programming Problems: Basic Ideas 2.1 Introduction to Linear Programming 2.2 Formulating and Solving Linear Programming Problems Using.

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;

Page 87: 1 Chapter 2: Linear Programming Problems: Basic Ideas 2.1 Introduction to Linear Programming 2.2 Formulating and Solving Linear Programming Problems Using.

94

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

Page 88: 1 Chapter 2: Linear Programming Problems: Basic Ideas 2.1 Introduction to Linear Programming 2.2 Formulating and Solving Linear Programming Problems Using.

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))

Page 89: 1 Chapter 2: Linear Programming Problems: Basic Ideas 2.1 Introduction to Linear Programming 2.2 Formulating and Solving Linear Programming Problems Using.

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}

Page 90: 1 Chapter 2: Linear Programming Problems: Basic Ideas 2.1 Introduction to Linear Programming 2.2 Formulating and Solving Linear Programming Problems Using.

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;

Page 91: 1 Chapter 2: Linear Programming Problems: Basic Ideas 2.1 Introduction to Linear Programming 2.2 Formulating and Solving Linear Programming Problems Using.

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

Page 92: 1 Chapter 2: Linear Programming Problems: Basic Ideas 2.1 Introduction to Linear Programming 2.2 Formulating and Solving Linear Programming Problems Using.

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.

Page 93: 1 Chapter 2: Linear Programming Problems: Basic Ideas 2.1 Introduction to Linear Programming 2.2 Formulating and Solving Linear Programming Problems Using.

100

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

Profit: $1,827

PROC OPTMODEL Output

Page 94: 1 Chapter 2: Linear Programming Problems: Basic Ideas 2.1 Introduction to Linear Programming 2.2 Formulating and Solving Linear Programming Problems Using.

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

Page 95: 1 Chapter 2: Linear Programming Problems: Basic Ideas 2.1 Introduction to Linear Programming 2.2 Formulating and Solving Linear Programming Problems Using.

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

Page 96: 1 Chapter 2: Linear Programming Problems: Basic Ideas 2.1 Introduction to Linear Programming 2.2 Formulating and Solving Linear Programming Problems Using.

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.)

Page 97: 1 Chapter 2: Linear Programming Problems: Basic Ideas 2.1 Introduction to Linear Programming 2.2 Formulating and Solving Linear Programming Problems Using.

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.)

Page 98: 1 Chapter 2: Linear Programming Problems: Basic Ideas 2.1 Introduction to Linear Programming 2.2 Formulating and Solving Linear Programming Problems Using.

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

Page 99: 1 Chapter 2: Linear Programming Problems: Basic Ideas 2.1 Introduction to Linear Programming 2.2 Formulating and Solving Linear Programming Problems Using.

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

Page 100: 1 Chapter 2: Linear Programming Problems: Basic Ideas 2.1 Introduction to Linear Programming 2.2 Formulating and Solving Linear Programming Problems Using.

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

Page 101: 1 Chapter 2: Linear Programming Problems: Basic Ideas 2.1 Introduction to Linear Programming 2.2 Formulating and Solving Linear Programming Problems Using.

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

Page 102: 1 Chapter 2: Linear Programming Problems: Basic Ideas 2.1 Introduction to Linear Programming 2.2 Formulating and Solving Linear Programming Problems Using.

109

These exercises reinforce the concepts discussed previously.

Exercises 7–9

Page 103: 1 Chapter 2: Linear Programming Problems: Basic Ideas 2.1 Introduction to Linear Programming 2.2 Formulating and Solving Linear Programming Problems Using.

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

Page 104: 1 Chapter 2: Linear Programming Problems: Basic Ideas 2.1 Introduction to Linear Programming 2.2 Formulating and Solving Linear Programming Problems Using.

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.

Page 105: 1 Chapter 2: Linear Programming Problems: Basic Ideas 2.1 Introduction to Linear Programming 2.2 Formulating and Solving Linear Programming Problems Using.

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

Page 106: 1 Chapter 2: Linear Programming Problems: Basic Ideas 2.1 Introduction to Linear Programming 2.2 Formulating and Solving Linear Programming Problems Using.

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

Page 107: 1 Chapter 2: Linear Programming Problems: Basic Ideas 2.1 Introduction to Linear Programming 2.2 Formulating and Solving Linear Programming Problems Using.

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)

Page 108: 1 Chapter 2: Linear Programming Problems: Basic Ideas 2.1 Introduction to Linear Programming 2.2 Formulating and Solving Linear Programming Problems Using.

115

[63, 54]

Feasible Region

y ax

is

x axis

optimal solution

Page 109: 1 Chapter 2: Linear Programming Problems: Basic Ideas 2.1 Introduction to Linear Programming 2.2 Formulating and Solving Linear Programming Problems Using.

116

[63, 54]

Feasible Region

dual value = 3.5

dual value = 8.5

dual value = 0

y ax

is

x axis

optimal solution

Page 110: 1 Chapter 2: Linear Programming Problems: Basic Ideas 2.1 Introduction to Linear Programming 2.2 Formulating and Solving Linear Programming Problems Using.

117

Feasible Region

y ax

is

x axis

optimal solution

[60.5, 56.5]

Page 111: 1 Chapter 2: Linear Programming Problems: Basic Ideas 2.1 Introduction to Linear Programming 2.2 Formulating and Solving Linear Programming Problems Using.

118

Feasible Region

y ax

is

x axis

optimal solution

[58, 59]

Page 112: 1 Chapter 2: Linear Programming Problems: Basic Ideas 2.1 Introduction to Linear Programming 2.2 Formulating and Solving Linear Programming Problems Using.

119

Feasible Region

y ax

is

x axis

optimal solution

[55.5, 61.5]

Page 113: 1 Chapter 2: Linear Programming Problems: Basic Ideas 2.1 Introduction to Linear Programming 2.2 Formulating and Solving Linear Programming Problems Using.

120

Feasible Region

y ax

is

x axis

optimal solution

[70.5, 51.5]

Page 114: 1 Chapter 2: Linear Programming Problems: Basic Ideas 2.1 Introduction to Linear Programming 2.2 Formulating and Solving Linear Programming Problems Using.

121

Feasible Region

y ax

is

x axis

optimal solution

[72, 51]

Page 115: 1 Chapter 2: Linear Programming Problems: Basic Ideas 2.1 Introduction to Linear Programming 2.2 Formulating and Solving Linear Programming Problems Using.

122

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

print Usage.dual;

Page 116: 1 Chapter 2: Linear Programming Problems: Basic Ideas 2.1 Introduction to Linear Programming 2.2 Formulating and Solving Linear Programming Problems Using.

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;

Page 117: 1 Chapter 2: Linear Programming Problems: Basic Ideas 2.1 Introduction to Linear Programming 2.2 Formulating and Solving Linear Programming Problems Using.

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

Page 118: 1 Chapter 2: Linear Programming Problems: Basic Ideas 2.1 Introduction to Linear Programming 2.2 Formulating and Solving Linear Programming Problems Using.

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

Page 119: 1 Chapter 2: Linear Programming Problems: Basic Ideas 2.1 Introduction to Linear Programming 2.2 Formulating and Solving Linear Programming Problems Using.

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

Page 120: 1 Chapter 2: Linear Programming Problems: Basic Ideas 2.1 Introduction to Linear Programming 2.2 Formulating and Solving Linear Programming Problems Using.

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

Page 121: 1 Chapter 2: Linear Programming Problems: Basic Ideas 2.1 Introduction to Linear Programming 2.2 Formulating and Solving Linear Programming Problems Using.

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

Page 122: 1 Chapter 2: Linear Programming Problems: Basic Ideas 2.1 Introduction to Linear Programming 2.2 Formulating and Solving Linear Programming Problems Using.

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.

Page 123: 1 Chapter 2: Linear Programming Problems: Basic Ideas 2.1 Introduction to Linear Programming 2.2 Formulating and Solving Linear Programming Problems Using.

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 ;

Page 124: 1 Chapter 2: Linear Programming Problems: Basic Ideas 2.1 Introduction to Linear Programming 2.2 Formulating and Solving Linear Programming Problems Using.

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

Page 125: 1 Chapter 2: Linear Programming Problems: Basic Ideas 2.1 Introduction to Linear Programming 2.2 Formulating and Solving Linear Programming Problems Using.

132

These exercises reinforce the concepts discussed previously.

Exercises 10–12


Recommended