Cvxpy - Convex - Optimization (tcmm2014, Slides)
Cvxpy - Convex - Optimization (tcmm2014, Slides)
1
Outline
Convex optimization
CVXPY
Image in-painting
Summary
Convex optimization 2
Convex optimization problem
minimize f0 (x)
subject to fi (x) ≤ 0, i = 1, . . . , m
Ax = b,
with variable x ∈ Rn
Convex optimization 3
Why convex optimization?
Convex optimization 4
How do you solve a convex problem?
Convex optimization 5
Outline
Convex optimization
CVXPY
Image in-painting
Summary
minimize c T x
subject to Ax = b
x ∈K
with variable x ∈ Rn
I K is convex cone
I x ∈ K is a generalized nonnegativity constraint
I linear objective, equality constraints
I special cases:
I K = Rn+ : linear program (LP)
I K = Sn+ : semidefinite program (SDP)
I general interface for solvers
Convex modeling languages 9
Outline
Convex optimization
CVXPY
Image in-painting
Summary
CVXPY 10
CVXPY
CVXPY 11
CVXPY solvers
I all open source
I CVXOPT (Vandenberghe, Dahl, Andersen)
I interior-point method
I in Python
I ECOS (Domahidi)
I interior-point method
I compact, library-free C code
I SCS (O’Donoghue)
I first-order method
I native support of exponential cone
I parallelism with OpenMP
CVXPY 12
CVXPY example
(constrained LASSO)
with variable x ∈ Rn
CVXPY 13
Outline
Convex optimization
CVXPY
Image in-painting
Summary
Image in-painting 14
Image in-painting
I a convex problem
Image in-painting 15
Example
Image in-painting 16
Image in-painting CVXPY code
Image in-painting 17
Example
Original Corrupted
Image in-painting 18
Example
Original Recovered
Image in-painting 19
Example (80% of pixels removed)
Original Corrupted
Image in-painting 20
Example (80% of pixels removed)
Original Recovered
Image in-painting 21
Outline
Convex optimization
CVXPY
Image in-painting
Summary
(LASSO)
minimize kAx − bk22 + γkxk1
with variable x ∈ Rn
x = Variable(n)
gamma = Parameter(sign="positive")
error = sum_squares(A*x-b)
regularization = gamma*norm(x,1)
prob = Problem(Minimize(error + regularization))
x_values = []
for val in numpy.logspace(-4, 2):
gamma.value = val
prob.solve()
x_values.append(x.value)
Convex optimization
CVXPY
Image in-painting
Summary
I variables are fi , sj
I φi convex flow cost functions
I ψj convex source cost functions
I can include constraints in φi , ψj
Single commodity flow 32
Matrix representation
class Node(object):
def __init__(self, cost):
self.source = Variable()
self.cost = cost(self.source)
self.edge_flows = []
def constraints(self):
"""The constraint net flow == 0."""
net_flow = sum(self.edge_flows) + self.source
return [net_flow == 0]
class Edge(object):
def __init__(self, cost):
self.flow = Variable()
self.cost = cost(self.flow)
Convex optimization
CVXPY
Image in-painting
Summary
Summary 41
Summary
Summary 42
Future work
Summary 43