Optimization with (in)equality constraints
Evelien van der Hurk
DTU Management Engineering
Today’s Topics in Optimization
•One variable without constraints
•Two or more variables without constraints
•Lagrange: Equality Constraints
•Equality and Inequality Constraints
Let’s start with a puzzle
To save the world from destruction, agent 007 has
to reach an island 50 meters off-shore from a point 100 meters further
along a straight beach and then disarm a timing device. The agent can run
along the shore at 5 meters per second, swim at 2 meters per second, and
disarm a timing device in 30 seconds. Can 007 save the world if the device
is set to trigger destruction in 73 seconds?
One variable without constraints
Two important theorems: (1) Fermat
The Fermat Theorem
Ifˆxis a point of local minimum (or maximum) of a functionf, then the main linear part of the increment is equal to zero.
y
y=x2
Example: verify Fermat
x y
y=x2
Verify the Fermat theorem for min f(x) = x
2→ x ˆ = 0 Let x ˆ be a point of local minimum of f .
Let x be a point arbitrarily close to x, ˆ and let h be the increment: x = ˆ x + h
The increment function:
f (x) − f(ˆ x) = (ˆ x + h
2) − x ˆ
2= 2ˆ xh + h
2Where 2ˆ xh is called the main linear part
and h
2is the remainder. This remainder is negligible for small enough h. E.g. h =
1001= 0.01
,h
2=
100001= 0.0001Now, Fermat:
The Fermat Theorem
Ifxˆis a point of local minimum (or maximum) of a function f, then the main linear part (here: 2ˆxh) of the increment is equal to zero.
That the main linear part 2ˆ xh = 0 for each h, implies ˆ
x = 0
Example: verify Fermat
x y
y=x2
Verify the Fermat theorem for min f(x) = x
2→ x ˆ = 0 Let x ˆ be a point of local minimum of f .
Let x be a point arbitrarily close to x, ˆ and let h be the increment: x = ˆ x + h The increment function:
f (x) − f(ˆ x) = (ˆ x + h
2) − x ˆ
2= 2ˆ xh + h
2Where 2ˆ xh is called the main linear part
and h
2is the remainder. This remainder is negligible for small enough h. E.g. h =
1001= 0.01
,h
2=
100001= 0.0001
Now, Fermat:
The Fermat Theorem
Ifxˆis a point of local minimum (or maximum) of a function f, then the main linear part (here: 2ˆxh) of the increment is equal to zero.
That the main linear part 2ˆ xh = 0 for each h, implies ˆ
x = 0
Example: verify Fermat
x y
y=x2
Verify the Fermat theorem for min f(x) = x
2→ x ˆ = 0 Let x ˆ be a point of local minimum of f .
Let x be a point arbitrarily close to x, ˆ and let h be the increment: x = ˆ x + h The increment function:
f (x) − f(ˆ x) = (ˆ x + h
2) − x ˆ
2= 2ˆ xh + h
2Where 2ˆ xh is called the main linear part
and h
2is the remainder. This remainder is negligible for small enough h. E.g. h =
1001= 0.01
,h
2=
100001= 0.0001Now, Fermat:
The Fermat Theorem
Ifˆxis a point of local minimum (or maximum) of a functionf, then the main linear part (here: 2ˆxh) of the increment is equal to zero.
That the main linear part 2ˆ xh = 0 for each h, implies ˆ
x = 0
Example: verify Fermat
x y
y=x2
Verify the Fermat theorem for min f(x) = x
2→ x ˆ = 0 Let x ˆ be a point of local minimum of f .
Let x be a point arbitrarily close to x, ˆ and let h be the increment: x = ˆ x + h The increment function:
f (x) − f(ˆ x) = (ˆ x + h
2) − x ˆ
2= 2ˆ xh + h
2Where 2ˆ xh is called the main linear part
and h
2is the remainder. This remainder is negligible for small enough h. E.g. h =
1001= 0.01
,h
2=
100001= 0.0001Now, Fermat:
The Fermat Theorem
Ifˆxis a point of local minimum (or maximum) of a functionf,
Fermat Theorem:
necessary conditions for one variable without constraints Consider a problem f (x) → extr, i.e. a one-variable optimization problem without constraints.
The Fermat Theorem
Assume that the functionf : (ˆx−,xˆ+)→Ris differentiable atx. Ifˆ xˆ is a local extremum of problemf(x), then: f0(ˆx) = 0.
Proof for x ˆ is a minimum.
f (ˆ x + h) − f (ˆ x) ≥ 0 for all h with |h| sufficiently small:
•Ifh >0, f(ˆx+h)−f(ˆh x) ≥0. Lettingh→0 givesf0(ˆx)≥0.
•Ifh <0, f(ˆx+h)−f(ˆh x) ≤0. Lettingh→0 givesf0(ˆx)≤0.
Therefore, f
0(ˆ x) = 0
Remark:
•Proof can be reformulated to link derivative to indicate increase/decrease inf(x)
•Necessary, but notsufficientcondition. Example: f(x) =x3
Fermat Theorem:
necessary conditions for one variable without constraints Consider a problem f (x) → extr, i.e. a one-variable optimization problem without constraints.
The Fermat Theorem
Assume that the functionf : (ˆx−,xˆ+)→Ris differentiable atx. Ifˆ xˆ is a local extremum of problemf(x), then: f0(ˆx) = 0.
Proof for x ˆ is a minimum.
f (ˆ x + h) − f (ˆ x) ≥ 0 for all h with |h| sufficiently small:
•Ifh >0, f(ˆx+h)−f(ˆh x) ≥0. Lettingh→0 givesf0(ˆx)≥0.
•Ifh <0, f(ˆx+h)−f(ˆh x) ≤0. Lettingh→0 givesf0(ˆx)≤0.
Two important theorems: (2) Weierstrass
The Weierstrass Theorem
If a functionf : [a, b]→Ron a closed interval is continuous, then the problem f(x)→min, a≤z≤b
has a point of global minimum.
Often: unbounded function; but coercive (for minimization):
|x|→+∞
lim f (x) = +∞
Corrollary
If a functionf :R→Ris continuous and coercive for minimization, then the problem
f(x)→min, x∈R
Weierstrass: example
Show that there exists a solution for the problem:
f (x) = x + 5x
−1 → min, x > 0
Solution: Observe that
|x|→+∞
lim f (x) = +∞ and lim
|x|↓+0
f (x) = +∞
Now, it is possible to choose M > 0 large enough that: f (x) > f (1) if x < 1/M or x > M.
Then we can add to the given problem the constraints 1 < M ≤ x ≤ M Conclusion:
f (x) → min, 1 < M ≤ x ≤ M has a point of global minimum, by the
Weierstrass theorem.
Weierstrass: example
Show that there exists a solution for the problem:
f (x) = x + 5x
−1 → min, x > 0 Solution: Observe that
|x|→+∞
lim f (x) = +∞ and lim
|x|↓+0
f (x) = +∞
Now, it is possible to choose M > 0 large enough that: f (x) > f (1) if x < 1/M or x > M.
Then we can add to the given problem the constraints 1 < M ≤ x ≤ M Conclusion:
f (x) → min, 1 < M ≤ x ≤ M has a point of global minimum, by the
Weierstrass theorem.
Weierstrass: example
Show that there exists a solution for the problem:
f (x) = x + 5x
−1 → min, x > 0 Solution: Observe that
|x|→+∞
lim f (x) = +∞ and lim
|x|↓+0
f (x) = +∞
Now, it is possible to choose M > 0 large enough that:
f (x) > f (1) if x < 1/M or x > M.
Then we can add to the given problem the constraints 1 < M ≤ x ≤ M
Conclusion:
f (x) → min, 1 < M ≤ x ≤ M has a point of global minimum, by the
Weierstrass theorem.
Weierstrass: example
Show that there exists a solution for the problem:
f (x) = x + 5x
−1 → min, x > 0 Solution: Observe that
|x|→+∞
lim f (x) = +∞ and lim
|x|↓+0
f (x) = +∞
Now, it is possible to choose M > 0 large enough that:
f (x) > f (1) if x < 1/M or x > M.
Then we can add to the given problem the constraints 1 < M ≤ x ≤ M Conclusion:
f (x) → min, 1 < M ≤ x ≤ M has a point of global minimum, by the
Unconstrained Optimization - summary
Problem
minimize f(x) subject to: x ∈R
The Two Theorems
•Weierstrass, existence:
•a functionf : [a, b]→Ron a closed interval is continuous
•a functionf :R→Ris coercive for minimization and continuous.
•Fermat : Assume that the functionf : (ˆx−,xˆ+)→Ris differentiable atx.ˆ Ifxˆ is a local extremum of problemf(x), then: f0(ˆx) = 0.
The Four-Step Method
The Four-Step Method for optimization
1 Model the problem and establish existence of global solutions (e.g. Weierstrass)
2 Write down the equation(s) of the first order necessary conditions (e.g. Fermat)
3 Investigate these equations
4 Write down the conclusion
Wait, What about the second order conditions?
•The second order conditions also form sufficient conditions to establish a global maximum or minimum for a problem with one variable – but the story becomes more complicated for functions with multiple variables.
•The four step method isuniversal. It works for all optimization problems that can be solved analytically.
The Four-Step Method
The Four-Step Method for optimization
1 Model the problem and establish existence of global solutions (e.g. Weierstrass)
2 Write down the equation(s) of the first order necessary conditions (e.g. Fermat)
3 Investigate these equations
4 Write down the conclusion
Wait, What about the second order conditions?
•The second order conditions also form sufficient conditions to establish a global maximum or minimum for a problem with one variable – but the story becomes more complicated for functions with multiple variables.
The Four-Step Method: example
Using the four-step method, solve the problem:
f (x) = x + 5x
−1 → min, x > 0
Solution:
1 lim
|x|→+∞f(x) = +∞and lim
|x|↓+0f(x) = +∞
and so existence of a global solutionxˆ follows, using Weierstrass theorem
2 Fermat: f0(x) = 0→1−5x−2= 0
3 x=√
5(note thatx=−√
5 contradictsx >0)
4 xˆ=√ 5
The Four-Step Method: example
Using the four-step method, solve the problem:
f (x) = x + 5x
−1 → min, x > 0 Solution:
1 lim
|x|→+∞f(x) = +∞and lim
|x|↓+0f(x) = +∞
and so existence of a global solutionxˆ follows, using Weierstrass theorem
2 Fermat: f0(x) = 0→1−5x−2= 0
3 x=√
5(note thatx=−√
5 contradictsx >0)
4 xˆ=√ 5
The Four-Step Method: example
Using the four-step method, solve the problem:
f (x) = x + 5x
−1 → min, x > 0 Solution:
1 lim
|x|→+∞f(x) = +∞and lim
|x|↓+0f(x) = +∞
and so existence of a global solutionxˆ follows, using Weierstrass theorem
2 Fermat: f0(x) = 0→1−5x−2= 0
3 x=√
5(note thatx=−√
5 contradictsx >0)
4 xˆ=√ 5
The Four-Step Method: example
Using the four-step method, solve the problem:
f (x) = x + 5x
−1 → min, x > 0 Solution:
1 lim
|x|→+∞f(x) = +∞and lim
|x|↓+0f(x) = +∞
and so existence of a global solutionxˆ follows, using Weierstrass theorem
2 Fermat: f0(x) = 0→1−5x−2= 0
3 x=√
5(note thatx=−√
5 contradictsx >0)
4 xˆ=√ 5
The Four-Step Method: example
Using the four-step method, solve the problem:
f (x) = x + 5x
−1 → min, x > 0 Solution:
1 lim
|x|→+∞f(x) = +∞and lim
|x|↓+0f(x) = +∞
and so existence of a global solutionxˆ follows, using Weierstrass theorem
2 Fermat: f0(x) = 0→1−5x−2= 0
3 x=√
5(note thatx=−√
5 contradictsx >0)
4 xˆ=√ 5
The Four-Step Method: In-class assignment
Using the four-step method, solve the problem:
f (x) = x
x
2+ 1 max
The Four-Step Method for optimization
1 Model the problem and establish existence of global solutions (e.g. Weierstrass)
2 Write down the equation(s) of the first order necessary conditions (e.g. Fermat)
3 Investigate these equations
4 Write down the conclusion
The Four-Step Method: In-class assignment
Using the four-step method, solve the problem:
f (x) = x
x
2+ 1 max
The Four-Step Method for optimization
1 Model the problem and establish existence of global solutions (e.g. Weierstrass)
2 Write down the equation(s) of the first order necessary conditions (e.g. Fermat)
3 Investigate these equations
4 Write down the conclusion
The Four-Step Method: In-class assignment Using the four-step method, solve the problem:
f (x) = x
x
2+ 1 max
Solution:
1 lim
|x|→+∞f(x) = 0
There exists a numberx¯ withf(x)>0(e.g. x¯= 2, f(¯x) =15). Then we could take a large numberN, such that for x0 > N andx0<−N, f(x0)< f(¯x). Therefore (as we are maximizing), we can find the maximum off(x)on the closed interval[−N, N], and thus by the Weierstrass theorem there exists a global maximumx.ˆ
2 Fermat: f0(x) = 0→ x2+1−x(2x)x2+1 = 0
3 x2+ 1−2x2= 0→x2= 1→x=±1
Compare values off at the candidate solutions 1 and -1: f(−1) =−12 andf(1) = 12
4 xˆ= 1
The Four-Step Method: In-class assignment Using the four-step method, solve the problem:
f (x) = x
x
2+ 1 max Solution:
1 lim
|x|→+∞f(x) = 0
There exists a numberx¯ withf(x)>0(e.g. x¯= 2, f(¯x) =15). Then we could take a large numberN, such that for x0 > N andx0<−N, f(x0)< f(¯x).
Therefore (as we are maximizing), we can find the maximum off(x)on the closed interval[−N, N], and thus by the Weierstrass theorem there exists a global maximumx.ˆ
2 Fermat: f0(x) = 0→ x2+1−x(2x)x2+1 = 0
3 x2+ 1−2x2= 0→x2= 1→x=±1
Compare values off at the candidate solutions 1 and -1: f(−1) =−12 andf(1) = 12
4 xˆ= 1
The Four-Step Method: In-class assignment Using the four-step method, solve the problem:
f (x) = x
x
2+ 1 max Solution:
1 lim
|x|→+∞f(x) = 0
There exists a numberx¯ withf(x)>0(e.g. x¯= 2, f(¯x) =15). Then we could take a large numberN, such that for x0 > N andx0<−N, f(x0)< f(¯x).
Therefore (as we are maximizing), we can find the maximum off(x)on the closed interval[−N, N], and thus by the Weierstrass theorem there exists a global maximumx.ˆ
2 Fermat: f0(x) = 0→ x2+1−x(2x)x2+1 = 0
3 x2+ 1−2x2= 0→x2= 1→x=±1
Compare values off at the candidate solutions 1 and -1: f(−1) =−12 andf(1) = 12
4 xˆ= 1
The Four-Step Method: In-class assignment Using the four-step method, solve the problem:
f (x) = x
x
2+ 1 max Solution:
1 lim
|x|→+∞f(x) = 0
There exists a numberx¯ withf(x)>0(e.g. x¯= 2, f(¯x) =15). Then we could take a large numberN, such that for x0 > N andx0<−N, f(x0)< f(¯x).
Therefore (as we are maximizing), we can find the maximum off(x)on the closed interval[−N, N], and thus by the Weierstrass theorem there exists a global maximumx.ˆ
2 Fermat: f0(x) = 0→ x2+1−x(2x)x2+1 = 0
3 x2+ 1−2x2= 0→x2= 1→x=±1
Compare values off at the candidate solutions 1 and -1: f(−1) =−12 andf(1) = 12
4 xˆ= 1
The Four-Step Method: In-class assignment Using the four-step method, solve the problem:
f (x) = x
x
2+ 1 max Solution:
1 lim
|x|→+∞f(x) = 0
There exists a numberx¯ withf(x)>0(e.g. x¯= 2, f(¯x) =15). Then we could take a large numberN, such that for x0 > N andx0<−N, f(x0)< f(¯x).
Therefore (as we are maximizing), we can find the maximum off(x)on the closed interval[−N, N], and thus by the Weierstrass theorem there exists a global maximumx.ˆ
2 Fermat: f0(x) = 0→ x2+1−x(2x)x2+1 = 0
4 xˆ= 1
The Four-Step Method: In-class assignment Using the four-step method, solve the problem:
f (x) = x
x
2+ 1 max Solution:
1 lim
|x|→+∞f(x) = 0
There exists a numberx¯ withf(x)>0(e.g. x¯= 2, f(¯x) =15). Then we could take a large numberN, such that for x0 > N andx0<−N, f(x0)< f(¯x).
Therefore (as we are maximizing), we can find the maximum off(x)on the closed interval[−N, N], and thus by the Weierstrass theorem there exists a global maximumx.ˆ
2 Fermat: f0(x) = 0→ x2+1−x(2x)x2+1 = 0
3 x2+ 1−2x2= 0→x2= 1→x=±1
Compare values off at the candidate solutions 1 and -1:
Two or more variables without constraints
Historical remark: it took no less than two centuries before the inventions of derivatives by Newton and Leibniz for functions with one variable, was extended to functions with more variables.
The conclusion? The definition for functions with n variables can be given in exactly the same way as functions of one variable! (provided we use the approximation definition and make use of vectors)
f
0(x) =
δf (ˆ x)
δx
1, ..., δf (ˆ x δx
nTwo or more variables without constraints
Historical remark: it took no less than two centuries before the inventions of derivatives by Newton and Leibniz for functions with one variable, was extended to functions with more variables.
The conclusion? The definition for functions with n variables can be given in exactly the same way as functions of one variable! (provided we use the approximation definition and make use of vectors)
f
0(x) =
δf (ˆ x)
δx
1, ..., δf (ˆ x δx
nTwo or more variables without constraints
Historical remark: it took no less than two centuries before the inventions of derivatives by Newton and Leibniz for functions with one variable, was extended to functions with more variables.
The conclusion? The definition for functions with n variables can be given in exactly the same way as functions of one variable! (provided we use the approximation definition and make use of vectors)
f
0(x) =
δf(ˆ x)
δx
1, ..., δf (ˆ x δx
nUnconstrained Optimization - two or more variables
Problem
f(x)→extr withxann-variable vector
The Two Theorems
•Weierstrass, existence:
•a continuous function f on a compact set in Rn attains its global maxima and minima
•a continuous function f :Rn→Ris coercive (for minimization) if lim
|x|→+∞f(x) = +∞. A continuous functionf :Rn→Rthat is coercive for minimization has a global minimum.
•Fermat : Assume thatf :Un(ˆx,¯)→Ris differentiable atx. Ifˆ xˆis a local
The Four-Step Method: In-class assignment
Using the four-step method, solve the problem:
f (x) = |x|
2= x
21+ x
22→ min, x ∈ R
2The Four-Step Method for optimization
1 Model the problem and establish existence of global solutions (e.g. Weierstrass)
2 Write down the equation(s) of the first order necessary conditions (e.g. Fermat)
3 Investigate these equations
4 Write down the conclusion
The Four-Step Method: In-class assignment
Using the four-step method, solve the problem:
f (x) = |x|
2= x
21+ x
22→ min, x ∈ R
2The Four-Step Method for optimization
1 Model the problem and establish existence of global solutions (e.g. Weierstrass)
2 Write down the equation(s) of the first order necessary conditions (e.g. Fermat)
3 Investigate these equations
4 Write down the conclusion
A puzzle: Ice cream on the beach
Two ice cream stands on the beach
There is a 200 meter stretch of beach. Customers are uniformly distributed over the beach. Because the sand is hot, they will always go to the nearest ice cream stand.
Question: Should the town council of a seaside resort tell the sellers of ice cream on its beach where to stand? Compare:
•Sellers choose location
•Prescribed location to the sellers
Using the four-step method, solve the problem:
The Four-Step Method for optimization
Unconstrained Optimization - alternative approach
Second Order Necessary Conditions
Ifx∗ is a local minimizer off(x)and∇2f(x)is continuously differentiable in an open neighbourhood ofx∗, then
∇f(x∗) =0
∇2f(x∗)is positivesemi definite
Second Order Sufficient Conditions
Suppose that∇2f(x)is continuously differentiable in an open neighbourhood of x∗. If the following two conditions are satisfied, thenx∗ is a local minimum of f(x).
∇f(x∗) =0
∇2f(x∗)ispositive definite
Optimization with Equality Constraints
Equality Constrained Optimization
Problem
minimize f0(x)
subject to: fi(x) = 0∀i= 1,2, . . . m x ∈Rn
Equality Constrained Optimization
Example
minimize 2x21+x22 subject to: x1+x2 = 1
•Let us first consider the unconstrained case
•Differentiate with respect tox1andx2
∂f(x1, x2)
∂x1
= 4x1
∂f(x1, x2)
∂x2 = 2x2
Equality Constrained Optimization
•Let us penalize ourselves for not satisfying the constraint
•This gives
L(x1, x2, λ1) = 2x21+x22+λ1(1−x1−x2)
•This is known as theLagrangianof the problem
•Try to adjust the valueλ1so we use just the right amount of resource
λ1= 0→get solutionx1=x2= 0,1−x1−x2= 1 λ1= 1→get solutionx1= 14, x2=12,1−x1−x2= 14 λ1= 2→get solutionx1= 12, x2= 1,1−x1−x2=−12 λ1= 43 →get solutionx1= 13, x2=23,1−x1−x2= 0
Equality Constrained Optimization
•Let us penalize ourselves for not satisfying the constraint
•This gives
L(x1, x2, λ1) = 2x21+x22+λ1(1−x1−x2)
•This is known as theLagrangianof the problem
•Try to adjust the valueλ1so we use just the right amount of resource λ1= 0→get solutionx1=x2= 0,1−x1−x2= 1
λ1= 1→get solutionx1= 14, x2=12,1−x1−x2= 14 λ1= 2→get solutionx1= 12, x2= 1,1−x1−x2=−12 λ1= 43 →get solutionx1= 13, x2=23,1−x1−x2= 0
Equality Constrained Optimization
•Let us penalize ourselves for not satisfying the constraint
•This gives
L(x1, x2, λ1) = 2x21+x22+λ1(1−x1−x2)
•This is known as theLagrangianof the problem
•Try to adjust the valueλ1so we use just the right amount of resource λ1= 0→get solutionx1=x2= 0,1−x1−x2= 1
λ1= 1→get solutionx1= 14, x2= 12,1−x1−x2= 14
λ1= 2→get solutionx1= 12, x2= 1,1−x1−x2=−12 λ1= 43 →get solutionx1= 13, x2=23,1−x1−x2= 0
Equality Constrained Optimization
•Let us penalize ourselves for not satisfying the constraint
•This gives
L(x1, x2, λ1) = 2x21+x22+λ1(1−x1−x2)
•This is known as theLagrangianof the problem
•Try to adjust the valueλ1so we use just the right amount of resource λ1= 0→get solutionx1=x2= 0,1−x1−x2= 1
λ1= 1→get solutionx1= 14, x2= 12,1−x1−x2= 14 λ1= 2→get solutionx1= 12, x2= 1,1−x1−x2=−12
λ1= 43 →get solutionx1= 13, x2=23,1−x1−x2= 0
Equality Constrained Optimization
•Let us penalize ourselves for not satisfying the constraint
•This gives
L(x1, x2, λ1) = 2x21+x22+λ1(1−x1−x2)
•This is known as theLagrangianof the problem
•Try to adjust the valueλ1so we use just the right amount of resource λ1= 0→get solutionx1=x2= 0,1−x1−x2= 1
λ1= 1→get solutionx1= 14, x2= 12,1−x1−x2= 14 λ1= 2→get solutionx1= 12, x2= 1,1−x1−x2=−12 λ1= 43 →get solutionx1= 13, x2=23,1−x1−x2= 0
Equality Constrained Optimization:
The Lagrange multiplier rule
Lagrange multiplier rule
Given a problemf0(x)→extr,fi(x) = 0,,i≤i≤m.
Assume that this problem is smooth atxˆ in the following sense. A function f0:Un(ˆx, )→Ris differentiable atˆxand the functions
fi:Un(ˆx, )→R,1≤i≤m, are continuously differentiable atx.ˆ
Ifˆxis a point of local extremum of this problem, then it is a stationary point of the Lagrange function of the problem for a suitable nonzero selection of Lagrange multipliersλ∈(Rm+1)0, that is:
Lx(ˆx, λ) = 0Tn ⇐⇒Pm
i=0λifi0(ˆx) = 0Tn ⇐⇒Pm i=0λiδfi
δxj(ˆx) = 0,1≤j≤n
To remember it, you can write:
The Lagrange multiplier rule
A few remarks:
•The clever idea behind the Lagrange method is to reverse the order used in Fermat: differentiate first and eliminate after
•The secret of its success lies in the idea of reducing the main task, anonlinear elimination problem, to an easier task, alinear elimination problem
•In many applications, we will not need to values of the lagrange multipliers themselves.
•The lagrange multiplier rule is a necessary condition – using the four-step method you do not need other sufficient conditions.
The Lagrange multiplier rule - in class exercise
Solve , for a given constant a > 0, the problem:
f
0(x) = x
1x
2→ max, f
1(x) = x
21+ x
22− a
2= 0, x
i> 0, i = 1, 2
Equality Constrained Optimization
Assume x
∗minimizes the following
minimize f (x)
subject to: h
i(x) = 0 ∀i = 1, 2, . . . m x ∈ R
nThe following two cases are possible:
1 The vectors∇h1(x∗),∇h2(x∗), . . . ,∇hm(x∗)are linearly dependent
2 There exists a vectorλ∗ such that
∂L(x∗,λ∗)
∂x1
= ∂L(x∗,λ∗)
∂x2
= ∂L(x∗,λ∗)
∂x3
=, . . . ,=∂L(x∗,λ∗)
∂xn
= 0
∂L(x∗,λ∗) ∂L(x∗,λ∗) ∂L(x∗,λ∗) ∂L(x∗,λ∗)
Case 1: Example
Example
minimize x1+x2+x23 subject to: x1= 1 x21+x22= 1
•The minimum is achieved atx1= 1, x2= 0, x3= 0
•The Lagrangian is:
L(x1, x2, x3, λ1, λ2) =x1+x2+x23+λ1(1−x1) +λ2(1−x21−x22)
•Observe that:
∂L(1,0,0, λ1, λ2)
Case 2: Example
Example
minimize 2x21+x22 subject to: x1+x2 = 1
•The Lagrangian is:
L(x1, x2, λ1) = 2x21+x22+λ1(1−x1−x2)
•Solve for the following:
∂L(x∗1, x∗2, λ∗1
∂x1
) = 4x∗1−λ∗1= 0
∂L(x∗1, x∗2, λ∗1
∂x2 ) = 2x∗2−λ∗1= 0
Case 2: Example continued
•Solving this system of equations yieldsx∗1= 13, x∗2=23, λ∗1= 43
•Is this a minimum or a maximum?
Graphically
x
1x
2x1+x2= 1 1
1
Graphically
x
1x
2x1+x2= 1 1
x∗1=13 1
x∗2=23 ∇f(x∗) =λ∗∇h(x∗)
Geometric Interpretation
•Consider the gradients off andhat the optimal point
•They must point in the same direction, though they may have different lengths
∇f(x∗) =λ∗∇h(x∗)
•Along with feasibility ofx∗, is the condition ∇L(x∗,λ∗) = 0
•From the example, atx∗1=13, x∗2= 23, λ∗1= 43
∇f(x∗1, x∗2) =h
4x∗1 2x∗2 i
=h
4 3
4 3
i
∇h1(x∗1, x∗2) =h
1 1 i
Geometric Interpretation
•∇f(x)points in the direction of steepest ascent
•−∇f(x)points in the direction of steepest descent
•In two dimensions:
•∇f(xo)is perpendicular toalevel curve off
•∇hi(xo)is perpendicular tothelevel curvehi(xo) = 0
Equality, Inequality Constrained Optimization
Inequality Constraints
General Problem
maximize f(x)
subject to: gi(x) ≤0 (µi) ∀i∈I hj(x) = 0 (λj) ∀i∈J
•Given a feasible solutionxo, the set ofbindingconstraints is:
I ={i:gi(xo) = 0}
The Lagrangian
L(x, λ, µ) = f (x) +
m
X
i=1
µ
i(0 − g
i(x)) +
k
X
j=1
λ
j(0 − h
j(x))
Inequality Constrained Optimization Assume x
∗maximizes the following
maximize f (x)
subject to: g
i(x) ≤ 0 (µ
i) ∀i ∈ I h
j(x) = 0 (λ
j) ∀i ∈ J
The following two cases are possible:
1 ∇h1(x∗), . . . ,∇hk(x∗),∇g1(x∗), . . . ,∇gm(x∗)are linearly dependent
2 There exist vectorsλ∗ andµ∗such that
∇f(x∗)−
k
Xλj∇hj(x∗)−
m
Xµi∇gi(x∗) = 0
Inequality Constrained Optimization
•These conditions are known as the Karush-Kuhn-Tucker Conditions
•We look for candidate solutionsx∗ for which we can findλ∗ andµ∗
•Solve these equations using complementary slackness
•At optimality some constraints will be binding and some will be slack
•Slack constraints will have a correspondingµi of zero
•Binding constraints can be treated using the Lagrangian
Constraint qualification
KKT constraint qualification
∇gi(xo)fori∈I are linearly independent
Slater constraint qualification
•gi(x)fori∈I are convex functions
•A non boundary point exists: gi(x)<0fori∈I
Case 1 Example
The Problem
maximize x
subject to: y ≤(1−x)3 y ≥0
•Consider the global max: (x, y) = (1,0)
•After reformulation, the gradients are
∇f(x, y) = (1,0)
∇g1 = (3(x−1)2,1)
∇g2 = (0,−1)
Graphically
x y
1
1
Case 1 Example
We get:
"
1 0
#
− µ
1"
0 1
#
− µ
2"
0
−1
#
•Noµ1andµ2 exist such that:
∇f(x, y)−
2
X
i=1
µi∇gi(x, y) =0
Case 2 Example
The Problem
maximize −(x−2)2−2(y−1)2
subject to: x+ 4y ≤3
x ≥y
The Problem (Rearranged)
maximize −(x−2)2−2(y−1)2
subject to: x+ 4y ≤3
−x+y ≤0
Case 2 Example
•The Lagrangian is:
L(x1, y, µ1, µ2) =−(x−2)2−2(y−1)2+µ1(3−x−4y) +µ2(0 +x−y)
•This gives the following KKT conditions
∂L
∂x =−2(x−2)−µ1+µ2= 0
∂L
∂y =−4(y−1)−4µ1−µ2= 0 µ1(3−x−4y) = 0
µ2(x−y) = 0 µ , µ ≥0
Case 2 Example
We have two complementarity conditions → check 4 cases
1 µ1=µ2= 0→x= 2, y= 1
2 µ1= 0, x−y= 0→x= 43, µ2=−43
3 3−x−4y= 0, µ2= 0→x=53, y=13, µ1= 23
4 3−x−4y= 0, x−y= 0→x=35, y=35, µ1= 2225, µ2=−4825
Optimal solution is therefore x
∗=
53, y
∗=
13, f (x
∗, y
∗) = −
49Case 2 Example
We have two complementarity conditions → check 4 cases
1 µ1=µ2= 0→x= 2, y= 1
2 µ1= 0, x−y= 0→x= 43, µ2=−43
3 3−x−4y= 0, µ2= 0→x=53, y=13, µ1= 23
4 3−x−4y= 0, x−y= 0→x=35, y=35, µ1= 2225, µ2=−4825
Optimal solution is therefore x
∗=
53, y
∗=
13, f (x
∗, y
∗) = −
49Continued
The Problem
minimize (x−3)2+ (y−2)2 subject to: x2+y2 ≤5
x+ 2y ≤4 x, y ≥0
The Problem (Rearranged)
maximize −(x−3)2−(y−2)2 subject to: x2+y2 ≤5
x+ 2y ≤4
Inequality Example
•The gradients are:
∇f(x, y) = (6−2x,4−2y)
∇g1(x, y) = (2x,2y)
∇g2(x, y) = (1,2)
∇g3(x, y) = (−1,0)
∇g4(x, y) = (0,−1)
Inequality Example
•Consider the point(x, y) = (2,1)
It is feasibleI ={1,2}
•This gives
"
2 2
#
−µ1
"
4 2
#
−µ2
"
1 2
#
=
"
0 0
#
•µ1=13, µ2= 23 satisfy this
Sufficient condition
General Problem
maximize f(x)
subject to: gi(x) ≤0 ∀i∈I
Theorem
Iff(x)is concave andgi(x)fori∈Iare convex functions then a feasible KKT point is optimal
•An equality constraint is equivalent to two inequality constraints:
hj(x) = 0⇔hj(x)≤0and −hj(x)≤0
•The corresponding two nonnegative multipliers may be combined to one free one
Equality constraints
General Problem
maximize f(x)
subject to: gi(x) ≤0 ∀i∈I hj(x) = 0 ∀j∈J
•Letxobe a feasible solution
•As before,I={i:gi(xo) = 0}
•Assume constraint qualification holds
Equality constraints
KKT Necessary Optimality Conditions
Ifxo is a local maximum, there exist multipliersµi≥0∀i∈Iandλj ∀j∈J such that
∇f(xo)−X
i∈I
µi∇gi(xo)−X
j
λj∇hj(xo) =0
KKT Sufficient Optimality Conditions
Iff(x)is concave,gi(x)∀i∈Iare convex functions andhj ∀j∈J are affine then a feasible KKT point is optimal
KKT Conditions - Summary
General Problem
maximize f(x)
subject to: gi(x) ≤0 ∀i∈I hj(x) = 0 ∀j∈J
KKT conditions
∇f(xo)−P
iµi∇gi(xo)−P
jλj∇hj(xo) =0
µigi(xo) = 0 ∀i∈I µi ≥0 ∀i∈I
o
Alternative Formulation
General Problem
maximize f(x) subject to: g(x) ≤0
h(x) = 0
KKT Conditions
∇f(xo)−µ∇g(xo)−λ∇h(xo) =0 µg(xo) =0 µ ≥0 xo feasible
Class Exercise 1
The Problem
maximize ln(x+ 1) +y subject to: 2x+y ≤3
x, y ≥0
Class Exercise 2
The problem
minimize x2+y2 subject to: x2+y2 ≤5
x+ 2y = 4 x, y ≥0
Class Exercise 3
Write the KKT conditions for
maximize cTx subject to: Ax ≤b
x ≥0
Richard M. Lusby
DTU Management Engineering, Technical University of Denmark
Building 424, Room 208 rmlu@dtu.dk
2800 Kgs. Lyngby, Denmark phone +45 4525 3084 http://www.man.dtu.dk