Optora
A small, composable, PyTorch-native library for distributionally robust optimization (DRO).
Status: pre-alpha (v0.0.3) · Python 3.10+ · PyTorch ≥2.2 · MIT License
I started building Optora because most of the DRO code I ran into while
reading papers lived inside one-off experiment scripts, hard-wired to
whatever setup that particular paper used. Optora is a small, composable
set of pieces instead — a divergence, an ambiguity set, a solver — that
you wire together yourself rather than calling a fit() that picks an
algorithm on your behalf. Everything runs on PyTorch tensors, so gradients
flow through the whole pipeline and nothing here blocks running on a GPU.
Quick start
Optora is pre-alpha and not yet published on PyPI; install it from a local clone in editable mode:
pip install -e ".[dev,docs]"
Find the decision x that minimizes the worst-case squared error against
a KL-ball of plausible distributions over four observed outcomes:
import torch
from optora.dro import KLAmbiguitySet, MinimaxProblem, MinimaxSolver
nominal = torch.tensor([0.25, 0.25, 0.25, 0.25])
outcomes = torch.tensor([1.0, 2.0, 3.0, 10.0])
problem = MinimaxProblem(
ambiguity_set=KLAmbiguitySet(nominal=nominal, radius=0.1),
loss_fn=lambda x: (outcomes - x) ** 2,
initial_point=torch.tensor(0.0),
)
robust_decision = MinimaxSolver().solve(problem).point
What is implemented today
Ambiguity sets (optora.dro), the divergences underneath them
(optora.divergences), and the solvers underneath those (optora.solvers)
are implemented end to end: KLAmbiguitySet, PhiAmbiguitySet (plus
ChiSquareAmbiguitySet and TotalVariationAmbiguitySet), and
WassersteinAmbiguitySet, wired together by MinimaxSolver. Every piece
is covered by pytest tests checked against known closed-form results,
independent grid-search cross-checks, convergence limits, and
monotonicity properties, and the whole package is type-checked under
mypy's strict mode.
Learn more
- Full mathematical formulations and design rationale:
docs/formulations.md. - Runnable, visualized DRO examples (GitHub-only, not shipped with the
package):
examples/— install with theexamplesextra (pip install -e ".[examples]"). - API reference: built with Zensical from source docstrings, see
docs/.
Development
Optora targets Python 3.10+ and PyTorch 2.2+. From an activated virtual environment in the repository root:
pip install -e ".[dev,docs]"
pytest
ruff check .
ruff format --check .
mypy
License
Optora is distributed under the MIT License; see LICENSE
for the full text.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file optora-0.0.5.tar.gz.
File metadata
- Download URL: optora-0.0.5.tar.gz
- Upload date:
- Size: 22.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7bf771d77451024396347da2eb9f68cc88a8e2d88b944b7f30eef028c07fc455
|
|
| MD5 |
a9e700a817fe16d96279f41c4ae2dc7e
|
|
| BLAKE2b-256 |
39b450ec0ed269e40867a01634e46acac4cd94ea855966fac2b9793b30559c58
|
Provenance
The following attestation bundles were made for optora-0.0.5.tar.gz:
Publisher:
release.yml on navidsharifi/optora
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
optora-0.0.5.tar.gz -
Subject digest:
7bf771d77451024396347da2eb9f68cc88a8e2d88b944b7f30eef028c07fc455 - Sigstore transparency entry: 2582688456
- Sigstore integration time:
-
Permalink:
navidsharifi/optora@f6b6915ac11bbba3f5c4dbd6a755c14a4a0e1d09 -
Branch / Tag:
refs/tags/v0.0.5 - Owner: https://github.com/navidsharifi
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@f6b6915ac11bbba3f5c4dbd6a755c14a4a0e1d09 -
Trigger Event:
push
-
Statement type:
File details
Details for the file optora-0.0.5-py3-none-any.whl.
File metadata
- Download URL: optora-0.0.5-py3-none-any.whl
- Upload date:
- Size: 28.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1b9eea902ce5ac5931111793863501503cc9c57efe35c8bda8ed8f0115e138a4
|
|
| MD5 |
4299c36e96b5fcc9a4d9d897a6cd185f
|
|
| BLAKE2b-256 |
7999991e5e2c2c7ee0830c669141d4226987f02c89c80596efe36c97b57558cc
|
Provenance
The following attestation bundles were made for optora-0.0.5-py3-none-any.whl:
Publisher:
release.yml on navidsharifi/optora
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
optora-0.0.5-py3-none-any.whl -
Subject digest:
1b9eea902ce5ac5931111793863501503cc9c57efe35c8bda8ed8f0115e138a4 - Sigstore transparency entry: 2582688460
- Sigstore integration time:
-
Permalink:
navidsharifi/optora@f6b6915ac11bbba3f5c4dbd6a755c14a4a0e1d09 -
Branch / Tag:
refs/tags/v0.0.5 - Owner: https://github.com/navidsharifi
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@f6b6915ac11bbba3f5c4dbd6a755c14a4a0e1d09 -
Trigger Event:
push
-
Statement type: