Skip to content
Edit this page View source of this page

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),

\[ \sup_{P:\, \mathcal{W}_\epsilon(\hat P, P) \le \rho} \mathbb{E}_P[\ell] = \sup_{\gamma_1, \ldots, \gamma_n} \Big\{ \sum_i \hat p_i\, \mathbb{E}_{\gamma_i}[\ell] \;:\; \epsilon \sum_i \hat p_i\, \mathrm{KL}(\gamma_i \,\|\, Q_i) \le \bar\rho \Big\}, \]

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

EntropicTransportDivergence holding cost, reference, and epsilon, which contains uses.

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 (n, n) between the support points.

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 worst_case_expectation's loss.

required
reference Tensor | None

Nonnegative reference measure \(\nu\) of shape (n,) that the worst case may move mass onto. Defaults to the counting measure on the whole support.

None
max_iter int

Sinkhorn iterations, used only by contains. The worst case does not iterate.

1000
tol float

Sinkhorn tolerance for contains only.

1e-09
eps float | None

Deprecated and ignored, as in EntropicTransportDivergence. Passing it emits a DeprecationWarning.

None
check_interval int

Sinkhorn host-read interval for contains only.

DEFAULT_CHECK_INTERVAL
validate bool

Whether to run the value checks that synchronize with the device on nominal, a tensor radius, cost, and reference.

False

Raises:

Type Description
ValueError

If cost does not match nominal's support, a hyperparameter is invalid, radius is a negative float, or validate is set and an input is invalid.

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 nominal's.

None

Returns:

Type Description
Tensor

The distribution attained at radius zero, of nominal's shape.

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 nominal.

required

Returns:

Type Description
Tensor

A boolean tensor that is True where the divergence of

Tensor

candidate from nominal does not exceed radius.

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 (..., n), one trailing entry per element of nominal's support. Leading dimensions are a batch of independent loss vectors, bisected together in one vectorized solve.

required

Returns:

Type Description
Tensor

A tensor of shape (...) holding the worst-case expected loss.

Tensor

When radius is a zero float it is the exact expectation at

Tensor

the start of the tilt path (_center_expectation), which is

Tensor

sum(nominal * loss) by default. Otherwise it is the

Tensor

expectation of loss under the feasible tilted distribution

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 max(loss)

Tensor

rather than directly. Every term of

Tensor

sum(q * (loss - max(loss))) is nonpositive, so the result can

Tensor

never round to above max(loss), and a loss with a small

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 loss's trailing dimension does not match nominal's support size, its batch shape does not broadcast against nominal and radius, or validate is set and loss is not finite.