optora.dro.sinkhorn_dro¶
Sinkhorn-distance-constrained ambiguity set (Sinkhorn DRO).
SinkhornAmbiguitySet
¶
Bases: TiltedAmbiguitySet
Sinkhorn-distance ball for Sinkhorn DRO (Wang, Gao and Xie 2025).
The Sinkhorn ball around the nominal \(\hat P\) with entropic strength
\(\epsilon\), reference measure \(\nu\), and ground cost \(C\) is
\(\{P : \mathcal{W}_\epsilon(\hat P, P) \le \rho\}\) (see
optora.divergences.EntropicTransportDivergence). On a finite support
it is a shared-budget mixture of KL balls (their Lemma 3.11),
where \(Q_i \propto \nu\, e^{-C_{i\cdot}/\epsilon}\) is the Gibbs kernel
row of support point \(i\) and \(\bar\rho = \rho - \min_P
\mathcal{W}_\epsilon(\hat P, P)\) is the budget in excess of the
entropic bias. radius is \(\bar\rho\), so every nonnegative radius is
feasible. Radius zero gives the smallest non-empty set, the single
kernel-smoothed nominal \(P^0 = \hat p^\top Q\) rather than \(\hat P\)
itself.
Every row's maximizer is an exponential tilt
\(\gamma_i \propto Q_i\, e^{\ell/(\lambda \epsilon)}\) at one shared
temperature (their Remark 3.3), so the worst case is pinned by the
bracketed tilt bisection of optora.core.TiltedAmbiguitySet, as for
optora.dro.KLAmbiguitySet. The solve needs no iterative solver and no
host synchronization, and its first and second derivatives are exact.
The worst-case distribution
\(\sum_i \hat p_i \gamma_i\) is supported on the support of \(\nu\), not
only of \(\hat P\), and the worst case saturates at the largest loss on
that support once
\(\bar\rho \ge \epsilon \sum_i \hat p_i \log(1 / Q_i(A))\), with \(A\) the
highest-loss scenarios. With a zero cost every row is \(\nu\) and the set
is the KL ball of radius \(\bar\rho/\epsilon\) around \(\nu\). As
\(\epsilon \to 0\) the dual tends to the Wasserstein-DRO dual (their
Remark 3.2).
Attributes:
| Name | Type | Description |
|---|---|---|
nominal |
Tensor
|
Nominal distribution \(\hat P\) the transport starts from. |
divergence |
EntropicTransportDivergence
|
|
radius |
float | Tensor
|
Nonnegative budget \(\bar\rho\) in excess of the entropic bias, a float or a tensor of radii evaluated as one batch. |
cost
property
¶
Ground cost matrix, aliasing divergence.cost.
epsilon
property
¶
Entropic regularization strength, aliasing divergence.epsilon.
__init__(nominal, cost, epsilon, radius, reference=None, max_iter=1000, tol=1e-09, eps=None, check_interval=DEFAULT_CHECK_INTERVAL, validate=False)
¶
Initialize the Sinkhorn DRO ambiguity set.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
nominal
|
Tensor
|
Nominal distribution, a nonnegative tensor that sums to one along its last dimension. |
required |
cost
|
Tensor
|
Square ground cost matrix of shape |
required |
epsilon
|
float
|
Positive entropic regularization strength. |
required |
radius
|
float | Tensor
|
Nonnegative budget in excess of the entropic bias. A
tensor radius is broadcast against the batch shape of
|
required |
reference
|
Tensor | None
|
Nonnegative reference measure \(\nu\) of shape |
None
|
max_iter
|
int
|
Sinkhorn iterations, used only by |
1000
|
tol
|
float
|
Sinkhorn tolerance for |
1e-09
|
eps
|
float | None
|
Deprecated and ignored, as in
|
None
|
check_interval
|
int
|
Sinkhorn host-read interval for |
DEFAULT_CHECK_INTERVAL
|
validate
|
bool
|
Whether to run the value checks that synchronize with
the device on |
False
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
smoothed_nominal(dtype=None)
¶
Return the kernel-smoothed nominal \(P^0 = \hat p^\top Q\), the ball's centre.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dtype
|
dtype | None
|
Dtype to compute in. Defaults to |
None
|
Returns:
| Type | Description |
|---|---|
Tensor
|
The distribution attained at radius zero, of |
contains(candidate)
¶
Check whether a candidate distribution lies inside the ambiguity set.
The answer is returned as a boolean tensor on candidate's device
rather than as a Python bool, so membership can be used as a mask
or composed with further tensor work without forcing a
device-to-host synchronization. Call bool(...) on the result only
where a host-side branch is genuinely needed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
candidate
|
Tensor
|
Candidate distribution with the same shape as
|
required |
Returns:
| Type | Description |
|---|---|
Tensor
|
A boolean tensor that is |
Tensor
|
|
worst_case_expectation(loss)
¶
Compute the worst-case expected loss at the tilt pinned by radius.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
loss
|
Tensor
|
Per-scenario loss values of shape |
required |
Returns:
| Type | Description |
|---|---|
Tensor
|
A tensor of shape |
Tensor
|
When |
Tensor
|
the start of the tilt path ( |
Tensor
|
|
Tensor
|
expectation of |
Tensor
|
the search returned, which equals the largest reachable loss |
Tensor
|
once the radius saturates the set. |
Tensor
|
The expectation is accumulated as a correction to |
Tensor
|
rather than directly. Every term of |
Tensor
|
|
Tensor
|
never round to above |
Tensor
|
spread around a large offset keeps the precision of its spread |
Tensor
|
instead of losing it to the offset. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |