LP Modelling
LP Modelling
Dritan Nace
i
ii INTRODUCTION
Contents
Introduction i
1
2 CONTENTS
Chapter 1
Introduction to Linear
Programming
Let start with an example: Consider a production facility (or an activity) for a
manufacturing company. The facility is capable of producing a variety of prod-
ucts that, for simplicity, we shall enumerate as 1, 2, . . . , n. These products are
manufactured out of certain raw materials. Let us assume that there are m
di↵erent raw materials, which again we shall simply enumerate as 1, 2, . . . , m.
The decisions involved in managing/operating this facility are complicated and
arise dynamically as market conditions evolve around it. However, to describe
a simple, fairly realistic optimization problem, we shall consider a particular
snapshot of the dynamic evolution. At this specific point in time, the facility
has, for each raw material j = 1, 2, . . . , m, a known amount, say bj , on hand.
Furthermore, each raw material has at this moment in time a known unit market
value. We shall denote the unit value of the j th raw material by cj . In addition,
each product is made from known amounts of the various raw materials. That
is, producing one unit of product i requires a certain known amount, say aij
units, of raw material j. Also, the ith final product can be sold at the known
prevailing market price of pi euros per unit.
The problem we wish to consider is the one faced by the company’s pro-
duction manager. It is the problem of how to use the raw materials on hand.
Let us assume that the manager decides to produce xi units of the ith product,
i = 1, 2, . . . , n. As said above, the revenue associated with the production of
one unit of product i is pi . But there is also a cost of raw materials that must
be considered.
Pm
The cost of producing one unit of product i is expressed as j=1 aij cj.
Therefore, the net revenue associated with the production of one unit is the
di↵erence between the revenue and the cost. Since the net revenue plays an
important
Pm role in our model, we introduce notation for it by setting fi = pi
j=1 aij cj, which gives the objectif function:
3
f,a and b are parameters: known values
xi are decision variables because we dont know what is the best value of x in order to get the best profit
n
X
max fi xi (1.1)
the objectif function i=1
Now, let look at the raw materials on hand. Assuming that he decides to
produce xi units of the ith product, i = 1, 2, . . . , n, the manager can’t produce
more product than he has raw material for. The amount of raw material j
consumed by a given production process is aij , and so he must adhere to the
following constraints:
n
X
aij xi bj , j = 1, 2, . . . , m (1.2)
i=1
xi 0, i = 1, 2, . . . , n (1.3)
1. Decision variables, that are the unknowns that the user needs to determine.
5.
linear programming because all functions used are
1.2. LINEAR OPTIMIZATION linear 5
Note that each of the constraints should be arranged such that all terms with
decision variables be on the left of the constraint realation, and the only part
that appears on the right is the constant term.
Converting various forms of LP to the standard form can be done as follows:
1. (Slack variables). Consider the problem as in the standard form but con-
straints are typically: ai1 x1 + ai2 x2 + · · · + ain xn bi . These constraints
can be rewritten as equalities by adding a new variable (slack variable) to
the left hand side.
ya (1.9a)
y Mx (1.9b)
y a + (x 1)M (1.9c)
where M is a large value constant. The case when both are binary variables is
handled similarly.
Di↵erent situations may be met when modeling constraints as well. For
instance, the so-called capacity constraints usually give rise to upper bound
constraints; In the same line, demand constraints will usually give rise to lower
bound constraints. Another type of frequently met constraint is the socalled
mass balance one, which expresses the requirement of conservation of mass. An
obvious example of this constraint is found in flow problems when expressing
that the amount of flow entering in some transit node is equal to the amount of
flow going out.
Another type of constraints are the proportion constraints where one decision
variable needs to represent a fixed part of a given sum. For instance, let a, b and
c give all, and a is required to be exactly 30% of all. Then, it can be expressed
as: a = 0.3(a + b + c).
We assume that there are available at the market n di↵erent foods and that the
j th food sells at a price cj per unit. In addition there are m basic nutritional
ingredients and, to achieve a balanced diet, each individual must receive at least
bi units of the ith nutrient per day. Finally, we assume that each unit of food j
contains aij units of the ith nutrient.
If we denote by xj the number of units of food j in the diet, the problem then
is to select the xj ’s to minimize the total cost: c1 x1 + c2 x2 + · · · + cn xn subject
to the nutritional constraints: ai1 x1 + ai2 x2 + · · · + ain xn bi , i = 1, . . . , m, and
the non-negativity constraints: xj 0 for all j.
Consider the problem of operating a warehouse, by buying and selling the stock
of a certain commodity, in order to maximize profit over a certain length of time,
say n months. The warehouse has a fixed capacity C, and there is a cost r per
unit for holding stock for one period. The selling price, pi , of the commodity is
known to fluctuate over a number of time periods n indexed by i. In any period
i the price holding for purchase is fi . The warehouse is originally empty and is
required to be empty at the end of the last period.
To formulate this problem, variables are introduced for each time period. In
particular, let zi denote the level of stock in the warehouse at the beginning of
period i. Let xi denote the amount bought during period i, and let yi denote
the amount sold during period i. If there are n periods, the problem may be
written as:
1.4. EXAMPLES OF LINEAR PROGRAMMING PROBLEMS 9
n
X n
X n
X
min fi xi pi yi + zi r (1.10a)
i=1 i=1 i=1
subject to
x i + zi yi = zi+1 1 i n (1.10b)
zi C 1 i n (1.10c)
z1 = zn+1 = 0 (1.10d)
x, y, z 0. (1.10e)
10 CHAPTER 1. INTRODUCTION TO LINEAR PROGRAMMING
les exercices 1 2 3 ne sont pas demandes
1.4.6 Exercises
1. Convert the following problem to standard form:
max x + 2y + 3z (1.11a)
subject to
6 x + y + z 15, (1.11b)
x 2, y 0, z 0 (1.11c)
Alloy 1 2 3 4 5
%A 10 25 50 75 95
%B 90 75 50 25 5
Price/lb 5 4 3 2 1.50
The desired alloy will be produced by combining some of the other alloys.
The manufacturer wishes to find the amounts of the various alloys needed and to
determine the least expensive combination. Formulate this problem as a linear
program.
6. A small firm specializes in making five types of spare automobile parts.
Each part is first cast from iron in the casting shop and then sent to the finishing
shop where holes are drilled, surfaces are turned, and edges are ground. The
required worker-hours (per 100 units) for each of the parts of the two shops are
shown below:
.''
1.4. EXAMPLES OF LINEAR PROGRAMMING PROBLEMS 11
Part 1 2 3 4 5
Casting 2 1 3 3 1
Finishing 3 2 2 1 1
The profits from the parts are 30, 20, 40, 25, and 10 (per 100 units), respec-
tively. The capacities of the casting and finishing shops over the next month are
700 and 1000 worker-hours, respectively. Formulate the problem of determining
the quantities of each spare part to be made during the month so as to maximize
profit.
7. A small computer manufacturing company forecasts the demand over
the next n months to be di , i = 1, 2, . . . , n. In any month it can produce at
most r units, using regular production, at a cost of b dollars per unit. By using
overtime, it can produce additional units at c dollars per unit, where c > b.
The firm can store units from month to month at a cost of s dollars per unit
per month. Formulate the problem of determining the production schedule that
minimizes the cost.
12 CHAPTER 1. INTRODUCTION TO LINEAR PROGRAMMING
Chapter 2
13
14CHAPTER 2. LOGISTIC, TRANSPORTATION AND SCHEDULING PROBLEMS MODELLING
Objective: calculate the sites to be opened to cover all the requests, with a
minimum total cost.
Binary linear programming formulation:
2.1. LOGISTIC PROBLEMS 15
n
X
min c i xi (2.1a)
i=1
subject to
n
X
ai,j xi 1, 8j 2 {1, . . . , m} (2.1b)
i=1
xi 2 {0, 1}, 8i 2 {1, . . . , n}. (2.1c)
m
X
max d j zj (2.2a)
j=1
subject to
n
X
zj ai,j xi 8j 2 {1, . . . , m} (2.2b)
i=1
n
X
xi p, (2.2c)
i=1
xi 2 {0, 1}, 8i 2 {1, . . . , n} (2.2d)
zj 2 {0, 1}, 8j 2 {1, . . . , m}. (2.2e)
•M
n: a set of a number of nodes to serve,
• a set of n sites, of which only p sites can open,
• Distance matrix dij between sites and nodes,
• yij : a binary variable taking 1 if site i is covering demand j,
16CHAPTER 2. LOGISTIC, TRANSPORTATION AND SCHEDULING PROBLEMS MODELLING
min z (2.3a)
subject to
n
X
yij = 1, 8j 2 {1, . . . , m} (2.3b)
i=1
X
xi p, (2.3c)
i
n
X
dij yij z, 8j 2 {1, . . . , m} (2.3d)
i=1
yij xi , 8i 2 {1, . . . , n}, 8j 2 {1, . . . , m} (2.3e)
xi 2 {0, 1}, 8i 2 {1, . . . , n} (2.3f)
yij 2 {0, 1}, 8i 2 {1, . . . , n}, 8j 2 {1, . . . , m}. (2.3g)
m
X X
min qj dij yij (2.4a)
j=1 i
subject to
n
X
yij = 1, 8j 2 {1, . . . , m} (2.4b)
i=1
n
X
xi p, (2.4c)
i=1
yi,j xi , 8i 2 {1, . . . , n}, 8j 2 {1, . . . , m} (2.4d)
xi 2 {0, 1}, 8i 2 {1, . . . , n} (2.4e)
yi,j 2 {0, 1}, 8i 2 {1, . . . , n}, 8j 2 {1, . . . , m}. (2.4f)
n
X m X
X n
min fi xi + cij yij (2.5a)
i=1 j=1 i=1
subject to
n
X
yij = dj , 8j 2 {1, . . . , m} (2.5b)
i=1
m
X
yi,j M xi 8i 2 {1, . . . , n}, (2.5c)
j=1
n X
X m
min cij xij (2.6a)
i=1 j=1
subject to
m
X
xij ai , i = 1, 2, . . . , n (2.6b)
j=1
n
X
xij bj , j = 1, 2, . . . , m (2.6c)
i=1
xij 0, i = 1, 2, ..., n; j = 1, 2, . . . , m. (2.6d)
X
min dij xij (2.7a)
i,j
subject to
n
X
xij = 1, 8i = 1, 2, . . . , n (2.7b)
j=1
Xn
xij = 1, 8j = 1, 2, . . . , n (2.7c)
i=1
X
xij 1, 8S ⇢ V (2.7d)
i2S,j2V \S
In
Clearly constraints (2.7d) are very numerous and cannot be all put explicitly.
Then, we start with a subset of such constraints and solve the problem. The
obtained solution x is necessarily composed of circuits and all nodes are visited.
If the solution corresponds to a single circuit, then the solution is optimal,
otherwise one can build a constraint of type (2.7d) by putting in a set S all
nodes contained in a sub-tour and next add it in the formulation and solve
again the augmented problem1 .
X
Minimum en
·
max f (2.8a)
subject to
X X
-
xsj xjs f = 0, (2.8b)
-
le
-
j2U + (s) j2U (s)
X X -
:
be formulated as the -
maximum flow problem instead that f is now a parameter
and the objective function becomes:
O
X
min wi,j xi,j
-
(i,j)2E
1 Other formulations are also possible. Another option to avoid sub-tours is to add some
variables and constraints. Then, instead of constraints (2.7d), we add new variables ui (one
per node) and constraints: ui uj n 1; 2 i 6= j n, ui 2 N It can be shown that this
constraint avoids having sub-tours in the obtained solution.
20CHAPTER 2. LOGISTIC, TRANSPORTATION AND SCHEDULING PROBLEMS MODELLING
X X
min wi,j xdi,j (2.9a)
(i,j)2E d
subject to
X X
xds(d),j xdj,s(d) = fd , 8d 2 D (2.9b)
j2U + (sd)) j2U (s(d))
X X
xdij xdji = 0, 8d 2 D, 8i 2 V \ {s(d), t(d)} (2.9c)
j2U + (i) j2U (i)
X
xdij Cij , 8(i, j) 2 E (2.9d)
d2D
Exercises
IE
placed at order j; M
deloged
n
X
1 xij = 1, 8i = 1, 2, . . . , n (2.10b)
j=1
Yj
=
o othermise Xn
xij = 1, 8j = 1, 2, . . . , n (2.10c)
i=1
n
X ryzo
-----
tj
i=1
xij ri , 8j = 1, 2, . . . , n (2.10d)
n
X
V .
tj + xij pi tj+1 , 8j = 1, 2, . . . , n (2.10e)
&3
i=1
Mjj tj +
n
X
xij pi
n
X
xij di , 8j = 1, 2, . . . , n (2.10f)
i=1 i=1
xij 2 {0, 1}, 8i = 1, 2, . . . , n, j = 1, 2, . . . , n (2.10g)
Egli
22CHAPTER 2. LOGISTIC, TRANSPORTATION AND SCHEDULING PROBLEMS MODELLING
X
min yj (2.11a)
j
subject to
ti < tj 8(i, j) 2 P rec, (2.11b)
tj + 1 dj + M yj , 8j = 1, 2, . . . , n (2.11c)
tj 0, 8j = 1, 2, . . . , n (2.11d)
yj 2 {0, 1}, 8j = 1, 2, . . . , n (2.11e)
2.3.3 Exercises
Exercise 1. The company Tapisall must fulfill a command of three models of
wallpaper: one (model 1) has a blue background with green patterns, another
(model 2) has a green background with blue patterns, and the last ( model 3) is
entirely in green. Each model is manufactured as a roll of continuous paper that
passes over several machines, each printing a di↵erent color (machine 1 for blue
color and machine 2 for green). The order of passage on the machines varies
from model to model: we first print the blue background on model 1, then
the green patterns. For model 2, apply the green background, then the blue
patterns. We also know that for operational reasons model 3 must be processed
first on machine 2 (compared to the other two models on the same machine)
and that any started task must be completed before starting another one. The
execution time of these operations is variable according to the surface to be
printed. The times (in minutes) required to apply each color to each model are
denoted with pij , that is duration of process i on machine j.
=I
T
-
model 2 Pas
2.4. ADDITIONAL EXERCISES 23
for this problem. The surveillance zone can be represented by a graph where
the nodes are the crossroads and the arcs are the streets.