optora.dro.minimax_solver¶
Minimax solver wiring a divergence-based ambiguity set and a solver together.
MinimaxProblem
dataclass
¶
Distributionally robust minimization problem solved by MinimaxSolver.
Represents the DRO minimax problem
Every AmbiguitySet subclass in optora.dro evaluates its inner
supremum over candidate distributions q in worst_case_expectation,
either in closed form or by a dedicated inner solve. MinimaxProblem
therefore only describes the remaining outer minimization over the
decision variable x.
Attributes:
| Name | Type | Description |
|---|---|---|
ambiguity_set |
AmbiguitySet
|
Divergence-based ambiguity set whose
|
loss_fn |
Callable[[Tensor], Tensor]
|
Differentiable per-scenario loss as a function of the
decision variable, returning a tensor shaped like
|
initial_point |
Tensor
|
Starting point for the decision variable. |
MinimaxResult
dataclass
¶
Bases: ConvergenceDiagnostics
Outcome of a MinimaxSolver solve.
Attributes:
| Name | Type | Description |
|---|---|---|
point |
Tensor
|
Final decision-variable iterate. |
value |
Tensor
|
Worst-case expected loss at |
status |
ConvergenceStatus
|
Convergence diagnostics of the outer solve, exposed on the
host as |
MinimaxSolver
¶
Bases: Solver[MinimaxProblem, MinimaxResult]
Solves the DRO minimax problem by delegating to an ambiguity set's dual.
Wires together a divergence-based AmbiguitySet and an (outer) Solver
to solve
Every AmbiguitySet subclass evaluates its inner supremum in
worst_case_expectation(loss), so the composed function
x -> ambiguity_set.worst_case_expectation(loss_fn(x)) is an ordinary
differentiable scalar objective of x, and the remaining work is a
plain minimization over x. The composition stays differentiable in
x without differentiating through the inner solve. Each ambiguity
set finds its maximizer, or its dual optimum, in a detached solve and
attaches only the final value to the graph. By Danskin's theorem the
derivative of the supremum with respect to loss is the maximizing
distribution, so the chain rule through loss_fn gives the exact
gradient in x.
MinimaxSolver therefore passes that composed objective to solver,
the outer solver minimizing over x. It does not run a primal-dual
ascent-descent over the full candidate distribution q, as the
generic SaddlePointSolver does. Each concrete AmbiguitySet already
replaces that \(n\)-dimensional inner maximization with a closed form, a
scalar root search, a low-dimensional convex dual or, for
MMDAmbiguitySet, an interior-point method. None of them iterates
over the simplex.
One outer iteration therefore costs an entire inner solve, which is
orders of magnitude more expensive than the host synchronization of a
convergence check. Configure solver with check_interval=1. The
library-wide default optora.core.convergence.DEFAULT_CHECK_INTERVAL
is tuned for cheap inner loops, and with it the outer loop would keep
running frozen, and therefore wasted, inner solves after it has
converged.
The solve composes with torch.func transforms of its caller whenever
solver does, as optora.solvers.GradientDescent does. Every
ambiguity set's worst_case_expectation supports them, so
torch.func.vmap over a tensor radius, for example, solves one robust
problem per radius in one call.
Attributes:
| Name | Type | Description |
|---|---|---|
solver |
Solver minimizing the composed worst-case-expectation
objective over the decision variable. Should use
|
__init__(solver)
¶
Initialize the minimax solver.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
solver
|
Solver[MinimizationProblem, MinimizationResult]
|
Solver minimizing the composed worst-case-expectation
objective over the decision variable. Should use
|
required |
solve(problem)
¶
Solve the DRO minimax problem described by problem.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
problem
|
MinimaxProblem
|
Ambiguity set, per-scenario loss function, and initial decision-variable point to solve from. |
required |
Returns:
| Type | Description |
|---|---|
MinimaxResult
|
A |
MinimaxResult
|
and convergence diagnostics from |