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 Clarabel (interior point, the default) or a dense active-set backend, and an ℓ1 merit line search. 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="clarabel" or "active-set", elastic_mode with the active-set backend for infeasible linearizations); 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.

Metadata

Release files for sqp-craft 0.18.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.18.0
File Size Uploaded Provenance Actions
sqp_craft-0.18.0.tar.gz 193.8 kB Without provenance Details for sqp_craft-0.18.0.tar.gz

Built distributions (wheels)

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

Total release size: 3.0 MB

Release files / sqp_craft-0.18.0.tar.gz

Download URL sqp_craft-0.18.0.tar.gz
Size 193.8 kB
Tags Source
SHA-256 checksum
How to use checksums
5da431187e0c59b8a87af39fda5d9feb0c97c42b1ad3f71b5b1453717179a59d
BLAKE2b-256 checksum
How to use checksums
58aeae56e77ad7c3e490d4f42d40bc84da4081f8c143baa70fd0cce98bf7e733
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.7 {"installer":{"name":"uv","version":"0.13.7","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.18.0-cp310-abi3-win_amd64.whl

Download URL sqp_craft-0.18.0-cp310-abi3-win_amd64.whl
Size 610.3 kB
Tags CPython 3.10 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
cf1637b5931af93e171a4cefb6c45b027da32dc566668911494cdc6181f70394
BLAKE2b-256 checksum
How to use checksums
16ea5b740d52d3ec016e9e1803bea30e29909133e240747720a16b978ffb71c3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.7 {"installer":{"name":"uv","version":"0.13.7","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.18.0-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL sqp_craft-0.18.0-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 774.5 kB
Tags CPython 3.10 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
47a3523571a922fb245eacb6dfca991c23f5cb7dd0598aae3e80ca3161ac3970
BLAKE2b-256 checksum
How to use checksums
380cf175683291213932e10145c351b7cb49a24ed8b84d6dff9c55b46e244e3d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.7 {"installer":{"name":"uv","version":"0.13.7","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.18.0-cp310-abi3-macosx_11_0_arm64.whl

Download URL sqp_craft-0.18.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
8db4cde85041f2fcb18440c88c4b4f8a4800ed0bd6f3d31b118ae95bfa893106
BLAKE2b-256 checksum
How to use checksums
742a20fe8d94d3e3fea89a5d41da11dcdc9effa0a54e8a3d74b50072f89473d9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.7 {"installer":{"name":"uv","version":"0.13.7","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.18.0-cp310-abi3-macosx_10_12_x86_64.whl

Download URL sqp_craft-0.18.0-cp310-abi3-macosx_10_12_x86_64.whl
Size 695.8 kB
Tags CPython 3.10 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
0acad7ddf5a9df5dd7655fa1913e084b4e23823297f3a6a3da8ff7a41f20a419
BLAKE2b-256 checksum
How to use checksums
49cc2b676af709172fbcca4c082af1c1c05fe5aeebdf8c1a4edbc4d5f8940ce0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.7 {"installer":{"name":"uv","version":"0.13.7","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.18.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