Skip to main content

PURIN logo

PURIN

Differentiable constraint projections and sparse numerical kernels in JAX.

CI Validation CodeQL Dependency review Coverage

Python 3.10–3.15 CPU platforms JAX License: Apache 2.0 Citation: BibTeX

Turn a parameterized constraint problem into a reusable projection layer. Use PURIN independently or as the numerical backend for OHAGI and the HardNet frontends.

  • Projection formulations: Euclidean distance, diagonal weighted distance and objective-aware local quadratic corrections.
  • Six solver methods: affine equality projection, Chambolle–Pock, ADMM, full/reduced Fischer–Burmeister and primal-dual interior point.
  • Sparse computation: reusable operators and kernels, including matrix-free paths where supported by the selected solver.
  • Differentiable layers: solver-specific implicit differentiation and numerical diagnostics for constrained learning.

Installation · Basic API · Projection methods · Documentation · Contributing · Citation

Installation

Requires Python 3.10 or newer. Install from PyPI:

python -m pip install purin

From a local stack checkout, use python -m pip install ./purin. PURIN does not depend on OHAGI or any frontend package.

Basic API

Project a point onto the affine equality u + v = b:

import jax
import jax.numpy as jnp
from purin import Distance, Projection

jax.config.update("jax_enable_x64", True)

problem = Projection()
p = problem.add_parameter(["b"])
y = problem.add_variable(["u", "v"])
problem.objective = 0.0
problem.constraints.add(y.u + y.v == p.b)

project = Distance(problem, "linear-equality").prepare(batch_size=1)
candidate = jnp.array([[2.0, 0.0]])  # Shape: (batch, variables).
parameters = jnp.array([[1.0]])     # Shape: (batch, parameters).
projected = project(candidate, parameters)
print(projected)  # [[ 1.5 -0.5]]

Prepare once and reuse the layer for its configured shapes and dtype. The same problem interface accepts other registered solver methods when their constraint requirements are satisfied.

Projection methods

Choose a solver for the constraint structure of your projection problem:

Algorithm / method name Suitable problems Implementation notes
Linear equality (linear-equality) Euclidean projection onto affine equalities, such as conservation equations or linear balance constraints. Direct equality-system solve. Requires verified affine constraints; inequalities and nonlinear equalities are rejected.
Chambolle–Pock (chambolle-pock) Convex distance projections with affine equalities, affine inequalities and bounds; useful for sparse polyhedral constraints. First-order primal-dual splitting with fixed-step or accelerated updates through ChambollePockConfig(accelerated=...). Both variants use shared sparse kernels.
ADMM (admm) Convex distance projections with affine equalities, affine inequalities and bounds, including structured linear constraints. OSQP-style operator splitting with configurable penalty and linear solves. Requires verified affine constraints.
Full Fischer–Burmeister Newton (fischer-burmeister-newton) Distance projections with smooth nonlinear equalities and inequalities, as well as affine constraints. Solves the full stationarity, feasibility and complementarity system using a Fischer–Burmeister reformulation.
Reduced Fischer–Burmeister (fischer-burmeister-reduced) The same affine or smooth nonlinear constrained projection class, especially when a reduced sparse Newton system is useful. Uses pivot reduction and sparse linear-system operators for the complementarity equations.
Primal-dual interior point (primal-dual-interior-point) Distance projections with smooth equality and inequality constraints, including nonlinear formulations. Uses primal-dual barrier iterations and Newton systems with positive slack and inequality-multiplier iterates.

Distance defines Euclidean projection; WeightedDistance supplies a positive diagonal metric for the supported CP, ADMM and interior-point interfaces. LocalQuadratic builds a positive diagonal quadratic objective and linearizes constraints around an anchor, then solves the local QP with CP. Its nonlinear constraints are approximated in that subproblem. Sequential composes corrections; it is not a separate numerical solver.

Lower-level closed-form BoxProjection (bound clipping) and AffineProjection (affine equality projection) utilities are available in purin.projections.closed_form. Use registered_methods() to list the six solver method names above; these utilities are not additional registry entries.

For nonlinear, nonconvex constraints, convergence to a local stationary point does not establish a globally nearest feasible point. Check solver diagnostics and residuals, and choose precision and tolerances for your problem.

The HardNet stack

  • KKTHN, DAEHN and NLPOPTNet supply problem formulations and framework-specific processing.
  • OHAGI composes models, runs the shared learning engine, and handles checkpoints and JAX deployment.
  • PURIN owns projection problems, numerical solvers, sparse kernels and projection differentiation.

Compatibility and validation

The PyPI CPU installation matrix covers Python 3.10–3.15 on Linux, Windows and macOS, plus Linux ARM64 on Python 3.13. It uses current compatible JAX releases; regular CI additionally tests JAX 0.6.2 on Python 3.12. See the release workflow for exact environments; accelerator installation follows the JAX guide.

  • CI: tests, distribution builds and installation checks.
  • Validation: public APIs, numerical references, documentation and code quality.
  • Coverage: at least 90% combined statement and branch coverage; the badge links to the measured report for this branch.
  • Security: CodeQL analysis and dependency review.

Documentation

Read the full documentation — installation, tutorials, user guide and API reference.

The full Sphinx guide follows the Read the Docs style: contents, runnable examples, API reference and build instructions.

Resource Contents
Projection methods Algorithm names, suitable problems and formulation choices
Contribution guide Solver boundaries, numerical validation and packaging
Validation policy API, gradient, sparse-kernel and quality checks
Changelog Initial release scope and changes

Contributing

Bug reports, examples and focused pull requests are welcome. Read CONTRIBUTING.md for setup, numerical checks and compatibility requirements. Keep generated results, environments and checkpoints out of Git.

Citation

Use CITATION.bib for a copyable BibTeX entry or GitHub's Cite this repository menu for citation metadata.

License

Apache License 2.0. Authorship and upstream attribution are recorded in AUTHORS and NOTICE.

Changelog · Report an issue

Metadata

Release files for purin 1.0.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 purin 1.0.0
File Size Uploaded Provenance Actions
purin-1.0.0.tar.gz 1.2 MB With provenance Details for purin-1.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for purin 1.0.0
File Interpreter ABI Platform Actions
purin-1.0.0-py3-none-any.whl Python 3 none any Details for purin-1.0.0-py3-none-any.whl

Total release size: 1.4 MB

Release files / purin-1.0.0.tar.gz

Download URL purin-1.0.0.tar.gz
Size 1.2 MB
Tags Source
SHA-256 checksum
How to use checksums
8b4b0727a0d18f8b72e0c97dd4bb1f46b8cde4b59311b66e40f460615ef6fedf
BLAKE2b-256 checksum
How to use checksums
5034832f393b1a65b794790b1f0ba55f901a5420f0e5b48685b0c7bab19ee452
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 5, 2026.

Transparency log

Release files / purin-1.0.0-py3-none-any.whl

Download URL purin-1.0.0-py3-none-any.whl
Size 232.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f8e904b6f6a6ad2d64183875dd92c768656841df7e72af4118661dc094aa035e
BLAKE2b-256 checksum
How to use checksums
202ed9424d8f41bd81094bbcf256eb08ec23f0ca50cfb81a66af5422aad3231a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 5, 2026.

Transparency log

Security for purin 1.0.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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for purin-1.0.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 5, 2026.

Transparency log

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