Вы находитесь на странице: 1из 70

Mathematical Programming

Linear Programming

Three Goals in this Chapter


Learn the principle of Simplex-Algorithm
Learn how to formulate pbs as LPs
Like brainteasers: can be fun
Many problems that do not look like
stereotypical product mix problems can be
formulated as LPs
Spotting LPs is an art

Learn how to implement and solve LPs


in Excel
2

Linear Programming

LP Models

LP Model
An optimization model is a linear
program (or LP) if it has continuous
variables, a single linear objective
function, and all constraints are
linear equalities or inequalities.

LP Model
Linearity
Divisibility (Continuous)
Assumption of Certainty

LP Model

Maximize : 20 x1 24 x2
s.t. 3x1 6 x2 60
4 x1 2 x2 32

NNC : x1 0; x2 0;
6

Standard Form
Min : 20 x1 24 x2 0 x3 0 x4
s.t. 3x1 6 x2 x3
4 x1 2 x2

60
x4 32

NNC : x1 0; x2 0;
x3 0; x4 0;
7

Linear Programming
For purposes of describing and analyzing algorithms, the
problem is often stated in the standard form
T

min{c x : Ax b, x 0}
where x is the vector of n unknowns, c is the n dimensional
cost vector, and A the constraint matrix (m rows and n
columns).

Steps in Formulating a Linear


Programming Problem

Understand the problem


Identify the Decision Maker (DM)
Identify the decision variables
State the obj. function as a linear
combination of the decision variables
State the constraints as a linear
combination of the decision variables
Identify upper or lower bounds on DVs
9

Linear Programming

Solving and Sensitivity

10

Linear Programming
Each constraint (equation) defines a straight line in
the space of the unknowns x
The feasible region described by the constraints
is a polytope, or simplex, and at least one
member of the solution set lies at a vertex of this
polytope

11

Ways of Solving an LP
Graphical Method
Enumerating all extreme points
Simplex method invented by G. Dantzig
Specialized software such as LINDO
General software such as Excel solver

Interior point methods of the sort proposed by


Karmarkar
Specialized algorithms for special types of
LPs
12

Sensitivity Analysis of
LPs
Simplex Method is a standard way to solve linear
programs
Its solution yields a simplex tableau with dual
variables which solve a closely related dual problem
& which contain sensitivity analysis information for
original problem concerning
How much could obj. fn. coefficients change without changing
optimal solution?
How would changing RHS values affect value of optimal
solution?
By how much could one change the RHS values without
changing the pattern (nature) of optimal solution?
Would it be optimal to produce a new product if it were
available?

13

Simplex-Based Sensitivity
Analysis is Very Limited
Cant see around corners
Only relevant for linear programs
Was more relevant before CPU cycles
became cheap
Now more convenient to solve
iteratively and plot results, e.g., with
Spider Table
Solver Table
14

Linear Programming

Various types of LP Models

15

Next Topic: Learning


How to Formulate LPs
Getting dec vars right is often the key
Dont reinvent the wheel; get familiar with
common types of LPs
Many problems are variants on these
common types
Many other problems have components which
are similar to one or more of the common
types

There are tricks for linearizing things that


arent naturally linear
No substitute for practice
16

Review of
Types of

Common
LP Pbs.

1) Product mix problems


2) Make vs. buy
3) Investment/Portfolio allocation pbs
4) Scheduling
5) Transportation/Assignment problems
6) Blending
7) Multi-period planning
8) Cutting stock problems
17

Review of
Types of

Common
LP Pbs.

1) Product mix problems


2) Make vs. buy
3) Investment/Portfolio allocation pbs
4) Scheduling
5) Transportation/Assignment problems
6) Blending
7) Multi-period planning
8) Cutting stock problems
18

#1: Product Mix Decisions


(Like the Howies Problem)
Decision: How many of each type of product
should be made (offered)
Decision variables
Xi = amount of product i to make (offer)

Typical Constraints
Nonnegative production
Production capacity constraints (i.e, limits on
resources which are consumed in the process of
producing products)

Objective: Maximize profit (or min cost)


19

Review of
Types of

Common
LP Pbs.

1) Product mix problems


2) Make vs. buy
3) Investment/Portfolio allocation pbs
4) Scheduling
5) Transportation/Assignment problems
6) Blending
7) Multi-period planning
8) Cutting stock problems
20

#2: Make vs. Buy


Decisions
Several products, each can be made in
house or purchased from vendors
Decision: Not just how much of each product
to obtain but also how much to make and
how much to buy, so ...
Decision variables
for each product i:
Mi = amount of product i to make in house
Bi = amount of product i to purchase
21

Make vs. Buy Decisions


Constraints
Meet demand
Production capacity constraints
Nonnegativity

Objective: Minimize cost (or max profit)


Examples
CHAMPUS (Civilian Health and Medical Program
of the Uniformed Services)
Outsourcing/privatization
Staffing courses with adjuncts
22

Make vs. Buy Decisions


More General Perspective
Several products, each can be obtained
through one or more sources
Decision variables
Xij = amount of product i obtained from source j

Constraints

Supply constraints on each source j


Demand constraints on each product i
Production capacity constraints
Nonnegativity
23

Review of
Types of

Common
LP Pbs.

1) Product mix problems


2) Make vs. buy
3) Investment/Portfolio allocation pbs
4) Scheduling
5) Transportation/Assignment problems
6) Blending
7) Multi-period planning
8) Cutting stock problems
24

#3: Investment/Portfolio
Allocation
Pool of resources (e.g., money or
workers) needs to be allocated across a
number of available instruments
Decision: how much to put (e.g., invest)
in each instrument, so ...
Decision variables
for each product i:
Xi = amount of invested in instrument i
25

Investment/Portfolio
Allocation Decisions
Constraints
All resources allocated
Diversity constraints on amount invested in any
one instrument or type of instrument
Nonnegativity

Objective: Maximize return/benefit


Examples
Dollars to financial investments
Dollars to development projects
Staff/personnel to work projects
26

Review of
Types of

Common
LP Pbs.

1) Product mix problems


2) Make vs. buy
3) Investment/Portfolio allocation pbs
4) Scheduling
5) Transportation/Assignment problems
6) Blending
7) Multi-period planning
8) Cutting stock problems
27

#4: Scheduling Personnel (or


Other Resources) to Shifts
Outline of problem: Demand for services varies
over time (time of day or day of week). You can
have employees start at any time, but you have
less control over when they stop. Typically they
want to work in blocks of time of at least some
minimum length and must be paid a bonus (OT)
to work longer than the standard period. You
could hire enough people at all times to meet the
peak demand, but that would be wasteful. How
can you find a more efficient schedule?
28

Personnel Scheduling Natural


Language Description
Decisions: How many people should be
assigned to each shift (or shift type)
(Must explicitly identify shifts!)

Objective: Minimize the cost of the


assignment, which is the sum over all shifts of
the number of people working that shift times
the cost/person assigned to that shift
Constraints: One for every time period. Meet
demand in that period (& nonneg)
29

Scheduling Example:
Police Shift Assignment
Demand for police is defined for four hour
blocks throughout a 24 hour day
(Typically would really look at 168 hour week and
pay attention to # of consecutive days officers
worked too.)

Officers can work 8 or 12 hour shifts


Police are paid double time for working
beyond 8 hours, so 12 hour shift costs twice
as much as an 8 hour shift
30

Demand Data for Police


Shift Assignment Example
Period

Times

Officers Needed

11 pm - 3 am

30

3 am - 7 am

12

7 am - 11 am

16

11 am - 3 pm

20

3 pm - 7 pm

36

7 pm - 11 pm

34
31

Algebraic Formulation of
Police Scheduling Example
Decision Variables
Xi = officers starting 8 hour shift in period i
Yi = officers starting 12 hour shift in period i

Objective: Minimize Labor Cost


Assume base pay equal for all officers, and
measure in terms of multiples of base pay
for one shift
Min Z = X1 + 2 Y1 + X2 + 2 Y2 + ...
32

Algebraic Formulation
(cont.)
Constraints
X6 + X1 + Y5 + Y6 + Y1 >= 30
X1 + X2 + Y6 + Y1 + Y2 >= 12
X2 + X3 + Y1 + Y2 + Y3 >= 16
X3 + X4 + Y2 + Y3 + Y4 >= 20
X4 + X5 + Y3 + Y4 + Y5 >= 36
X5 + X6 + Y4 + Y5 + Y6 >= 34
Xi, Yi >= 0 for all i

(Period 1)
(Period 2)
(Period 3)
(Period 4)
(Period 5)
(Period 6)

33

Review of
Types of

Common
LP Pbs.

1) Product mix problems


2) Make vs. buy
3) Investment/Portfolio allocation pbs
4) Scheduling
5) Transportation/Assignment problems
6) Blending
7) Multi-period planning
8) Cutting stock problems
34

#5: Transportation/
Assignment Problems
Have various quantities of a commodity at
multiple sources. Need to meet demand for
that commodity at sinks (destinations). How
much should you move that from each source
to each sink in order to minimize the cost of
meeting demand at each destination.
Decision variables
Xij = amount sent from source i to sink j

Cost parameters
cij = cost per unit of shipping from source i to sink j
35

Review of
Types of

Common
LP Pbs.

1) Product mix problems


2) Make vs. buy
3) Investment/Portfolio allocation pbs
4) Scheduling
5) Transportation/Assignment problems
6) Blending
7) Multi-period planning
8) Cutting stock problems
36

#6: Blending Problems


Several ingredients (feedstocks) are mixed to
create different final products. How much of
each ingredient should go into each product
in order to minimize production costs while
satisfying quality constraints on the products?
E.g,

oil refining
producing animal feed mixes
production of dairy products
allocation of coal to power plants
37

Blending Problems
Decision Variables
Xij =units of ingredient i used in product j
units could be pounds, tons, gallons, etc.

Objective
Minimize cost of producing required
amounts of each product (typically driven
by cost of ingredients)
38

Blending Problems:
Constraint Formulation
Demand constraint example
Need at least 8,000 pounds of product 1
X11 + X21 >= 8,000

Quality constraint example


Ingredient 1 is 20% corn. Ingredient 2 is
50% corn.
Product 1 must be at least 30% corn.
0.20 X11 + 0.50 X21 >= 0.30 (X11 + X21)
39

Review of
Types of

Common
LP Pbs.

1) Product mix problems


2) Make vs. buy
3) Investment/Portfolio allocation pbs
4) Scheduling
5) Transportation/Assignment problems
6) Blending
7) Multi-period planning
8) Cutting stock problems
40

#7: Multi-period Planning


Problems
These show up in many contexts, e.g.
investing (over time)
production planning (over time)
workforce planning (over time)

Key characteristics
decisions about multiple time periods
some quantity is conserved over time, creating
constraints that span or link different time periods

41

#7a: Multi-period Financial


Planning Problems
Invest money to maximize return,
manage cash flow during construction
project, etc.
Decision variables
Xij=amount invested in instrument i at time j

Typical objectives
Maximize value in last period or
Minimize amount needed in first period
42

Multi-period Planning
Constraints
Mass balance constraint on money for each
time period
Revenue at time t + $ maturing at time t =
amount invested at time t + payments
due at time t (for every period t)

Constraints on mix of investments


Do not exceed maximum risk threshold
Maintain minimum level of liquidity
Etc.

43

#7b: Multi-Period Planning:


Trading Off OT and Inventory
Suppose that in some periods demand
exceeds normal production capacity.
Three (costly) possible responses:
Use over-time
Produce ahead and hold in inventory
Fail to meet demand fully

What balance of these strategies is best


in each period?
44

Notation
Decision variables
Xi = regular production in period i
Yi = OT production in period i
Zi = shortage in period i
Ii = inventory carried into period i

Parameters
Di = demand in period i
I1 = initial inventory
Cost parameters

45

Formulation
Minimize weighted sum of Xs, Ys, Zs,
and Is
Subject to
Xi <= regular production capacity
Yi <= OT production capacity
Ii <= storage capacity
Ii + Xi + Yi + Zi = Di + Ii+1
mass balance constraint
46

#7c: Multi-Period Planning:


Work Force Scheduling
Size of (trained) labor force required varies
over time (e.g., IRS staff)
Can
Hire new employees, but they need to be trained
by experienced workers (which takes time away
from primary task) and may not stay with
organization
(Sometimes) can lay-off employees
(Sometimes) can outsource or hire temps, but
typically at a high cost
(or proactively balance the workload)
47

Notation
Decision variables
Wi = # of contractors hired in period i
Xi = # employees hired & trained in period i
Yi = # of experienced workers in period i
Zi = # layed off at beginning of period i

Parameters
Di = demand for exp. workers in period i
Y0 = initial number of experienced workers
Cost parameters

48

Formulation
Min weighted sum of Ws, Xs, Ys, &Zs
Suppose
One exp worker can train four new hires
95% retention of experienced workers
50% retention of trainees

Then constraints for each period i are


Wi Yi 0.25 Xi >= Di
Yi + Zi = 0.95 Yi-1 + 0.5 Xi-1
nonnegativity

mass balance

49

Review of
Types of

Common
LP Pbs.

1) Product mix problems


2) Make vs. buy
3) Investment/Portfolio allocation pbs
4) Scheduling
5) Transportation/Assignment problems
6) Blending
7) Multi-period planning
8) Cutting stock problems
50

#8: Cutting Stock Problem


Suppose you produce a wide,
continuous sheet of material (steel, film,
paper, fabric, etc.). Customers demand
various quantities (lengths) of thinner
strips. How should you cut the wide
sheet into strips to meet demand while
minimizing either amount of raw
material cut or amount wasted?
51

Cutting Stock Problem:


Decision Variables
There are a finite number of reasonable
cutting patterns which are characterized by
where the cutting blades are placed.
Decision Variables
Xi = # of feet (length) of wide sheet cut according
to pattern i

Suppose
Sheets are 36 feet wide and
Customers want 8, 12, and 16 foot strips

52

Example of Patterns for 36


Foot Wide Raw Material
Pattern
#1
#2
#3
#4
#5
#6
#7

8' pieces 12' pieces 16' pieces


4
0
0
3
1
0
2
0
1
1
2
0
1
1
1
0
3
0
0
0
2

Waste
4
0
4
4
0
0
4
53

Cutting Stock
Problem Constraints
Meet demand for 8 foot strips
4 X1 + 3 X2 + 2 X3 + X4 + X5 >= b1

Meet demand for 12 foot strips


X2 + 2 X4 + X5 + 3 X6 >= b2

Meet demand for 16 foot strips


X3 + X5 + 2 X7 >= b3

Nonnegativity
Xi >= 0 for all i
54

Linear Programming

Solving LPs in MS Excel

55

Solving LPs in Excel

Organize data for model in spreadsheet


Reserve cells for decision variables
Create formula for the obj. function val.
For each constraint, create
algebraic expression for LHS value
RHS constraint value

Label everything!
56

Recall Course Mix Examples


Algebraic Formulation
Decision variables
X1 = # of seminars offered
X2 = # of lectures offered

Maximize Z = 3 X1 + 2 X2
s.t.
X1 + 2 X2 <= 34
(faculty time)
X2 <= 10 (lecture rooms)
X1 <= 20 (seminar rooms)
25 X1 + 100 X2 >= 800
(enrollment)
X1, X2 >= 0
(non-negativity)

57

Course Mix Example:


Spreadsheet Formulation
X1 = # of
Seminars
0
3
0

X2 = # of
Lectures
0
2
0

<= constraints
1
0
1

2
1
0

>= constraints
25
100

# offered
Unit Variety Score
Variety Total

Course
Variety
Index
0

Used
0
0
0

Available
34
Faculty Time
10
Lecture Halls
20
Seminar Rooms

Available
0

Needed
800

Enrollment

58

Course Mix Example:


Spreadsheet Formulas
X1 = # of X2 = # of
Seminars Lectures
0
3
=A3*A4

# offered

Variety

2
Unit Variety Score
=B3*B4 Variety Total

Index
=A5+B5

<= constraints
1
2
0
1

1
0

>= constraints
25

Course

Used
=A$3*A8+B$3*B8
=A$3*A9+B$3*B9
=A$3*A10+B$3*B10
Available

100

=A$3*A13+B$3*B13

Available
34
10
20

Faculty Time
Lecture Halls
Seminar Rooms

Needed
800

Enrollment

59

Spreadsheet Solution:
Cells Specified to Solver
X1 = # of X2 = # of
Seminars Lectures
0
0
# offered
3
2
Unit Variety Score
0
0
Variety Total

Course
Variety
Index
0

<= constraints
1
2
0
1
1
0

Used
0
0
0

Available
34
Faculty Time
10
Lecture Halls
20
Seminar Rooms

>= constraints
25
100

Available
0

Needed
800

Enrollment

60

The Solver Dialog Box


Enter target cell, changing cells, and
constraint cells information
can just point to cells; no need to type
can highlight sets of constraints at once
nonnegativity constraints are just like other
constraints; for RHS just type in 0

Under options
Check Assume linear model
All other defaults should be fine
61

Spreadsheet Solution:
Obtained by Solver
X1 = # of X2 = # of
Seminars Lectures
20
7
3
2
60
14

# offered
Unit Variety Score
Variety Total

<= constraints
1
2
0
1
1
0

Used
34
7
20

Available
34
Faculty Time
10
Lecture Halls
20
Seminar Rooms

>= constraints
25
100

Available
1200

Needed
800

Course
Variety
Index
74

Enrollment

62

Suppose Had One More


Faculty: Enter 35
X1 = # of X2 = # of
Seminars Lectures
20
7
3
2
60
14

# offered
Unit Variety Score
Variety Total

<= constraints
1
2
0
1
1
0

Used
34
7
20

Available
35
Faculty Time
10
Lecture Halls
20
Seminar Rooms

>= constraints
25
100

Available
1200

Needed
800

Course
Variety
Index
74

Enrollment

63

Pull Down Solver and


Click on Solve
X1 = # of X2 = # of
Seminars Lectures
20
7.5
3
2
60
15

# offered
Unit Variety Score
Variety Total

<= constraints
1
2
0
1
1
0

Used
35
7.5
20

Available
35
Faculty Time
10
Lecture Halls
20
Seminar Rooms

>= constraints
25
100

Available
1250

Needed
800

Course
Variety
Index
75

Enrollment

64

Spreadsheet Design
Guidelines
Build model around display of data
Dont bury constants in formulas
Logically close quantities should be
physically close
Design so formulas can be copied
Use color, shading, borders, and
protection
Document with text boxes & cell notes
65

Some Excel Functions That


Are Useful in LP Formulation
SUMPRODUCT(array1, array2)
IF(logical expression,
value if true, value if false)
OR(logical exp., logical exp., ...)
ISTEXT(value)
VLOOKUP(lookup_value, table_array,
col_index_num)
66

Summary of Solving LPs


with Excels Solver
Excel facilitates entering & solving LPs
Easy to explore what if variations
To minimize errors
Think hard about layout of spreadsheet
Check for typos in formulas
Look at solution obtained; does it make
sense?

Can use texts examples as templates


67

Mathematical Programming

Linear Programming
MS Excel Solver
Cases
68

Linear Programming

Homework

69

Break

70

Вам также может понравиться