Notes

Optimization

Mathematical optimization

Optimization arises everywhere.

But most of them are intractable.

Exception is the tractable Convex optimization.

Convex optimization

Problem definition (standard form)

minimize f0(x)subject to fi(x)0,i=1,...,mAx=bminimize \ f_0(x) \\ subject \ to \ f_i(x) \le 0, i=1,...,m \\ Ax=b
  • xRnx \in R^n
  • equality constraints are linear
  • f0,...,fmf_0, ..., f_m are convex.

Solvers

CVXPY

from cvxpy import *

x = Variable(n)
cost = sum_squares(A*x-b) + gamma*norm(x,1)
prob = Problem(Minimize(cost), [norm(x, "inf")<=1])
opt_val = prob.solve()
solution = x.value
python

Applications

Portfolio Optimization

Regression variation

Model fitting

Regularized loss minimization

  • Regression Problem
RnR{}R^n \rightarrow R\cup\{\infty\}
  • Regularized Loss

    m examples, each has n dimensions.

(1/m)inL(xi,yi,θ)+r(θ)(1/m)\sum_i^nL(x_i, y_i, \theta) + r(\theta)
  • λ>0\lambda > 0 scales regularization.
  • all lead to convex fitting problems.

Constructive Convex Analysis & DCP

Convex Optimization

Conic form

minimize cTxsubject to Ax=b, xKminimize\ c^Tx \\ subject\ to\ Ax=b,\ x\in K
  • xRnx \in R^n
  • KK is convex cone.
  • linear objective, equality constraints.

How to solve a convex optimization problem?

Curvature

  • convex (凹)
    • definition: f(θx+(1θ)y)θf(x)+(1θ)f(y)f(\theta x+(1-\theta)y) \le \theta f(x)+(1-\theta)f(y)
    • 2f(x)0\nabla^2f(x)\ge0
    • can be constructed using basic functions that are convex or concave, and using transformations that preserve convexity.
  • concave (凸)
    • f(x)-f(x) is convex
  • affine
    • both concave and convex.
    • has the form f(x)=aTx+bf(x) = a^Tx+b

Basic convex functions

  • xp, p1 or p0x^p,\ p\ge1\ or\ p\le 0
  • exe^x
  • xlogxxlogx
  • aT+ba^T+b, affine
  • xTPx, P0x^TPx,\ P\ge0
  • x||x||
  • max(x1,x2,..)max(x_1, x_2, ..)

Less basic ones:

  • x2y,y>0\frac {x^2} {y}, y>0, jointly convex for x and y.
  • xlog(x/y)xlog(x/y), jointly convex for x and y.
  • xTY1x, Y0x^TY^{-1}x,\ Y\ge0
  • log(ex1+ex2+...)log(e^{x_1}+e^{x_2}+...)
  • sum of largest k entries
  • λmax(X),X=XT\lambda_{max}(X), X=X^T

Basic concave functions

  • xp, 0p1x^p,\ 0 \le p\le 1
  • logxlogx
  • xTPx, P0x^TPx,\ P\le0
  • min(x1,x2,...)min(x_1, x_2, ...)

Less basic ones:

  • log det Xlog\ det\ X
  • λmin(X),X=XT\lambda_{min}(X), X=X^T

Calculus rules that keeps convexity

  • nonnegative scaling

  • sum

  • affine composition

  • pointwise maximum (non-differentiability)

  • general composition rule:

    h(f1(x),...,fk(x))h(f_1(x), ..., f_k(x)) is convex when hh is convex and for each ii:

    • hh is increasing in argument ii, and fif_i is convex, or
    • hh is decreasing in argument ii, and fif_i is concave, or
    • fif_i is affine

eg. show the following function is convex:

f(u,v)=(u+1)log(u+1min(u,v))f(u, v) = (u+1)log(\frac {u+1}{min(u,v)})

Constructive Convexity verification

view the function as an expression tree, and use the general composition rule to determine the convexity.

sufficient, but not necessary for convexity.

  • f(x)=1+x2f(x)=\sqrt{1+x^2} is convex, but can't be proved by Constructive Convexity verification.

Disciplined Convex Program (DCP)

framework for describing convex optimization problems based on constructive convex analysis.

Definition

a DCP has

  • zero or one objective with form
    • minimize {scalar convex expression} or
    • maximize {scalar concave expression}
  • zero or more constraints, with form
    • {convex expression} <= {concave expression} or
    • {concave expression} >= {convex expression} or
    • {affine expression} == {affine expression}

Expressions are formed from variables, constants, and functions have known convexity, monotonicity and sign properties.

Canonicalization

DCP is very easy to build a parser/analyzer, and be transformed to cone form, then solved by some generic solver.

CVXPY will raise error if the constraints not obey the DCP rules.

Type to search.