8.3 Geometric Programming

gp( K, F, g [, G, h [, A, b]])
Solves a geometric program in convex form

\begin{displaymath}
\begin{array}{ll}
\mbox{minimize} & f_0(x) = \mathop{\bf lse...
...,\quad i=1,\ldots,m \\
& Gx \preceq h \\
& Ax=b
\end{array}\end{displaymath}

where

\begin{displaymath}
\mathop{\bf lse}(u) = \log \sum_k \exp(u_k), \qquad
F = \l...
...}{cccc}
g_0^T & g_1^T & \cdots & g_m^T \end{array}\right]^T.
\end{displaymath}

K is a list of m+1 positive integers with K[i] equal to the number of rows in Fi. F is a dense or sparse real matrix of size (sum(K),n). g is a dense real matrix of size (sum(K),1). G and A are dense or sparse real matrices. Their default values are sparse matrices with zero rows. h and b are dense real matrices with one column. Their default values are matrices of size (0,1).

gp() returns a dictionary with keys 'status', 'x', 'snl', 'sl', 'y', 'znl' and 'zl'. The possible values of the 'status' key are:

'optimal'
In this case the 'x' entry is the primal optimal solution, the 'snl' and 'sl' entries are the corresponding slacks in the nonlinear and linear inequality constraints. The 'znl', 'zl' and 'y' entries are the optimal values of the dual variables associated with the nonlinear and linear inequality constraints and the linear equality constraints. These values approximately satisfy

\begin{displaymath}
\nabla f_0(x) + \sum_{k=1}^m z_{\mathrm{nl},k}
\nabla f_k...
...quad k=1,\ldots,m, \qquad
Gx + s_\mathrm{l} = h, \qquad Ax=b
\end{displaymath}

and

\begin{displaymath}
s_\mathrm{nl}\succeq 0, \qquad s_\mathrm{l}\succeq 0, \qquad...
...\mathrm{nl}^T z_\mathrm{nl} + s_\mathrm{l}^T z_\mathrm{l} = 0.
\end{displaymath}

'unknown'
This means that the algorithm reached the maximum number of iterations before a solution was found. The 'x', 'snl', 'sl', 'y', 'znl' and 'zl' entries are None.

As an example, we solve the small GP on page 8 of the paper A Tutorial on Geometric Programming. The posynomial form of the problem is

\begin{displaymath}
\begin{array}{ll}
\mbox{minimize} & w^{-1} h^{-1} d^{-1} \...
...mma wd^{-1} \leq 1 \\
& (1/\delta)dw^{-1} \leq 1
\end{array}\end{displaymath}

with variables h, w, d.

from cvxopt.base import matrix, log, exp
from cvxopt import solvers

Aflr  = 1000.0
Awall = 100.0
alpha = 0.5
beta  = 2.0
gamma = 0.5
delta = 2.0

F = matrix( [[-1., 1., 1., 0., -1.,  1.,  0.,  0.], 
             [-1., 1., 0., 1.,  1., -1.,  1., -1.], 
             [-1., 0., 1., 1.,  0.,  0., -1.,  1.]])
g = log( matrix( [1.0, 2/Awall, 2/Awall, 1/Aflr, alpha, 1/beta, gamma, 1/delta]) )
K = [1, 2, 1, 1, 1, 1, 1]
h, w, d = exp( solvers.gp(K, F, g)['x'] )