Skip to main content

InvOpt: Inverse Optimization with Python

InvOpt is an open-source Python package for solving Inverse Optimization (IO) problems. In IO problems, our goal is to model the behavior of an expert agent, which given an exogenous signal, returns a response action. The underlying assumption of IO is that to compute its response, the expert agent solves an optimization problem parametric in an exogenous signal. We assume to know the constraints imposed on the expert, but not its cost function. Therefore, using examples of exogenous signals and corresponding expert response actions, our goal is to model the cost function being optimized by the expert. More concretely, given a dataset $\mathcal{D} = \{(\hat{s}_ i, \hat{x}_ i)\}_ {i=1}^N$ of exogenous signals $\hat{s}_ i$ and the respective expert's response $\hat{x}_ i$, feature mapping $\phi$, our goal is to find a cost vector $\theta \in \mathbb{R}^p$ such that a minimizer $x_ i$ of the Forward Optimization Problem (FOP)

$$ x_i \in \arg\min_ {x \in \mathbb{X}(\hat{s}_ i)} \ \langle \theta,\phi(\hat{s}_ i,x) \rangle $$

reproduces (or in some sense approximates) the expert's action $\hat{x}_ i$. For a more detailed description of IO problems and their modeling, please refer to Zattoni Scroccaro et al. (2023) and the references therein.

Installation

pip install invopt

InvOpt depends on numpy. Moreover, some of its functions also depend on gurobipy or cvxpy. You can get a free academic license for Gurobi here.

Usage and examples

The following functions are available in the InvOpt package:

  • discrete_consistent: for FOPs with discrete decision spaces (e.g., binary), and when the dataset is consistent with some cost vector. Can be used to check if the data is consistent.
  • discrete: for FOPs with dicrete decision spaces (e.g., binary).
  • continuous_linear: for continuous, linear FOPs.
  • continuous_quadratic: for continuous, quadratic FOPs.
  • mixed_integer_linear: for FOPs with mixed-integer decision spaces and cost functions linear w.r.t. the continuous part of the decision variable.
  • mixed_integer_quadratic: for FOPs with mixed-integer decision spaces and cost functions quadratic w.r.t. the continuous part of the decision variable.
  • FOM: for general FOPs. Solves IO problem approximately using first-order methods.

Contributing

Contributions, pull requests and suggestions are very much welcome. The TODO file contains some ideas to possibly improve the InvOpt package.

Citing

If you use InvOpt for research, please cite our accompanying paper:

@article{zattoniscroccaro2023learning,
  title={Learning in Inverse Optimization: Incenter Cost, Augmented Suboptimality Loss, and Algorithms},
  author={Zattoni Scroccaro, Pedro and Atasoy, Bilge and Mohajerin Esfahani, Peyman},
  journal={https://arxiv.org/abs/2305.07730},
  year={2023}
}

Metadata

Release files for invopt 0.0.7

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for invopt 0.0.7
File Size Uploaded Provenance Actions
invopt-0.0.7.tar.gz 15.4 kB Without provenance Details for invopt-0.0.7.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for invopt 0.0.7
File Interpreter ABI Platform Actions
invopt-0.0.7-py3-none-any.whl Python 3 none any Details for invopt-0.0.7-py3-none-any.whl

Total release size: 29.2 kB

Release files / invopt-0.0.7.tar.gz

Download URL invopt-0.0.7.tar.gz
Size 15.4 kB
Tags Source
SHA-256 checksum
How to use checksums
bc02017229aa632f20c3ec90de6e0cfb9e7965d11166354024d0826c2cd10861
BLAKE2b-256 checksum
How to use checksums
47fef472991eb69c18c26f75be67e5b050931903ee66bfdea5fa95ce17a1b3bb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.12.1

Release files / invopt-0.0.7-py3-none-any.whl

Download URL invopt-0.0.7-py3-none-any.whl
Size 13.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
cec82df4a412b127b509b039eb96bde1943c49c494df624748638b991dcddf33
BLAKE2b-256 checksum
How to use checksums
453ed2b4c2fd2e63b4c10c9a75b7c887aff2b409170b5cdc7cccf310f746c11b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.12.1

Security for invopt 0.0.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page