Implements MomentAmbiguitySet.


class picos.expressions.uncertain.pert_moment.MomentAmbiguitySet(parameter_name, shape, nominal_mean=0, nominal_covariance='I', alpha=0, beta=1, sample_space=None)[source]

Bases: picos.expressions.uncertain.perturbation.PerturbationUniverse

A moment-uncertain description of a random perturbation parameter.

Model of uncertainty

As a distributional ambiguity set, an instance \mathcal{P} of this class

  1. represents a safety region for a partially known (ambiguous) probability distribution \Xi \in \mathcal{P} and

  2. provides a random, ambiguously distributed perturbation parameter \xi \sim \Xi that can be used to define worst-case-expectation expressions of the form

    \mathop{(\max\;\textit{or}\;\min)}_{\Xi \in \mathcal{P}}
\mathbb{E}_\Xi[f(x, \xi)]

    for a selection of functions f and a decision variable x.


Formally, this class can describe ambiguity sets of the form

\mathcal{P} = \left\{
    \Xi \in \mathcal{M} ~\middle|~
        \mathbb{P}(\xi \in \mathcal{S}) &= 1, \\
        \left( \mathbb{E}[\xi] - \mu \right)^T \Sigma^{-1}
            \left( \mathbb{E}[\xi] - \mu \right) &\leq \alpha, \\
        \mathbb{E}[(\xi - \mu)(\xi - \mu)^T] &\preceq \beta \Sigma


  1. \mathcal{M} is the set of all Borel probability measures on \mathbb{R}^n,

  2. the sample space \mathcal{S} \subseteq \mathbb{R}^n bounds the support of \Xi and may be given as either \mathbb{R}^n or as an n-dimensional ellipsoid,

  3. \mu \in \mathbb{R}^n and \Sigma \in \mathbb{S}^n with \Sigma \succ 0 are the nominal mean and covariance matrix of \Xi, respectively, and

  4. \alpha \geq 0 and \beta \geq 1 are meta-parameters bounding the uncertainty concerning the mean and the covariance matrix, respectively.

Unless \mathcal{S} = \mathbb{R}^n, this class can also represent the limit cases of \alpha \to \infty and \beta \to \infty denoting an unbounded mean and covariance matrix, respectively.


While \alpha = 0 denotes that the nominal mean \mu is certain, there is a subtle difference between setting \beta = 1 on the one hand and assuming a certain form for the covariance matrix on the other hand: In the former case, the worst case covariance matrix may be Lowener smaller than the nominal one. Setting a lower bound on the covarianve matrix is computationally difficult and not supported.

Supported functions

  1. A squared norm f(x, \xi) = \lVert A(x, \xi) \rVert_F^2 where A is biaffine in x and \xi. This can be written as abs(A)**2 in Python.

  2. A convex piecewise linear function f(x, \xi) = max_{i=1}^k a_i(x,
\xi) where a is biaffine in x and \xi for all i \in [k]. This can be written as picos.max([a_1, ..., a_k]) in Python.

  3. A concave piecewise linear function f(x, \xi) = min_{i=1}^k a_i(x,
\xi) where a is biaffine in x and \xi for all i \in [k]. This can be written as picos.min([a_1, ..., a_k]) in Python.


We show that for unbounded mean and support (i.e. \alpha \to \infty and \beta \to \infty) and for a finite samples space S, this distributional ambiguity set can be used in the context of classical (non-distributional) robust optimization applied to least squares problems.

>>> from picos import Constant, diag, Ellipsoid, Problem, RealVariable
>>> from picos.uncertain import ConicPerturbationSet, MomentAmbiguitySet
>>> import numpy
>>> numpy.random.seed(1)
>>> # Setup data and variables of the nominal least squares problem.
>>> n = 3
>>> A = Constant("A", numpy.random.random((n, n)))
>>> b = Constant("b", numpy.random.random(n))
>>> x = RealVariable("x", n)
>>> # Setup an ellipsoid S bounding the uncertainty in both models.
>>> N = n**2
>>> S = Ellipsoid(N, diag(range(1, N + 1)), range(N))
>>> # Define and solve both robust models.
>>> U1 = ConicPerturbationSet.from_constraints(
...     "Y", RealVariable("Y", N) << S)
>>> U2 = MomentAmbiguitySet("Z", N, alpha=None, beta=None, sample_space=S)
>>> Y = U1.parameter.reshaped((n, n))
>>> Z = U2.parameter.reshaped((n, n))
>>> P1, P2 = Problem(), Problem()
>>> P1.objective = "min", abs((A + Y)*x - b)
>>> P2.objective = "min", abs((A + Z)*x - b)**2
>>> _ = P1.solve(solver="cvxopt")
>>> x1 = ~x  # Save current value of x as a constant PICOS expression x1.
>>> _ = P2.solve(solver="cvxopt")
>>> x2 = ~x
>>> # Verify that both models yield the same robust regression vector.
>>> x1.equals(x2, relTol=1e-4)
__init__(parameter_name, shape, nominal_mean=0, nominal_covariance='I', alpha=0, beta=1, sample_space=None)[source]

Create a MomentAmbiguitySet.

  • parameter_name (str) – Name of the random parameter \xi.

  • shape (anything recognized by load_shape) – Shape of \xi. Must characterize a column vector. If None, then the shape is inferred from the nominal mean.

  • nominal_mean (anything recognized by load_data) – The nominal mean \mu of the ambiguous distribution \Xi.

  • nominal_covariance (anything recognized by load_data) – The nominal covariance matrix \Sigma of the ambiguous distribution \Xi.

  • alpha (float) – The parameter \alpha \geq 0 bounding the uncertain mean. The values None and float("inf") denote an unbounded mean.

  • beta (float) – The parameter \beta \geq 1 bounding the uncertain covariance matrix. The values None and float("inf") denote unbounded covariances.

  • sample_space (None or TheField or Ellipsoid) – The sample space \mathcal{S}. If this is None or an instance of TheField (i.e. \mathbb{R}^n), then the support of \Xi is unbounded. If this is an n-dimensional instance of Ellipsoid, then the support of \Xi is a subset of that ellipsoid.

property alpha

The parameter \alpha.

A value of None denotes \alpha \to \infty.

property beta

The parameter \beta.

A value of None denotes \beta \to \infty.

property dim

The dimension n of the sample space.

property distributional

Implement for PerturbationUniverse.

property nominal_covariance

The nominal covariance matrix \Sigma.

property nominal_mean

The nominal mean \mu of the ambiguous distribution.

property parameter

The random perturbation parameter \xi.

property sample_space

The sample space (bound on support) \mathcal{S}.

A value of None means \mathcal{S} = \mathbb{R}^n.