.. _geometricprogramming:

Geometric Programming 101
*************************

What is a GP?
=============

A Geometric Program (GP) is a type of non-linear optimization problem whose objective and constraints have a particular form.

The decision variables must be strictly positive (non-zero, non-negative) quantities. This is a good fit for engineering design equations (which are often constructed to have only positive quantities), but any model with variables of unknown sign (such as forces and velocities without a predefined direction) may be difficult to express in a GP. Such models might be better expressed as :ref:`Signomials <signomials>`.

More precisely, GP objectives and inequalities are formed out of *monomials* and *posynomials*. In the context of GP, a monomial is defined as:

.. math::

   f(x) = c x_1^{a_1} x_2^{a_2} ... x_n^{a_n}

where :math:`c` is a positive constant, :math:`x_{1..n}` are decision variables, and :math:`a_{1..n}` are real exponents.  For example, taking :math:`x`, :math:`y` and :math:`z` to be positive variables, the expressions

.. math::

   7x \qquad   4xy^2z  \qquad  \frac{2x}{y^2z^{0.3}}  \qquad  \sqrt{2xy}

are all monomials.  Building on this, a posynomial is defined as a sum of monomials:

.. math::

   g(x) = \sum_{k=1}^K c_k x_1^{a_1k} x_2^{a_2k} ... x_n^{a_nk}

For example, the expressions

.. math::

   x^2 + 2xy + 1  \qquad  7xy + 0.4(yz)^{-1/3}  \qquad  0.56 + \frac{x^{0.7}}{yz}

are all posynomials.
Alternatively, monomials can be defined as the subset of posynomials having only one term.
Using :math:`f_i` to represent a monomial and :math:`g_i` to represent a posynomial,
a GP in standard form is written as:

.. math:: \begin{array}{lll}\text{}
    \text{minimize} & g_0(x) & \\
    \text{subject to} & f_i(x) = 1, & i = 1,....,m \\
                      & g_i(x) \leq 1, & i = 1,....,n
                      \end{array}

Boyd et. al. give the following example of a GP in standard form:

.. math:: \begin{array}{llll}\text{}
    \text{minimize} & x^{-1}y^{-1/2}z^{-1} + 2.3xz + 4xyz \\
    \text{subject to} & (1/3)x^{-2}y^{-2} + (4/3)y^{1/2}z^{-1} \leq 1 \\
                      & x + 2y + 3z \leq 1 \\
                      & (1/2)xy = 1
                      \end{array}

Why are GPs special?
====================

Geometric programs have several powerful properties:

    #. Unlike most non-linear optimization problems, large GPs can be **solved extremely quickly**.
    #. If there exists an optimal solution to a GP, it is guaranteed to be **globally optimal**.
    #. Modern GP solvers require **no initial guesses** or tuning of solver parameters.

These properties arise because GPs become *convex optimization problems* via a logarithmic transformation. In addition to their mathematical benefits, recent research has shown that many practical problems can be formulated as GPs or closely approximated as GPs.


.. _signomials:

What are Signomials / Signomial Programs?
=========================================

When the coefficients in a posynomial are allowed to be negative (but the variables stay strictly positive), that is called a Signomial.

A Signomial Program has signomial constraints. While they cannot be solved as quickly or to global optima, because they build on the structure of a GP they can often be solved more quickly than a generic nonlinear program. More information can be found under :ref:`signomialprogramming`.


Where can I learn more?
=======================

To learn more about GPs, refer to the following resources:

    * `A tutorial on geometric programming <http://stanford.edu/~boyd/papers/pdf/gp_tutorial.pdf>`_, by S. Boyd, S.J. Kim, L. Vandenberghe, and A. Hassibi.
    * `Convex optimization <http://stanford.edu/~boyd/cvxbook/>`_, by S. Boyd and L. Vandenberghe.
    * `Geometric Programming for Aircraft Design Optimization <http://web.mit.edu/~whoburg/www/papers/hoburgabbeel2014.pdf>`_, Hoburg, Abbeel 2014
