Last updated: 2017-06-23

Code version: 3ad2ba7

Introduction

It has been noted that in the specific maximum likelihood estimation problem, optimization runs faster in the dual form than in the primal one. We are testing that with a simple numeric example.

Problem

Let \(A_{n \times m}\) be a matrix with \(n \geq m\) and \(a\) an \(n\)-vector. The prototypical convex optimization problem in my applications is

\[ \begin{array}{rl} \min\limits_{f \in \mathbb{R}^m, \ \ g \in \mathbb{R}^n} & -\sum\limits_{i = 1}^n\log\left(g_i\right) \\ \text{s.t.} & Af + a = g\\ & g \geq 0 \ . \end{array} \] Note here the only reason we are adding the latent variable \(g\) is that in this way we can code the problem using Rmosek::mosek as a “separable convex optimization” (SCOPT) problem.

Its dual form is

\[ \begin{array}{rl} \min\limits_{\nu \in \mathbb{R}^n} & a^T\nu-\sum\limits_{i = 1}^n\log\left(\nu_i\right) \\ \text{s.t.} & A^T\nu = 0\\ & \nu\geq0 \ . \end{array} \]

The idea is that when \(n \gg m\), the dual optimization should be much faster than the primal one using Rmosek::mosek.

Comparison

Let \(n = 10^4\), \(m = 10\), so that indeed \(n \gg m\). We run \(1000\) simulation trials. In each trial we feed the primal and the dual with the same \(A\) and \(a\). \(A\) and \(a\) are generated so that both the primal and dual problems are feasible at least in theory. Now we are comparing accuracy, time cost, and numbers of iterations of the two forms.

In the following comparisons, we only compare the results when both primal and dual reach the optimal. Worthnoting is that out of \(1000\) runs, the dual reaches optimal in all of them, whereas the primal doesn’t in 61 of them, or \(6.1\%\).

Total time cost

Number of iterations

Time per iteration

Log likelihood

It appears the dual form also gives better results in the sense that the log-likelihood given by dual is larger than the log-likelihood given by primal, when both reach the optimal. For both forms, the log-likelihood is given by \(\sum\log\left(Af + a\right) = \sum\log\left(g\right)\).

Session information

sessionInfo()
R version 3.3.3 (2017-03-06)
Platform: x86_64-apple-darwin13.4.0 (64-bit)
Running under: macOS Sierra 10.12.5

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

loaded via a namespace (and not attached):
 [1] backports_1.0.5 magrittr_1.5    rprojroot_1.2   tools_3.3.3    
 [5] htmltools_0.3.6 yaml_2.1.14     Rcpp_0.12.11    stringi_1.1.2  
 [9] rmarkdown_1.6   knitr_1.16      git2r_0.18.0    stringr_1.2.0  
[13] digest_0.6.12   evaluate_0.10  

This R Markdown site was created with workflowr