Skip to main content
mpfit

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


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 constraints
  • QCQ_GNEP — (multi-agent) GNEP with convex quadratic objectives and shared quadratic and linear constraints
  • NL_GNEP — general nonlinear GNEPs
  • MPQP — (single-agent) multiparametric QPs
  • MPQCQP — (single-agent) multiparametric QCQPs
  • MPNLP - (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 2605.28757},
    year=2026
}

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.

ERC

Metadata

Release files for mpfit 0.1.1

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

Source distribution (sdist)

Source distribution for mpfit 0.1.1
File Size Uploaded
mpfit-0.1.1.tar.gz 45.1 kB Details

Built distribution (wheel)

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

Total release size: 102.8 kB

Release files / mpfit-0.1.1.tar.gz

Download URL mpfit-0.1.1.tar.gz
Size 45.1 kB
Tags Source
SHA-256 checksum
How to use checksums
016210cb3a034572a9890334060b231702d3c43a373118ae66dc9a3befa2b0ca
BLAKE2b-256 checksum
How to use checksums
b4cc70e83e0e043e7a05f02f9a98f82061562e6a76b0d29b84eb402fc756bbfd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.15

Release files / mpfit-0.1.1-py3-none-any.whl

Download URL mpfit-0.1.1-py3-none-any.whl
Size 57.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e649fd2faf323209d4e400e327789a84367fb5600ab8468bfb3a096a19849556
BLAKE2b-256 checksum
How to use checksums
2904960d4f3d0355d57043fa3629d39aaf5c3d9b2c748d723b2cde33f27fc653
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.15

Release history Release notifications | RSS feed

0.1.2

2 release files

This release

0.1.1 This release

2 release files

0.1.0

2 release files

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