Академический Документы
Профессиональный Документы
Культура Документы
Solutions 9
Demo 1: KKT conditions with inequality constraints
Using the Karush-Kuhn-Tucker conditions, see if the points x = (x1 , x2 ) = (2, 4) or
x = (x1 , x2 ) = (6, 2) are the local optima of the problem. Draw a picture.
Solution
The feasible set is illustrated in the following picture.
8
−x21 + x2 ≤ 0
7
6 x1 + 2x2 − 10 ≤ 0
5
x2
0 x1 − 3x2 ≤ 0
−1
−3 −2 −1 0 1 2 3 4 5 6 7
x1
Functions gi (x) are constraint functions and λi the respective Lagrange multipliers.
Constraints are always of the form gi (x) ≤ 0. Now the constraint functions gi (x)
are:
g1 (x) = −x21 + x2
g2 (x) = x1 + 2x2 − 10
g3 (x) = x1 − 3x2
1
Note. The conditions above are the KKT conditions for a maximization problem.
For a minimization problem the conditions are similar, except the inequality of the
last condition is reversed, i.e. λi ≥ 0 ∀i.
Let us first look at x = (2, 4). We determine which constraints are active:
g1 (2, 4) = −22 − 4 = 0
g2 (2, 4) = 2 + 2 · 4 − 10 = 0
g3 (2, 4) = 2 − 3 · 3 = −7
Constraints g1 and g2 are active in the current point, i.e. they have the value 0.
The third constraint on the other hand is not active. According to the third KKT
condition, the Lagrange multipliers of inactive constraints are zero, i.e. now λ3 = 0.
3x21
2x1 1 1
∇f (x) = ∇g1 (x) = ∇g2 (x) = ∇g3 (x) =
3 3 2 −3
3 · 22
2·2 1 1
= + λ1 + λ2 + λ3
3 3 2 −3
12 + 4λ1 + λ2 + λ3
=
3 + 3λ1 + 2λ2 − 4λ3
Let us examine the other point: x = (6, 2). In this point the active constraints are:
g2 (6, 2) = 62 · 2 + 10 = 0
2
g3 (6, 2) = 6 − 3 · 2 = 0
The active constraints are constraints 2 and 3. The first constaint is not active, so
λ1 = 0. We replace the point x = (6, 2) into the Lagrange function’s gradient and
require it to be zero:
3 · 62 + λ2 + λ3
0
∇L(6, 2, λ1 , λ2 , λ3 ) = = .
3 + 2λ2 − 3λ3 0
Now we can solve the Lagrange multipliers, which are:
λ1 = −65.4 ja λ2 = −42.6.
The multipliers are negative and thus the KKT conditions are satisfied. The point
satisfies the KKT conditions and it is a optimum candidate.
Solution
The feasible area is illustrated in the following picture.
3.5
3
x2
2.5
1.5
1
1 2 x1 − x2 = −1
0.5
0
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
x1
In the problem we minimize the distance to the origin. The optimum is thus the
nearest point of the feasible set, x = (2, 2).
3
Note. The equality constraints’ Lagrange multipliers do not have similar positivity
or negativity constraints as the inequality constraints. The equality constraints’
Lagrange multipliers are often denoted µi .
g(2, 2) = (2 − 3)2 + 1 − 2 = 0
The constraint is active and thus the respective Lagrange multiplier can be non-zero.
We solve the point in which the gradient of the Lagrange function is zero. For this,
we first need to determine the gradients of the objective and constraint functions:
1
2x1 2(x1 − 3) 2
∇f (x) = ∇g(x) = ∇h(x) =
2x2 −x2 −1
2 · 2 + 2(2 − 3)λ + 21 µ
=
2 · 2 − 2λ − µ
4 − 2λ + 12 µ
0
= =
4 − 2λ − µ 0
We can solve the equations e.g. by first solving λ from the first equation and then
replacing it into the second. This yields λ = 2 and µ = 0. The Lagrange multiplier
of the inequality is positive, so point (2,2) satisfies the necessary KKT conditions of
the minimization problem.
4
Solution
2
x1 ≤ 2
1.5
0.5
x2
−0.5
−1 x22 + 1 ≤ x1
−1.5
−2
−1 −0.5 0 0.5 1 1.5 2 2.5 3 3.5 4
x1
5
Solution
The feasible area:
2 x1 ≥ −10
1 (x1 + 4)2 − 2 ≤ x2
x2
−1
−2
x1 − x2 + 4 = 0
−3
−11 −10 −9 −8 −7 −6 −5 −4 −3 −2 −1
x1
g2 (x) = x1 − x2 + 4
From the picture we see that the optimum is at (-5,-1). Let’s determine if it satifies
the KKT conditions. The active constraints:
∇L(−5, −1, λ1 , µ, λ2 ) = ∇f (−5, −1)+λ1 ∇g1 (−5, −1)+µ∇h(−5, −1)+λ2 ∇g2 (−5, −1)
1 + λ1 · 2(−5 + 4) + µ · (−1) 1 − 2λ1 − µ 0
= = =
0 + λ1 · (−1) + µ · 1 −λ1 + µ 0
From the lower equation we get λ1 = µ, which can be replaced in the upper equation.
This yields 1 − 2µ − µ = 0, i.e. µ = 31 . Furthermore, λ1 = µ = 13 . The problem is a
minimization problem and the KKT conditions require that the Lagrange multipliers
for inequality constraints are positive. This is now the case and the point satisfies
the KKT conditions.
6
Problem 3: Linear Programming Problem
a) Solve the problem graphically and determine if the solution satisfies the KKT
conditions.
c) Compare the solution of the dual and the Lagrange multipliers of the primal
problem.
max x1 + x2
s.e. x1 + 3x2 ≤ 9
2x1 + x2 ≤ 8
x1 ≥ 0, x2 ≥0
Solution
a) The feasible set is illustrated in the following picture:
4 x1 ≥ 0 2x1 + x2 ≤ 8
x1 + 3x2 ≤ 9
x2
0
x2 ≥ 0
−1
−1 0 1 2 3 4 5
x1
THe picture shows that the optimum is at the point (3,2). The constraint
functions are:
g1 (x) = x1 + 3x2 − 9
g2 (x) = 2x1 + x2 − 8
g3 (x) = −x1
g4 (x) = −x2
g1 (3, 2) = 3 + 3 · 2 − 9 = 0
g2 (3, 2) = 2 · 3 + 2 − 8 = 0
g3 (3, 2) = −3
g4 (3, 2) = −2
7
Constraints 1 and 2 are active, constraints 3 and 4 are not. Thus, λ3 = λ4 = 0
and we can leave the respective terms out of the Lagrange function. The
gradient of the Lagrange function is zero:
∇L(3, 2, λ1 , λ2 ) = ∇f (3, 2) + λ1 ∇g1 (3, 2) + λ2 ∇g2 (3, 2)
1 + λ1 · 1 + λ2 · 2 0
= =
1 + λ1 · 3 + λ2 · 1 0
The solution of the equations is λ1 = − 15 and λ2 = − 52 . The multipliers are
negative and the the problem is a maximization problem. Thus, the KKT
conditions are satisfied.
b) The dual of the problem is:
min 9y1 + 8y2
s.e. y1 + 2y2 ≥ 1
3y1 + y2 ≥ 1
y1 ≥ 0, y2 ≥ 0
2
y1 ≥ 0
1.5
1
y2
y1 + 2y2 ≥ 1
0.5
0
y2 ≥ 0
3y1 + y2 ≥ 1
−0.5
−0.5 0 0.5 1 1.5 2 2.5 3
y1
8
Solution
The feasible set is illustrated in the following picture:
4 x2 ≤ −(x1 − 4)3
3
x2
0
x2 ≥ 0
−1
−2
0 1 2 3 4 5 6
x1
The optimum is at (x1 , x2 ) = (4, 0). Let us determine if the point satisfies the KKT
conditions. The constraint functions are
g2 (x) = −x2
Both constraints are active at the optimum so the respective Lagrange multipliers
can be non-zero. The gradients of the objective and constraint functions are:
3(x1 − 4)2
1 0
∇f (x) = ∇g1 (x) = ∇g2 (x) =
0 1 −1
1 + λ1 · 3(4 − 4)2 + λ2 · 0
1 0
= = =
0 + λ1 · 1 + λ2 · (−1) λ1 − λ2 0
The first equation cannot be satisfied with any values of the multipliers λ1 and λ2 .
The point is clearly the optimum, so what went wrong?
The KKT conditions are the necessary conditions, assuming the gradients of the
constraint functions are linearly independent. Now the gradients at the optimum
are
0 0
∇g1 (4, 0) = ∇g2 (4, 0) =
1 −1
i.e. g1 (4, 0) = −g2 (4, 0). The gradients are linearly dependent and thus the optimum
does not need to satisfy the KKT conditions. Note that this point is still the
optimum.
Note. Usually one does not need to check the linear dependence of the constraints.
9
Problem 5: The legendary Enchanted forest
Sepeteus is trying to catch the legendary forest troll. The Enchanted forest limits
the whereabouts of the troll to a certain area. The area is defined the constraints :
x2 ≤ 2e−x1
x1 ≤2
x2 ≥ 41 x21
x2 ≤ 2x1 + 2
Sepeteus has at his disposal a trap. He has also build a noise making contraption
onto point (1,-1). He knows the troll is afraid of the contraption and runs as far away
from the contraption as possible. Although, the troll will stay inside the Enchanted
forest.
a) Solve the point where the troll will run, i.e. the Sepeteus should place the
trap. You can solve the point graphically.
b) Determine if the point satisfies the KKT conditions.
Solution
Let’s draw a map of the Enchanted forest:
x2 ≤ 2e−x1
2
x2 ≥ 41 x21
1
x2
−1
−2 x1 ≤ 2
x2 ≤ 2x1 + 2
−3
−3 −2 −1 0 1 2 3
x1
The noise making contraption is marked with a cross. The troll wants to maximize
the distance from the contraption so we can write the troll’s optimization problem:
max (x1 − 1)2 + (x2 + 1)2
s.e. x2 ≤ 2e−x1
x1 ≤ 2
x2 ≥ 14 x21
x2 ≤ 2x1 + 2
From the map we see that the troll should run to the point (0,2). Let’s determine
whether the point satisfies the KKT conditions. The constaint functions are:
g1 (x) = x2 − 2e−x1
10
g2 (x) = x1 − 2
1
g3 (x) = x21 − x2
4
g4 (x) = −2x1 + x2 − 2
∇L(0, 2, λ1 , λ2 , λ3 , λ4 ) = ∇f (0, 2)+λ1 ∇g1 (0, 2)+λ2 ∇g2 (0, 2)+λ3 ∇g3 (0, 2)+λ4 ∇g4 (0, 2)
11