Download as pdf or txt
Download as pdf or txt
You are on page 1of 22

LINDO

LINDO (Linear Interactive and Discrete Optimizer) is


a computer package that can be used to solve linear,
integer, and quadratic programming problems.

§ A MAX (max) or MIN (min) is entered to introduce the


objective function
§ Enter the constraints by typing SUBJECT TO (or st) on
the next line. Then enter the constraints.
§ General information: Chapter 4, Appendix A
LINDO
View the LINDO Help file for syntax questions.
n LINDO assumes the < symbol means ≤ and the > symbol means ≥.
n Do not insert the asterisk symbol between coefficients and variables
to indicate multiplication.
n LINDO does not recognize bracket signs “(“ or “)”
(leads to error message)
n LINDO assumes all variables are nonnegative,
so nonnegativity constraints are not necessary.
n Everything behind “!” are comments
(write whatever you want, no syntax rules)
LINDO formulations
Note! The three most common errors in LINDO:

1. Using a constant in the objective function or the left hand side of a constraint:
e.g. MIN 10 + 2x1 + 3x2 + 9x3
sol. MIN 2x1 + 3x2 +9x3

e.g. x1 + x3 + 2 > 10
sol. x1 + x3 > 8

2. Putting a variable in the right hand side of a constraint:


e.g. x1 + x2 < x3
sol. x1 + x2 - x3 < 0

3. Using “*” or “(“ “)” :


e.g. 2*x1 + 3(x2+x3) + 5*(x4-x5) = 10
sol. 2x1 + 3x2 +3x3 + 5x4 - 5x5 = 10
LINDO
To solve the model, select the SOLVE
command or click the red bulls eye button.
• When asked if you want to do a range (sensitivity)
analysis, choose no (will be discussed later).
• When the solution is complete, a display showing
the status of the Solve command will be present.
• View the displayed information.

Note: In LINDO, the objective function row is labeled row 1 and


constraints rows 2-….
LINDO
§ Lindo printscreen:
LINDO
§ Reports window:
The LINDO output shows:
§ LINDO found the optimum solution after 2 iterations (pivots)
§ The optimal z-value = 44
§ VALUE gives the value of the variable in the optimal solution.
Thus the optimal solution is x1=4, x2=0, x3=4.

§ SLACK OR SURPLUS gives (by constraint row) the value of


slack or excess in the optimal solution.

§ REDUCED COST and DUAL PRICE columns: see later


(sensitivity analysis).
LINDO
• An LO package may have trouble solving LOs in
which there are nonzero coefficients that are either
very small (<0.0001) or very large (>100 000) in
absolute value.
• In these cases, LINDO will respond with a message
that the LP is poorly scaled.
The workforce problem

minimise 300(x1 + x2 + x3 + x4) + MIN 300x1 + 300x2 + 300x3 + 300x4


492(x5 + x6 + x7 + x8) + 492x5 + 492x6 + 492x7 + 492x8
subject to
subject to x1 + x4 + x5 + x7 + x8 > 12
Lindo x1 + x2 + x5 + x6 + x8 > 8
x1 + x4 + x5 + x7 + x8 ≥ 12
x2 + x3 + x5 + x6 + x7 > 6
x1 + x2 + x5 + x6 + x8 ≥ 8
x3 + x4 + x6 + x7 + x8 > 15
x2 + x3 + x5 + x6 + x7 ≥ 6
end
x3 + x4 + x6 + x7 + x8 ≥ 15

xi ≥ 0 for i=1, 2, …, 8

9
About variables names
You are free to name your variables any way you want,
however, your model is easier to read if you:

• Use same letter for similar variables, differentiate


with an index

• Example:
t1, t2, …, t4 for #tables produced in period 1, 2, …, 4
and c1, c2, …, c4 for #chairs produced in period 1, 2, …, 4
(instead of a, b, c, d,…, h or x1, x2, …, x8)

10
About variables names
Use multi-dimensional index when variables have a natural
organization in rows & columns; or links between sets of
objects/agents

• Example:
given 3 workers (Tom, Ben, Matt) and 2 machines (1,2), represent
the number of minutes each worker operates each machine as:
xT,1, xT,2, xB,1, xB,2, xM,1, and xM,2 (instead of x1, x2, x3, …, x6)

• Example:
xd,l,w = volume of drink of type d produced in factory at location l
in week w, with d = {Sprite, Fanta}, l = {LA, Baltimore},
w = {1, 2, … 52}.
11
Types of LO problems
• A diet problem (3.4)
• A work scheduling problem (3.5)
• A capital budgeting problem (3.6)
• Short-term financial planning (3.7)
• Blending problems (3.8)
• Production process models (3.9)
• A cutting problem (-)
• Inventory problems (3.10)
• Multi-period financial model (3.11)
• Multi-period work scheduling problem (3.12)
• Transportation problem (7.1)
• Assignment problem (7.5)
• Transshipment problem (7.6)
12
Example 7.11
A transportation problem (7.11)
• Consider a car producer with manufacturing
plants in Los Angeles, Detroit, and New Orleans.
• The distribution centers are located in Denver
and Miami.

• In the next quarter, the production Distances Denver Miami


capacity of the three plants will be
1000, 1500, and 1200 respectively. Los Angeles 1000 2690

• The demand for the two distribution Detroit 1250 1350


centers for cars is 2300 and 1400,
respectively. New Orleans 1275 850
• Distances shown in the table (in miles).

Transportation of the cars is by train, and costs 5 dollars per car


per mile. Formulate this problem as an LO problem.

14
Transportation: variables
Define
Denver Miami
xij = number of cars that is transported from
Los 1000 2690
plant i to distribution centre j Angeles
Detroit 1250 1350
( i = 1. Los Angeles, 2. Detroit, 3. New Orleans,
New 1275 850
j = 1. Denver, 2. Miami ) Orleans

15
Transportation: variables
Define
Denver Miami
xij = number of cars that is transported from
Los 1000 2690
plant i to distribution centre j Angeles
Detroit 1250 1350
( i = 1. Los Angeles, 2. Detroit, 3. New Orleans,
New 1275 850
j = 1. Denver, 2. Miami ) Orleans

Constraint:
No plant can transport more cars than its capacity
x11 + x12 ≤ 1000 [LA]
x21 + x22 ≤ 1500 [Detroit]
x31 + x32 ≤ 1200 [New Orleans]
16
Transportation: variables
Define
Denver Miami
xij = number of cars that is transported from
Los 1000 2690
plant i to distribution centre j Angeles
Detroit 1250 1350
( i = 1. Los Angeles, 2. Detroit, 3. New Orleans,
New 1275 850
j = 1. Denver, 2. Miami ) Orleans

Constraint:
Each distribution centre receives at least the required number of cars
x11 + x21 + x31 ≥ 2300 [ Denver ]
x12 + x22 + x32 ≥ 1400 [ Miami ]

17
Transportation: variables
Define
Denver Miami
xij = number of cars that is transported from
Los 1000 2690
plant i to distribution centre j Angeles
Detroit 1250 1350
( i = 1. Los Angeles, 2. Detroit, 3. New Orleans,
New 1275 850
j = 1. Denver, 2. Miami ) Orleans

Objective:
Total transportation costs? Σ (number of miles) * $5 * number of cars

min z = 5000x11 + 13450x12 + 6250x21 + 6750x22 + 6375x31 + 4250x32

18
Transportation: variables
Define
Denver Miami
xij = number of cars that is transported from
Los 1000 2690
plant i to distribution centre j Angeles
Detroit 1250 1350
( i = 1. Los Angeles, 2. Detroit, 3. New Orleans,
New 1275 850
j = 1. Denver, 2. Miami ) Orleans

min z = 5000x11 + 13450x12 + 6250x21 + 6750x22 + 6375x31 + 4250x32


s.t. x11 + x12 ≤ 1000
x21 + x22 ≤ 1500
x31 + x32 ≤ 1200
x11 + x21 + x31 ≥ 2300
x12 + x22 + x32 ≥ 1400
xij ≥ 0 i=1,2,3, j=1,2
19
Transportation problem
min z = 5000x11 + 13450x12 + 6250x21 + 6750x22 + 6375x31 + 4250x32
s.t. x11 + x12 ≤ 1000
x21 + x22 ≤ 1500
x31 + x32 ≤ 1200
x11 + x21 + x31 ≥ 2300
x12 + x22 + x32 ≥ 1400
xij ≥ 0 i=1,2,3, j=1,2

This is a special LO-problem. Why?


• each technological coefficient has value 0 or 1,
• each variable occurs exactly twice with coefficient 1,
• all right-hand sides are integers.

Such problem is called a transportation problem (see Winston 7.1).

Property: if an optimal solution exists, then there exists


an integer optimal solution.
20
Transportation problem
source destination

supply demand

Terminology:
• there are n sources, each with supply ai, and
there are m destinations, each with demand bj,
• for each source-destination pair, a cost cij is given. 21
Transportation problem
$ &

min 𝑧 = ' ' 𝑐!% 𝑥!%


In general !"# %"#
&
• There are m sources, supply 𝑎! s.t. ' 𝑥!% ≤ 𝑎! 𝑖 = 1, … , 𝑚
• There are n destinations, demand 𝑏" %"#
$
• For each source – destination pair,
a tranportation cost 𝑐!" ' 𝑥!% ≥ 𝑏% 𝑗 = 1, … , 𝑛
!"#
𝑥!% ≥ 0 𝑖 = 1, … , 𝑚
• Note that a necessary condition for
𝑗 = 1, … , 𝑛
the existence of a feasible solution is
$ &

! 𝑎! ≥ ! 𝑏%
!"# %"#

$ &
• If total supply equals total demand we
! 𝑎! = ! 𝑏%
say that the transportation problem is !"# %"#
balanced.
22

You might also like