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.20.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.20.0
File Size Uploaded Provenance Actions
sqp_craft-0.20.0.tar.gz 204.8 kB Without provenance Details for sqp_craft-0.20.0.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for sqp-craft 0.20.0
File Actions
sqp_craft-0.20.0-cp310-abi3-win_amd64.whl CPython 3.10 abi3 Windows x86-64 Details for sqp_craft-0.20.0-cp310-abi3-win_amd64.whl
sqp_craft-0.20.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.20.0-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
sqp_craft-0.20.0-cp310-abi3-macosx_11_0_arm64.whl CPython 3.10 abi3 macOS 11.0+ ARM64 Details for sqp_craft-0.20.0-cp310-abi3-macosx_11_0_arm64.whl
sqp_craft-0.20.0-cp310-abi3-macosx_10_12_x86_64.whl CPython 3.10 abi3 macOS 10.12+ x86-64 Details for sqp_craft-0.20.0-cp310-abi3-macosx_10_12_x86_64.whl

Total release size: 3.0 MB

Release files / sqp_craft-0.20.0.tar.gz

Download URL sqp_craft-0.20.0.tar.gz
Size 204.8 kB
Tags Source
SHA-256 checksum
How to use checksums
cb2a98ac1751d439dee66e51ec1b7ce0b3d6eb2961c66ab865c0fcd9a0c79399
BLAKE2b-256 checksum
How to use checksums
b0dec7ed150c1f3951fa99fa2f780d888fa1783809fa873381ef6bf3d6646d6e
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.20.0-cp310-abi3-win_amd64.whl

Download URL sqp_craft-0.20.0-cp310-abi3-win_amd64.whl
Size 621.0 kB
Tags CPython 3.10 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
786e17c23374a352f88f2755a7bbaa8aa6f6a693430c5971e3737deb04d80531
BLAKE2b-256 checksum
How to use checksums
cbfb4dbd674867c6009b6f80adee00c8d131189e850e955722cba829ef5225ce
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.20.0-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL sqp_craft-0.20.0-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 785.6 kB
Tags CPython 3.10 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
37153a9603d4f006a45a4a771c56842a600d37f985993d3e993f538979ad1446
BLAKE2b-256 checksum
How to use checksums
b122d19b4ae8cfb126ada13493d2d04bbaa8a9c24bff32dabafd39e197ca149c
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.20.0-cp310-abi3-macosx_11_0_arm64.whl

Download URL sqp_craft-0.20.0-cp310-abi3-macosx_11_0_arm64.whl
Size 690.0 kB
Tags CPython 3.10 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
e6269b37393c82a5b8c09c2d8ba4160259ef0ab6bf54f0ac478ce85402fd264e
BLAKE2b-256 checksum
How to use checksums
e65542b5e6f457aba3d4f6f22bfca56b3998a806ff3470caa0c693d8a549423f
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.20.0-cp310-abi3-macosx_10_12_x86_64.whl

Download URL sqp_craft-0.20.0-cp310-abi3-macosx_10_12_x86_64.whl
Size 705.5 kB
Tags CPython 3.10 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
4ae6024cefcc60932fc9624e022ce878e05f6fd3158f88fb7e44fe95053a74cf
BLAKE2b-256 checksum
How to use checksums
d605dc3154420c0a0c8586f432c759314354f7add757dd42d1890b441bbfb229
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.20.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