You are on page 1of 82

MDP 631

Advanced Industrial Operations


Research
Lecture 4
The model formulation process and Introduction to LINGO
Today’s lecture
• The model formulation process
• Common errors in formulating a model
• Template models
• LINGO software
– Interface
– Entering and solving small models
– Interpreting solution reports
The model formulation process
• In using any kind of analytical or modeling approach for
attacking a problem, there are five major steps:
1. Understanding the real problem.
2. Formulating a model of the problem.
3. Gathering and generating the input data for the model
(e.g., per unit costs to be used, etc.).
4. Solving or running the model. Here, model verification is
conducted to make sure that the model is correctly
formulated and it reflects exactly the assumptions made.
5. Implementing and interpreting the solution in the real
world. This involves model validation to make sure that the
results obtained are accurate representation the the real
situation.
The model formulation process
• In general, there is a certain amount of
iteration over the five steps (e.g., one does
not develop the most appropriate model the
first time around).
• The easiest is solving the model on the
computer. This is not because it is intrinsically
easiest, but because it is the most susceptible
to mathematical analysis.
The model formulation process
• Steps 1, 3, and 5 are, if not the most difficult,
at least the most time consuming.
• Success with these steps depends to a large
extent upon being very familiar with the
organization involved (e.g., knowing who
knows what the real production rate is on the
punch press machine).
• Step 2 requires the most analytical skill.
• Steps 1 and 5 require the most people skills.
Model building is an art
• Formulating good models is an art bordering
on a science.
• The artistic ability is in developing simple
models that are nevertheless good
approximations of reality.
Approaches to Model Formulation
• We take two approaches to formulating models:
– Template approach,
– Constructive approach.
• The constructive approach is the more fundamental and general.
• Readers with less analytic skill may prefer the template approach. The
latter is essentially a “model in a can” approach.
• In the template approach, examples of standard applications are
illustrated in substantial detail.
• If you have a problem that closely resembles one of these “template”
models, you may be able to adjust it to your situation by making modest
changes to the template model.
• The advantage of this approach is that the user may not need much
technical background if there is a template model that closely fits the real
situation.
Templates for LP models
• We are going to look at some template
models including:
– Blending (food-mix or Diet) problem
– Capital budgeting (Portfolio planning) problem
– Work scheduling problem
– Product-mix problem
– Multi-period production scheduling problem
Blending (Food-mix or Diet) Problem
Frederick's Feed Company receives four raw grains from
which it blends its dry pet food. The pet food advertises that
each 8-ounce can meets the minimum daily requirements for
vitamin C, protein and iron. The cost of each raw grain as well
as the vitamin C, protein, and iron units per pound of each
grain are summarized on the next slide.
Frederick's is interested in producing the 8-ounce mixture
at minimum cost while meeting the minimum daily
requirements of 6 units of vitamin C, 5 units of protein, and 5
units of iron.
Blending (Food-mix or Diet) Problem
Vitamin C Protein Iron
Grain Units/lb Units/lb Units/lb Cost/lb

1 9 12 0 .75
2 16 10 14 .90
3 8 10 15 .80
4 10 8 7 .70
Blending (Food-mix or Diet) Problem
• Define the decision variables

xj = the pounds of grain j (j = 1,2,3,4)


used in the 8-ounce mixture

• Define the objective function

Minimize the total cost for an 8-ounce mixture:


MIN .75x1 + .90x2 + .80x3 + .70x4
Blending (Food-mix or Diet) Problem
• Define the constraints
Total weight of the mix is 8-ounces (.5 pounds):
(1) x1 + x2 + x3 + x4 = .5
Total amount of Vitamin C in the mix is at least 6 units:
(2) 9x1 + 16x2 + 8x3 + 10x4 > 6
Total amount of protein in the mix is at least 5 units:
(3) 12x1 + 10x2 + 10x3 + 8x4 > 5
Total amount of iron in the mix is at least 5 units:
(4) 14x2 + 15x3 + 7x4 > 5
Nonnegativity of variables: xj > 0 for all j
Portfolio Planning Problem
Winslow Savings has $20 million available
for investment. It wishes to invest over the
next four months in such a way that it will
maximize the total interest earned over the
four month period as well as have at least $10
million available at the start of the fifth month
for a high rise building venture in which it will
be participating.
Portfolio Planning Problem
For the time being, Winslow wishes to
invest only in 2-month government bonds
(earning 2% over the 2-month period) and 3-
month construction loans (earning 6% over
the 3-month period). Each of these is
available each month for investment. Funds
not invested in these two investments are
liquid and earn 3/4 of 1% per month when
invested locally.
Portfolio Planning Problem
Formulate a linear program that will help
Winslow Savings determine how to invest over
the next four months if at no time does it wish
to have more than $8 million in either
government bonds or construction loans.
Portfolio Planning Problem
• Define the decision variables

gj = amount of new investment in


government bonds in month j

cj = amount of new investment in


construction loans in month j

lj = amount invested locally in month j,


where j = 1,2,3,4
Portfolio Planning Problem
• Define the objective function

Maximize total interest earned over the 4-month period.

MAX (interest rate on investment)(amount invested)

MAX .02g1 + .02g2 + .02g3 + .02g4


+ .06c1 + .06c2 + .06c3 + .06c4
+ .0075l1 + .0075l2 + .0075l3 + .0075l4
Portfolio Planning Problem
• Define the constraints

Month 1's total investment limited to $20 million:


(1) g1 + c1 + l1 = 20,000,000

Month 2's total investment limited to principle and interest invested locally
in Month 1:
(2) g2 + c2 + l2 = 1.0075l1
or g2 + c2 - 1.0075l1 + l2 = 0
Portfolio Planning Problem
• Define the constraints (continued)

Month 3's total investment amount limited to principle and interest


invested in government bonds in Month 1 and locally invested in Month 2:
(3) g3 + c3 + l3 = 1.02g1 + 1.0075l2
or - 1.02g1 + g3 + c3 - 1.0075l2 + l3 = 0
Portfolio Planning Problem
• Define the constraints (continued)

Month 4's total investment limited to principle and interest invested in


construction loans in Month 1, goverment bonds in Month 2, and locally
invested in Month 3:
(4) g4 + c4 + l4 = 1.06c1 + 1.02g2 + 1.0075l3
or - 1.02g2 + g4 - 1.06c1 + c4 - 1.0075l3 + l4 = 0

$10 million must be available at start of Month 5:


(5) 1.06c2 + 1.02g3 + 1.0075l4 > 10,000,000
Portfolio Planning Problem
• Define the constraints (continued)

No more than $8 million in government bonds at any time:


(6) g1 < 8,000,000
(7) g1 + g2 < 8,000,000
(8) g2 + g3 < 8,000,000
(9) g3 + g4 < 8,000,000
Portfolio Planning Problem
• Define the constraints (continued)

No more than $8 million in construction loans at any time:


(10) c1 < 8,000,000
(11) c1 + c2 < 8,000,000
(12) c1 + c2 + c3 < 8,000,000
(13) c2 + c3 + c4 < 8,000,000

Nonnegativity: gj, cj, lj > 0 for j = 1,2,3,4


Work Scheduling Problem
• Each postal worker works for 5 consecutive days,
followed by 2 days off, repeated weekly.

Day Mon Tues Wed Thurs Fri Sat Sun

Demand 17 13 15 19 14 16 11

• Minimize the number of postal workers


(for the time being, we will permit
fractional workers on each day.)
Work Scheduling Problem

• Select the decision variables


– Let x1 be the number of workers who start
working on Monday, and work till Friday
– Let x2 be the number of workers who start on
Tuesday …
– Let x3, x4, …, x7 be defined similarly.
Day Mon Tues Wed Thurs Fri Sat Sun
The linear program
Demand 17 13 15 19 14 16 11

Minimize z = x1 + x2 + x3 + x4 + x5 + x6 + x7

subject to x1 + x4 + x5 + x6 + x7  17
x1 + x2 + x5 + x6 + x7  13
x1 + x2 + x3 + x6 + x7  15
x1 + x2 + x3 + x4 + x7  19
x1 + x2 + x3 + x4 + x5  14
x2 + x3 + x4 + x5 + x6  16
x3 + x4 + x5 + x6 + x7  11
xj  0 for j = 1 to 7
Product-Mix Problem

• Produce 4 types of men's ties


• Use 3 materials (limited resources)

Decision: How many of each type of tie to


make per month?

Objective: Maximize profit


Resource Data

Cost per Yards available


Material yard per month
Silk $20 1,000
Polyester $6 2,000
Cotton $9 1,250

Labor cost is $0.75 per tie


Product Data
Type of Tie

Silk Polyester Blend 1 Blend 2


Selling Price
(per tie) $6.70 $3.55 $4.31 $4.81

Monthly Minimum
6,000 10,000 13,000 6,000

Monthly Maximum
7,000 14,000 16,000 8,500

Total material
(yards per tie) 0.125 0.08 0.10 0.10
Material Requirements
(yards per tie)
Type of Tie
Blend 1 Blend 2
Silk Polyester
Material (50/50) (30/70)

Silk 0.125 0 0 0

Polyester 0 0.08 0.05 0.03

Cotton 0 0 0.05 0.07

Total yards 0.125 0.08 0.10 0.10


Decision Variables
S = number of silk ties to make per month

P = number of polyester ties to make per month

B1 = number of poly-cotton blend 1 ties to make per month

B2 = number of poly-cotton blend 2 ties to make per month


Profit Per Tie Calculation
Profit per tie =
(Selling price) – (material cost) –(labor cost)

Silk Tie
Profit = $6.70 – (0.125 yds)($20/yd) - $0.75
= $3.45 per tie
Objective Function (in $ of profit)

Max 3.45S + 2.32P + 2.81B1 + 3.25B2

Subject to the constraints:

Material Limitations (in yards)


0.125S < 1,000 (silk)
0.08P + 0.05B1 + 0.03B2 < 2,000 (poly)
0.05B1 + 0.07B2 < 1,250 (cotton)
Min and Max Number of Ties to Make
6,000 < S < 7,000
10,000 < P < 14,000
13,000 < B1 < 16,000
6,000 < B2 < 8,500

Finally nonnegativity S, P, B1, B2 > 0


Multiperiod Production Scheduling
Problem
Need to schedule production of 2 electrical motors for
each of the next 4 months

Decision: How many of each type of motor to make


each month?

Objective: Minimize total production and inventory


cost
Decision Variables
PAt = number of motor A to produce in
month t (t=1,…,4)
PBt = number of motor B to produce in
month t (t=1,…,4)

IAt = inventory of motor A at end of


month t (t=1,…,4)
IBt = inventory of motor B at end of
month t (t=1,…,4)
Sales Demand Data

Motor
Month A B
1 (January) 800 1000
2 (February) 700 1200
3 (March) 1000 1400
4 (April) 1100 1400
Production Data
Motor
(values are per motor)
A B
Production cost $10 $6

Labor hours 1.3 0.9

• Production costs will be 10% higher in months


3 and 4
• Monthly labor hours most be between
2240 and 2560
Inventory Data

Motor
A B
Inventory cost
$0.18 $0.13
(per motor per month)
Beginning inventory
0 0
(beginning of month 1)
Ending Inventory
450 300
(end of month 4)

Max inventory is 3300 motors


Production and Inventory Balance
(inventory at end of previous period)
+ (production the period)
- (sales this period)
= (inventory at end of this period)
Objective Function (in $ of cost)

Min 10PA1 + 10PA2 + 11PA3 + 11PA4


+ 6PB1 + 6 PB2 + 6.6PB3 + 6.6PB4
+ 0.18(IA1 + IA2 + IA3 + IA4)
+ 0.13(IB1 + IB2 + IB3 + IB4)
Subject to the constraints:

(see next slide)


Production & Inventory Balance
0 + PA1 – 800 = IA1 (month 1)
0 + PB1 – 1000 = IB1
IA1 + PA2 – 700 = IA2 (month 2)
IB1 + PB2 – 1200 = IB2
IA2 + PA3 – 1000 = IA3 (month 3)
IB2 + PB3 – 1400 = IB3
IA3 + PA4 – 1100 = IA4 (month 4)
IB3 + PB4 – 1400 = IB4
Ending Inventory
IA4 = 450
IB4 = 300

Maximum Inventory level


IA1 + IB1 < 3300 (month 1)
IA2 + IB2 < 3300 (month 2)
IA3 + IB3 < 3300 (month 3)
IA4 + IB4 < 3300 (month 4)
Range of Labor Hours
2240 < 1.3PA1 + 0.9PB1 < 2560 (month 1)
2240 < 1.3PA2 + 0.9PB2 < 2560 (month 2)
2240 < 1.3PA3 + 0.9PB3 < 2560 (month 3)
2240 < 1.3PA4 + 0.9PB4 < 2560 (month 4)

finally nonnegativity: PAi, PBi, IAi, IBi > 0


Common Errors in Formulating
Models
• When you develop a first formulation of some
real problem, the formulation may contain
errors or bugs. These errors will fall into the
following categories:
A. Simple typographical errors;
B. Fundamental errors of formulation;
C. Errors of approximation.
Dealing with errors
• Category A errors are easy to identify because they are clerical
in nature. In a large model, however, tracking them down may
be a difficult search problem.
• Category B errors are more fundamental because they involve
a misunderstanding of either the real problem or the nature
of LP models.
• Category C errors are subtler. Generally, a model of a real
situation involves some approximation (e.g., many products
are aggregated together into a single macro-product, the days
of a week are lumped together, or costs that are not quite
proportional to volume are nevertheless treated as linear).
Avoiding category C errors requires skill in identifying which
approximations can be tolerated.
Introduction to LINGO software
Lingo
• Lingo is a program designed specifically for
solving optimization problems
• It uses a syntax that is similar to what would
be written by hand, or what would be used in
Excel, not requiring variables to be declared
• For example, y = 3*x^2 is y = 3x2
How to get it
• Download page
– http://www.lindo.com
Lingo Operators
• Many of Lingo’s mathematical operators are
similar to what Excel uses:
– Addition: + - Multiplication: *
– Subtraction: - - Division: /
– For exponents: X^n
– Equals: =
– Greater than or less than: > or <
• Note: Lingo accepts ‘<’ as being ‘<=’. It does not support
strictly less than or greater than.
Lingo Operators (cont.)
• Absolute value of x: @abs(x)
• Natural log of x: @log(x)
• Trigonometric functions: @sin(x), @cos(x),
@tan(x) (x in radians)
• Exponentials: @exp(x)
• To return integer portion of decimal number:
@floor(x)
• @sign(x): returns -1 if x < 0, or else 1
Lingo Operators (cont.)
• Find max or min value in a set:
@smax(x1,x2…,xn) or @smin(x1,x2…,xn)
• To find maximum or minimum of a function:
max or min
• To allow negative variables: @free(x)
• Lingo has a number of other operators, but
these are the mathematical operators that are
most likely to be used
Using Lingo
• Other operators, like logic operators, can be
found in the help file’s complete list of
operators
• Now that we have the mathematical operators
that are likely to be used, we can demonstrate
how Lingo works with some examples
• Lingo can be used strictly as an equation
solver or as an optimizer
Lingo Screenshot
If additional help Solve – to solve
is needed current problem set
Basic Equation Solver

This will find the


intersection of the lines “y
= 3x + 4” and “y = 5x +
1”
Solution

Note: Lingo does not


distinguish between small and
capital letters
Equation Solver #2
Solution #2

Only one solution was found!


There should be two solutions
to this problem. The solver
automatically stops when it
finds the first solution.
Solution #2
20

15

10
7.791
Y

5
3.2087

0
-5 0 5 10 15

-5
3.2087 7.791
X
Non-linear Difficulties
• Lingo is not designed to deal with non-linear
equations
• It cannot find multiple solutions
• There is a problem with solving non-linear
problems, especially if the solution is in the
negative domain
Maximum and Minimum
• The maximum and minimum functions are the
most important functions needed for
optimization problems
• These functions are used as follows:
max = objective function;
min = objective function;
Chemical Plant Example
• Objective: Maximize 1000x1 + 1500x2

• Constraints:
4x1 + 2x2 <= 80
2x1 + 5x2 <= 60
4x1 + 4x2 <= 75
x1, x2 >= 0
Chemical Plant Example
Lingo Solution

Solution, including
value of objective
function at
optimum and
optimum point
Another Example
Slack or Surplus
• The “Slack or Surplus” column contains the
values of the slack or surplus variables in the
optimal solution.
• A zero slack or surplus value means that the
corresponding constraint is binding.
Dual Price
• The dual price of a constraint is the rate at
which the objective function value will
improve as the right-hand side or constant
term of the constraint is increased a small
amount.
• It is equivalent to the shadow price term
which we learnt earlier.
Dual price illustration
Reduced Cost
• Associated with each variable in any solution is a quantity
known as the reduced cost.
• If the units of the objective function are dollars and the units
of the variable are gallons, then the units of the reduced cost
are dollars per gallon.
• The reduced cost of a variable is the amount by which the
profit contribution of the variable must be improved (e.g., by
reducing its cost) before the variable in question would have
a positive value in an optimal solution.
• Obviously, a variable that already appears in the optimal
solution will have a zero reduced cost.
Reduced cost illustration
Reduced cost illustration
Negative Values
• Lingo cannot automatically solve for a
negative variable value
• If it is suspected that a solution will be
negative, then that variable will need to be
specifically declared as free:
@free(x);
• It is a good idea to declare all variables like
this, unless of course a negative value is
infeasible
Attempting to Obtain a Negative
Solution
• The following example will demonstrate what
happens if a negative value is required to get
an optimum solution
• Lingo will automatically solve for the optimum
solution obtained from only positive variables,
even if this is not the true optimum
Attempting to Obtain a Negative
Solution
Attempting to Obtain a Negative
Solution

This solution
is viable if the
variable
values must
be positive,
but this is not
the true
optimum
Attempting to Obtain a Negative
Solution

These statements allow


negative values to be used
for these variables
Attempting to Obtain a Negative
Solution

Now the true


optimum is
obtained,
with negative
variables
Greater Than or Less Than
• Another potential problem that will be
encountered using Lingo is that it treats <
the same as <=, and > the same as >=
• Thus, if a variable must be strictly greater than
a value, the constraint is best treated as
follows:
– For x > A, where A is a solution otherwise, use
x > A + b;
where b is an arbitrary value, like 0.1, that covers a
portion where the solution will not lie
Example of < or >
Example of < or >

Clearly this is
not correct as
X1 was
constrained to
be greater
than 0!
Example of < or >

This will now force X1 and


X2 to be greater than 0.
We can do this because
we know X1 and X2 are
also greater than 0.1.
Example of < or >

Variables now
obey desired
constraints.
Objective just
happens to be
the same in this
case.

You might also like