Chapter 3: Linear Programming Problems: Additional Topics - PowerPoint PPT Presentation

1 / 53
About This Presentation
Title:

Chapter 3: Linear Programming Problems: Additional Topics

Description:

9 Chapter 3: Linear Programming Problems: Additional Topics 3.1 Basic Control Flow and Operators in the OPTMODEL Procedure 3.2 Model Updates in the OPTMODEL Procedure – PowerPoint PPT presentation

Number of Views:153
Avg rating:3.0/5.0
Slides: 54
Provided by: Kristin339
Category:

less

Transcript and Presenter's Notes

Title: Chapter 3: Linear Programming Problems: Additional Topics


1
9
Chapter 3 Linear Programming Problems
Additional Topics
3.1 Basic Control Flow and Operators in the OPTMODEL Procedure
3.2 Model Updates in the OPTMODEL Procedure
3.3 Sensitivity Analysis and Parametric Programming (Self-Study)
3.4 Network Flow Models
2
9
Chapter 3 Linear Programming Problems
Additional Topics
3.1 Basic Control Flow and Operators in the OPTMODEL Procedure
3.2 Model Updates in the OPTMODEL Procedure
3.3 Sensitivity Analysis and Parametric Programming (Self-Study)
3.4 Network Flow Models
3
Objectives
  • Program simple routines using PROC OPTMODEL as an
    algebraic modeling language.

4
PROC OPTMODEL Programming Statements
  • Control flow statements in PROC OPTMODEL should
    be familiar to users of the SAS DATA step

assignment () CONTINUE DO (blocks) DO
(iterative) DO UNTIL DO WHILE FOR IF THEN IF
THEN ELSE LEAVE null () STOP
5
PROC OPTMODEL Programming Statements
  • FOR iterates over the
    members of an index set.

assignment () CONTINUE DO (blocks) DO
(iterative) DO UNTIL DO WHILE FOR IF THEN IF
THEN ELSE LEAVE null () STOP
num DistOrigins,Destinations num
LongCities, LatCities for i in Origins
for j in Destinations / calculate
Disti,j /
Task Calculate the distances between all origin
and destination locations.
6
PROC OPTMODEL Programming Statements
  • FOR iterates over the
    members of an index set.

assignment () CONTINUE DO (blocks) DO
(iterative) DO UNTIL DO WHILE FOR IF THEN IF
THEN ELSE LEAVE null () STOP
num DistOrigins,Destinations num
LongCities, LatCities for i in Origins
for j in Destinations / calculate
Disti,j /
(There is a distance formula if Long and Lat are
measured in radians.)
7
PROC OPTMODEL Programming Statements
  • FOR iterates over the
    members of an index set.

assignment () CONTINUE DO (blocks) DO
(iterative) DO UNTIL DO WHILE FOR IF THEN IF
THEN ELSE LEAVE null () STOP
num DistOrigins,Destinations num
LongCities, LatCities for i in Origins
do x1 Longi y1 Lati for j in
Destinations if (ij) then Disti,j0
else do x2 Longj y2 Latj
Disti,j arcos(sin(y1)sin(y2)
cos(y1)cos(y2)cos(x2-x1))3956 end
end
8
PROC OPTMODEL Set and Logical Operators
  • PROC OPTMODEL defines new types of expressions
    for the manipulation of sets, such as
    aggregation operators.

AND CARD CROSS DIFF IF THEN ELSE INNOT
IN INTER MAXMIN OR PRODSUM SLICE SYMDIFF UNION W
ITHIN
9
PROC OPTMODEL Set and Logical Operators
  • PROC OPTMODEL defines new types of expressions
    for the manipulation of sets, such as
    aggregation operators.

AND CARD CROSS DIFF IF THEN ELSE INNOT
IN INTER MAXMIN OR PRODSUM SLICE SYMDIFF UNION W
ITHIN
lt1,1gt lt3,1gt lt4,1gt lt5,1gt
lt1,2gt lt3,2gt lt6,2gt
lt2,3gt lt4,3gt
lt1,4gt lt2,4gt lt4,4gt lt5,4gt lt6,4gt
lt2,5gt lt3,5gt lt6,5gt
lt1,6gt lt3,6gt lt4,6gt

2 3 6
SLICE(lt ,5gt,SET)2,3,6
10
PROC OPTMODEL Set and Logical Operators
  • PROC OPTMODEL defines new types of expressions
    for the manipulation of sets, such as
    aggregation operators.

AND CARD CROSS DIFF IF THEN ELSE INNOT
IN INTER MAXMIN OR PRODSUM SLICE SYMDIFF UNION W
ITHIN
lt2,1gt lt3,1gt lt6,1gt
lt2,2gt lt3,2gt lt6,2gt

lt2,4gt lt3,4gt lt6,4gt
lt2,5gt lt3,5gt lt6,5gt


2 3 6
2,3,6 CROSS 1,2,4,5
11
PROC OPTMODEL Set and Logical Operators
  • PROC OPTMODEL defines new types of expressions
    for the manipulation of sets, such as
    aggregation operators.

B
AND CARD CROSS DIFF IF THEN ELSE INNOT
IN INTER MAXMIN OR PRODSUM SLICE SYMDIFF UNION W
ITHIN
Network of Nodes and Arcs
C
A
D
E
set Arcs /ltA Bgt ltB Cgt ltC Dgt ltD Egt ltA Dgt/
set ltstrgt Nodes
12
PROC OPTMODEL Set and Logical Operators
  • PROC OPTMODEL defines new types of expressions
    for the manipulation of sets, such as
    aggregation operators.

B
AND CARD CROSS DIFF IF THEN ELSE INNOT
IN INTER MAXMIN OR PRODSUM SLICE SYMDIFF UNION W
ITHIN
Network of Nodes and Arcs
C
A
D
E
set Arcs /ltA Bgt ltB Cgt ltC Dgt ltD Egt ltA Dgt/
set ltstrgt Nodes Nodes unionlti,jgt in Arcs
i,j
13
PROC OPTMODEL Set and Logical Operators
  • PROC OPTMODEL defines new types of expressions
    for the manipulation of sets, such as
    aggregation operators.

B
AND CARD CROSS DIFF IF THEN ELSE INNOT
IN INTER MAXMIN OR PRODSUM SLICE SYMDIFF UNION W
ITHIN
Network of Nodes and Arcs and Paths of Arcs
C
A
D
E
set Arcs /ltA Bgt ltB Cgt ltC Dgt ltD Egt ltA Dgt/
set ltstrgt Nodes set ltstr,strgt Paths Nodes
unionlti,jgt in Arcs i,j Paths ????
Task Find all nodes connected by paths.
14
PROC OPTMODEL Set and Logical Operators
  • PROC OPTMODEL defines new types of expressions
    for the manipulation of sets, such as
    aggregation operators.

B
AND CARD CROSS DIFF IF THEN ELSE INNOT
IN INTER MAXMIN OR PRODSUM SLICE SYMDIFF UNION W
ITHIN
Network of Nodes and Arcs
C
A
D
E
set Arcs /ltA Bgt ltB Cgt ltC Dgt ltD Egt ltA Dgt/
set ltstrgt Nodes set ltstr,strgt Paths Nodes
unionlti,jgt in Arcs i,j Paths Arcs
for n in Nodes Paths Paths union (
slice(lt,ngt,Paths) cross slice(ltn,gt,Paths)
)
15
PROC OPTMODEL Set and Logical Operators
  • PROC OPTMODEL defines new types of expressions
    for the manipulation of sets, such as
    aggregation operators.

B
AND CARD CROSS DIFF IF THEN ELSE INNOT
IN INTER MAXMIN OR PRODSUM SLICE SYMDIFF UNION W
ITHIN
Network of Nodes and Arcs
C
A
D
E
set Arcs /ltA Bgt ltB Cgt ltC Dgt ltD Egt ltA Dgt/
set ltstrgt Nodes set ltstr,strgt Paths Nodes
unionlti,jgt in Arcs i,j Paths Arcs
for n in Nodes Paths Paths union (
slice(lt,ngt,Paths) cross slice(ltn,gt,Paths)
)
16
PROC OPTMODEL Set and Logical Operators
  • PROC OPTMODEL defines new types of expressions
    for the manipulation of sets, such as
    aggregation operators.

B
AND CARD CROSS DIFF IF THEN ELSE INNOT
IN INTER MAXMIN OR PRODSUM SLICE SYMDIFF UNION W
ITHIN
Network of Nodes and Arcs
C
A
D
E
set Arcs /ltA Bgt ltB Cgt ltC Dgt ltD Egt ltA Dgt/
set ltstrgt Nodes set ltstr,strgt Paths Nodes
unionlti,jgt in Arcs i,j Paths Arcs
for n in Nodes Paths Paths union (
slice(lt,ngt,Paths) cross slice(ltn,gt,Paths)
)
17
PROC OPTMODEL Set and Logical Operators
  • PROC OPTMODEL defines new types of expressions
    for the manipulation of sets, such as
    aggregation operators.

B
AND CARD CROSS DIFF IF THEN ELSE INNOT
IN INTER MAXMIN OR PRODSUM SLICE SYMDIFF UNION W
ITHIN
Network of Nodes and Arcs and Paths
of Arcs
C
A
D
E
set Arcs /ltA Bgt ltB Cgt ltC Dgt ltD Egt ltA Dgt/
set ltstrgt Nodes set ltstr,strgt Paths Nodes
unionlti,jgt in Arcs i,j Paths Arcs
for n in Nodes Paths Paths union (
slice(lt,ngt,Paths) cross slice(ltn,gt,Paths)
)
18
PROC OPTMODEL Set and Logical Operators
  • PROC OPTMODEL defines new types of expressions
    for the manipulation of sets, such as
    aggregation operators.

B
AND CARD CROSS DIFF IF THEN ELSE INNOT
IN INTER MAXMIN OR PRODSUM SLICE SYMDIFF UNION W
ITHIN
Network of Nodes and Arcs and Paths
of Arcs
C
A
D
E
set Arcs /ltA Bgt ltB Cgt ltC Dgt ltD Egt ltA Dgt/
set ltstrgt Nodes set ltstr,strgt Paths Nodes
unionlti,jgt in Arcs i,j Paths Arcs
for n in Nodes Paths Paths union (
slice(lt,ngt,Paths) cross slice(ltn,gt,Paths)
)
19
PROC OPTMODEL Set and Logical Operators
  • PROC OPTMODEL defines new types of expressions
    for the manipulation of sets, such as
    aggregation operators.

B
AND CARD CROSS DIFF IF THEN ELSE INNOT
IN INTER MAXMIN OR PRODSUM SLICE SYMDIFF UNION W
ITHIN
Network of Nodes and Arcs and Paths
of Arcs
C
A
D
E
set Arcs /ltA Bgt ltB Cgt ltC Dgt ltD Egt ltA Dgt/
set ltstrgt Nodes set ltstr,strgt Paths Nodes
unionlti,jgt in Arcs i,j Paths Arcs
for n in Nodes Paths Paths union (
slice(lt,ngt,Paths) cross slice(ltn,gt,Paths)
)
20
PROC OPTMODEL Set and Logical Operators
  • PROC OPTMODEL defines new types of expressions
    for the manipulation of sets, such as
    aggregation operators.

B
AND CARD CROSS DIFF IF THEN ELSE INNOT
IN INTER MAXMIN OR PRODSUM SLICE SYMDIFF UNION W
ITHIN
Network of Nodes and Arcs and Paths
of Arcs
C
A
D
E
set Arcs /ltA Bgt ltB Cgt ltC Dgt ltD Egt ltA Dgt/
set ltstrgt Nodes set ltstr,strgt Paths Nodes
unionlti,jgt in Arcs i,j Paths Arcs
for n in Nodes Paths Paths union (
slice(lt,ngt,Paths) cross slice(ltn,gt,Paths)
)
21
PROC OPTMODEL Set and Logical Operators
  • PROC OPTMODEL defines new types of expressions
    for the manipulation of sets, such as
    aggregation operators.

B
AND CARD CROSS DIFF IF THEN ELSE INNOT
IN INTER MAXMIN OR PRODSUM SLICE SYMDIFF UNION W
ITHIN
Network of Nodes and Arcs and Paths
of Arcs
C
A
D
E
set Arcs /ltA Bgt ltB Cgt ltC Dgt ltD Egt ltA Dgt/
set ltstrgt Nodes set ltstr,strgt Paths Nodes
unionlti,jgt in Arcs i,j Paths Arcs
for n in Nodes Paths Paths union (
slice(lt,ngt,Paths) cross slice(ltn,gt,Paths)
)
22
PROC OPTMODEL Set and Logical Operators
  • PROC OPTMODEL defines new types of expressions
    for the manipulation of sets, such as
    aggregation operators.

B
AND CARD CROSS DIFF IF THEN ELSE INNOT
IN INTER MAXMIN OR PRODSUM SLICE SYMDIFF UNION W
ITHIN
Network of Nodes and Arcs and Paths
of Arcs
C
A
D
E
set Arcs /ltA Bgt ltB Cgt ltC Dgt ltD Egt ltA Dgt/
set ltstrgt Nodes set ltstr,strgt Paths Nodes
unionlti,jgt in Arcs i,j Paths Arcs
for n in Nodes Paths Paths union (
slice(lt,ngt,Paths) cross slice(ltn,gt,Paths)
)
23
PROC OPTMODEL Set and Logical Operators
  • PROC OPTMODEL defines new types of expressions
    for the manipulation of sets, such as
    aggregation operators.

B
AND CARD CROSS DIFF IF THEN ELSE INNOT
IN INTER MAXMIN OR PRODSUM SLICE SYMDIFF UNION W
ITHIN
Network of Nodes and Arcs and Paths
of Arcs
C
A
D
E
set Arcs /ltA Bgt ltB Cgt ltC Dgt ltD Egt ltA Dgt/
set ltstrgt Nodes set ltstr,strgt Paths Nodes
unionlti,jgt in Arcs i,j Paths Arcs
for n in Nodes Paths Paths union (
slice(lt,ngt,Paths) cross slice(ltn,gt,Paths)
)
24
Computing Reachable Nodes Using PROC OPTMODEL
reachable.sas
  • This demonstration illustrates some of the set
    operations available in PROC OPTMODEL to find the
    find all the nodes that are reachable by paths in
    a simple network of nodes and arcs.

25
PROC OPTMODEL Set and Logical Operators
  • PROC OPTMODEL defines new types of expressions
    for the manipulation of sets, such as
    aggregation operators.

Productioni
AND CARD CROSS DIFF IF THEN ELSE INNOT
IN INTER MAXMIN OR PRODSUM SLICE SYMDIFF UNION W
ITHIN
Demandi
num T 5, Demand1..T var
Production1..T, Inventory1..T-1 con
Inventory_Balancei in 1..T Productioni
Demandi ????
Task Formulate balance constraints.
26
PROC OPTMODEL Set and Logical Operators
  • PROC OPTMODEL defines new types of expressions
    for the manipulation of sets, such as
    aggregation operators.

AND CARD CROSS DIFF IF THEN ELSE INNOT
IN INTER MAXMIN OR PRODSUM SLICE SYMDIFF UNION W
ITHIN
num T 5, Demand1..T var
Production1..T, Inventory1..T-1 con
Inventory_Balancei in 1..T Productioni
Demandi if (i1) then
Inventory1 else if (iT) then
InventoryT-1 else Inventoryi
Inventoryi-1
27
Exercises 12
  • These exercises reinforce the concepts discussed
    previously.

28
9
Chapter 3 Linear Programming Problems
Additional Topics
3.1 Basic Control Flow and Operators in the OPTMODEL Procedure
3.2 Model Updates in the OPTMODEL Procedure
3.3 Sensitivity Analysis and Parametric Programming (Self-Study)
3.4 Network Flow Models
29
Objectives
  • Understand how the presolver simplifies linear
    programming problems.
  • Be able to modify a linear programming problem
    (changing bounds or objective/constraint
    coefficients, fixing variables, adding variables
    or constraints) within the OPTMODEL procedure.

30
Automatic Updates The Presolver
  • Before solving a mathematical programming
    problem, the OPTMODEL presolver does the
    following
  • processes linear constraints to tighten bounds on
    variables
  • converts simple bound constraints to bounds on
    variables
  • eliminates constraints that are implied by
    variable bounds
  • eliminates variables whose values are fixed

31
OPTMODEL Presolver Example
  • Suppose that these are the constraints of the
    problem


2xy 6 2x7y 14 xy 5 x 0, y
0
32
OPTMODEL Presolver Example
  • Suppose that these are the constraints of the
    problem


2xy 6 x (6-y)/2 3 2x7y 14 y
(14-2x)/7 2 xy 5 x 0, y 0
33
OPTMODEL Presolver Example
  • Suppose that these are the constraints of the
    problem
  • (The constraint xy 5 is implied by the bounds.)

2xy 6 x (6-y)/2 3 2x7y 14 y
(14-2x)/7 2 xy 5 x 0, y 0
2xy 6 2x7y 14 0 x 3, 0 y
2
34
The OPTLP Presolver
  • The LP solver has its own preprocessor, which can
    further reduce the size of the problem

35
OPTMODEL/OPTLP Presolver Options
PROC OPTMODEL PRESOLVER option
SOLVE WITH LP / PRESOLVER option
Option Description
AUTOMATIC Default setting (between moderate and aggressive)
NONE Disable presolver
BASIC Remove empty constraints, substitute fixed variables
MODERATE A higher level of preprocessing
AGGRESSIVE Highest level of preprocessing
36
The PROC OPTMODEL and OPTLP Presolvers
product_mix.sas
  • This demonstration illustrates the effect of the
    PROC OPTMODEL and OPTLP presolvers on the organic
    potting soils product mix problem.

37
Adding New Variables
  • Recall Tables require 3 hours of labor, 1 pound
    of metal, and 2 ft3 wood. Tables sell for 55.
    The dual prices show that making tables is a
    profitable activity
  • but how many should be produced?


set ltstrgt Products, Resources num
CostResources, AvailabilityResources num
Selling_PriceProducts num RequirementsResour
ces,Products Products Products union
/tables/
38
Model Updates Adding New Variables
  • Recall Tables require 3 hours of labor, 1 pound
    of metal, and 2 ft3 wood. Tables sell for 55.
    The dual prices show that making tables is a
    profitable activity
  • but how many should be produced?


set ltstrgt Products, Resources num
CostResources, AvailabilityResources num
Selling_PriceProducts num RequirementsResour
ces,Products Products Products union
/tables/ Selling_Price'tables'55
Requirements'labor','tables'3
Requirements'metal','tables'1
Requirements'wood','tables'2
39
Reading Data for New Variables
  • SAS Data Set Work.New_Products


Product Selling_Price labor metal wood
1 tables 55 3 1 2
set ltstrgt Products, Resources num
CostResources, AvailabilityResources num
Selling_PriceProducts num RequirementsResour
ces,Products Products Products union
/tables/ read data New_Products into
Product Selling_Price r in Resources
ltRequirementsr,Productcol(r)gt
40
Adding a New Variable to an LP in PROC OPTMODEL
furniture_tables.sas
  • This demonstration illustrates a simple way to
    add a new variable to a linear programming
    problem in PROC OPTMODEL.

41
Changing Variable/Constraint Bounds
  • In the McDonalds diet problem, suppose you want
    to add the restriction that at most two of each
    item can be included in the diet.
  • Upper and lower bounds for variables and
    constraints can be modified and/or read from SAS
    data sets.
  • Objective and constraint coefficients can also be
    modified, unless their values are assigned in a
    declaration statement.

for j in Food xj.ub 2
42
Fixing/Unfixing Variables
  • What is the minimum cost diet with a Big Mac?
  • The syntax is

fix x'Big Mac' 1
FIX identifier-list ( expression )
43
Fixing/Unfixing Variables
  • What is the minimum cost diet with a Big Mac?
  • The syntax is
  • The effect can be reversed


fix x'Big Mac' 1
FIX identifier-list ( expression )
UNFIX identifier-list ( expression )
44
Dropping/Restoring Constraints
  • How much will the cost of the optimal diet
    decrease if there is no limit on sodium?
  • The effect can be reversed with similar syntax


drop Diet'Sodium'
DROPRESTORE identifier-expression
45
Dropping/Restoring Constraints
  • How much will the cost of the optimal diet
    decrease if there is no limit on sodium?
  • The effect can be reversed with similar syntax
  • What will these statements do?

drop Diet'Sodium'
DROPRESTORE identifier-expression
drop Diet restore Diet'Cal'
Diet'Protein'
46
Adding Constraints
  • Some ad hoc constraints would make the McDonalds
    diet problem more realistic
  • Limit sauces by the number/size of McNuggets
    ordered (2 for 6 pieces 3 for 9 pieces 6 for 20
    pieces).
  • Limit salad dressings and toppings by the number
    of salads ordered.
  • Require one drink per meal.
  • At most 30 of the calories should be from fat
    (RDA requirement).

47
Re-optimizing in PROC OPTMODEL
  • For many of these updates, it is more efficient
    to re-optimize, starting from the previous
    optimal solution


2D LP
48
Re-optimizing in PROC OPTMODEL
  • For many of these updates, it is more efficient
    to re-optimize, starting from the previous
    optimal solution

Re-optimizing (Primal Simplex)
3D LP
2D LP
49
The BASISWARMSTART Option
  • To re-optimize, the presolvers should be disabled
    and the primal or dual simplex solver called
  • When the optimal solution is feasible for the new
    problem (adding variables, changing objective)
    use the primal simplex otherwise (changing
    bounds, adding constraints), use the dual
    simplex.

PROC OPTMODEL PRESOLVERNONE SOLVE
WITH LP / BASIS WARMSTART PRESOLVERNONE
SOLVERPSDS
50
Bogus OPTMODEL Program Structure
  • What is wrong with this OPTMODEL program
    structure?

proc optmodel presolvernone / declare
sets and parameters / / declare variables
/ / declare constraints / for j
in index-set do / declare objective
/ solve with lp / basiswarmstart
presolvernone / print
solution / end quit
51
Corrected OPTMODEL Program Structure
proc optmodel presolvernone / declare
sets and parameters / / declare variables
/ / declare constraints / /
declare objective / for j in index-set
do parameter j solve with lp
/ basiswarmstart
presolvernone / print solution /
end quit
52
Re-Optimizing the McDonalds Diet Problem
in PROC OPTMODEL mcdonalds_reopt.sas
  • This demonstration illustrates how PROC OPTMODEL
    can be used to re-optimize after making various
    updates to the McDonalds diet problem.

53
Exercises 3-4
  • These exercises reinforce the concepts discussed
    previously.
Write a Comment
User Comments (0)
About PowerShow.com