{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Nonconvex least squares\n", "\n", "Suppose a signal $x\\in\\{-1,1\\}^{n}$ is sent over over a noisy channel, and received as $b=Ax + v$ where $v\\sim\\mathcal{N}(0,\\sigma^{2}I)$ is Gaussian noise. Based on the received signal $b\\in\\mathbb{R}^{m}$, the **maximum likelihood estimate** $x_{\\text{ML}}^{*}$ of the original signal $x$ is obtained by solving\n", "\n", "$$x_{\\text{ML}}^{*} = \\underset{x\\in\\mathbb{R}^{n}}{\\arg\\min}\\quad \\|Ax - b\\|_{2}^{2}\\\\\n", "\\qquad\\qquad\\qquad\\qquad\\text{subject to} \\quad x_{j}^{2} = 1, \\quad\\forall j =1,..., n,$$\n", "\n", "where $A\\in\\mathbb{R}^{m\\times n}$ and $b\\in\\mathbb{R}^{m}$ are known. Assume that $\\text{rank}(A)=n$, that is, $A^{\\top}A$ is nonsingular." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## (a) [2 + 15 = 17 points] Primal and its convex relaxation\n", "\n", "(i) **Why** the primal problem above is nonconvex?\n", "\n", "(ii) A convex relaxation of the primal is obtained by simply deleting the nonconvex constraint, and is therefore a convex optimization problem. **Numerically solve the convex relaxation of the primal** in MATLAB/Python/Julia using cvx/cvxpy/Convex.jl for the $A,b$ data given in the starter code $\\texttt{AM229F20HW7problem.m}$ (inside CANVAS). **Report the numerically computed optimal value, and the percentage error between true $x$ and $\\text{sign}(x_{a})$ where $x_{a}$ is the minimizer of the convex relaxation. Submit your code**. " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Solution for part (a):\n", "\n", "(i) The constraint set $\\{x\\in\\mathbb{R}^{n}\\mid x_{j}^{2}=1,\\;\\forall\\:j=1,...,n\\}=\\{-1,1\\}^{n}$ being the union of vertices of a cube with each coordinate $\\pm 1$, is nonconvex. Therefore, the given optimization problem asks us to minimize a convex function over a nonconvex set, and hence a nonconvex problem. \n", "\n", "(ii) The convex relaxation, obtained by deleting the constraints $x_{j}^{2}=1$, becomes the ordinary least squares. The posted code $\\texttt{AM229F20HW7solution.m}$ in CANVAS Files section, inside folder HW problems and solutions, gives\n", "\n", "$$\\|A\\text{sign}(x_{a})-b\\|_{2}^{2} = 63.791726053201685.$$\n", "\n", "The error is $0\\%$, i.e., composing the argmin of the convex relaxation with the sign function recovers the true signal $x$. " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## (b) [30 + 15 = 45 points] Dual\n", "\n", "(i) **Derive the Lagrange dual problem** of the original primal problem as an SDP.\n", "\n", "**Hint:** use epigraph form followed by Schur complement lemma for possibly singular matrices (see textbook Appendix A.5.5, printed page number 651).\n", "\n", "(ii) Use the same code (and problem data) in part (a)(ii) to numerically solve the dual problem of part(b)(i). **Report the numerically computed optimal value of the dual problem, and submit your code (same file as in part(a))**. " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Solution for part (b):\n", "\n", "(i) The Lagrangian\n", "\\begin{align*}\n", "L(x,\\nu) &= \\|Ax-b\\|_{2}^{2} + \\sum_{j=1}^{n}\\nu_{j}\\left(x_{j}^{2}-1\\right)\\\\\n", "&= (Ax-b)^{\\top}(Ax-b) + x^{\\top}\\operatorname{diag}(\\nu)x - \\mathbf{1}^{\\top}\\nu\\\\\n", "&= x^{\\top}\\left(A^{\\top}A + \\operatorname{diag}(\\nu)\\right)x - 2b^{\\top}Ax - \\mathbf{1}^{\\top}\\nu + b^{\\top}b\n", "\\end{align*}\n", "\n", "is unbounded if **either** $A^{\\top}A + \\operatorname{diag}(\\nu) \\not\\succeq 0$ **or** if $-A^{\\top}b \\not\\in\\text{range}(A^{\\top}A + \\operatorname{diag}(\\nu))$. \n", "\n", "When **both** $A^{\\top}A + \\operatorname{diag}(\\nu) \\succeq 0$ **and** $-A^{\\top}b \\in\\text{range}(A^{\\top}A + \\operatorname{diag}(\\nu))$, then to compute the infimum of $L$, we solve $\\nabla_{x}L = 0$ as\n", "$$\\left(A^{\\top}A + \\operatorname{diag}(\\nu)\\right)x^{\\text{opt}} = A^{\\top}b\\quad\\Rightarrow\\quad x^{\\text{opt}} = \\left(A^{\\top}A + \\operatorname{diag}(\\nu)\\right)^{\\dagger}A^{\\top}b.$$\n", "\n", "Thus, the infimum value of the Lagrangian (a.k.a. the Lagrange dual function) is\n", "\n", "\\begin{align*}\n", "&g(\\nu) = \\underset{x}{\\inf}\\;L(x,\\nu) = L\\left(x= x^{\\text{opt}},\\nu\\right)\\\\\n", "&= -b^{\\top}A\\left(A^{\\top}A + \\operatorname{diag}(\\nu)\\right)^{\\dagger}A^{\\top}b - \\mathbf{1}^{\\top}\\nu + b^{\\top}b, \\,\\text{if}\\, A^{\\top}A + \\operatorname{diag}(\\nu) \\succeq 0, \\:\\text{and}\\: -A^{\\top}b \\in\\text{range}(A^{\\top}A + \\operatorname{diag}(\\nu)),\n", "\\end{align*}\n", "\n", "and $g(\\nu)= -\\infty$ otherwise. Hence the dual problem is (maximize is negative of minimize):\n", "\n", "\\begin{align*}\n", "&\\underset{\\nu\\in\\mathbb{R}^{n}}{\\text{minimize}}\\quad\\mathbf{1}^{\\top}\\nu +b^{\\top}A\\left(A^{\\top}A + \\operatorname{diag}(\\nu)\\right)^{\\dagger}A^{\\top}b - b^{\\top}b\\\\\n", "&\\text{subject to}\\quad A^{\\top}A + \\operatorname{diag}(\\nu) \\succeq 0,\\\\\n", "&\\qquad\\qquad -A^{\\top}b \\in\\text{range}(A^{\\top}A + \\operatorname{diag}(\\nu)).\n", "\\end{align*}\n", "\n", "Using epigraph form for the nonlinear (in $\\nu$) term in the objective, we rewrite the dual problem as\n", "\n", "\\begin{align*}\n", "&\\underset{\\nu\\in\\mathbb{R}^{n}}{\\text{minimize}}\\quad\\mathbf{1}^{\\top}\\nu + t - b^{\\top}b\\\\\n", "&\\text{subject to}\\quad b^{\\top}A\\left(A^{\\top}A + \\operatorname{diag}(\\nu)\\right)^{\\dagger}A^{\\top}b \\leq t,\\\\\n", "&\\qquad\\qquad\\; A^{\\top}A + \\operatorname{diag}(\\nu) \\succeq 0,\\\\\n", "&\\qquad\\qquad -A^{\\top}b \\in\\text{range}(A^{\\top}A + \\operatorname{diag}(\\nu)).\n", "\\end{align*}\n", "\n", "Following the hint, we notice that by Schur complement lemma (see Appendix A.5.5 last para in text, printed page number 651), the above three constraints are equivalent to the LMI\n", "$$\\begin{pmatrix}\n", "A^{\\top}A + \\operatorname{diag}(\\nu) & -A^{\\top}b\\\\\n", "-b^{\\top}A & t\n", "\\end{pmatrix} \\succeq 0.$$\n", "Therefore, the dual problem is the SDP\n", "\\begin{align*}\n", "&\\underset{\\nu\\in\\mathbb{R}^{n}}{\\text{minimize}}\\quad\\mathbf{1}^{\\top}\\nu + t - b^{\\top}b\\\\\n", "&\\text{subject to}\\quad \\begin{pmatrix}\n", "A^{\\top}A + \\operatorname{diag}(\\nu) & -A^{\\top}b\\\\\n", "-b^{\\top}A & t\n", "\\end{pmatrix} \\succeq 0.\n", "\\end{align*}\n", "\n", "(ii) The posted code $\\texttt{AM229F20HW7solution.m}$ gives the optimal value of the dual: $d^{*} = 63.791723605885636$." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## (c) [20 + 15 + 3 = 38 points] Bidual\n", "\n", "(i) Starting from part (b)(i), **prove that the bidual (dual of the dual) problem** can be written as:\n", "\n", "$$\\text{minimize}\\quad \\operatorname{trace}(A^{\\top}AZ) -2b^{\\top}Az + b^{\\top}b\\\\\n", "\\text{subject to} \\quad \\operatorname{diag}(Z) = \\mathbf{1}, \\quad \\begin{pmatrix}\n", "Z & z\\\\\n", "z^{\\top} & 1\n", "\\end{pmatrix} \\succeq \\mathbf{0}.$$\n", "\n", "(ii) Use the same code (and problem data) in part (a)(ii) and (b)(ii) to numerically solve the bidual problem of part(c)(i). **Report the numerically computed optimal value, and the percentage error between true $x$ and $\\text{sign}(z)$ where $z$ is the minimizer in part (c)(i). Submit your code (same file as in part(a))**.\n", "\n", "(iii) **Explain what you observe** by comparing the numerically computed optimal solutions from (a)(ii), (b)(ii) and c(ii). " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Solution for part (c):\n", "\n", "(i) Corresponding to the LMI derived in part (b)(i), we introduce a Lagrange multiplier \n", "$$\\begin{pmatrix}\n", "Z & z\\\\\n", "z^{\\top} & \\lambda\n", "\\end{pmatrix}.$$\n", "Then the Lagrangian of the optimization problem derived in part (b)(i) is\n", "\n", "\\begin{align*}\n", "L(\\nu,t,Z,z,\\lambda) &= 1^{\\top}\\nu + t - b^{\\top}b - \\text{trace}\\left(\\begin{pmatrix}\n", "Z & z\\\\\n", "z^{\\top} & \\lambda\n", "\\end{pmatrix}\\begin{pmatrix}\n", "A^{\\top}A + \\text{diag}(\\nu) & -A^{\\top}b\\\\\n", "-b^{\\top}A & t\n", "\\end{pmatrix}\\right)\\\\\n", "&= 1^{\\top}\\nu + t - b^{\\top}b - \\text{trace}\\left(Z\\left(A^{\\top}A + \\text{diag}(\\nu)\\right) - zb^{\\top}A\\right) - \\left(-z^{\\top}A^{\\top}b + \\lambda t\\right)\\\\\n", "&= 1^{\\top}\\nu + t - b^{\\top}b - \\text{trace}\\left(A^{\\top}AZ\\right) -(\\text{diag}(Z))^{\\top}\\nu + b^{\\top}Az + z^{\\top}A^{\\top}b - \\lambda t\\\\\n", "&= \\left(\\mathbf{1}-\\text{diag}(Z)\\right)^{\\top}\\nu + t(1-\\lambda) - \\text{trace}\\left(A^{\\top}AZ\\right) + 2 b^{\\top}Az - b^{\\top}b. \n", "\\end{align*}\n", "\n", "The above Lagrangian is unbounded below unless $\\text{diag}(Z)=\\mathbf{1}$ and $\\lambda = 1$. Thus, the dual function is\n", "$$g(Z,z,\\lambda) = -\\text{trace}\\left(A^{\\top}AZ\\right) + 2b^{\\top}Az - b^{\\top}b, \\quad \\text{if}\\;\\text{diag}(Z)=\\mathbf{1},\\:\\lambda = 1,$$\n", "and $g(Z,z,\\lambda) = -\\infty$ otherwise. Hence the bidual problem is\n", "$$\\text{maximize}\\quad -\\operatorname{trace}(A^{\\top}AZ) +2b^{\\top}Az - b^{\\top}b\\\\\n", "\\text{subject to} \\quad \\operatorname{diag}(Z) = \\mathbf{1}, \\quad \\begin{pmatrix}\n", "Z & z\\\\\n", "z^{\\top} & 1\n", "\\end{pmatrix} \\succeq \\mathbf{0}.$$\n", "Negating the objective above, we arrive at the desired form.\n", "\n", "(ii) The posted code $\\texttt{AM229F20HW7solution.m}$ gives the optimal value of the bidual: $63.791752427470477$. The error is $0\\%$, that is, the bidual minimizer recovers the true signal $x$.\n", "\n", "(iii) We see that the numerically computed optimal solutions from a(ii), b(ii) and c(ii) match very well (modulo floating point arithmetic). For the randomly generated problem data given, the convex relaxation recovers the true signal. But this is not guaranteed for any problem data. Numerical experiments (with different random seeds) show that the recovery does occur often (i.e., with high probability) but not always. The dual and the bidual problems are both convex optimization problems. From the numerics, they have zero duality gap." ] } ], "metadata": { "kernelspec": { "display_name": "Python 2", "language": "python", "name": "python2" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 2 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython2", "version": "2.7.16" } }, "nbformat": 4, "nbformat_minor": 2 }