Skip to main content

SQP-craft: smooth constrained optimization in Rust

sqp-craft

Sequential quadratic programming (SQP) for smooth constrained nonlinear problems, with a native Rust solver: damped BFGS updates of a dense Hessian approximation, step QPs solved by active-set or Clarabel, and an ℓ1 merit line search. Since 0.19.0 the qp_solver="auto" default uses active-set with elastic steps for full/block BFGS and Clarabel for partitioned/exact curvature. Results report stationarity, complementarity and dual-sign residuals of the KKT conditions, and kkt_residuals and check_derivatives check points and derivatives independently.

Install

python -m pip install sqp-craft

Wheels (abi3, CPython 3.10 or newer) cover Linux x86_64, Windows x64 and macOS x86_64/arm64 and need no compiler. On other platforms pip builds the source distribution, which needs Rust 1.85 or newer. The package depends on nothing else at run time.

Example

from sqp_craft import ProblemSpec, check_derivatives, solve

class Model:
    """minimize (x0-2)^2 + (x1-1)^2  subject to  x0^2 - x1 <= 0,  x0 + x1 <= 2"""
    def functions(self, x):
        return (x[0] - 2) ** 2 + (x[1] - 1) ** 2, [x[0] ** 2 - x[1], x[0] + x[1]]

    def derivatives(self, x):  # gradient, then the Jacobian values in CSR order
        return [2 * (x[0] - 2), 2 * (x[1] - 1)], [2 * x[0], -1.0, 1.0, 1.0]

inf = float("inf")
spec = ProblemSpec(lower=[-5, -5], upper=[5, 5],
                   constraint_lower=[-inf, -inf], constraint_upper=[0, 2],
                   jacobian_indptr=[0, 2, 4], jacobian_indices=[0, 1, 0, 1])
assert check_derivatives(spec, Model(), [0.5, 0.5]).passed
result = solve(spec, Model(), [0.5, 0.5], method="sqp")
print(result.status, result.candidate, result.evaluation.objective)
# converged, candidate ≈ [1, 1], objective ≈ 1

Pass method="sqp": the default method="dummy" only evaluates the start point. SqpOptions configures the solver (iteration, callback and time limits, KKT tolerances, qp_solver="auto", "clarabel" or "active-set", elastic_mode=None for the policy default or an explicit boolean); invalid values raise ValueError. Callbacks run serially on the calling thread.

Limits

  • Smooth (twice continuously differentiable) objective and constraints with first derivatives; kinks, noise and branches break BFGS and the line search.
  • Full and uniform-block BFGS accept up to 256 variables. Experimental structured SQP uses sparse curvature and Clarabel for larger models with declared structure.
  • A local method: converged means a first-order KKT point within the tolerances, not a global optimum. Use several starts for multimodal models.

More

MIT license.

See backend selection for migration. Explicit backends retain nonelastic behavior unless elastic_mode=True is requested. Reports expose the resolved qp_solver and elastic_mode, including before the first QP on cancelled or limited runs.

Metadata

Release files for sqp-craft 0.19.0

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

Source distribution (sdist)

Source distribution for sqp-craft 0.19.0
File Size Uploaded Provenance Actions
sqp_craft-0.19.0.tar.gz 196.6 kB Without provenance Details for sqp_craft-0.19.0.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for sqp-craft 0.19.0
File Actions
sqp_craft-0.19.0-cp310-abi3-win_amd64.whl CPython 3.10 abi3 Windows x86-64 Details for sqp_craft-0.19.0-cp310-abi3-win_amd64.whl
sqp_craft-0.19.0-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl CPython 3.10 abi3 Linux glibc 2.17+ x86-64 Details for sqp_craft-0.19.0-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
sqp_craft-0.19.0-cp310-abi3-macosx_11_0_arm64.whl CPython 3.10 abi3 macOS 11.0+ ARM64 Details for sqp_craft-0.19.0-cp310-abi3-macosx_11_0_arm64.whl
sqp_craft-0.19.0-cp310-abi3-macosx_10_12_x86_64.whl CPython 3.10 abi3 macOS 10.12+ x86-64 Details for sqp_craft-0.19.0-cp310-abi3-macosx_10_12_x86_64.whl

Total release size: 3.0 MB

Release files / sqp_craft-0.19.0.tar.gz

Download URL sqp_craft-0.19.0.tar.gz
Size 196.6 kB
Tags Source
SHA-256 checksum
How to use checksums
35d75956d2a89d83d79791a8705c4423cf753a50e199f771d5b7071c3041948e
BLAKE2b-256 checksum
How to use checksums
948caf887a2206aa471da5f09f924f4b51f2a2a9eb2c054ff904cec9eb7bac69
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.8 {"installer":{"name":"uv","version":"0.13.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / sqp_craft-0.19.0-cp310-abi3-win_amd64.whl

Download URL sqp_craft-0.19.0-cp310-abi3-win_amd64.whl
Size 610.8 kB
Tags CPython 3.10 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
7fe88b81aff47fe87c5f8080766808f80421ec12ea7fd595ed25ac4b782e7ab5
BLAKE2b-256 checksum
How to use checksums
1223125d71fe501194cc13fe733ae2273c7acf7ff4ff8df2e0ac5fe87cfed4db
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.8 {"installer":{"name":"uv","version":"0.13.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / sqp_craft-0.19.0-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL sqp_craft-0.19.0-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 774.1 kB
Tags CPython 3.10 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
7eafded7e6103e3ff9410aa401f7b9016cb23987e8d4f1d1bee4022c94d9b78f
BLAKE2b-256 checksum
How to use checksums
014db20a6ae01ddbcef63e5541173a9655be914cc8c7aa24f1fb90f5378d21b7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.8 {"installer":{"name":"uv","version":"0.13.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / sqp_craft-0.19.0-cp310-abi3-macosx_11_0_arm64.whl

Download URL sqp_craft-0.19.0-cp310-abi3-macosx_11_0_arm64.whl
Size 687.2 kB
Tags CPython 3.10 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
0b1227c3b30b45ca6921b55c9c49ce4458b17b3d86aa231ecc5fca5a5c375057
BLAKE2b-256 checksum
How to use checksums
397935e64c6216408d075d1f852adc9bee31db206bb9ab72ede89f81f108256c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.8 {"installer":{"name":"uv","version":"0.13.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / sqp_craft-0.19.0-cp310-abi3-macosx_10_12_x86_64.whl

Download URL sqp_craft-0.19.0-cp310-abi3-macosx_10_12_x86_64.whl
Size 696.5 kB
Tags CPython 3.10 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
7ae3798c699dba82999970c7daee3e028d485bbf9dd232973ec6d7e22128ab8f
BLAKE2b-256 checksum
How to use checksums
b51591a548e4e920d3edb27ad07608f62fc698161f193d9ffbe14dcf22df5f9b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.8 {"installer":{"name":"uv","version":"0.13.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for sqp-craft 0.19.0

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