Lecture7[1]
Lecture7[1]
Introduction to Optimization
28 Jan 2025
Recap
1 / 28
References
• https://stanford.edu/∼boyd/cvxbook/bv cvxbook.pdf
• https://web.stanford.edu/class/msande310/310trialtext.pdf
• Chapter 5 (Vector Calculus)
• https://indrag49.github.io/Numerical-Optimization/index.html
• https://slds-lmu.github.io/website optimization/
• Essence of Calculus
• NPTEL Course
2 / 28
Unconstrained (Uni-variate and Discrete)
Maximizing profit
• How many units of goods to produce?
• Cost of producing x units is c( x )
• Profit from selling x units is p( x )
• x ∈ {0, 1, 2, . . .}
• Optimization problem to minimize cost
max c( x ) − p( x )
x
3 / 28
Unconstrained Optimization (Uni-variate and Continuous)
• Maximize profit
• Distance traveled is x, where x ∈ R
•
f ( x ) = 4x2 − 10x
4 / 28
Unconstrained Optimization (Multi-variate)
• Maximize profit
• Distance traveled
is x1 and time taken
x
x2 where x = 1 ∈ R2
x2
•
5 / 28
Supervised Learning
6 / 28
Supervised Learning
6 / 28
Supervised Learning
1
min
w,b n ∑(yi − w1 xi1 − w2 xi2 − b)2
i
6 / 28
Supervised Learning
7 / 28
Supervised Learning
7 / 28
Supervised Learning
7 / 28
Supervised Learning
8 / 28
Supervised Learning
1 1
w11 . . . w14
• w1 = . .. ..
.. . .
1
w31 . . . w34 1
8 / 28
Unsupervised Learning
min ∥ A − UV T ∥
U,V
9 / 28
Unconstrained Optimization
min f ( x )
x
10 / 28
Constrained Optimization
Knapsack Problem
maxxi v T x s.t. w T x ≤ W
• n items
v1
• Value of item i: vi , v = ...
vn
w1
• ..
Weight of item i: wi , w = .
wn
• Maximize value under weight constraints
W
x1
• ..
xi ∈ {0, 1} inclusion of i, x = .
xn
11 / 28
Max-Flow Problem
10
s a
15
5 5
b t
Given a network G = (V, E, s, t, c) 10
• V: set of vertices • Flow at every edge
• E: set of edges ▶ f sa ≤ 10, f sb ≤ 5, f ab ≤ 5, f bq ≤ 10
etc
• s: source
• At node a, inflow = outflow
• t: sink (target) ▶ f sa = f ab + f at
• c: cost for every edge • At node b, inflow = outflow
▶ f sb + f ab = f bt
12 / 28
Max-Flow Problem
max ( f sa + f sb )
f
Subject to:
f sa = f at + f ab
f sb = f bt + f ab
12 / 28
Max-Flow Problem
max ∑ xsj
j ∈V
Subject to:
∑ x ji = ∑ xij , ∀i ∈ V \ {s, t}
j∈V; ji ∈ E j∈V; ij∈ E
12 / 28
Supervised Learning
13 / 28
Supervised Learning
Regularization as constrained optimization
• f ( x ) = w1 x18 + w2 x17 + . . . + b
• f ( x ) = 0.x18 + 0.x17 + . . . + w1 x3 + w2 x2 + w3 x + b (Sparser)
14 / 28
Supervised Learning
Lasso regression adds a penalty on the L1 norm of the coefficients. The regularized
optimization problem is:
!
m
min
w
∑ ( y i − x i w )2 subject to ∥ w ∥1 ≤ λ
i =1
where:
• ∥w∥1 = ∑nj=1 |w j | is the L1 norm of the weight vector w,
• λ is the regularization parameter.
15 / 28
Supervised Learning
16 / 28
Supervised Learning
1
min ∥w∥2
w,b 2
yi (w T xi + b) ≥ 1, ∀i = 1, 2, . . . , n
17 / 28
Supervised Learning
Margin
17 / 28
Unsupervised Learning
K-Means clustering as unconstrained optimization
18 / 28
Unsupervised Learning
18 / 28
Unsupervised Learning
The objective function is:
n K
min ∑ ∑ sik ∥xi − ck ∥2
C,S
i =1 k =1
where:
• C = {c1 , c2 , . . . , cK } clusters centers
• S = {sik }, where sik = 1 if point xi is assigned to cluster k, and sik = 0 otherwise,
• Cluster Assignment: Each data point must be assigned to exactly one cluster:
K
∑ sik = 1, ∀i = 1, 2, . . . , n
k =1
n K K
min ∑ ∑ sik ∥xi − ck ∥2 subject to ∑ sik = 1, sik ∈ {0, 1}
C,S
i =1 k =1 k =1
18 / 28
Constrained Optimization
min f (x)
x
s.t. gi (x) ≤ 0, i = 1, 2, . . . , m
h j (x) = 0, j = 1, 2, . . . , p
x∈S
19 / 28
Linear Programming
20 / 28
Quadratic Programming
21 / 28
Convexity
22 / 28
Convex Sets
A set C is convex if
• for all x1 , x2 in C
• the line segment joining x1 and x2 must be within C
▶ θx1 + (1 − θ ) x2 ∈ C, for any θ ∈ [0, 1]
22 / 28
Convex Sets
22 / 28
Convex Sets
22 / 28
Half-Spaces
• Hyperplane S = { x |wT x = b} is convex
▶ x1 , x2 ∈ S, θ ∈ [0, 1]
▶ Take a point x = θx1 + (1 − θ ) x2
▶ w T ( x ) = θw T x1 + (1 − θ )w T x2 = θb + (1 − θ )b = b
• Half-spaces S = { x | aT x ≤ b}, a ̸= 0 is convex
23 / 28
Norm Balls
S = { x |∥ x − xc ∥ ≤ r }
• x1 and x2 ∈ S, θ ∈ [0, 1]
• x = θx1 + (1 − θ ) x2
• ∥ x − xc ∥ = ∥θx1 + (1 − θ ) x2 − xr ∥
= ∥θ ( x1 − xr ) + (1 − θ )( x2 − xr )∥
≤ θ ∥ x1 − xr ∥ + (1 − θ )∥ x2 − xr ∥ ≤ r
24 / 28
Polyhedra
S = { x | a Tj x ≤ b j , j = 1 . . . m, ciT x = di , i = 1, . . . , p}
25 / 28
Convex Sets
• The set of points closer to one set than a given set i.e.,
25 / 28
Convex Functions
26 / 28
Convex Functions
A function f : Rn → R is called convex if its domain dom( f ) is a convex set and for
all x, y ∈ dom( f ) and λ ∈ [0, 1], the following inequality holds:
Also, f ” ( x ) ≥ 0 when x ∈ R
26 / 28
Convex Functions
26 / 28
Convex Optimization
min f (x)
x
s.t. gi (x) ≤ 0, i = 1, . . . , m,
h j (x) = 0, j = 1, . . . , p,
27 / 28
Categorization
28 / 28