Skip to main content

mincon

Nonlinear constrained optimization with a Rust solver and a simple Python API. Supply your objective, starting point and constraints. Derivative estimation, scaling and solver configuration have automatic defaults.

Experimental 0.1 release. This is research software under active development, not a completed or proven superior replacement for MATLAB's fmincon. It computes local solutions; it does not guarantee global minima.

Install

python -m pip install mincon

Prebuilt wheels target standard CPython on Windows x86_64 and Linux x86_64. NumPy is installed automatically. On platforms without a matching wheel, pip builds from source and requires Rust 1.83 or newer and a C/C++ toolchain. macOS wheels and broader runtime coverage remain release work.

Familiar fmincon inputs

from mincon import fmincon

# Closest point to (1, 1), subject to x[0] + x[1] <= 1.
result = fmincon(
    lambda x: ((x - 1)**2).sum(),
    [0., 0.],
    nonlcon=lambda x: ([x.sum() - 1], []),
)
print(result.x)       # approximately [0.5, 0.5]
print(result.fun)     # approximately 0.5
print(result.success, result.message)

No gradients, Hessians, algorithm selection or tolerance settings are required. Optional constraint arguments use MATLAB's conventions:

Argument Meaning
A, b A @ x <= b
Aeq, beq Aeq @ x == beq
lb, ub Lower/upper bounds, scalars or vectors
nonlcon Returns (c, ceq) with c <= 0, ceq == 0; use [] for an absent component

For example, fmincon(fun, x0, A=[[1, 1]], b=[1], lb=0) uses only linear constraints and bounds. The result is a Python object, not MATLAB's output tuple. result.multipliers groups multipliers with MATLAB's signs. Options use Python names such as options={"maxiter": 500}, not MATLAB option names.

SciPy-style inputs

from mincon import minimize

result = minimize(
    lambda x: ((x - 1)**2).sum(),
    [0., 0.],
    constraints={"type": "ineq", "fun": lambda x: 1 - x.sum()},
)

Sign convention: minimize inequalities mean fun(x) >= 0; fmincon nonlinear inequalities mean c(x) <= 0. Equalities are zero in both. Use bounds=[(0, None), (0, None)] with minimize; use lb=0 with fmincon.

Supply jac= if you have an analytical objective gradient. It is optional. args=(...) passes additional arguments to your objective and nonlinear constraints. Inspect help(fmincon) or help(minimize) for the full interface.

Interpreting results

  • x, fun: returned point and objective.
  • success: requested numerical first-order and feasibility checks passed. This is not a second-order or global-minimum certificate.
  • maxcv: constraint violation in your original units.
  • usable: a usable-point status; it does not replace checking success.
  • message, notes: termination reason and solver diagnostics.
  • nfev, nit: objective calls across the portfolio and iteration count.

Always examine the status and feasibility before using the result. An Acceptable or stagnation exit has success=False. Finite differences and noisy model evaluations limit attainable accuracy.

Current scope

Implemented: primal-dual interior point, feasibility restoration, automatic gradient scaling, bounded finite differences with retreat, Jacobian sparsity detection/coloring and a portfolio of interior-point configurations. Python callbacks run serially. SQP, sparse user Jacobians, limited-memory curvature, hard per-callback evaluation budgets and progress callbacks are not complete. maxfev and time limits are checked between batches/iterations; they cannot interrupt an ongoing callback. The derivative checker needs further validation for failed or unevaluable checks; it is not a certificate.

The local development suite passes 54/54 expected fixture outcomes, with 40 strict Optimal returns. Fixture passes also include accurate points with non-success statuses and expected infeasible/unbounded diagnostics. Broader CUTEst and matched competitor comparisons remain outstanding.

License

MIT OR Apache-2.0. Rust dependency notices are included in the installed package as THIRD_PARTY_LICENSES.txt. Source is included in the source distribution; no MATLAB installation or license is required.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mincon-0.1.0.tar.gz (165.5 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

mincon-0.1.0-cp39-abi3-win_amd64.whl (367.8 kB view details)

Uploaded CPython 3.9+Windows x86-64

mincon-0.1.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (465.2 kB view details)

Uploaded CPython 3.9+manylinux: glibc 2.17+ x86-64

File details

Details for the file mincon-0.1.0.tar.gz.

File metadata

  • Download URL: mincon-0.1.0.tar.gz
  • Upload date:
  • Size: 165.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.12.14

File hashes

Hashes for mincon-0.1.0.tar.gz
Algorithm Hash digest
SHA256 17fad632ccde81d1c318bbc62244b19f5ee8231f0b9f6b21ab4801edb74f4cf3
MD5 cc7e08b1c020e058172e203d6e2131e9
BLAKE2b-256 7f5efa9835b8805c783c9f3490903ae8c15b352da22d0f3fcbc9a8eeafa1ef17

See more details on using hashes here.

File details

Details for the file mincon-0.1.0-cp39-abi3-win_amd64.whl.

File metadata

  • Download URL: mincon-0.1.0-cp39-abi3-win_amd64.whl
  • Upload date:
  • Size: 367.8 kB
  • Tags: CPython 3.9+, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.12.14

File hashes

Hashes for mincon-0.1.0-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 211cddf4ac7864409ada839980cfe0c7726d73e61dc5e1b5f0f9017952f71d31
MD5 1bba509ac35681be51066c37f9a38ff5
BLAKE2b-256 88568c3cb6b10634c354279c6a6c1549bb8aef615a77940b644425d66d73e85c

See more details on using hashes here.

File details

Details for the file mincon-0.1.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for mincon-0.1.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 619fe5054c4347ae776fbdf72a99b9bb45b727229d5b6f129f8d228066a83ad9
MD5 41df1cfbb7d5f57ae1ac9dc85ddbb0b1
BLAKE2b-256 17711ae4e0b5b704382a6080fc5f27b2644681c3131a5c484a46db63e0a4d1e9

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.1.0 This release

3 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