Examples

Each page below is an executable notebook — built and run by Sphinx on every docs build, so the outputs you see are guaranteed to match the current code.

Getting started

Notebook

Demonstrates

A first MPCC

The 15-line quickstart, walked through with full output explained.

Tour of strategies

Same problem solved by all six canonical reformulations.

MCP variable-paired form

comp_var_pairs for \(x_j \ge 0\ \perp\ F(x) \ge 0\) pairs.

Sparse Jacobians

COO sparsity for comp_G_jacobian, etc.; dense vs. sparse parity.

Stationarity hierarchy

S / M / C / W stationarity in one notebook.

KKT residual

Reading and recomputing result.kkt_residual.

Strategies & solvers

Notebook

Demonstrates

Slack-lifting strategy

strategy="slack" for large-n MPCCs with dense \(G\), \(H\).

NCP variants

The seven smooth-NCP-function reformulations side-by-side.

Multistart

pympcc.multistart with n_starts, unique_optima(), parallel notes.

Stateful warm hot-start

MPCCSolver.resolve() for MPC and parametric sweeps.

Diagnostics & certification

Notebook

Demonstrates

Presolve

Pinned-variable elimination, FBBT, dead-pair pruning.

Diagnostics tour

CQ, B-stationarity, SOSC, merit cross-check, degeneracy report.

TNLP refinement

Certified MPCC multipliers via tnlp_refine=True.

Bilevel & differentiable

Notebook

Demonstrates

Bilevel KKT emission

pympcc.bilevel.from_lower_level on two small bilevels.

Differentiable solve

jax.grad through a converged MPCC; FD verification.

Parametric sweep

pympcc.sensitivity validated against a re-solve.