小写:
x
x
x 表示一维变量
粗体小写:
x
\mathbf{x}
x 表示n维向量
大写:
X
X
X 表示矩阵
1 凸函数的定义和例子
Def.1 如果函数
f
:
R
n
→
R
f:\mathbb{R}^n\rightarrow\mathbb{R}
f:Rn→R 的前域
d
o
m
f
\mathbf{dom} f
domf 是凸集, 且对于任意
x
,
y
∈
d
o
m
f
x,y\in\mathbf{dom} f
x,y∈domf 和任意
θ
∈
[
0
,
1
]
\theta\in[0,1]
θ∈[0,1] 下式成立, 那么
f
f
f 是凸函数:
f
(
θ
x
+
(
1
−
θ
)
y
)
≤
θ
f
(
x
)
+
(
1
−
θ
)
f
(
y
)
f(\theta x+(1-\theta) y) \leq \theta f(x) +(1-\theta) f(y)
f(θx+(1−θ)y)≤θf(x)+(1−θ)f(y)
- 几何解释: 任意两点间的线段都在这两点之间的 f f f 曲线之上.
- 严格凸函数 (strictly convex function): 上述定义中的 θ ∈ ( 0 , 1 ) \theta\in(0,1) θ∈(0,1) 和不等式符号改为小于号 < < <.
- 如果函数 f f f 是convex function, 那么 − f -f −f 是 concave function.
Examples for scalar x ∈ R x\in\mathbb{R} x∈R:
-
即是 convex 又是 concave:
仿射函数(affine function): f ( x ) = a x + b f(x)=ax+b f(x)=ax+b 对于任意 a , b ∈ R a,b\in\mathbb{R} a,b∈R. -
convex functions:
- 二次函数(quadratic function): f ( x ) = x 2 f(x)= x^2 f(x)=x2
- 指数函数(exponential function): f ( x ) = exp a x f(x)=\exp{ax} f(x)=expax 对于任意 a ∈ R a\in\mathbb{R} a∈R
- 幂函数(powers function): f ( x ) = x α f(x)=x^{\alpha} f(x)=xα, d o m f = R + + \mathbf{dom} f=\mathbb{R}_{++} domf=R++, 对于任意 α ≥ 1 \alpha\geq 1 α≥1 或 α ≤ 0 \alpha\leq 0 α≤0
- 绝对值的幂函数(powers of absolute value): f ( x ) = ∣ x ∣ p f(x)=|x|^p f(x)=∣x∣p 对于任意 p ≥ 1 p\geq 1 p≥1
- ReLu: f ( x ) = max { 0 , x } f(x)=\max\{0,x\} f(x)=max{0,x}
- 熵的负数(negative entropy): f ( x ) = x log x f(x)=x\log x f(x)=xlogx, d o m f = R + + \mathbf{dom} f=\mathbb{R}_{++} domf=R++
-
concave functions:
- 负二次函数(quadratic function): f ( x ) = − x 2 f(x)= -x^2 f(x)=−x2
- 幂函数(powers function): f ( x ) = x α f(x)=x^{\alpha} f(x)=xα, d o m f = R + + \mathbf{dom} f=\mathbb{R}_{++} domf=R++, 对于任意 α ∈ [ 0 , 1 ] \alpha\in [0,1] α∈[0,1]
- 对数函数(logarithm): f ( x ) = log x f(x)=\log x f(x)=logx , d o m f = R + + \mathbf{dom} f=\mathbb{R}_{++} domf=R++
- 熵(entropy): f ( x ) = − x log x f(x)=-x\log x f(x)=−xlogx, d o m f = R + + \mathbf{dom} f=\mathbb{R}_{++} domf=R++
- 负数部分: f ( x ) = min { 0 , x } f(x)=\min\{0,x\} f(x)=min{0,x}
上述没有强调前域的函数, 其前域为 d o m f = R \mathbf{dom} f=\mathbb{R} domf=R, 即整个实数集. 而 R + + \mathbb{R}_{++} R++ 为正实数集合(不包括 0).
Examples for vector x ∈ R n \mathbf{x}\in\mathbb{R}^n x∈Rn:
- 即是 convex 又是 concave:
仿射函数(affine function): f ( x ) = a T x + b f(\mathbf{x})=a^{T}\mathbf{x}+b f(x)=aTx+b 对于任意 a , b ∈ R n a,b\in\mathbb{R}^n a,b∈Rn. - convex functions:
- 范数函数( ℓ p \ell_p ℓp norms): f ( x ) = ∣ ∣ x ∣ ∣ p = ( ∣ x 1 ∣ p + . . . + ∣ x n ∣ p ) 1 / p f(\mathbf{x})=||\mathbf{x}||_p=(|x_1|^p+...+|x_n|^p)^{1/p} f(x)=∣∣x∣∣p=(∣x1∣p+...+∣xn∣p)1/p
- 平方和函数(sum of square/ square of ℓ 2 \ell_2 ℓ2 norm): f ( x ) = x 1 2 + . . . + x n 2 f(\mathbf{x})=x_1^2+...+x_n^2 f(x)=x12+...+xn2
- 极大值函数(max function): f ( x ) = max ( x ) = max { x 1 , . . . , x n } f(\mathbf{x})=\max(\mathbf{x})=\max\{x_1,...,x_n\} f(x)=max(x)=max{x1,...,xn}
- 平滑最大值函数(log-sum-exp function): f ( x ) = LSE ( x ) = log ( exp x 1 + . . . + exp x n ) f(\mathbf{x})=\textbf{LSE}(\mathbf{x})=\log(\exp x_1+...+\exp x_n) f(x)=LSE(x)=log(expx1+...+expxn)
Examples for matrix X ∈ R m × n X\in\mathbb{R}^{m\times n} X∈Rm×n:
-
即是 convex 又是 concave:
- 矩阵的迹(Trace): f ( X ) = t r ( X ) f(X)=tr(X) f(X)=tr(X), d o m f = { X : X ∈ R n × n } \mathbf{dom} f=\{X:X\in\mathbb{R}^{n\times n}\} domf={X:X∈Rn×n} (方阵)
- afftine function: f ( X ) = t r ( A T X ) + b = ∑ i = 1 m ∑ j = 1 n A i j X i j + b f(X)=tr(A^TX)+b=\sum_{i=1}^{m}\sum_{j=1}^n A_{ij}X_{ij}+b f(X)=tr(ATX)+b=∑i=1m∑j=1nAijXij+b 对于任意 A ∈ R m × n , b ∈ R A\in\mathbb{R}^{m\times n}, b\in\mathbb{R} A∈Rm×n,b∈R. 其中 t r ( A T X ) = < A , X > tr(A^T X)=<A,X> tr(ATX)=<A,X>, 内积.
-
convex functions:
- 最大的特征值(max eigenvalue): f ( X ) = λ m a x ( X ) f(X)=\lambda_{max}(X) f(X)=λmax(X), d o m f = S n \mathbf{dom} f=\mathbf{S}^n domf=Sn. (n维对称阵)
- 谱范数/最大奇异值(spectral norm/ maximum singular value): f ( X ) = ∣ ∣ X ∣ ∣ 2 = σ m a x ( X ) = ( λ m a x ( X T X ) ) 1 / 2 f(X)=||X||_2=\sigma_{max}(X)=(\lambda_{max}(X^TX))^{1/2} f(X)=∣∣X∣∣2=σmax(X)=(λmax(XTX))1/2
-
concave functions:
- 最小的特征值(min eigenvalue): f ( X ) = λ m i n ( X ) f(X)=\lambda_{min}(X) f(X)=λmin(X), d o m f = S \mathbf{dom} f=\mathbf{S} domf=S
- 对数行列式函数(log-determinant function): f ( X ) = log det ( X ) f(X)=\log \det (X) f(X)=logdet(X) , d o m f = S + + n \mathbf{dom} f=\mathbf{S}^n_{++} domf=S++n. (n维正定矩阵, positive definite matrix)
2. 如何判断凸函数
- 通过定义证明(或通过下面的方法1)
- 通过二阶条件(下面的方法3)
- 通过保留凸性的运算, 即 f f f 由 f 1 , . . . , f m f_1,...,f_m f1,...,fm 通过某些运算组成的, f i f_i fi 相对更容易判断其凹凸性(下面的方法5)
接下来介绍这些方法.
3. 判断凸函数的方法1
f
:
R
n
→
R
f:\mathbb{R}^n\rightarrow\mathbb{R}
f:Rn→R 是凸函数
⇔
\Leftrightarrow
⇔ 对于任意
x
∈
dom
f
\mathbf{x}\in \textbf{dom } f
x∈dom f 和
y
∈
R
n
\mathbf{y}\in\mathbb{R}^n
y∈Rn,
g
(
t
)
=
f
(
x
+
t
y
)
g(t)=f(\mathbf{x}+t\mathbf{y})
g(t)=f(x+ty) 是变量为
t
t
t 的凸函数,
dom
g
=
{
t
∣
x
+
t
y
∈
dom
f
}
\textbf{dom } g=\{t|\mathbf{x}+t\mathbf{y}\in\textbf{dom} f\}
dom g={t∣x+ty∈domf}.
这个方法称为 Restriction of a convex function to a line, 即
f
f
f 在某一条直线上的形状是否为凸. 可以用这个方法证明 log-determinant function 是凸函数.
4. 判断凸函数的方法2: 一阶条件 First-order condition
Def.2 如果
f
:
R
n
→
R
f:\mathbb{R}^n\rightarrow\mathbb{R}
f:Rn→R 可微 (differentiable), 那么
f
f
f 在点
x
∈
dom
f
\mathbf{x}\in\textbf{dom } f
x∈dom f 处的梯度存在, 为:
▽
f
(
x
)
=
(
∂
f
(
x
)
∂
x
1
,
.
.
.
,
∂
f
(
x
)
∂
x
n
)
∈
R
n
\triangledown f(\mathbf{x})=(\frac{\partial f(x)}{\partial x_1},...,\frac{\partial f(x)}{\partial x_n})\in\mathbb{R}^n
▽f(x)=(∂x1∂f(x),...,∂xn∂f(x))∈Rn
凸函数的一阶条件 (first-order convexity condition):
假设
f
(
x
)
f(\mathbf{x})
f(x) 可微, 且其前域为凸集.
-
f
f
f 是凸函数
⇔
\Leftrightarrow
⇔ 对于任意
x
,
y
∈
dom
f
\mathbf{x},\mathbf{y}\in\textbf{dom } f
x,y∈dom f 下式成立:
f ( y ) ≥ f ( x ) + ▽ f ( x ) T ( y − x ) f(\mathbf{y})\geq f(\mathbf{x})+\triangledown f(\mathbf{x})^T(\mathbf{y}-\mathbf{x}) f(y)≥f(x)+▽f(x)T(y−x)
右边的项是泰勒级数的一部分(Taylor series).
5. 判断凸函数的方法3: 二阶条件 Second-order condition
Def.3 如果
f
:
R
n
→
R
f:\mathbb{R}^n\rightarrow\mathbb{R}
f:Rn→R 一个二次可微 (twice differentiable), 那么
f
f
f 在点
x
∈
dom
f
\mathbf{x}\in\textbf{dom } f
x∈dom f 处的 Hessian 矩阵存在, 为:
H
=
▽
2
f
(
x
)
=
∂
2
f
(
x
)
∂
x
T
∂
x
=
{
∂
2
f
(
x
)
∂
x
i
∂
x
j
}
H=\triangledown^2 f(\mathbf{x})=\frac{\partial^2 f(x)}{\partial \mathbf{\mathbf{x}}^T \partial \mathbf{x}}=\{\frac{\partial^2 f(\mathbf{x})}{\partial x_i \partial x_j}\}
H=▽2f(x)=∂xT∂x∂2f(x)={∂xi∂xj∂2f(x)}
凸函数的二阶条件 (second-order convexity condition):
假设
f
(
x
)
f(\mathbf{x})
f(x) 二次可微, 且其前域为凸集.
-
f
f
f 是凸函数
⇔
\Leftrightarrow
⇔ 对于任意
x
∈
dom
f
\mathbf{x}\in\textbf{dom } f
x∈dom f, 有:
H = ▽ 2 f ( x ) ⪰ 0 H=\triangledown^2 f(\mathbf{x})\succeq 0 H=▽2f(x)⪰0 -
f
f
f 是严格凸函数
⇔
\Leftrightarrow
⇔ 对于任意
x
∈
dom
f
\mathbf{x}\in\textbf{dom } f
x∈dom f, 有:
H = ▽ 2 f ( x ) ≻ 0 H=\triangledown^2 f(\mathbf{x})\succ 0 H=▽2f(x)≻0
6. 判断凸函数的方法4: 利用上镜图(epigraph)
Def.4 函数
f
:
R
n
→
R
f:\mathbb{R}^n\rightarrow\mathbb{R}
f:Rn→R 的
α
\alpha
α-下水平集 (
α
\alpha
α-sublevel set) 为:
C
α
=
{
x
∈
dom
f
∣
f
(
x
)
≤
α
}
C_\alpha = \{\mathbf{x}\in \textbf{dom } f| f(\mathbf{x})\leq\alpha\}
Cα={x∈dom f∣f(x)≤α}
- f f f 为凸函数 ⇒ \Rightarrow ⇒ f f f 的下水平集为凸集. (无法反推)
Def.5 函数
f
:
R
n
→
R
f:\mathbb{R}^n\rightarrow\mathbb{R}
f:Rn→R 的上镜图(epigraph)为:
epi
f
=
{
(
x
,
t
)
∣
x
∈
dom
f
,
f
(
x
)
≤
t
}
\textbf{epi} f=\{(\mathbf{x}, t)|\mathbf{x}\in \textbf{dom } f, f(\mathbf{x})\leq t\}
epif={(x,t)∣x∈dom f,f(x)≤t}
即为
f
f
f 图像上方的全部区域.
- f f f 为凸函数 ⇔ \Leftrightarrow ⇔ epi f \textbf{epi} f epif 为凸集.
7. 判断凸函数的方法5: 保留凸性的运算(Operations that preserve convexity)
跟第二章中介绍的(集合的)运算类似. 由于一维变量的函数很好证明 (二阶导大于等于0即可), 这章主要考虑当输入变量是 n n n 维向量的情况.
-
非负乘法:
f ( x ) f(\mathbf{x}) f(x) 是凸函数且 α ≥ 0 \alpha\geq 0 α≥0 ⇒ \Rightarrow ⇒ α f ( x ) \alpha f(\mathbf{x}) αf(x) 是凸函数 -
加法:
f 1 ( x ) f_1(\mathbf{x}) f1(x) 和 f 2 ( x ) f_2(\mathbf{x}) f2(x) 是凸函数 ⇒ \Rightarrow ⇒ f 1 ( x ) + f 2 ( x ) f_1(\mathbf{x})+f_2(\mathbf{x}) f1(x)+f2(x) 是凸函数, 结论可扩展到无限个凸函数相加和积分形式 ∫ \int ∫. -
非负加权之和(nonnegative weighted sums):
f i ( x ) f_i(\mathbf{x}) fi(x)是凸函数且 α i ≥ 0 \alpha_i\geq 0 αi≥0 ( i = 1 , . . . , n ) (i=1,...,n) (i=1,...,n) ⇒ \Rightarrow ⇒ ∑ i n α i f i ( x ) \sum_i^n \alpha_i f_i(\mathbf{x}) ∑inαifi(x) 是凸函数, 同样结论可扩展到无限个凸函数相加和积分形式. -
composition with affine function:
f ( x ) f(\mathbf{x}) f(x) 是凸函数 ⇒ \Rightarrow ⇒ f ( A x + b ) f(A\mathbf{x}+b) f(Ax+b) 是凸函数 -
pointwise maximum:
f i ( x ) f_i(\mathbf{x}) fi(x)是凸函数 ( i = 1 , . . . , n ) (i=1,...,n) (i=1,...,n) ⇒ \Rightarrow ⇒ max i ∈ [ n ] { f i ( x ) } \max_{i\in[n]}\{f_i(\mathbf{x})\} maxi∈[n]{fi(x)} 是凸函数
f i ( x ) f_i(\mathbf{x}) fi(x)是凸函数 ( i = 1 , . . . , n ) (i=1,...,n) (i=1,...,n) ⇒ \Rightarrow ⇒ min i ∈ [ n ] { f i ( x ) } \min_{i\in[n]}\{f_i(\mathbf{x})\} mini∈[n]{fi(x)} 是concave
例子:
f ( x ) = max i ∈ [ m ] { a i T x + b i } f(\mathbf{x})=\max_{i\in[m]}\{a_i^T \mathbf{x}+b_i\} f(x)=maxi∈[m]{aiTx+bi} 是凸函数, 等价于求 A x + b A\mathbf{x}+b Ax+b 最大的元素, A ∈ R m × n A\in\mathbb{R}^{m\times n} A∈Rm×n 是由 a i a_i ai 组成, b b b 为 n 维向量, 由 b i b_i bi 组成.
最大的 r r r 个元素之和: f ( x ) = x [ 1 ] + x [ 2 ] + . . . + x [ r ] f(\mathbf{x})=x_{[1]}+x_{[2]}+...+x_{[r]} f(x)=x[1]+x[2]+...+x[r] 是凸函数 -
pointwise supremum :
f ( x , y ) f(\mathbf{x}, \mathbf{y}) f(x,y)对于每个 y ∈ A \mathbf{y}\in\mathcal{A} y∈A 是关于 x \mathbf{x} x 的凸函数 ⇒ \Rightarrow ⇒ g ( x ) = sup y ∈ A f ( x , y ) g(\mathbf{x})=\sup_{\mathbf{y}\in\mathcal{A}}f(\mathbf{x},\mathbf{y}) g(x)=supy∈Af(x,y) 是凸函数.
例子:
集合 C C C 的support function: S C ( x ) = sup y ∈ C y T x S_C(\mathbf{x})=\sup_{\mathbf{y}\in C} \mathbf{y}^T\mathbf{x} SC(x)=supy∈CyTx 是凸函数.
点 x \mathbf{x} x 与集合 C C C 之间最远的距离: f ( x ) = sup y ∈ C ∣ ∣ x − y ∣ ∣ f(\mathbf{x})=\sup_{\mathbf{y}\in C} ||\mathbf{x}-\mathbf{y}|| f(x)=supy∈C∣∣x−y∣∣ (任意norm 距离) 是凸函数. -
函数复合(Composition with scalar functions)
假设 f ( x ) = h ( g ( x ) ) f(\mathbf{x})=h(g(\mathbf{x})) f(x)=h(g(x)), 其中 g : R n → R g:\mathbb{R}^n\rightarrow\mathbb{R} g:Rn→R, h : R → R h:\mathbb{R}\rightarrow\mathbb{R} h:R→R:
g g g 是凸函数, h h h 是凸且非递减的函数 ⇒ \Rightarrow ⇒ f ( x ) f(\mathbf{x}) f(x)是凸函数
g g g 是concave函数, h h h 是凸且非递增的函数 ⇒ \Rightarrow ⇒ f ( x ) f(\mathbf{x}) f(x)是凸函数
例子:
f ( x ) = exp g ( x ) f(\mathbf{x})=\exp g(\mathbf{x}) f(x)=expg(x), 若 g 是凸函数, 那么 f 是凸函数. (因为 exp 是单调递增的凸函数)
f ( x ) = 1 / g ( x ) f(\mathbf{x})=1/g(\mathbf{x}) f(x)=1/g(x), 若 g 是 concave 且大于0, 那么 f 是凸函数. (因为当定义域大于0时, 1/x 是单调递减的凸函数). -
复合函数(对 g, h 没有维度约束)
假设 f ( x ) = h ( g ( x ) ) f(\mathbf{x})=h(g(\mathbf{x})) f(x)=h(g(x)), 其中 g : R n → R k g:\mathbb{R}^n\rightarrow\mathbb{R}^k g:Rn→Rk, h : R k → R h:\mathbb{R}^k\rightarrow\mathbb{R} h:Rk→R, 也就是 f ( x ) = h ( g 1 ( x ) , . . . , g k ( x ) ) f(\mathbf{x})=h(g_1(\mathbf{x}),...,g_k(\mathbf{x})) f(x)=h(g1(x),...,gk(x)):
对于全部 i ∈ [ k ] i\in[k] i∈[k], g i g_i gi 是凸函数, h h h 是凸函数且 h h h 对于第 i i i 维输入是非递减的函数 ⇒ \Rightarrow ⇒ f ( x ) f(\mathbf{x}) f(x)是凸函数
对于全部 i ∈ [ k ] i\in[k] i∈[k], g i g_i gi 是concave, h h h 是凸函数且 h h h 对于第 i i i 维输入是非递增的函数 ⇒ \Rightarrow ⇒ f ( x ) f(\mathbf{x}) f(x)是凸函数
对于全部 i ∈ [ k ] i\in[k] i∈[k], g i g_i gi 是affine, h h h 是凸函数 ⇒ \Rightarrow ⇒ f ( x ) f(\mathbf{x}) f(x)是凸函数
8. 拟凸函数(Quasiconvex function)
Def. 6 如果函数 f ( x ) f(\mathbf{x}) f(x) 的前域 dom f \textbf{dom } f dom f 是凸集且下水平集 C α C_\alpha Cα (对于任意 α \alpha α) 也是凸集, 那么 f f f 为拟凸函数.
- − f -f −f is quasiconcave ⇒ \Rightarrow ⇒ f f f is quasiconvex
- f f f is quasiconvex and quasiconcave ⇒ \Rightarrow ⇒ f f f is quasilinear
例子:
- ∣ x ∣ \sqrt{|x|} ∣x∣ is quasiconcave
- c e i l ( x ) = min { z ∈ Z : z ≥ x } ceil(x)=\min\{z\in \mathbb{Z}: z\geq x\} ceil(x)=min{z∈Z:z≥x} is quasilinear
- log ( x ) \log(x) log(x) is quasilinear on x > 0 x>0 x>0