Chapter 23. Optimization Algorithms
Recommended reading: 【Algorithms】 Algorithms and Machine Learning: Table of Contents
1. Overview
7. Others
1. Overview
⑴ Objective function
⑵ Constraints
⑶ Feasible solution
⑷ Local optimum, global optimum
2. Convex Optimization
⑴ Convex set: A set that contains every point on the line segment connecting any two points in the set
① Definition 1. A line segment between $x_1 \in \mathbb{R}^n$ and $x_2 \in \mathbb{R}^n$ is the set $L = {x \in \mathbb{R}^n \mid x = \theta x_1 + (1-\theta)x_2,\ \theta \in [0,1]}$.
② Definition 2. A convex set is a set $S \subseteq \mathbb{R}^n$ such that, for all $x_1, x_2 \in S$, the line segment $L$ between $x_1$ and $x_2$ is also contained in $S$.
③ Definition 3. Given $x_1, x_2, \ldots, x_n \in \mathbb{R}^n$ and scalars $\theta_1, \theta_2, \ldots, \theta_n \in \mathbb{R}$ such that $\theta_i \geq 0$ and $\sum_i \theta_i = 1$, the sum $\sum_i \theta_i x_i$ is a convex combination of the $x_i$.
④ Definition 4. The convex hull of a set $S$, denoted $\operatorname{Conv}(S)$, is the set of all convex combinations of elements in $S$.
○ $\operatorname{Conv}(S) = \lbrace \sum_i \theta_i x_i \mid x_i \in S,\ \theta_i \geq 0,\ \sum_i \theta_i = 1\rbrace$
⑤ Fact 1. $\operatorname{Conv}(S)$ is the smallest convex set containing $S$.
○ $\operatorname{Conv}(S)$ is convex (∵ for all $x,y \in \operatorname{Conv}(S)$ and $t \in [0,1]$, $(1-t)x + ty \in \operatorname{Conv}(S)$ (∵ the coefficients sum to $1$; definition of $\operatorname{Conv}(S)$)).
○ Let $C$ be a convex set containing $S$. Then every convex combination $x = \sum_i \lambda_i x_i$ of points in $S$ belongs to $C$ (∵ $x_i \in C$, and $\sum_i \lambda_i x_i$ can be constructed through successive line segment combinations).
⑥ Definition 5. A hyperplane is a subset of $\mathbb{R}^n$ of the form $H = {x \in \mathbb{R}^n \mid a^{\mathsf T}x = b,\ a \neq \mathbf{0},\ b \in \mathbb{R}}$.
⑦ Fact 2. A hyperplane is a convex set.
⑧ Definition 6. A half-space is the set $P_{\mathrm{hs}} = {x \in \mathbb{R}^n \mid a^{\mathsf T}x \leq b}$.
⑨ Fact 3. A half-space is convex.
⑩ Definition 7. A polyhedron is a set of the form:
○ $P = {x \mid a_j^{\mathsf T}x \leq b_j,\ a_j \neq \mathbf{0},\ b_j \in \mathbb{R},\ j = 1,2,\ldots,m,\ \text{and } c_i^{\mathsf T}x = d_i,\ c_i \neq \mathbf{0},\ d_i \in \mathbb{R},\ i = 1,\ldots,p}$
⑪ Definition 8. A polytope is a bounded polyhedron.
⑫ Definition 9. An infinity-norm ball is the set $B_\infty = {x \in \mathbb{R}^n \mid \lVert x \rVert_\infty \leq 1}$.
⑬ Fact 4. $B_\infty$ is convex, a polyhedron, and a polytope.
⑭ Definition 10. $(A,b,C,d)$ → hyperplane representation of the polyhedron.
⑮ Definition 11. A hyperbox is a set of the form:
○ $P_{\mathrm{hb}} = {x \in \mathbb{R}^n \mid L_i \leq x_i \leq u_i,\ i = 1,\ldots,n} = [L_1,u_1] \times \cdots \times [L_n,u_n]$
⑯ Definition 12. Convex function
○ A function for which ${(x,y) \mid y \geq f(x)}$ is a convex set. In other words, its graph curves upward.
○ In general, $\forall s_1,s_2 \in \mathcal{X},\ \forall \theta \in [0,1],\ o(\theta s_1 + (1-\theta)s_2) \leq \theta o(s_1) + (1-\theta)o(s_2)$.
⑵ Operations that preserve convexity: Intersection, Minkowski sum, affine (linear) transformation
① Type 1. Intersection (however, union does not preserve convexity)
② Type 2. $\max$, $\sup$
③ Type 3. The Minkowski sum ($\oplus$) of sets $S_1$ and $S_2$ is $S_1 \oplus S_2 = {x_1 + x_2 \mid x_1 \in S_1,\ x_2 \in S_2}$.
④ Type 4. Let $S$ be a set. Then the affine transformation of $S$ is $\widehat{S} = {Ax + b \mid x \in S}$.
⑤ Fact 1. If $S$ is convex, $\widehat{S}$ is convex.
⑥ Fact 2. $f$ is convex $\Rightarrow S_{f,\alpha} = {x \in \mathbb{R}^n \mid f(x) \leq \alpha}$ is convex. (The converse does not hold.)
Figure 1. A counterexample in which every sublevel set is convex, but the function $f$ itself is not convex
⑶ Convex optimization
① Definition 1. The case where $f$ is convex and $h$ is affine
② Definition 2. The case where $f_0$ is convex and the feasible set is a convex set
③ Property 1. Local minimum = global minimum
④ Property 2. Well-established algorithms are available: KKT (Karush–Kuhn–Tucker) and duality (dual, primal)
⑤ Application 1. An algorithm for determining whether a given point $x$ belongs to the zonotope $Z = \left(c, \langle g_1, \ldots, g_p \rangle\right)$.
⑥ Application 2. An algorithm for determining whether the zonotope $Z = \left(c, \langle g_1, \ldots, g_p \rangle\right) \subset \mathbb{R}^n$ intersects the set $P = \lbrace x \mid Hx \leq k\rbrace \subset \mathbb{R}^n$.
⑦ Application 3. An algorithm for determining whether the zonotope $Z = (c, \langle g_1, \ldots, g_p \rangle)$ is entirely contained within a given convex polygon $P$: Let $v_j$ be a point on the $j$-th edge of $P$, and let $n_j$ be the outward normal vector to that edge.
⑧ Application 4. Conservative overapproximation of a zonotope
3. Linear Programming
⑴ Linear programming (LP): The case where $f$ and $h$ in the convex optimization formulation above are affine functions
⑵ Quadratic programming (QP)
① $x$ is the decision variable vector, and $Q$ is a symmetric matrix.
② A QP with $Q \succeq 0$ is called a convex quadratic program: It can be expressed as an SDP.
③ A QP with $Q = 0$ is a linear program.
④ If the constraints also contain quadratic expressions, it is QCCP (quadratically constrained quadratic programming).
⑶ Cone programming (SOCP)
⑷ Semidefinite programming (SDP)
① Quadratic forms of matrices: PD, PSD, ND, NSD
○ PSD $\Leftrightarrow F(x) \succeq 0 \Leftrightarrow \forall v,\ v^{\mathsf T}F(x)v \geq 0$
○ Although it is impossible to check every $v$ individually, the condition can be determined through a finite computation using eigendecomposition or matrix factorization.
② Example 1. SDP for continuous hybrid systems
③ Example 2. SDP for discrete hybrid systems
④ Use an interior-point method with an auxiliary problem.
○ Assume that the matrix is positive definite and repeatedly solve the following problem.
○ As the matrix eigenvalues approach $0$, $-\log\det F(x)$ increases, preventing the solution from crossing the boundary.
○ As $\mu \to 0$, the solution approaches the optimal solution of the original SDP: Use Newton’s method.
○ Polynomial-time complexity is guaranteed under appropriate assumptions.
4. Polynomial Optimization
⑴ Polynomial
① Definition 1. Given $\alpha \in \mathbb{N}^n$, a monomial in $n$ variables is a function $m_\alpha : \mathbb{R}^n \to \mathbb{R}$ defined as $m_\alpha(x) := x^\alpha := x_1^{\alpha_1}\cdots x_n^{\alpha_n}$.
○ Example: If $\alpha = (1,2)$, then $m_\alpha(x) = x_1x_2^2$.
② Definition 2. The degree of a monomial is expressed as $\deg m_\alpha := \sum_{i=1}^n \alpha_i$.
○ Example: The degree of $x_1x_2^2$ is $3$.
③ Definition 3. A polynomial in $n$ variables is a function $p : \mathbb{R}^n \to \mathbb{R}$ defined as a linear combination of monomials.
○ $p(x) = \sum_{\alpha \in \mathcal{A}} c_\alpha x^\alpha$, where $\mathcal{A}$ is a finite set of nonnegative integer vectors and $c_\alpha \in \mathbb{R}$ is a coefficient.
④ Definition 4. $\mathbb{R}[x]$, with $x \in \mathbb{R}^n$, denotes the set of all polynomials in $n$ variables.
⑤ Definition 5. The degree of a polynomial $p$ is the maximum degree of its monomials.
○ $\deg p := \max_{\alpha \in \mathcal{A},\ c_\alpha \neq 0} (\deg m_\alpha)$
⑥ Definition 6. A polynomial $p$ of degree $\leq 2d$ in $n$ variables
○ With $n$ variables, a maximum degree of $d$, and products between variables allowed, the number of possible monomials is $\binom{n+d}{d}$.
○ A matrix $Q$ exists such that $p = z^{\mathsf T}Qz$ and $\deg z \leq d$, although $Q$ need not be unique.
⑦ Definition 7. $z_{n,d}$: The vector of monomials in $n$ variables up to degree $d$
○ The first type of polynomial representation: $z_{n,d}^{\mathsf T}Az_{n,d}$
○ The second type of polynomial representation: $c_i^{\mathsf T}z_{n,d}$
⑵ Polynomial optimization
① Significance: Consider polynomial variables to search for functions in an infinite-dimensional function space.
② Definition 1. Find $p_1(x),p_2(x),\ldots,p_n(x)$ such that $p_i(x)$ satisfies some property. (Difficult to solve)
③ Definition 2. A nonconvex problem involving finite-dimensional polynomials as follows:
○ $\min_{x \in \mathbb{R}^n} p_0(x)$ subject to $p_i(x) \leq 0,\ i = 1,\ldots,k$, where each $p_i$ is a polynomial.
④ Fact 1. Differentiation, addition, and multiplication by a fixed polynomial are polynomial operations that transform the coefficients linearly (i.e., through multiplication by a matrix).
⑶ Sum of squares (SOS): Stability conditions for polynomial systems → Formulate using SOS conditions instead of $P \succeq 0$.
① Definition: The case where $p(x)$ can be expressed as $p(x) = \sum_{i=1}^m (p_i(x))^2$
○ Example 1. Second-order polynomial: $p(x) = x^{\mathsf T}Qx,\ Q \succ 0$
\[M(x,y)=x^4y^2+x^2y^4+1-3x^2y^2.\]○ Example 2. The Motzkin polynomial is nonnegative everywhere but is not SOS.
\[M(x,y)\ge 3\sqrt[3]{x^6y^6}-3x^2y^2=3x^2y^2-3x^2y^2=0.\]○ Why is it nonnegative? By the arithmetic–geometric mean (AM–GM) inequality,
○ Why is it not SOS? If $M=\sum_i q_i^2$, the only monomials that can appear in each $q_i$ are $1$, $xy$, $x^2y$, and $xy^2$. The $x^2y^2$ term can therefore arise only from squaring the $xy$ term. Its coefficient in $\sum_i q_i^2$ must be nonnegative, but its coefficient in $M$ is $-3$.
② Theorem : A polynomial $p$ is a sum of squares $\Leftrightarrow \exists Q \succeq 0$ such that $p = z^{\mathsf T}Qz$, where $z$ is a vector of monomials.
○ Proof of the forward direction
$p$ is SOS; $n$ variables, degree $\leq 2d$
$\exists p_i,\ i = 1,\ldots,m$, such that $p(x) = \sum_{i=1}^m p_i^2(x)$
$\therefore \forall i,\ \deg(p_i) \leq d$
$\therefore p_i(x) = c_i^{\mathsf T}z_{n,d}$
$\therefore p(x) = \sum_{i=1}^m (c_i^{\mathsf T}z_{n,d})^2 = \sum_{i=1}^m z_{n,d}^{\mathsf T}c_ic_i^{\mathsf T}z_{n,d} = z_{n,d}^{\mathsf T}Qz_{n,d},\ Q \succeq 0$ ■
○ Proof of the reverse direction
$p = z^{\mathsf T}Qz;\ Q \succeq 0,\ z \in \mathbb{R}^{m_1}$
$\exists B = [b_1,\ldots,b_{m_2}] \in \mathbb{R}^{m_1 \times m_2}$ such that $Q = BB^{\mathsf T}$ (∵ $Q$ is PSD)
$\therefore p(x) = z^{\mathsf T}BB^{\mathsf T}z = z^{\mathsf T}[b_1,\ldots,b_{m_2}][b_1,\ldots,b_{m_2}]^{\mathsf T}z = z^{\mathsf T}\left(\sum_{i=1}^{m_2}b_ib_i^{\mathsf T}\right)z = \sum_{i=1}^{m_2}(b_i^{\mathsf T}z)^2 = \sum_{i=1}^{m_2}(p_i(x))^2$
③ SOS programming
④ Example 1. Searching for a Lyapunov function
⑤ Example 2. Generalized S-procedure
5. Integer Programming
⑴ Integer programming (IP): A problem with integer constraints on the decision variables. It does not have to be linear.
⑵ Mixed-integer linear programming (MILP): A mixed-integer problem with a linear objective function and linear constraints
⑶ Mixed-integer quadratic programming (MIQP)
① Definition: An optimization problem with a quadratic objective, linear constraints, and integer restrictions on some variables.
\[\min_{z,w,x}\;(z-1.4)^2+(w-0.6)^2+(x-0.5)^2, \qquad 0\leq z,w\leq3,\quad z,w\in\mathbb Z,\quad x\in\mathbb R.\]② Example:
○ Step 1. Remove the integer restrictions and solve the convex QP: $(z,w,x)=(1.4,0.6,0.5)$, with objective value 0.
○ Step 2. Since $z=1.4$, split the problem into $z\leq1$ and $z\geq2$, and solve the convex QP in each branch. For this strictly convex objective, the optimal $z$ lies at the respective integer boundary.
○ $z\leq1$: $(z,w,x)=(1,0.6,0.5)$, with objective value 0.16.
○ $z\geq2$: $(z,w,x)=(2,0.6,0.5)$, with objective value 0.36.
○ Step 3. In the $z\leq1$ branch, $w=0.6$. Split this branch into $w\leq0$ and $w\geq1$, and solve the convex QP in each branch. The optimal $w$ now lies at the respective integer boundary.
○ $z\leq1,\;w\leq0$: $(z,w,x)=(1,0,0.5)$, with objective value 0.52.
○ $z\leq1,\;w\geq1$: $(z,w,x)=(1,1,0.5)$, with objective value 0.32.
○ Prune the entire $z\geq2$ branch: The integer-feasible solution with objective value 0.32 is already better than this branch’s lower bound of 0.36, obtained in Step 2. No further exploration is needed.
○ Final result: $(z,w,x)=(1,1,0.5)$, with optimal objective value 0.32.
6. Dynamic Programming
⑴ Etymology
① Bellman: Pioneered the systematic study of dynamic programming in the 1950s
② Dynamic programming = planning over time
③ The Secretary of Defense was hostile toward mathematical research.
④ Bellman sought a plausible name to avoid confrontation.
⑵ Representative examples
① Example 1. Unix diff for comparing two files
② Example 2. Viterbi for hidden Markov models
③ Example 3. Smith–Waterman for genetic sequence alignment
④ Example 4. Shortest-path algorithms (Dijkstra’s and Floyd’s algorithms)
⑤ Example 5. Bellman–Ford for shortest-path routing in networks
⑥ Example 6. Cocke–Kasami–Younger for parsing context-free grammars
7. Others
⑸ Euler–Maruyama method
⑹ R code: RSolnp, optim, GenSA, alabama
⑺ Python code
① Nelder–Mead method (amoeba method, Nelder–Mead method, downhill simplex method): A method for finding the minimum or maximum of a loss function in a multidimensional space
import numpy as np
from scipy.optimize import minimize
from scipy.stats import spearmanr
def model(X, coeffs):
return np.sum(X.T * coeffs, axis=1)
def objective_function(coeffs, X, target):
prediction = model(X, coeffs)
return -spearmanr(target, prediction)[0]
def optimize_spearman(X, target, initial_guess=None):
if initial_guess is None:
initial_guess = np.zeros(X.shape[0]) # Default to zero coefficients
result = minimize(objective_function, initial_guess, args=(X, target), method='Nelder-Mead')
optimal_coeffs = result.x
maximized_corr = -objective_function(optimal_coeffs, X, target)
return optimal_coeffs, maximized_corr
# Example usage
# new_bulk = np.array(...) # Replace with your 11x471 matrix
# target_vector = np.array(...) # Replace with your 471-D target vector
# optimal_coeffs, maximized_corr = optimize_spearman(new_bulk, target_vector)
# print("Optimal coefficients:", optimal_coeffs)
# print("Maximized Spearman Correlation:", maximized_corr)
④ BFGS method (Broyden–Fletcher–Goldfarb–Shanno optimization): Because computing the inverse Hessian matrix in Newton’s method is computationally expensive, an approximation is used to determine the search direction.
⑯ SANN (simulated annealing): A slow stochastic global optimizer. It works well for difficult functions, including nondifferentiable or nonconvex functions.
Entered: 2026.11.10 23:15