You are on page 1of 24

Formulation – Modeling

Michel Bierlaire

Practice quiz

An investment fund is trying to determine how to invest its assets for the
following year, in order to maximize its profit. Currently, the fund has 2.5
million euros that it can invest in state bonds, real estate loans, car loans or
scholarship loans. The annual interest rates of the listed investment types
are 4% for state bonds, 6% for real estate loans, 8% for car loans and 9% for
scholarship loans.
To minimize risks, the investment fund allows only the selection of a
strategy satisfying the following restrictions:

• the amount invested in car and scholarship loans must not exceed twice
the amount invested in bonds;

• the amount invested in car loans must be larger or equal than the
amount invested in scholarship loans;

• the investment in car loans should not exceed the investment in real
estate loans by more than 70%.

Formulate this problem as an optimization problem by determining

1. the decision variables,

2. the objective function, and

3. the constraint(s).
Formulation – Modeling
Michel Bierlaire

Solution of the practice quiz

We proceed with the three steps of the modeling process.


Decision variables The decision variables are the amounts in euros in-
vested for
• state bonds: xsb ,
• real estate loans: xre ,
• car loans: xcℓ , and,
• scholarship loans: xsℓ .
Objective function As the company wants to maximize its profit, the ob-
jective function must provide the profit as a function of the decision
variables:
f : R4 → R : f (xsb , xre , xcℓ , xsℓ ).
The profit of the investment fund for the following year is calculated
based on the interest rates using the following formula:
f (xsb , xre , xcℓ , xsℓ ) = 0.04xsb + 0.06xre + 0.08xcl + 0.09xsℓ .
Therefore, we can write the problem as
max 0.04xsb + 0.06xre + 0.08xcl + 0.09xsℓ .
xsb ,xre ,xcℓ ,xsℓ

Constraints The total amount to invest is 2.5 Me. This is modeled using
the following constraint:
xsb + xre + xcℓ + xsℓ = 2′ 500′ 000

Each restriction is modeled as follows:


• the total amount invested in car and scholarship loans (xcℓ + xsℓ )
must not exceed twice the amount invested in bonds (2xsb ):

xcℓ + xsℓ ≤ 2xsb .

• the amount invested in car loans (xcℓ ) must be larger or equal


than the amount invested in scholarship loans (xsℓ ):

xsℓ ≤ xcℓ .

• the investment in car loans (xcℓ ) should not exceed the investment
in real estate loans (xre ) by more than 70%:

xcℓ ≤ 1.7xre .

Finally, we must impose all the decision variables to be non negative:

xsb , xre , xcℓ , xsℓ ≥ 0.

Putting everything together, we obtain the following optimization prob-


lem:
max 0.04xsb + 0.06xre + 0.08xcℓ + 0.09xsℓ
subject to

xsb + xre + xcℓ + xsℓ = 2′ 500′ 000,


xcℓ + xsℓ ≤ 2xsb ,
xsℓ ≤ xcℓ ,
xcℓ ≤ 1.7xre ,
xsb , xre , xcℓ , xsℓ ≥ 0.

For your information, the optimal solution (rounded to 1/10 of euros) is:

• State bonds: 696’721.3 euros

• Real estate loans: 409’836.1 euros

• Car loans: 696’721.3 euros

• Scholarship loans: 696’721.3 euros


for a total profit of 170’902.6 euros
The constraints are verified:

• Constraint 1: 696′ 721.3+409′ 836.1+696′ 721.3+696′ 721.3 = 2′ 500′ 000.0,

• Constraint 2: 696′ 721.3+696′ 721.3 = 1′ 393′ 442.62∗696′ 721.3 = 1′ 393′ 442.6,

• Constraint 3: 696′ 721.3 <= 696′ 721.3,

• Constraint 4: 696′ 721.3 <= 1.7 · 409′ 836.1 = 696′ 721.3.


Formulation – Modeling
Michel Bierlaire

Practice quiz

The company Coola-Coola Ltd. wants to design a can of soda of volume


0.33 liters. They need to set the dimensions (in centimeters) of this can to
use the minimum amount of aluminium, knowing that the form of the can is a
perfect cylinder, and the thickness of the aluminium is the same everywhere.
Write the problem as an optimization problem.
Formulation – Modeling
Michel Bierlaire

Solution of the practice quiz

We consider the three steps of the modeling process.

Decision variables The design of the cylinder depends on two variables,


both expressed in centimeters:

• the radius of the basis: r,


• the height of the cylinder: h.

Objective function Since the thickness of the aluminium is the same at


any part of the can, the total surface of the cylinder has to be min-
imized. The objective function must provide the total surface as a
function of the decision variables:

f : R2 → R : f (r, h).

• Each basis is a circle of radius r, so its surface is πr2 .


• The side of the can is a rectangle of area 2πrh.

Therefore, the objective function to minimize is

f (r, h) = 2πr2 + 2πrh.


Constraints The volume of the can must be 0.33 liters, that is 330 cm3 .
The first constraint is therefore:

πr2 h = 330.

We also need non negativity constraints:

r ≥ 0,
h ≥ 0.

The optimization problem is therefore:

min 2πr2 + 2πrh


r,h

subject to

πr2 h = 330,
r ≥ 0,
h ≥ 0.

The optimal solution of this problem is r = 3.746 cm and h = 7.491 cm.


Transformations
Michel Bierlaire

Practice quiz

Given the following optimization problem, transform it in such a way as


to obtain a minimization problem in which all decision variables must be non
negative and all constraints are defined by lower inequalities.

max −x21 + sin x2

subject to

6x1 − x22 ≥ 1,
x21 + x22 = 3,
x1 ≥ 2,
x2 ∈ R.
Transformations
Michel Bierlaire

Solution of the practice quiz

We apply a sequence of simple transformations to the optimization prob-


lem.

1. A maximization problem whose objective function is f (x) is equivalent


to a minimization problem whose objective function is −f (x):

argmaxx f (x) = argmaxx −f (x)

and
max f (x) = − min −f (x).
By applying statement (a) to our problem we obtain:

− min x21 − sin x2


subject to

6x1 − x22 ≥ 1,
x21 + x22 = 3,
x1 ≥ 2,
x2 ∈ R.

2. Now we transform the constraints. An equality constraint can be writ-


ten as the combination of two inequalities.

g(x) ≤ 0
g(x) = 0 ⇐⇒
g(x) ≥ 0.
The optimization problem becomes

− min x21 − sin x2

subject to

6x1 − x22 ≥1
x21 + x22 ≤3
x21 + x22 ≥3
x1 ≥2
x2 ≥ 0.

3. A constraint defined by a lower inequality can be multiplied by −1 to


get an upper inequality:

g(x) ≤ 0 ⇐⇒ −g(x) ≥ 0.

− min x21 − sin x2


subject to

−6x1 + x22 ≤ −1
x21 + x22 ≤3
−x21 − x22 ≤ −3
x1 ≥2
x2 ∈ R.

4. If a variable x can take any real value, it can be replaced by two non
negative artificial variables denoted by x+ and x− , such that

x = x+ − x− .

We can impose x+ ≥ 0 and x− ≥ 0, without loss of generality. We


apply this to the variable x2 in our formulation.

− min x21 − sin(x+ −


2 − x2 )
subject to

−6x1 + (x+ − 2
2 − x2 ) ≤ −1
x21 + (x+ − 2
2 − x2 ) ≤3
−x21 − (x+ − 2
2 − x2 ) ≤ −3
x1 ≥2
x+
2 ≥0
x−
2 ≥ 0.

5. In the presence of a constraint x ≥ a, with a ∈ R, a simple change of


variable
x = x̂ + a
transforms the constraint in

x̂ ≥ 0.

We apply this last principle to variable x1 , and we obtain:

− min(x̂1 + 2)2 − sin(x+ −


2 − x2 )

subject to

−6(x̂1 + 2) + (x+ − 2
2 − x2 ) ≤ −1
(x̂1 + 2)2 + (x+ − 2
2 − x2 ) ≤3
−(x̂1 + 2)2 − (x+ − 2
2 − x2 ) ≤ −3
x̂1 ≥0
x+
2 ≥0
x−
2 ≥ 0.

As requested, it is a minimization problem, all decision variables are non


negative and all constraints are defined by lower inequalities. Any solution
(x̂1 , x+ −
2 , x2 ) of this problem corresponds to the following solution of the orig-
inal problem:
x1 = x̂1 + 2
x2 = x+ −
2 − x2 .
Transformations
Michel Bierlaire

Practice quiz

The following optimization problem is not linear, because of the absolute


value in the objective function. Transform it into a linear problem in which
all decision variables must be non negative.

min | x1 − x2 |

subject to

x1 ≥ 0,
x2 ≥ 0.
Transformations
Michel Bierlaire

Solution of the practice quiz

To solve this exercise, we remember that if a variable x can take any real
value, it can be replaced by two non negative artificial variables denoted by
x+ and x− , such that x = x+ − x− . We also recall that the absolute value of
x is defined as 
x if x ≥ 0,
|x| =
−x if x < 0.
In our case, we have that

x1 − x2 if x1 ≥ x2 ,
|x1 − x2 | =
x2 − x1 if x1 < x2 .

Since x1 and x2 are non negative real numbers, the difference x1 − x2 can
take any real value.
Let us study the absolute value by examining the two cases:
• If x1 − x2 ≥ 0, we can define the non negative quantity
(
x1 − x2 , if x1 − x2 > 0,
y+ =
0, otherwise.

• If x1 − x2 < 0, we can define the positive quantity


(
x2 − x1 , if x1 − x2 < 0,
y− =
0, otherwise.

Consequently, the absolute value of the difference can then be written as

|x1 − x2 | = y + + y − .
Furthermore, if we impose that y + ≥ 0 and y − ≥ 0, we have that our
minimization problem can be written as
min (y + + y − )
x1 ,x2 ,y + ,y −

subject to
y+ ≥ x1 − x2 ,
y− ≥ x2 − x1 ,
x1 ≥ 0,
x2 ≥ 0,
y+ ≥ 0,
y− ≥ 0.
Note that this formulation is not strictly equivalent to the original one
for all feasible solutions. For instance, the feasible solution x1 = 0, x2 = 0,
y + = 1, y − = 1 has objective value 2 in the transformed problem, and 0 in
the original one.
But it is equivalent at the optimal solution. Denote the optimal solution
of the original problem (x∗1 , x∗2 ).
• If x∗1 − x∗2 > 0, the lowest possible value for y + , denoted by (y + )∗ , is
x∗1 −x∗2 (because of the constraint y + ≥ x1 −x2 ), and the lowest possible
value for y − , denoted by (y − )∗ , is 0 (because of the constraint y − ≥ 0).
Therefore, the objective function of the transformed problem at the
optimal solution is
(y + )∗ + (y − )∗ = x∗1 − x∗2 + 0 = |x∗1 − x∗2 |.

• If x∗1 − x∗2 < 0, for similar reasons, we have (y + )∗ = 0 and (y − )∗ =


x∗2 − x∗1 . Therefore, the objective function of the transformed problem
at the optimal solution is
(y + )∗ + (y − )∗ = 0 + x∗2 − x∗1 = |x∗1 − x∗2 |.

• If x∗1 − x∗2 = 0, we have (y + )∗ = 0 and (y − )∗ = 0. Therefore, the


objective function of the transformed problem at the optimal solution
is
(y + )∗ + (y − )∗ = 0 + 0 = |x∗1 − x∗2 |.
Problem definition
Michel Bierlaire

Practice quiz

Can a function have both a global and a local minimum? If so, provide
an example. If not, explain why.
Problem definition
Michel Bierlaire

Solution of the practice quiz

Yes. Any global minimum is also a local minimum. If the function is


convex, a local minimum is also a global minimum. If not, there may be
local minima that are not global. An example of such a function could be

f (x) = −2x2 + x4 − x3 .

6
f (x)
4

x
−3 −2 −1 1 2 3
−2

−4

We use the optimality conditions to identify the maxima and minima of the
function. The first derivative of f (x) is

f ′ (x) = −4x + 4x3 − 3x2 .

If we solve f ′ (x) = 0, we obtain three solutions:

x1 = 0, x2 = −0.693, x3 = 1.443.

These are the only candidates to be minima or maxima.


• Consider the interval [−0.1, 0.1]. x1 reaches the maximum of f in this
neighborhood. It is therefore a local maximum.

• Consider the interval [−0.7, −0.6]. x2 reaches the minimum of f in this


neighborhood. It is therefore a local minimum.

• Consider the interval [1.4, 1.5]. x3 reaches the minimum of f in this


neighborhood. It is therefore a local minimum.

This can also be verified using the second derivative of the function f (x):

f ′′ (x) = −4 + 12x2 − 6x.

Indeed, if we substitute the solutions x in the function f ′′ (x) we obtain:

f ′′ (x1 ) = −4 + 12(0)2 − 6(0) = −4 < 0 ⇒local maximum,


′′ 2
f (x2 ) = −4 + 12(−0.693) − 6(−0.693) = 5.92 > 0 ⇒local minimum,
f ′′ (x3 ) = −4 + 12(1.443)2 − 6(1.443) = 12.32 > 0 ⇒local minimum.

Since the function is a polynomial, we have

lim f (x) = lim −2x2 + x4 − x3 = +∞,


x→∞ x→∞
lim f (x) = lim −2x2 + x4 − x3 = +∞.
x→−∞ x→−∞

Therefore, the function has no global maximum. Its global minimum is the
local minimum associated with the lowest value of f . We can conclude that
the function has

• a local maximum at x1 = 0, f (x1 ) = 0,

• a local minimum at x2 = −0.693, f (x2 ) = −0.554, and

• a global minimum at x3 = 1.443, f (x3 ) = −2.77.


Problem definition
Michel Bierlaire

Practice quiz

Consider the following objective functions,

1. f1 (x) = x2 .

2. f2 (x) = 1/|x|.

3. f3 (x) = 1/x.

For each function, provide its infimum on R, or show that it does not
exist. Provide also its minimum on R, or show that it does not exist.
Answer the same question if the decision variable is constrained as follows:

−1 ≤ x ≤ 2.
Problem definition
Michel Bierlaire

Solution of the practice quiz


We first plot the function f1 to have an intuition.
6
f1 (x) = x2

x
0
−3 −2 −1 0 1 2 3

The infimum of x2 on R is 0:
inf x2 = 0.
x∈R

Indeed, for each M > 0, there exists



M
y=
2
such that y 2 = M
4
< M . The function has also a minimum at x∗ = 0, as
f1 (x∗ ) = inf x2 = 0.
x∈R

When the constraints are introduced, the same arguments can be used to
reach the same conclusions: the infimum is 0, and x∗ = 0 is an optimum.
We now analyze the function f2 .
6
f2 (x) = 1/|x|

x
0
−2 0 2 4

The infimum of 1/|x| on R is 0:


1
inf = 0.
x∈R |x|

Indeed, for each M > 0, there exists


2
y=
M
such that f2 (x) = M
2
< M . However, there is no minimum, as there is no x
such that
1
= 0.
|x|
The infimum of 1/|x| on Y = {x ∈ R| − 1 ≤ x ≤ 2} is 0.5. Indeed, for
each M > 0.5, there exists
y=2∈Y
such that f2 (y) = 0.5 < M . And the minimum is x∗ = 2, as
1
f2 (x∗ ) = 0.5 = inf .
x∈Y |x|

Finally, we analyze the function f3 .


6

f2 (x) = 1/x 2

−2

−4

−6
−4 −2 0 2 4
x

There is no infimum on R. Indeed, the function is not bounded from


below. As the infimum is the best lower bound, and there is no lower bound,
there is no infimum. Consequently, there is no optimum either. As the
function is also not bounded from below on the interval [−1 : 2], we reach
the same conclusions for the constrained case.
Problem definition
Michel Bierlaire

Practice quiz

Does the following function f (x1 , x2 ) : R2 → R have a global maximum


and a global minimum in the feasible set A?

f (x1 , x2 ) = x21 + x22 − 2x1 x2


,

A = (x1 , x2 ) ∈ R2 |(x1 − 1)2 + (x2 − 2)2 ≤ 1 .




Hint: use the Weierstrass extreme value theorem.


Problem definition
Michel Bierlaire

Solution of the practice quiz

The function f (x1 , x2 ) = x21 +x22 −2x1 x2 is a continuous function, because


it is the sum of continuous functions.

·105

0
0 200
100
200
300 0

The set A = (x1 , x2 ) ∈ R2 |(x1 − 1)2 + (x2 − 2)2 ≤ 1 is a compact set:
6 x
2

2 A

x1
−4 −3 −2 −1 1 2 3

Weierstrass’s theorem guarantees that the given function has both a max-
imum and a minimum when optimized on the feasible set A.

You might also like