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.
  • At most 256 variables (dense BFGS). For larger sparse problems, an IPOPT-family solver fits better.
  • 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.17.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.17.0
File Size Uploaded Provenance
sqp_craft-0.17.0.tar.gz 178.0 kB Without provenance Details

Built distributions (wheels)

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

Total release size: 2.7 MB

Release files / sqp_craft-0.17.0.tar.gz

Download URL sqp_craft-0.17.0.tar.gz
Size 178.0 kB
Tags Source
SHA-256 checksum
How to use checksums
b81e8f6e086b61bea37d44705d68b3b7080dccfba743a7bcde19825e10b63aa3
BLAKE2b-256 checksum
How to use checksums
4149cdac1fcd12944ed8aad6181017dee4899dfa2b1ddb4440670931e6aba778
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.5 {"installer":{"name":"uv","version":"0.13.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","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.17.0-cp310-abi3-win_amd64.whl

Download URL sqp_craft-0.17.0-cp310-abi3-win_amd64.whl
Size 549.6 kB
Tags CPython 3.10 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
a6754d3a947dfaa6ea52b98bb76321ed73d90b2fee0c933343e2b868fdb8cf1a
BLAKE2b-256 checksum
How to use checksums
ba0be56f86b9c7da0eba38a6bea20799e7ca828d224e6a40914ba26b707e546d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.5 {"installer":{"name":"uv","version":"0.13.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","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.17.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL sqp_craft-0.17.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 713.0 kB
Tags CPython 3.10 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
586cafda88e6736e524807cafbfc015857110074b1ef8b7f809e6b68e054647e
BLAKE2b-256 checksum
How to use checksums
dd4ec3c4cdfa3f0dd51ac5ef4b8afe2d4dc66bfb38820705aa32fe32c4ac502c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.5 {"installer":{"name":"uv","version":"0.13.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","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.17.0-cp310-abi3-macosx_11_0_arm64.whl

Download URL sqp_craft-0.17.0-cp310-abi3-macosx_11_0_arm64.whl
Size 632.3 kB
Tags CPython 3.10 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
e3bdcc0424364f2f4a79a32d412a7978b22d291e29139bee7968f3194101be65
BLAKE2b-256 checksum
How to use checksums
c03421d904492aff67dfaa416310bf0b88d3b070d444592ad17a894ad39ab6b4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.5 {"installer":{"name":"uv","version":"0.13.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","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.17.0-cp310-abi3-macosx_10_12_x86_64.whl

Download URL sqp_craft-0.17.0-cp310-abi3-macosx_10_12_x86_64.whl
Size 635.1 kB
Tags CPython 3.10 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
a9ecd9fa6430f7ec71a69389e9172e139be7c689e1b80e283137c888244ca1e1
BLAKE2b-256 checksum
How to use checksums
05b39edd4de82b8370eca4626d7f6d98eea9b0fcdf167ea3770b426463721178
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.5 {"installer":{"name":"uv","version":"0.13.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","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.17.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.

Release history Release notifications | RSS feed

This release

0.17.0 This release

5 release files No provenance

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