robustfpm.pricing.set_handler module
This submodule implements ISetHandler as an abstract interface for set and different types of sets with
respective methods.
- class robustfpm.pricing.set_handler.ISetHandler
Bases:
abc.ABCInterface which contains the set-based operations for implementation in non-abstract SetHandlers.
- abstract project(lattice)
Projects the set onto the lattice.
- Parameters
lattice (lattice) – Target lattice.
- Returns
Array of points on the lattice which belong to the set.
- Return type
np.ndarray
- abstract support_function(x)
Returns value of the support function of the set at point x.
- Parameters
x (np.ndarray, size = (m,n)) – Array of points from \(\mathbb{R}^{n}\).
- Returns
Array of support function values, may be np.Inf.
- Return type
np.ndarray
Notes
The support function \(\sigma_A(l)\) of any non-empty subset \(A \subseteq X\), where \(X\) is a Banach space, is defined by the following relation:
\[\sigma_A(l) = \sup\limits_{a \in A} \langle a, l \rangle,\]for each \(l \in X^*\) — continuous dual space of X
- abstract iscompact()
Checks if the set is a compact subset of \(\mathbb{R}^{n}\).
- Returns
True if the set is compact.
- Return type
boolean
- abstract multiply(x)
Multiplies the set by a point x from \(\mathbb{R}^{n}\).
- Parameters
x (np.ndarray) – Point to multiply the set by
- Returns
Set handler that corresponds to the set \(\{x\cdot a, a \in A\}\), where \(A\) is the current set (self), \(x\cdot a\) — element-wise (Hadamard) product.
- Return type
- abstract add(x)
Adds a point x from \(\mathbb{R}^{n}\) to the set.
- Parameters
x (np.ndarray) – Point to add to the set
- Returns
Set handler that corresponds to the set \(\{x + a, a \in A\}\), where \(A\) is the current set (self).
- Return type
- abstract property dim
Returns dimension of set (or np.inf, if set handler can be of any dimension.
Notes
If set \(\mathcal{X} \in \mathbb{R}^n\), then this method should return n. If \(\mathcal{X}\) is independent of n (like RealSpaceHandler), then this method should return np.inf
- abstract contains(x, is_interior=False)
Check that points x from \(\mathbb{R}^n\) are in set
This method checks for \(x \in \mathcal{X}\) or for \(x \in int(\mathcal{X}\)) (if is_interior is True)
- Parameters
x (np.ndarray, size = (n,) or (m,n)) – Point(s) to check. If given multiple points, returns an array of boolean values for each point
is_interior (bool, default = False) – Flag whether to check that x is in interior of a set.
- Returns
True, if x (or x_i) lies in set (in its interior)
- Return type
np.ndarray, size = (m,)
- is_interior(x)
Wrapper for
self.contains(x, is_interior=True)See also
- class robustfpm.pricing.set_handler.RectangularHandler(bounds, dtype=<class 'numpy.float64'>)
Bases:
robustfpm.pricing.set_handler.ISetHandlerHandler for a rectangular set.
Such a set \(\mathcal{X}\subseteq \mathbb{R}^{n}\) is defined as:
\[\mathcal{X} = \{(x_1,\dots,x_n) \in \mathbb{R}^{n}:\; lb_i \leqslant x_i \leqslant ub_i, i = 1,2,\dots,n\},\]where \(lb_i, ub_i\) are given bounds on i-th dimension.
- Parameters
bounds (array_like, size = (2,) or (n,2)) – Array of boundary points [\(lb_i, ub_i\)]
dtype (np.dtype, default = np.float64) – Numpy datatype of points in bounds
- project(lattice)
Projects the set onto the lattice.
- Parameters
lattice (lattice) – Target lattice.
- Returns
Array of points on the lattice which belong to the set.
- Return type
np.ndarray
- support_function(x)
Returns value of the support function of the set at point x.
- Parameters
x (np.ndarray, size = (m,n)) – Array of points from \(\mathbb{R}^{n}\).
- Returns
Array of support function values, may be np.Inf.
- Return type
np.ndarray
Notes
The support function \(\sigma_A(l)\) of any non-empty subset \(A \subseteq X\), where \(X\) is a Banach space, is defined by the following relation:
\[\sigma_A(l) = \sup\limits_{a \in A} \langle a, l \rangle,\]for each \(l \in X^*\) — continuous dual space of X
- iscompact()
Checks if the set is a compact subset of \(\mathbb{R}^{n}\).
- Returns
True if the set is compact.
- Return type
boolean
- multiply(x)
Multiplies the set by a point x from \(\mathbb{R}^{n}\).
- Parameters
x (np.ndarray) – Point to multiply the set by
- Returns
Set handler that corresponds to the set \(\{x\cdot a, a \in A\}\), where \(A\) is the current set (self), \(x\cdot a\) — element-wise (Hadamard) product.
- Return type
- add(x)
Adds a point x from \(\mathbb{R}^{n}\) to the set.
- Parameters
x (np.ndarray) – Point to add to the set
- Returns
Set handler that corresponds to the set \(\{x + a, a \in A\}\), where \(A\) is the current set (self).
- Return type
- property dim
Returns dimension of set (or np.inf, if set handler can be of any dimension.
Notes
If set \(\mathcal{X} \in \mathbb{R}^n\), then this method should return n. If \(\mathcal{X}\) is independent of n (like RealSpaceHandler), then this method should return np.inf
- contains(x, is_interior=False)
Check that points x from \(\mathbb{R}^n\) are in set
This method checks for \(x \in \mathcal{X}\) or for \(x \in int(\mathcal{X}\)) (if is_interior is True)
- Parameters
x (np.ndarray, size = (n,) or (m,n)) – Point(s) to check. If given multiple points, returns an array of boolean values for each point
is_interior (bool, default = False) – Flag whether to check that x is in interior of a set.
- Returns
True, if x (or x_i) lies in set (in its interior)
- Return type
np.ndarray, size = (m,)
- is_interior(x)
Wrapper for
self.contains(x, is_interior=True)See also
- class robustfpm.pricing.set_handler.EllipseHandler(mu, sigma, conf_level=None, dtype=None)
Bases:
robustfpm.pricing.set_handler.ISetHandlerHandler for an n-dimensional ellipsoid with center \(\mu\) and matrix \(\Sigma\)
- Parameters
mu (np.ndarray, size = (n,) or (1,n)) – Coordinates of center of an ellipsoid \(\mu\)
sigma (np.ndarray, size = (n,n)) – Matrix of an ellipsoid \(\Sigma\)
conf_level (np.float64, default = None) – Confidence level of a multivariate normal distribution. See also: https://stats.stackexchange.com/questions/64680/how-to-determine-quantiles-isolines-of-a-multivariate-normal-distribution
dtype (np.dtype, default = np.float64) – Type of elements in mu, sigma
- project(lattice)
Projects the set onto the lattice.
- Parameters
lattice (lattice) – Target lattice.
- Returns
Array of points on the lattice which belong to the set.
- Return type
np.ndarray
- support_function(x, x_center=None)
Returns value of the support function of the set at point x.
- Parameters
x (np.ndarray, size = (m,n)) – Array of points from \(\mathbb{R}^{n}\).
- Returns
Array of support function values, may be np.Inf.
- Return type
np.ndarray
Notes
The support function \(\sigma_A(l)\) of any non-empty subset \(A \subseteq X\), where \(X\) is a Banach space, is defined by the following relation:
\[\sigma_A(l) = \sup\limits_{a \in A} \langle a, l \rangle,\]for each \(l \in X^*\) — continuous dual space of X
- iscompact()
Checks if the set is a compact subset of \(\mathbb{R}^{n}\).
- Returns
True if the set is compact.
- Return type
boolean
- multiply(x)
Multiplies the set by a point x from \(\mathbb{R}^{n}\).
- Parameters
x (np.ndarray) – Point to multiply the set by
- Returns
Set handler that corresponds to the set \(\{x\cdot a, a \in A\}\), where \(A\) is the current set (self), \(x\cdot a\) — element-wise (Hadamard) product.
- Return type
- add(x)
Adds a point x from \(\mathbb{R}^{n}\) to the set.
- Parameters
x (np.ndarray) – Point to add to the set
- Returns
Set handler that corresponds to the set \(\{x + a, a \in A\}\), where \(A\) is the current set (self).
- Return type
- property dim
Returns dimension of set (or np.inf, if set handler can be of any dimension.
Notes
If set \(\mathcal{X} \in \mathbb{R}^n\), then this method should return n. If \(\mathcal{X}\) is independent of n (like RealSpaceHandler), then this method should return np.inf
- contains(x, is_interior=False)
Check that points x from \(\mathbb{R}^n\) are in set
This method checks for \(x \in \mathcal{X}\) or for \(x \in int(\mathcal{X}\)) (if is_interior is True)
- Parameters
x (np.ndarray, size = (n,) or (m,n)) – Point(s) to check. If given multiple points, returns an array of boolean values for each point
is_interior (bool, default = False) – Flag whether to check that x is in interior of a set.
- Returns
True, if x (or x_i) lies in set (in its interior)
- Return type
np.ndarray, size = (m,)
- is_interior(x)
Wrapper for
self.contains(x, is_interior=True)See also
- class robustfpm.pricing.set_handler.RealSpaceHandler
Bases:
robustfpm.pricing.set_handler.ISetHandlerHandler for \(\mathbb{R}^{n}\)
- project(lattice)
Projects the set onto the lattice.
- Parameters
lattice (lattice) – Target lattice.
- Returns
Array of points on the lattice which belong to the set.
- Return type
np.ndarray
- support_function(x)
Returns value of the support function of the set at point x.
- Parameters
x (np.ndarray, size = (m,n)) – Array of points from \(\mathbb{R}^{n}\).
- Returns
Array of support function values, may be np.Inf.
- Return type
np.ndarray
Notes
The support function \(\sigma_A(l)\) of any non-empty subset \(A \subseteq X\), where \(X\) is a Banach space, is defined by the following relation:
\[\sigma_A(l) = \sup\limits_{a \in A} \langle a, l \rangle,\]for each \(l \in X^*\) — continuous dual space of X
- iscompact()
Checks if the set is a compact subset of \(\mathbb{R}^{n}\).
- Returns
True if the set is compact.
- Return type
boolean
- multiply(x)
Multiplies the set by a point x from \(\mathbb{R}^{n}\).
- Parameters
x (np.ndarray) – Point to multiply the set by
- Returns
Set handler that corresponds to the set \(\{x\cdot a, a \in A\}\), where \(A\) is the current set (self), \(x\cdot a\) — element-wise (Hadamard) product.
- Return type
- add(x)
Adds a point x from \(\mathbb{R}^{n}\) to the set.
- Parameters
x (np.ndarray) – Point to add to the set
- Returns
Set handler that corresponds to the set \(\{x + a, a \in A\}\), where \(A\) is the current set (self).
- Return type
- property dim
Returns dimension of set (or np.inf, if set handler can be of any dimension.
Notes
If set \(\mathcal{X} \in \mathbb{R}^n\), then this method should return n. If \(\mathcal{X}\) is independent of n (like RealSpaceHandler), then this method should return np.inf
- contains(x, is_interior=False)
Check that points x from \(\mathbb{R}^n\) are in set
This method checks for \(x \in \mathcal{X}\) or for \(x \in int(\mathcal{X}\)) (if is_interior is True)
- Parameters
x (np.ndarray, size = (n,) or (m,n)) – Point(s) to check. If given multiple points, returns an array of boolean values for each point
is_interior (bool, default = False) – Flag whether to check that x is in interior of a set.
- Returns
True, if x (or x_i) lies in set (in its interior)
- Return type
np.ndarray, size = (m,)
- is_interior(x)
Wrapper for
self.contains(x, is_interior=True)See also
- class robustfpm.pricing.set_handler.NonNegativeSpaceHandler
Bases:
robustfpm.pricing.set_handler.ISetHandlerHandler for closed non-negative orthant of \(\mathbb{R}^{n}\) Such an orthant is defined as
\[\mathbb{R}^{n}_{+} = \{(x_1,\dots,x_n) \in \mathbb{R}^n:\; x_i \geqslant 0, i = 1,2,\dots,n\}\]- project(lattice)
Projects the set onto the lattice.
- Parameters
lattice (lattice) – Target lattice.
- Returns
Array of points on the lattice which belong to the set.
- Return type
np.ndarray
- support_function(x)
Returns value of the support function of the set at point x.
- Parameters
x (np.ndarray, size = (m,n)) – Array of points from \(\mathbb{R}^{n}\).
- Returns
Array of support function values, may be np.Inf.
- Return type
np.ndarray
Notes
The support function \(\sigma_A(l)\) of any non-empty subset \(A \subseteq X\), where \(X\) is a Banach space, is defined by the following relation:
\[\sigma_A(l) = \sup\limits_{a \in A} \langle a, l \rangle,\]for each \(l \in X^*\) — continuous dual space of X
- iscompact()
Checks if the set is a compact subset of \(\mathbb{R}^{n}\).
- Returns
True if the set is compact.
- Return type
boolean
- multiply(x)
Multiplies the set by a point x from \(\mathbb{R}^{n}\).
- Parameters
x (np.ndarray) – Point to multiply the set by
- Returns
Set handler that corresponds to the set \(\{x\cdot a, a \in A\}\), where \(A\) is the current set (self), \(x\cdot a\) — element-wise (Hadamard) product.
- Return type
- add(x)
Adds a point x from \(\mathbb{R}^{n}\) to the set.
- Parameters
x (np.ndarray) – Point to add to the set
- Returns
Set handler that corresponds to the set \(\{x + a, a \in A\}\), where \(A\) is the current set (self).
- Return type
- property dim
Returns dimension of set (or np.inf, if set handler can be of any dimension.
Notes
If set \(\mathcal{X} \in \mathbb{R}^n\), then this method should return n. If \(\mathcal{X}\) is independent of n (like RealSpaceHandler), then this method should return np.inf
- contains(x, is_interior=False)
Check that points x from \(\mathbb{R}^n\) are in set
This method checks for \(x \in \mathcal{X}\) or for \(x \in int(\mathcal{X}\)) (if is_interior is True)
- Parameters
x (np.ndarray, size = (n,) or (m,n)) – Point(s) to check. If given multiple points, returns an array of boolean values for each point
is_interior (bool, default = False) – Flag whether to check that x is in interior of a set.
- Returns
True, if x (or x_i) lies in set (in its interior)
- Return type
np.ndarray, size = (m,)
- is_interior(x)
Wrapper for
self.contains(x, is_interior=True)See also
- class robustfpm.pricing.set_handler.NonNegativeSimplex(bounds, dtype=<class 'numpy.float64'>)
Bases:
robustfpm.pricing.set_handler.ISetHandlerRepresents an n-simplex with vertices \((0,\dots, 0), (x_i^1,\dots, x_i^j, \dots, x_i^n), \; i = 1,2,\dots, n\), where
\[x_i^j = b_i \cdot \delta_i^j, \; \forall i, j = 1,\dots, n, \; b_i > 0, \; \delta_i^j \text{ is a Kronecker delta.}\]- Parameters
bounds (array_like, size = (n,)) – Array of boundary points \(b_i\)
dtype (np.dtype, default = np.float64) – Numpy datatype of points in bounds
- project(lattice)
Projects the set onto the lattice.
- Parameters
lattice (lattice) – Target lattice.
- Returns
Array of points on the lattice which belong to the set.
- Return type
np.ndarray
- iscompact()
Checks if the set is a compact subset of \(\mathbb{R}^{n}\).
- Returns
True if the set is compact.
- Return type
boolean
- contains(x, is_interior=False)
Check that points x from \(\mathbb{R}^n\) are in set
This method checks for \(x \in \mathcal{X}\) or for \(x \in int(\mathcal{X}\)) (if is_interior is True)
- Parameters
x (np.ndarray, size = (n,) or (m,n)) – Point(s) to check. If given multiple points, returns an array of boolean values for each point
is_interior (bool, default = False) – Flag whether to check that x is in interior of a set.
- Returns
True, if x (or x_i) lies in set (in its interior)
- Return type
np.ndarray, size = (m,)
- support_function(x)
Returns value of the support function of the set at point x.
- Parameters
x (np.ndarray, size = (m,n)) – Array of points from \(\mathbb{R}^{n}\).
- Returns
Array of support function values, may be np.Inf.
- Return type
np.ndarray
Notes
The support function \(\sigma_A(l)\) of any non-empty subset \(A \subseteq X\), where \(X\) is a Banach space, is defined by the following relation:
\[\sigma_A(l) = \sup\limits_{a \in A} \langle a, l \rangle,\]for each \(l \in X^*\) — continuous dual space of X
- multiply(x)
Multiplies the set by a point x from \(\mathbb{R}^{n}\).
- Parameters
x (np.ndarray) – Point to multiply the set by
- Returns
Set handler that corresponds to the set \(\{x\cdot a, a \in A\}\), where \(A\) is the current set (self), \(x\cdot a\) — element-wise (Hadamard) product.
- Return type
- add(x)
Notes
This method is not implemented
- property dim
Returns dimension of set (or np.inf, if set handler can be of any dimension.
Notes
If set \(\mathcal{X} \in \mathbb{R}^n\), then this method should return n. If \(\mathcal{X}\) is independent of n (like RealSpaceHandler), then this method should return np.inf
- is_interior(x)
Wrapper for
self.contains(x, is_interior=True)See also