picos.expressions.uncertain.pert_moment¶
Implements MomentAmbiguitySet
.
Classes
- 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:
PerturbationUniverse
A moment-uncertain description of a random perturbation parameter.
- Model of uncertainty
As a distributional ambiguity set, an instance of this class
represents a safety region for a partially known (ambiguous) probability distribution and
provides a random, ambiguously distributed perturbation parameter that can be used to define worst-case-expectation expressions of the form
for a selection of functions and a decision variable .
- Definition
Formally, this class can describe ambiguity sets of the form
where
is the set of all Borel probability measures on ,
the sample space bounds the support of and may be given as either or as an -dimensional ellipsoid,
and with are the nominal mean and covariance matrix of , respectively, and
and are meta-parameters bounding the uncertainty concerning the mean and the covariance matrix, respectively.
Unless , this class can also represent the limit cases of and denoting an unbounded mean and covariance matrix, respectively.
Note
While denotes that the nominal mean is certain, there is a subtle difference between setting 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
A squared norm where is biaffine in and . This can be written as
abs(A)**2
in Python.A convex piecewise linear function where is biaffine in and for all . This can be written as
picos.max([a_1, ..., a_k])
in Python.A concave piecewise linear function where is biaffine in and for all . This can be written as
picos.min([a_1, ..., a_k])
in Python.
- Example
We show that for unbounded mean and support (i.e. and ) and for a finite samples space , 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) True
- __init__(parameter_name, shape, nominal_mean=0, nominal_covariance='I', alpha=0, beta=1, sample_space=None)[source]¶
Create a
MomentAmbiguitySet
.- Parameters
parameter_name (str) – Name of the random parameter .
shape (anything recognized by
load_shape
) – Shape of . Must characterize a column vector. IfNone
, then the shape is inferred from the nominal mean.nominal_mean (anything recognized by
load_data
) – The nominal mean of the ambiguous distribution .nominal_covariance (anything recognized by
load_data
) – The nominal covariance matrix of the ambiguous distribution .alpha (float) – The parameter bounding the uncertain mean. The values
None
andfloat("inf")
denote an unbounded mean.beta (float) – The parameter bounding the uncertain covariance matrix. The values
None
andfloat("inf")
denote unbounded covariances.sample_space (
None
orTheField
orEllipsoid
) – The sample space . If this isNone
or an instance ofTheField
(i.e. ), then the support of is unbounded. If this is an -dimensional instance ofEllipsoid
, then the support of is a subset of that ellipsoid.
- property dim¶
The dimension of the sample space.
- property distributional¶
Implement for
PerturbationUniverse
.
- property nominal_covariance¶
The nominal covariance matrix .
- property nominal_mean¶
The nominal mean of the ambiguous distribution.
- property parameter¶
The random perturbation parameter .