MPFit - A Python Library for Learning Approximate Solutions to Multiparametric Programming and Generalized Nash Equilibrium Problems.
Project description
mpfit
A Python library for Learning Approximate Solutions to Multiparametric Programming and Generalized Nash Equilibrium Problems
This repository includes a library for learning approximate solutions to multiparametric programming and generalized Nash equilibrium problems (GNEPs). Given a parametric optimization problem or a parametric GNEP, the library attempts fitting a solution model over a given set of parameters.
For more details about the mathematical formulations implemented in the library, see the arXiv preprint.
Installation
pip install mpfit
Usage
mpfit provides a general class MultiParametricFit to define rather arbitrary multiparametric GNE problems with $N$ players ($N>1$) and standard multiparametric programming problems ($N=1$).
For specific problems, the following classes are provided:
LQ_GNEP— (multi-agent) GNEP with convex quadratic objectives and shared linear constraintsQCQ_GNEP— (multi-agent) GNEP with convex quadratic objectives and shared quadratic and linear constraintsNL_GNEP— general nonlinear GNEPsMPQP— (single-agent) multiparametric QPsMPQCQP— (single-agent) multiparametric QCQPsMPNLP- (single agent) multiparametric NLPs
Example
Solve the following LQ-GNEP:
$$\min_{x_i}\ \tfrac{1}{2} x^T Q^{i} x + (c^i + F^i p)^T x \quad \text{s.t.} \quad Ax \leq b + Sp,\quad lb \le x \le ub$$
from mpfit import LQ_GNEP
# Define the problem, using `nashopt`'s syntax where Q = list of N dim(x)-by-dim(x) matrices,
# c = list of N vectors of dimension dim(x)
mp = LQ_GNEP(N, sizes, npar, Q, c, F, A, b, S, lb, ub, pmin, pmax, ncon)
# Stage 1: generate data and fit value functions
mp.setup(N_train=1000, N_val=1000)
# Stage 2: fit the solution network
mp.solve()
# Evaluate on test data
res = mp.test(N_test=1000)
# Predict GNE for a new parameter p
x_hat = mp.predict(p)
# Inspect the trained networks
sol_weights = mp.solution_network()
vf_weights = mp.value_function_network()
Citation
@article{MPFit,
author={A. Bemporad and T. Tatarenko},
title={Learning Approximate Solutions to Multiparametric Generalized {Nash} Equilibrium Problems},
journal = {arXiv preprint},
note = {\url{https://github.com/bemporad/mpfit}},
year=2026
}
Related packages
nashopt a Python library for computing generalized Nash equilibria and solving game-design and game-theoretic control problems.
nash-mpqp a Python package for solving parametric generalized Nash equilibrium problems with quadratic objectives and coupled linear inequality constraints in explicit form.
gnep-learn A Python package for solving Generalized Nash Equilibrium Problems by active learning of best-response models.
License
Apache 2.0
(C) 2026 A. Bemporad
Acknowledgement
This work was funded by the European Union (ERC Advanced Research Grant COMPACT, No. 101141351). Views and opinions expressed are however those of the authors only and do not necessarily reflect those of the European Union or the European Research Council. Neither the European Union nor the granting authority can be held responsible for them.
Project details
Release history Release notifications | RSS feed
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 mpfit-0.1.0.tar.gz.
File metadata
- Download URL: mpfit-0.1.0.tar.gz
- Upload date:
- Size: 44.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
331e50c565e87a86f7c890dcb35b299291c976740aa8fc95796f4230bdb61d33
|
|
| MD5 |
76ae8da24ea26a6af59f2e608cc98558
|
|
| BLAKE2b-256 |
f02545ac940cb3fa9fb4b83062c344408e2d0a1d5c5265da54173b7c7363fa19
|
File details
Details for the file mpfit-0.1.0-py3-none-any.whl.
File metadata
- Download URL: mpfit-0.1.0-py3-none-any.whl
- Upload date:
- Size: 57.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c3857998e64e04439d1513efce7a4a8e26aa5219c720ab8674eca7f242493738
|
|
| MD5 |
c583b2b3699a1e49e2f5f3d08201c333
|
|
| BLAKE2b-256 |
e4c26e19b5081de4b759d98bc0618939ef3c5e78292bb60590965a91174afd37
|