Professional Documents
Culture Documents
Linear Programming
Algorithmic Methods for Mathematical Models
(AMMM)
Enric Rodrı́guez-Carbonell
September 7, 2022
Example 1: Problem
A factory can produce five types of product (PROD1, PROD2, ..., PROD5)
by using two production processes: grinding and drilling.
Each unit of each product yields the following contributions to profit:
PROD1 PROD2 PROD3 PROD4 PROD5
550¿ 600¿ 350¿ 400¿ 200¿
Each unit requires a certain number of hours on each process.
A dash indicates when a process is not needed.
PROD1 PROD2 PROD3 PROD4 PROD5
Grinding 12 20 — 25 15
Drilling 10 8 16 — —
The final assembly of a unit of product uses 20 hours of an employee’s time.
The factory has 3 grinding machines and 2 drilling machines and works a
6-day week with 2 shifts of 8 hours on each day. In total 8 workers are
employed in assembly, each working one shift a day.
The problem is to find how much of each product is to be manufactured so as
to maximize the total profit contribution.
2 / ??
Example 1: Model
■ We introduce (decision) variables x1 , x2 , . . ., x5 representing the amount
of PROD1, PROD2, ..., PROD5 that should be produced in a week.
■ As each unit of PROD 1 yields 550¿ contribution to profit and each unit
of PROD 2 yields 600¿ contribution to profit, etc., our total profit
contribution will be represented by the expression:
3 / ??
Example 1: Model
■ Our processing and labour capacities limit the values the xj can take.
■ As we have 3 grinding machines working for a total of 2 × 8 × 6 = 96
hours a week each, we have 3 × 96 = 288 hours of grinding capacity.
■ Each unit of PROD1 uses 12 hours grinding.
So x1 units will use 12 x1 hours.
■ Similarly, x2 units of PROD2 will use 20 x2 hours.
■ Similarly for PROD3, PROD4, PROD5.
■ The total amount of grinding capacity that we use in a week is
■ As each unit of each product uses 20 hours of this capacity, we have the
constraint
5 / ??
Example 1: Model
We have now expressed our original problem as a mathematical model and is
now a well-defined mathematical object.
6 / ??
What is a Model
■ Many applications of science make use of models.
The term model is usually used for a structure built with the purpose of
exhibiting characteristics of some other object.
Generally, only some of these features will be retained in the model.
7 / ??
Why Do We Want Models?
There are a number of reasons for building models:
■ To improve understanding.
The actual exercise of building a model often reveals relationships that
were not apparent. As a result, a greater understanding is achieved of the
object being modelled.
8 / ??
Models and Data
■ A model is defined by its relationships, which are independent of the
actual data.
9 / ??
Mathematical vs. Computer Prog.
■ Mathematical programming is different from computer programming.
10 / ??
Components of a Model
■ Mathematical programming models are built on top of symbolic numerical
values called (decision) variables.
11 / ??
Types of Models
■ In this course we will confine our attention to some special types of
mathematical programming models:
◆ linear programming (LP) models
13 / ??
Example 1: Model (II)
Let us consider again the example of the factory. Recall the model:
■ Maximize profit: max 550x1 + 600x2 + 350x3 + 400x4 + 200x5
■ Subject To:
◆ Respect grinding capacity : 12x1 + 20x2 + 25x4 + 15x5 ≤ 288
◆ Respect drilling capacity: 10x1 + 8x2 + 16x3 ≤ 192
◆ Respect labour capacity: 20x1 + 20x2 + 20x3 + 20x4 + 20x5 ≤ 384
■ There are a number of implicit assumptions in this model:
2. We have assumed that the variables x1 , x2 , . . . , x5 can take fractional
values. This assumption may be appropriate or not. If, for example,
PROD1 represented litres of beer, fractional quantities would be OK.
But if it represented numbers of motor cars, it may not be.
In practice, the assumption that variables can be fractional is
acceptable if the errors involved in rounding to the nearest integer, if
needed, can be afforded. If this is not the case, we must resort to ILP.
But ILP models may be much harder to solve.
13 / ??
Example 2: Problem
A food is manufactured by refining raw oils and blending them together. The
raw oils come in two categories: vegetable oils (VEG1, VEG2) and
non-vegetable oils (OIL1, OIL2, OIL3).
Vegetable oils and non-vegetable oils require different production lines for
refining. It is not possible to refine more than 200 tons of vegetable oil and
more than 250 tons of non-vegetable oils. There is no loss of weight in the
refining process and the cost of refining may be ignored.
There is a technological restriction of hardness in the final product. In the
units in which hardness is measured, this must lie between 3 and 6. We
assume the hardness of final product is the weighted average of hardness of
the raw oils. The hardness of the raw oils and the costs (per ton) and are
VEG1 VEG2 OIL1 OIL2 OIL3
8.8 6.1 2.0 4.2 5.0
110 e 120 e 130 e 110 e 115 e
The final product sells for 150 e per ton.
How should we make the product in order to maximize net profit?
14 / ??
Example 2: Model
■ Variables are introduced to represent the unknown quantities:
◆ x1 , x2 , ..., x5 represent the quantities (tons) of VEG 1, VEG 2, OIL 1,
OIL 2 and OIL 3 that should be bought, refined and blended.
◆ y represents the quantity of the product that should be made.
15 / ??
Example 2: Model
■ Variables are introduced to represent the unknown quantities:
◆ x1 , x2 , ..., x5 represent the quantities (tons) of VEG 1, VEG 2, OIL 1,
OIL 2 and OIL 3 that should be bought, refined and blended.
◆ y represents the quantity of the product that should be made.
15 / ??
Example 2: Model
■ Variables are introduced to represent the unknown quantities:
◆ x1 , x2 , ..., x5 represent the quantities (tons) of VEG 1, VEG 2, OIL 1,
OIL 2 and OIL 3 that should be bought, refined and blended.
◆ y represents the quantity of the product that should be made.
15 / ??
Example 2: Model
■ Variables are introduced to represent the unknown quantities:
◆ x1 , x2 , ..., x5 represent the quantities (tons) of VEG 1, VEG 2, OIL 1,
OIL 2 and OIL 3 that should be bought, refined and blended.
◆ y represents the quantity of the product that should be made.
15 / ??
Example 2: Model
■ Variables are introduced to represent the unknown quantities:
◆ x1 , x2 , ..., x5 represent the quantities (tons) of VEG 1, VEG 2, OIL 1,
OIL 2 and OIL 3 that should be bought, refined and blended.
◆ y represents the quantity of the product that should be made.
15 / ??
Example 2: Model
■ Variables are introduced to represent the unknown quantities:
◆ x1 , x2 , ..., x5 represent the quantities (tons) of VEG 1, VEG 2, OIL 1,
OIL 2 and OIL 3 that should be bought, refined and blended.
◆ y represents the quantity of the product that should be made.
15 / ??
Example 2: Model
■ Hardness limitations on the final product are imposed by the constraints:
16 / ??
Example 2: Model
■ Hardness limitations on the final product are imposed by the constraints:
(8.8 x1 + 6.1 x2 + 2 x3 + 4.2 x4 + 5 x5 )/y ≤ 6 this looks like non-linear!
(8.8 x1 + 6.1 x2 + 2 x3 + 4.2 x4 + 5 x5 )/y ≥ 3
16 / ??
Example 2: Model
■ Hardness limitations on the final product are imposed by the constraints:
(8.8 x1 + 6.1 x2 + 2 x3 + 4.2 x4 + 5 x5 )/y ≤ 6 this looks like non-linear!
(8.8 x1 + 6.1 x2 + 2 x3 + 4.2 x4 + 5 x5 )/y ≥ 3
i.e.
8.8 x1 + 6.1 x2 + 2 x3 + 4.2 x4 + 5 x5 − 6y ≤ 0
8.8 x1 + 6.1 x2 + 2 x3 + 4.2 x4 + 5 x5 − 3y ≥ 0
16 / ??
Solving Models
■ The software for solving mathematical programming problems is often very
sophisticated and represents many person-years of programming effort.
■ When a mathematical programming model is built, it is usually worth
making use of an existing software to solve it rather than getting diverted
onto the task of programming the computer to solve the model oneself.
■ In the lab lectures we will use one of these packages: IBM ILOG CPLEX
17 / ??
Modeling Languages
■ Mathematical programming packages often include software for helping
users to structure and input their model into the package.
■ These programs use a high level programming language (the modelling
language) to express the models.
■ We will use OPL, which is the modelling language of CPLEX.
18 / ??
Modeling Languages
There are several reasons for modelling languages:
■ A more natural input format. The internal input formats required by most
solvers are designed more with the package in mind than the user.
■ Debugging is made easier. Modelling languages are high level
programming languages.
■ Modification is made easier. Models are often used on a regular basis with
minor modifications, or once built may be used experimentally many times
with small changes in data. The separation of the data from the structure
of the model, common in most modelling languages, facilitates this task.
■ Repetition is automated. Large models usually arise from the combination
or repetition of smaller models, for example, multiple periods, plants or
products. In such circumstances, there will be a lot of repetition of
particular items of data and structure. Modelling languages generally take
account of such repetition very easily.
19 / ??
Models in a Modeling Language
Typical parts of a model in a modelling language:
■ SETS. These usually represent indices for vectors, matrices, ... of decision
variables and data.
■ DATA. These are usually coefficients for the model, which may be defined
in arrays or read from external files. The items in the arrays or files are
often indexed by the indices described above.
■ VARIABLES. These are the decision variables that appear in the model,
typically defined in a vector, matrix, ... The sort of variable
(continuous/integer/binary, free/non-negative, etc.), is usually specified in
the variable declaration.
■ OBJECTIVE FUNCTION. Usually uses notation over index sets for
representing summation compactly.
■ CONSTRAINTS.
20 / ??
Models in a Modeling Language
21 / ??