optimization
optimization
J. Zico Kolter
1
Overview
• Introduction to mathematical programming problems
• Applications
• Applications
3
Formal definition
• Mathematical programs are problems of the form
minimize f (x)
x
subject to gi (x) ≤ 0 i = 1, . . . , m
– f : Rn → R is objective function
5
Overview
• Introduction to mathematical programming problems
• Applications
h(a)
b
h(ai) − bi
• Applications
10
Optimization problems
Semidefinite programming
Quadratic programming
Linear programming
10
Optimization problems
Semidefinite programming
Integer programming
Quadratic programming
Linear programming
10
Overview
• Introduction to mathematical programming problems
• Applications
x ∈ Rn
A ∈ Rm×n
Aij denotes the entry in the ith row and jth column
13
• Inner product: For x, y ∈ Rn
n
X
T
x y = hx, yi = x i yi
i=1
AA−1 = I = A−1 A
14
Overview
• Introduction to mathematical programming problems
• Applications
• Beautiful theory
16
Formal definition
minimize f (x)
x
subject to x ∈ C
17
Convex sets
• A set C is convex if, for a x, y ∈ C and θ ∈ [0, 1],
θx + (1 − θ)y ∈ C
• All of Rn : x, y ∈ Rn =⇒ θx + (1 − θ)y ∈ Rn
19
Convex functions
• A function f : Rn → R is convex if, for any x, y ∈ Rn and
θ ∈ [0, 1],
f (θx + (1 − θ)y) ≤ θf (x) + (1 − θ)f (y)
(y, f (y))
(x, f (x))
• f is concave if −f is convex
21
Examples
• Exponential: f (x) = exp(ax), [f 00 (x) = a2 exp(ax) ≥ 0∀x]
where fi convex, ∀i = 1, . . . , m
23
Convex optimization problems (again)
minimize f (x)
x
subject to gi (x) ≤ 0 i = 1, . . . , m
hi (x) = 0 i = 1, . . . , p
24
• Definition: a point x is globally optimal if x is feasible and
there is no feasible y such that f (y) < f (x)
R R
kx − zk2 = x − 1− x+ y
2kx − yk2 2kx − yk2 2
R
= (x − y) = R/2 < R
2kx − yk2 2
26
Example: least-squares
27
Example: Weber point
28
Example: linear programming
• General form of a linear program
minimize cT x
x
subject to Ax = b
Fx ≤ g
• You may have also seen this with just the inequality constraint
x ≥ 0 (these are equivalent, why?)
29
Example: quadratic programming
minimize xT Qx + rT x
x
subject to Ax = b
Fx ≤ g
30
Overview
• Introduction to mathematical programming problems
• Applications
minimize f (x)
x
subject to gi (x) ≤ 0 i = 1, . . . , m
hi (x) = 0 i = 1, . . . , p
32
• Local methods: Given some initial point x0 , repeatedly search
“nearby” points until finding a (feasible) solution x̂ that is
better than all it’s nearby points
33
Integer programming
minimize cT x
x
subject to Ax = b
Fx ≤ g
x∈Z
34
Overview
• Introduction to mathematical programming problems
• Applications
f (x)
∇x f (x) = 0
∂f (x)
(∇x f (x))i =
∂xi
37
How do we find ∇x f (x) = 0?
38
• Gradient descent: Take small steps in the direction of the
current (negative) gradient
f (x) f ′(x0)
x x0
39
• Newton’s method: Use root-finding algorithm to find solution
to (nonlinear) equation ∇x f (x) = 0
– Newton’s method: given g : R → R, find g(x) = 0 by iteration
f (x)
x←x−
f 0 (x)
40
Constrained optimization
• Now consider problem with constraints
minimize f (x)
x
subject to gi (x) ≤ 0 i = 1, . . . , m
– Example C = x ≥ 0,
41
• Barrier method: Approximate problem via unconstrained
optimization
m
X
minimize f (x) − t log(−gi (x))
x
i=1
42
Practically solving optimization problems
43
cvxpy
44
• Constrained Weber point, given ai ∈ R2 , i = 1, . . . , m
m
X
minimize kx − ai k2 , subject to x1 + x2 = 0
x
i=1
• cvxpy code
import cvxpy as cp
import cvxopt
n = 2
m = 10
A = cvxopt.normal(n,m)
x = cp.Variable(n)
f = sum([cp.norm(x - A[:,i],2) for i in range(m)])
constraints = [sum(x) == 0]
result = cp.Problem(cp.Minimize(f), constraints).solve()
print x.value
45
Take home points
46