purin 1.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- purin-1.0.0/AUTHORS +4 -0
- purin-1.0.0/CHANGELOG.md +43 -0
- purin-1.0.0/CITATION.bib +8 -0
- purin-1.0.0/CITATION.cff +10 -0
- purin-1.0.0/CONTRIBUTING.md +164 -0
- purin-1.0.0/LICENSE +201 -0
- purin-1.0.0/MANIFEST.in +4 -0
- purin-1.0.0/NOTICE +12 -0
- purin-1.0.0/PKG-INFO +205 -0
- purin-1.0.0/README.md +160 -0
- purin-1.0.0/assets/purin-logo-v2.png +0 -0
- purin-1.0.0/assets/purin-logo.png +0 -0
- purin-1.0.0/docs/BUILD.md +40 -0
- purin-1.0.0/docs/COMPATIBILITY.md +34 -0
- purin-1.0.0/docs/CONFIGURATION.md +32 -0
- purin-1.0.0/docs/ECOSYSTEM.md +18 -0
- purin-1.0.0/docs/INSTALL.md +23 -0
- purin-1.0.0/docs/MIGRATION.md +16 -0
- purin-1.0.0/docs/PROBLEM.md +37 -0
- purin-1.0.0/docs/PUBLISHING.md +114 -0
- purin-1.0.0/docs/SOLVERS.md +41 -0
- purin-1.0.0/docs/_static/custom.css +7 -0
- purin-1.0.0/docs/api/index.rst +13 -0
- purin-1.0.0/docs/api/operators.rst +11 -0
- purin-1.0.0/docs/api/problems.rst +17 -0
- purin-1.0.0/docs/api/projections.rst +17 -0
- purin-1.0.0/docs/api/solvers.rst +25 -0
- purin-1.0.0/docs/changelog.rst +7 -0
- purin-1.0.0/docs/citations.rst +8 -0
- purin-1.0.0/docs/conf.py +55 -0
- purin-1.0.0/docs/contributing.rst +7 -0
- purin-1.0.0/docs/examples/derivatives.py +24 -0
- purin-1.0.0/docs/examples/derivatives.rst +11 -0
- purin-1.0.0/docs/examples/index.rst +8 -0
- purin-1.0.0/docs/examples/quickstart.py +23 -0
- purin-1.0.0/docs/examples/quickstart.rst +25 -0
- purin-1.0.0/docs/index.rst +48 -0
- purin-1.0.0/docs/license.rst +11 -0
- purin-1.0.0/docs/requirements.txt +7 -0
- purin-1.0.0/docs/user-guide/index.rst +10 -0
- purin-1.0.0/pyproject.toml +70 -0
- purin-1.0.0/setup.cfg +4 -0
- purin-1.0.0/src/purin/__init__.py +45 -0
- purin-1.0.0/src/purin/_utils/__init__.py +1 -0
- purin-1.0.0/src/purin/_utils/validation.py +70 -0
- purin-1.0.0/src/purin/autodiff/complementarity.py +23 -0
- purin-1.0.0/src/purin/autodiff/fixed_point.py +42 -0
- purin-1.0.0/src/purin/compilation/__init__.py +13 -0
- purin-1.0.0/src/purin/differentiation/__init__.py +8 -0
- purin-1.0.0/src/purin/differentiation/policies.py +19 -0
- purin-1.0.0/src/purin/execution/__init__.py +1 -0
- purin-1.0.0/src/purin/execution/runtime.py +103 -0
- purin-1.0.0/src/purin/linalg/__init__.py +1 -0
- purin-1.0.0/src/purin/linalg/direct.py +98 -0
- purin-1.0.0/src/purin/linalg/equilibration.py +57 -0
- purin-1.0.0/src/purin/linalg/operators.py +66 -0
- purin-1.0.0/src/purin/linalg/sparse/__init__.py +31 -0
- purin-1.0.0/src/purin/linalg/sparse/assembly.py +91 -0
- purin-1.0.0/src/purin/linalg/sparse/conversion.py +39 -0
- purin-1.0.0/src/purin/linalg/sparse/minres.py +175 -0
- purin-1.0.0/src/purin/linalg/sparse/operators.py +663 -0
- purin-1.0.0/src/purin/linalg/sparse/types.py +29 -0
- purin-1.0.0/src/purin/problems/__init__.py +30 -0
- purin-1.0.0/src/purin/problems/canonical.py +52 -0
- purin-1.0.0/src/purin/problems/compile.py +143 -0
- purin-1.0.0/src/purin/problems/expressions.py +539 -0
- purin-1.0.0/src/purin/problems/functional.py +210 -0
- purin-1.0.0/src/purin/problems/problem.py +2282 -0
- purin-1.0.0/src/purin/problems/projection.py +34 -0
- purin-1.0.0/src/purin/problems/qp.py +402 -0
- purin-1.0.0/src/purin/problems/sparsity.py +100 -0
- purin-1.0.0/src/purin/problems/symbolic.py +85 -0
- purin-1.0.0/src/purin/problems/types.py +97 -0
- purin-1.0.0/src/purin/projections/__init__.py +5 -0
- purin-1.0.0/src/purin/projections/adapters.py +70 -0
- purin-1.0.0/src/purin/projections/closed_form.py +62 -0
- purin-1.0.0/src/purin/projections/diagnostics.py +20 -0
- purin-1.0.0/src/purin/projections/distance.py +61 -0
- purin-1.0.0/src/purin/projections/implicit_distance.py +137 -0
- purin-1.0.0/src/purin/projections/local_quadratic.py +220 -0
- purin-1.0.0/src/purin/projections/sequential.py +140 -0
- purin-1.0.0/src/purin/solvers/__init__.py +37 -0
- purin-1.0.0/src/purin/solvers/admm/__init__.py +7 -0
- purin-1.0.0/src/purin/solvers/admm/config.py +69 -0
- purin-1.0.0/src/purin/solvers/admm/factor.py +144 -0
- purin-1.0.0/src/purin/solvers/admm/kernels.py +283 -0
- purin-1.0.0/src/purin/solvers/admm/rows.py +84 -0
- purin-1.0.0/src/purin/solvers/admm/solver.py +296 -0
- purin-1.0.0/src/purin/solvers/api.py +141 -0
- purin-1.0.0/src/purin/solvers/capabilities.py +30 -0
- purin-1.0.0/src/purin/solvers/chambolle_pock/__init__.py +11 -0
- purin-1.0.0/src/purin/solvers/chambolle_pock/bounds.py +326 -0
- purin-1.0.0/src/purin/solvers/chambolle_pock/config.py +61 -0
- purin-1.0.0/src/purin/solvers/chambolle_pock/dense.py +102 -0
- purin-1.0.0/src/purin/solvers/chambolle_pock/dense_implicit.py +221 -0
- purin-1.0.0/src/purin/solvers/chambolle_pock/dense_layer.py +122 -0
- purin-1.0.0/src/purin/solvers/chambolle_pock/kernels.py +305 -0
- purin-1.0.0/src/purin/solvers/chambolle_pock/legacy.py +198 -0
- purin-1.0.0/src/purin/solvers/chambolle_pock/solver.py +432 -0
- purin-1.0.0/src/purin/solvers/config.py +166 -0
- purin-1.0.0/src/purin/solvers/diagonal_qp.py +349 -0
- purin-1.0.0/src/purin/solvers/fischer_burmeister/__init__.py +49 -0
- purin-1.0.0/src/purin/solvers/fischer_burmeister/common.py +546 -0
- purin-1.0.0/src/purin/solvers/fischer_burmeister/complementarity.py +59 -0
- purin-1.0.0/src/purin/solvers/fischer_burmeister/config.py +5 -0
- purin-1.0.0/src/purin/solvers/fischer_burmeister/dense_semismooth.py +366 -0
- purin-1.0.0/src/purin/solvers/fischer_burmeister/newton.py +860 -0
- purin-1.0.0/src/purin/solvers/fischer_burmeister/operators.py +166 -0
- purin-1.0.0/src/purin/solvers/fischer_burmeister/reduced.py +1181 -0
- purin-1.0.0/src/purin/solvers/fischer_burmeister/solver.py +427 -0
- purin-1.0.0/src/purin/solvers/implicit.py +288 -0
- purin-1.0.0/src/purin/solvers/linear_equality/__init__.py +21 -0
- purin-1.0.0/src/purin/solvers/linear_equality/config.py +5 -0
- purin-1.0.0/src/purin/solvers/linear_equality/solver.py +460 -0
- purin-1.0.0/src/purin/solvers/metric.py +182 -0
- purin-1.0.0/src/purin/solvers/primal_dual_interior_point/__init__.py +29 -0
- purin-1.0.0/src/purin/solvers/primal_dual_interior_point/assembly.py +178 -0
- purin-1.0.0/src/purin/solvers/primal_dual_interior_point/config.py +31 -0
- purin-1.0.0/src/purin/solvers/primal_dual_interior_point/conversion.py +87 -0
- purin-1.0.0/src/purin/solvers/primal_dual_interior_point/derivatives.py +130 -0
- purin-1.0.0/src/purin/solvers/primal_dual_interior_point/filter_metrics.py +70 -0
- purin-1.0.0/src/purin/solvers/primal_dual_interior_point/implicit_compat_jax.py +457 -0
- purin-1.0.0/src/purin/solvers/primal_dual_interior_point/implicit_compat_numpy.py +648 -0
- purin-1.0.0/src/purin/solvers/primal_dual_interior_point/newton.py +356 -0
- purin-1.0.0/src/purin/solvers/primal_dual_interior_point/operators.py +1125 -0
- purin-1.0.0/src/purin/solvers/primal_dual_interior_point/reference/__init__.py +34 -0
- purin-1.0.0/src/purin/solvers/primal_dual_interior_point/reference/bounds.py +368 -0
- purin-1.0.0/src/purin/solvers/primal_dual_interior_point/reference/filter.py +265 -0
- purin-1.0.0/src/purin/solvers/primal_dual_interior_point/reference/iteration.py +505 -0
- purin-1.0.0/src/purin/solvers/primal_dual_interior_point/reference/line_search.py +503 -0
- purin-1.0.0/src/purin/solvers/primal_dual_interior_point/reference/newton.py +872 -0
- purin-1.0.0/src/purin/solvers/primal_dual_interior_point/reference/residuals.py +411 -0
- purin-1.0.0/src/purin/solvers/primal_dual_interior_point/reference/state.py +254 -0
- purin-1.0.0/src/purin/solvers/primal_dual_interior_point/reference/step.py +348 -0
- purin-1.0.0/src/purin/solvers/primal_dual_interior_point/residuals.py +48 -0
- purin-1.0.0/src/purin/solvers/primal_dual_interior_point/scalar.py +169 -0
- purin-1.0.0/src/purin/solvers/primal_dual_interior_point/solver.py +2412 -0
- purin-1.0.0/src/purin/solvers/primal_dual_interior_point/types.py +361 -0
- purin-1.0.0/src/purin/solvers/registry.py +31 -0
- purin-1.0.0/src/purin/solvers/semismooth.py +110 -0
- purin-1.0.0/src/purin/solvers/types.py +97 -0
- purin-1.0.0/src/purin.egg-info/PKG-INFO +205 -0
- purin-1.0.0/src/purin.egg-info/SOURCES.txt +172 -0
- purin-1.0.0/src/purin.egg-info/dependency_links.txt +1 -0
- purin-1.0.0/src/purin.egg-info/requires.txt +20 -0
- purin-1.0.0/src/purin.egg-info/top_level.txt +1 -0
- purin-1.0.0/tests/test_dense_cp.py +80 -0
- purin-1.0.0/tests/test_diagonal_qp.py +130 -0
- purin-1.0.0/tests/test_expressions.py +154 -0
- purin-1.0.0/tests/test_kkt_reporting_contracts.py +143 -0
- purin-1.0.0/tests/test_linear_algebra.py +165 -0
- purin-1.0.0/tests/test_prepared_sparse.py +125 -0
- purin-1.0.0/tests/test_problem_adapters.py +156 -0
- purin-1.0.0/tests/test_projection_adapters.py +69 -0
- purin-1.0.0/tests/test_projections.py +156 -0
- purin-1.0.0/tests/test_readme.py +14 -0
- purin-1.0.0/tests/test_reference_adjoints.py +143 -0
- purin-1.0.0/tests/test_reference_ipm.py +184 -0
- purin-1.0.0/tests/test_regression_admm.py +199 -0
- purin-1.0.0/tests/test_regression_admm_diagnostics.py +104 -0
- purin-1.0.0/tests/test_regression_admm_factor.py +44 -0
- purin-1.0.0/tests/test_regression_admm_rows.py +95 -0
- purin-1.0.0/tests/test_regression_chambolle_pock.py +164 -0
- purin-1.0.0/tests/test_regression_cp_bound_presolve.py +119 -0
- purin-1.0.0/tests/test_regression_cp_diagonal_steps.py +112 -0
- purin-1.0.0/tests/test_regression_cp_proximal_coefficients.py +51 -0
- purin-1.0.0/tests/test_regression_linear_equality_sparse.py +149 -0
- purin-1.0.0/tests/test_runtime_configurations.py +33 -0
- purin-1.0.0/tests/test_scalar_reference.py +75 -0
- purin-1.0.0/tests/test_sparse_barrier_contracts.py +238 -0
- purin-1.0.0/tests/test_sparse_layouts.py +125 -0
- purin-1.0.0/tests/test_symbolic_workflow.py +164 -0
- purin-1.0.0/tests/test_training_metric_contracts.py +134 -0
- purin-1.0.0/tests/test_validation.py +165 -0
purin-1.0.0/AUTHORS
ADDED
purin-1.0.0/CHANGELOG.md
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
Notable changes to PURIN are recorded here. This history starts with the
|
|
4
|
+
initial public version; internal development steps are not separate releases.
|
|
5
|
+
The first GitHub publication contains the initial source distribution.
|
|
6
|
+
Version 1.0.0 remains unreleased until a release is explicitly published;
|
|
7
|
+
no release date is assigned.
|
|
8
|
+
|
|
9
|
+
## 1.0.0 — Unreleased
|
|
10
|
+
|
|
11
|
+
- Promote the shared-stack implementation to `main`; preserve the previous main in `v0.1.0`.
|
|
12
|
+
- Align main-branch installation links, badges and citation metadata.
|
|
13
|
+
|
|
14
|
+
### Added
|
|
15
|
+
|
|
16
|
+
- Added dense-reference KKT/Pallas-interpreter checks, barrier derivatives,
|
|
17
|
+
sparse adjoint validation and full-state projection pullback tests.
|
|
18
|
+
|
|
19
|
+
- API, numerical, frontend integration, dependency review, documentation,
|
|
20
|
+
quality regression and informational performance workflows.
|
|
21
|
+
|
|
22
|
+
- Expanded analytic, dense-reference, sparse-kernel and implicit-gradient tests,
|
|
23
|
+
with an inclusive 90% combined statement-and-branch coverage gate.
|
|
24
|
+
|
|
25
|
+
- Cross-platform CPU CI for Linux, Windows and Apple Silicon macOS, with
|
|
26
|
+
baseline/current JAX, runtime configuration artifacts and ARM64 coverage.
|
|
27
|
+
|
|
28
|
+
- GitHub Actions CI for numerical tests, package checks and Ruff, with measured
|
|
29
|
+
branch coverage reporting and scheduled Python CodeQL analysis.
|
|
30
|
+
|
|
31
|
+
- A standalone JAX library for constrained projections and sparse numerical
|
|
32
|
+
kernels, usable independently of OHAGI and the frontend frameworks.
|
|
33
|
+
- Projection problem interfaces and reusable preparation utilities.
|
|
34
|
+
- Euclidean distance, diagonal weighted-distance, local quadratic and
|
|
35
|
+
sequential projection interfaces.
|
|
36
|
+
- Linear equality, Chambolle–Pock, ADMM, Fischer–Burmeister and primal-dual
|
|
37
|
+
interior point projection methods.
|
|
38
|
+
- Sparse operators and projection differentiation utilities, including
|
|
39
|
+
implicit differentiation support.
|
|
40
|
+
- Shared projection infrastructure for OHAGI, KKTHN, DAEHN and NLPOPTNet.
|
|
41
|
+
- Python packaging, a runnable quick start, contribution guidance and a
|
|
42
|
+
BibTeX software citation.
|
|
43
|
+
- Apache-2.0 licensing and attribution notices.
|
purin-1.0.0/CITATION.bib
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
@misc{purin,
|
|
2
|
+
author = {{SOULS-TAMU contributors}},
|
|
3
|
+
title = {{PURIN}: Differentiable constrained projections and sparse numerical kernels in {JAX}},
|
|
4
|
+
howpublished = {Computer software},
|
|
5
|
+
version = {1.0.0},
|
|
6
|
+
url = {https://github.com/SOULS-TAMU/Purin},
|
|
7
|
+
note = {Version 1.0.0, initial release in preparation. Licensed under Apache-2.0}
|
|
8
|
+
}
|
purin-1.0.0/CITATION.cff
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
cff-version: 1.2.0
|
|
2
|
+
message: "If you use PURIN, please cite this software. A BibTeX entry is available in CITATION.bib."
|
|
3
|
+
type: software
|
|
4
|
+
title: "PURIN: Differentiable constrained projections and sparse numerical kernels in JAX"
|
|
5
|
+
authors:
|
|
6
|
+
- name: "SOULS-TAMU contributors"
|
|
7
|
+
version: "1.0.0"
|
|
8
|
+
url: "https://github.com/SOULS-TAMU/Purin"
|
|
9
|
+
repository-code: "https://github.com/SOULS-TAMU/Purin"
|
|
10
|
+
license: Apache-2.0
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
# Contributing to PURIN
|
|
2
|
+
|
|
3
|
+
Thank you for helping improve PURIN. Bug reports, documentation fixes,
|
|
4
|
+
examples and numerical improvements are welcome. This guide accompanies
|
|
5
|
+
the first public version of the project.
|
|
6
|
+
|
|
7
|
+
## Issues and proposals
|
|
8
|
+
|
|
9
|
+
For small fixes, open a focused
|
|
10
|
+
[pull request](https://github.com/SOULS-TAMU/Purin/pulls). Discuss new solvers,
|
|
11
|
+
public APIs, dependencies or changes to numerical behavior in an
|
|
12
|
+
[issue](https://github.com/SOULS-TAMU/Purin/issues) first.
|
|
13
|
+
|
|
14
|
+
For a bug report, provide a minimal reproducer, expected and observed
|
|
15
|
+
behavior, package versions, device, dtype, random seed and solver settings.
|
|
16
|
+
Include the problem dimensions and constraint residuals when relevant.
|
|
17
|
+
Remove private data and credentials from examples and logs.
|
|
18
|
+
|
|
19
|
+
## Development setup
|
|
20
|
+
|
|
21
|
+
Use Python 3.10 or newer in an isolated environment. Fork the repository
|
|
22
|
+
on GitHub for contributions, then clone your fork. For a local checkout of
|
|
23
|
+
the upstream source:
|
|
24
|
+
|
|
25
|
+
```sh
|
|
26
|
+
git clone https://github.com/SOULS-TAMU/Purin.git
|
|
27
|
+
cd Purin
|
|
28
|
+
python -m pip install -e ".[build]"
|
|
29
|
+
python -m pip install pytest ruff
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Create a focused branch for your changes and submit the pull request against
|
|
33
|
+
`main`.
|
|
34
|
+
|
|
35
|
+
Follow the [JAX installation guide](https://docs.jax.dev/en/latest/installation.html)
|
|
36
|
+
for your device. Install OHAGI and the relevant frontend in editable mode
|
|
37
|
+
only when checking their integration. PURIN itself must remain usable
|
|
38
|
+
without those packages.
|
|
39
|
+
|
|
40
|
+
## Library boundaries
|
|
41
|
+
|
|
42
|
+
PURIN owns projection problems, composition, solvers, sparse operators and
|
|
43
|
+
projection differentiation. Reuse its canonical solver implementations.
|
|
44
|
+
Keep training, neural network construction, checkpointing and model export
|
|
45
|
+
in OHAGI; keep framework-specific formulation policies in the frontends.
|
|
46
|
+
|
|
47
|
+
Do not introduce imports from OHAGI, KKTHN, DAEHN or NLPOPTNet into PURIN.
|
|
48
|
+
Avoid duplicating numerical kernels to support a new adapter.
|
|
49
|
+
|
|
50
|
+
## Code and documentation
|
|
51
|
+
|
|
52
|
+
Use descriptive names, focused functions and Google-style docstrings for
|
|
53
|
+
public interfaces. Document shapes, axis order, coordinate conventions,
|
|
54
|
+
constraint signs, metric assumptions and gradient behavior where relevant.
|
|
55
|
+
Explain mathematical choices and invariants rather than restating Python.
|
|
56
|
+
|
|
57
|
+
Run these checks from the PURIN directory:
|
|
58
|
+
|
|
59
|
+
```sh
|
|
60
|
+
python -m ruff format --check src
|
|
61
|
+
python -m ruff check --select F,E9 src
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
Use `python -m ruff format src` to apply formatting. Keep unrelated
|
|
65
|
+
formatting changes separate and leave benchmark scripts unchanged unless
|
|
66
|
+
the proposed change specifically concerns them.
|
|
67
|
+
|
|
68
|
+
## Numerical validation
|
|
69
|
+
|
|
70
|
+
Include focused regression tests or a reproducible validation script with
|
|
71
|
+
the pull request. Record commands and results. Run the README quick start
|
|
72
|
+
when changing the public projection workflow.
|
|
73
|
+
|
|
74
|
+
| Change | Validation |
|
|
75
|
+
| --- | --- |
|
|
76
|
+
| Solver or projection | Compare projected values, feasibility residuals, objective values and available convergence diagnostics. |
|
|
77
|
+
| Differentiation | Compare parameter and input gradients with the previous implementation; use an independent check on suitable smooth problems. |
|
|
78
|
+
| Sparse kernels | Compare with an equivalent small dense calculation and exercise supported shapes and dtypes. |
|
|
79
|
+
| Public interfaces | Check signatures, configuration defaults and the relevant unchanged frontend benchmarks. |
|
|
80
|
+
| Restructuring | Compare outputs and gradients before and after the change under identical settings. |
|
|
81
|
+
|
|
82
|
+
Use identical inputs, seeds, devices, JAX versions, precision and solver
|
|
83
|
+
settings for comparisons. State tolerances explicitly and investigate any
|
|
84
|
+
difference. Cover applicable boundary cases, including empty constraint
|
|
85
|
+
sets, degenerate systems, iteration limits and warm starts. At nonsmooth
|
|
86
|
+
points, check the documented differentiation convention rather than
|
|
87
|
+
assuming a unique derivative.
|
|
88
|
+
|
|
89
|
+
Separate intentional numerical changes from restructuring. For timing
|
|
90
|
+
comparisons, warm up compilation and synchronize device execution.
|
|
91
|
+
|
|
92
|
+
## Packaging
|
|
93
|
+
|
|
94
|
+
From the PURIN directory:
|
|
95
|
+
|
|
96
|
+
```sh
|
|
97
|
+
python -m build
|
|
98
|
+
python -m twine check dist/*
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
Install the built wheel in a separate environment and run the quick start.
|
|
102
|
+
Keep environments, caches, build output, generated results and model
|
|
103
|
+
artifacts out of version control.
|
|
104
|
+
|
|
105
|
+
## Pull request checklist
|
|
106
|
+
|
|
107
|
+
- Explain the problem, resulting behavior and compatibility implications.
|
|
108
|
+
- Keep changes focused and preserve public APIs and benchmark call signatures.
|
|
109
|
+
- Include reproducible numerical checks and explicit tolerances.
|
|
110
|
+
- Update documentation and the appropriate unreleased changelog entry.
|
|
111
|
+
- Preserve the dependency boundary between PURIN and its consumers.
|
|
112
|
+
|
|
113
|
+
Contributions are provided under the project's [Apache-2.0 license](LICENSE).
|
|
114
|
+
Retain relevant attribution in [AUTHORS](AUTHORS) and [NOTICE](NOTICE).
|
|
115
|
+
Keep [CITATION.bib](CITATION.bib) and [CITATION.cff](CITATION.cff) consistent.
|
|
116
|
+
The CFF metadata supports GitHub's citation panel; BibTeX remains available directly.
|
|
117
|
+
|
|
118
|
+
## Automated checks
|
|
119
|
+
|
|
120
|
+
CI runs the full numerical suite on CPU across these configurations:
|
|
121
|
+
|
|
122
|
+
| Platform | Python | JAX configuration |
|
|
123
|
+
| --- | --- | --- |
|
|
124
|
+
| Linux x86-64, Windows x86-64, macOS Apple Silicon | 3.10–3.14 | Newest compatible dependencies for each interpreter. |
|
|
125
|
+
| Linux x86-64, Windows x86-64, macOS Apple Silicon | 3.12 | JAX/JAXlib 0.6.2 baseline. |
|
|
126
|
+
| Linux ARM64 | 3.13 | Newest compatible dependencies. |
|
|
127
|
+
|
|
128
|
+
The configuration tests additionally exercise float32/float64, eager/JIT
|
|
129
|
+
execution and batch sizes one and four for the equality projection and
|
|
130
|
+
functional backbone interfaces. Full solver regression tests use float64.
|
|
131
|
+
Ruff runs on Linux; wheel and source-distribution builds and installation
|
|
132
|
+
checks run on Linux, Windows and macOS. Each core test job uploads its OS,
|
|
133
|
+
architecture, Python, package versions and JAX devices as a diagnostic artifact.
|
|
134
|
+
The test suite is in `tests/`. CPU results do not establish GPU/TPU support.
|
|
135
|
+
|
|
136
|
+
Install the test dependencies with `python -m pip install ".[test]"`, then run:
|
|
137
|
+
|
|
138
|
+
```sh
|
|
139
|
+
python -m pytest -q --cov=purin --cov-branch --cov-report=term-missing --cov-report=xml --cov-report=json
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
Coverage measures the entire package, including unexecuted modules. The badge
|
|
143
|
+
combines statement and branch coverage from the Linux x86-64 / Python 3.12 / current-JAX core test run.
|
|
144
|
+
Reports are retained as workflow artifacts; the badge and measured totals are
|
|
145
|
+
published to `codex/coverage` after successful trusted pushes to `main`.
|
|
146
|
+
Pull requests run checks with read-only repository access and do not publish
|
|
147
|
+
coverage. No third-party coverage account or additional secret is required.
|
|
148
|
+
|
|
149
|
+
CodeQL runs extended Python security analysis on pushes, pull requests and a
|
|
150
|
+
weekly schedule. Its badge reports workflow execution status; inspect code
|
|
151
|
+
scanning alerts separately. GitHub Actions dependencies are pinned to commits
|
|
152
|
+
and monitored by Dependabot.
|
|
153
|
+
|
|
154
|
+
The combined statement-and-branch coverage floor is 90%. Every source module,
|
|
155
|
+
including the dense reference solvers, remains in the denominator. Do not omit
|
|
156
|
+
modules to improve the score.
|
|
157
|
+
|
|
158
|
+
## Compatibility and quality regression checks
|
|
159
|
+
|
|
160
|
+
Additional workflows protect public APIs, numerical results and frontend
|
|
161
|
+
integration, validate documentation and dependency changes, and publish code
|
|
162
|
+
quality and performance reports. See the [validation policies](.github/validation/README.md)
|
|
163
|
+
for thresholds, existing baselines and reproduction instructions. Timing changes
|
|
164
|
+
are informational; correctness and quality regressions fail their checks.
|
purin-1.0.0/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2026 MM Faruque Hasan, Bimol Nath Roy and Rahul Golder
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
purin-1.0.0/MANIFEST.in
ADDED
purin-1.0.0/NOTICE
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
PURIN
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 SOULS-TAMU
|
|
4
|
+
|
|
5
|
+
Part of the HardNet stack maintained from SOULS-TAMU implementations.
|
|
6
|
+
KKT-HardNet, DAEHN, and NLPOpt-Net contributions retain their
|
|
7
|
+
upstream authorship and applicable license terms.
|
|
8
|
+
Original repositories: https://github.com/SOULS-TAMU/kkt-hardnet
|
|
9
|
+
and https://github.com/SOULS-TAMU/nlpoptnet.
|
|
10
|
+
|
|
11
|
+
The current project is licensed under the Apache License, Version 2.0.
|
|
12
|
+
See LICENSE for the full terms.
|
purin-1.0.0/PKG-INFO
ADDED
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: purin
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Differentiable constrained projections and sparse numerical kernels in JAX
|
|
5
|
+
Author: SOULS-TAMU contributors
|
|
6
|
+
License-Expression: Apache-2.0
|
|
7
|
+
Project-URL: Documentation, https://purin.readthedocs.io/en/latest/
|
|
8
|
+
Project-URL: Homepage, https://github.com/SOULS-TAMU/Purin
|
|
9
|
+
Project-URL: Repository, https://github.com/SOULS-TAMU/Purin
|
|
10
|
+
Project-URL: Issues, https://github.com/SOULS-TAMU/Purin/issues
|
|
11
|
+
Project-URL: Changelog, https://github.com/SOULS-TAMU/Purin/blob/main/CHANGELOG.md
|
|
12
|
+
Keywords: jax,constrained-learning,differentiable-optimization
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.15
|
|
21
|
+
Classifier: Operating System :: OS Independent
|
|
22
|
+
Classifier: Intended Audience :: Science/Research
|
|
23
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
24
|
+
Requires-Python: >=3.10
|
|
25
|
+
Description-Content-Type: text/markdown
|
|
26
|
+
License-File: LICENSE
|
|
27
|
+
License-File: NOTICE
|
|
28
|
+
Requires-Dist: jax>=0.4.30
|
|
29
|
+
Requires-Dist: numpy>=1.26
|
|
30
|
+
Requires-Dist: scipy>=1.11
|
|
31
|
+
Provides-Extra: docs
|
|
32
|
+
Requires-Dist: Sphinx<9,>=8.2; extra == "docs"
|
|
33
|
+
Requires-Dist: sphinx-rtd-theme<4,>=3.1; extra == "docs"
|
|
34
|
+
Requires-Dist: myst-parser<5,>=4; extra == "docs"
|
|
35
|
+
Provides-Extra: test
|
|
36
|
+
Requires-Dist: pytest>=8; extra == "test"
|
|
37
|
+
Requires-Dist: pytest-cov>=5; extra == "test"
|
|
38
|
+
Requires-Dist: osqp>=1; extra == "test"
|
|
39
|
+
Provides-Extra: build
|
|
40
|
+
Requires-Dist: build>=1; extra == "build"
|
|
41
|
+
Requires-Dist: twine>=5; extra == "build"
|
|
42
|
+
Provides-Extra: cuda12
|
|
43
|
+
Requires-Dist: jax[cuda12]>=0.4.30; extra == "cuda12"
|
|
44
|
+
Dynamic: license-file
|
|
45
|
+
|
|
46
|
+
<p align="center">
|
|
47
|
+
<img src="https://raw.githubusercontent.com/SOULS-TAMU/Purin/main/assets/purin-logo-v2.png" alt="PURIN logo" width="200">
|
|
48
|
+
</p>
|
|
49
|
+
|
|
50
|
+
# PURIN
|
|
51
|
+
|
|
52
|
+
**Differentiable constraint projections and sparse numerical kernels in JAX.**
|
|
53
|
+
|
|
54
|
+
[](https://github.com/SOULS-TAMU/Purin/actions/workflows/ci.yml?query=branch%3Amain)
|
|
55
|
+
[](https://github.com/SOULS-TAMU/Purin/actions/workflows/validation.yml?query=branch%3Amain)
|
|
56
|
+
[](https://github.com/SOULS-TAMU/Purin/actions/workflows/codeql.yml?query=branch%3Amain)
|
|
57
|
+
[](https://github.com/SOULS-TAMU/Purin/actions/workflows/dependency-review.yml?query=branch%3Amain)
|
|
58
|
+
[](https://github.com/SOULS-TAMU/Purin/tree/codex/coverage)
|
|
59
|
+
|
|
60
|
+
[](https://github.com/SOULS-TAMU/Purin/blob/main/.github/workflows/release.yml)
|
|
61
|
+
[](https://github.com/SOULS-TAMU/Purin/blob/main/.github/workflows/ci.yml)
|
|
62
|
+
[](https://docs.jax.dev/)
|
|
63
|
+
[](https://github.com/SOULS-TAMU/Purin/blob/main/LICENSE)
|
|
64
|
+
[](https://github.com/SOULS-TAMU/Purin/blob/main/CITATION.bib)
|
|
65
|
+
|
|
66
|
+
Turn a parameterized constraint problem into a reusable projection layer.
|
|
67
|
+
Use PURIN independently or as the numerical backend for OHAGI and the HardNet
|
|
68
|
+
frontends.
|
|
69
|
+
|
|
70
|
+
- **Projection formulations:** Euclidean distance, diagonal weighted distance
|
|
71
|
+
and objective-aware local quadratic corrections.
|
|
72
|
+
- **Six solver methods:** affine equality projection, Chambolle–Pock, ADMM,
|
|
73
|
+
full/reduced Fischer–Burmeister and primal-dual interior point.
|
|
74
|
+
- **Sparse computation:** reusable operators and kernels, including matrix-free
|
|
75
|
+
paths where supported by the selected solver.
|
|
76
|
+
- **Differentiable layers:** solver-specific implicit differentiation and
|
|
77
|
+
numerical diagnostics for constrained learning.
|
|
78
|
+
|
|
79
|
+
[Installation](#installation) · [Basic API](#basic-api) · [Projection methods](#projection-methods) · [Documentation](#documentation) · [Contributing](#contributing) · [Citation](#citation)
|
|
80
|
+
|
|
81
|
+
## Installation
|
|
82
|
+
|
|
83
|
+
Requires **Python 3.10 or newer**. Install from PyPI:
|
|
84
|
+
|
|
85
|
+
```shell
|
|
86
|
+
python -m pip install purin
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
From a local stack checkout, use `python -m pip install ./purin`.
|
|
90
|
+
PURIN does not depend on OHAGI or any frontend package.
|
|
91
|
+
|
|
92
|
+
## Basic API
|
|
93
|
+
|
|
94
|
+
Project a point onto the affine equality **u + v = b**:
|
|
95
|
+
|
|
96
|
+
```python
|
|
97
|
+
import jax
|
|
98
|
+
import jax.numpy as jnp
|
|
99
|
+
from purin import Distance, Projection
|
|
100
|
+
|
|
101
|
+
jax.config.update("jax_enable_x64", True)
|
|
102
|
+
|
|
103
|
+
problem = Projection()
|
|
104
|
+
p = problem.add_parameter(["b"])
|
|
105
|
+
y = problem.add_variable(["u", "v"])
|
|
106
|
+
problem.objective = 0.0
|
|
107
|
+
problem.constraints.add(y.u + y.v == p.b)
|
|
108
|
+
|
|
109
|
+
project = Distance(problem, "linear-equality").prepare(batch_size=1)
|
|
110
|
+
candidate = jnp.array([[2.0, 0.0]]) # Shape: (batch, variables).
|
|
111
|
+
parameters = jnp.array([[1.0]]) # Shape: (batch, parameters).
|
|
112
|
+
projected = project(candidate, parameters)
|
|
113
|
+
print(projected) # [[ 1.5 -0.5]]
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
Prepare once and reuse the layer for its configured shapes and dtype. The same
|
|
117
|
+
problem interface accepts other registered solver methods when their constraint
|
|
118
|
+
requirements are satisfied.
|
|
119
|
+
|
|
120
|
+
## Projection methods
|
|
121
|
+
|
|
122
|
+
Choose a solver for the constraint structure of your projection problem:
|
|
123
|
+
|
|
124
|
+
| Algorithm / method name | Suitable problems | Implementation notes |
|
|
125
|
+
| --- | --- | --- |
|
|
126
|
+
| 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. |
|
|
127
|
+
| 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. |
|
|
128
|
+
| 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. |
|
|
129
|
+
| 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. |
|
|
130
|
+
| 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. |
|
|
131
|
+
| 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. |
|
|
132
|
+
|
|
133
|
+
`Distance` defines Euclidean projection; `WeightedDistance` supplies a positive
|
|
134
|
+
diagonal metric for the supported CP, ADMM and interior-point interfaces.
|
|
135
|
+
`LocalQuadratic` builds a positive diagonal quadratic objective and linearizes
|
|
136
|
+
constraints around an anchor, then solves the local QP with CP. Its nonlinear
|
|
137
|
+
constraints are approximated in that subproblem. `Sequential` composes
|
|
138
|
+
corrections; it is not a separate numerical solver.
|
|
139
|
+
|
|
140
|
+
Lower-level closed-form `BoxProjection` (bound clipping) and `AffineProjection`
|
|
141
|
+
(affine equality projection) utilities are available in
|
|
142
|
+
`purin.projections.closed_form`. Use `registered_methods()` to list the six
|
|
143
|
+
solver method names above; these utilities are not additional registry entries.
|
|
144
|
+
|
|
145
|
+
For nonlinear, nonconvex constraints, convergence to a local stationary point
|
|
146
|
+
does not establish a globally nearest feasible point. Check solver diagnostics
|
|
147
|
+
and residuals, and choose precision and tolerances for your problem.
|
|
148
|
+
|
|
149
|
+
## The HardNet stack
|
|
150
|
+
|
|
151
|
+
- **[KKTHN](https://github.com/SOULS-TAMU/kkt-hardnet/tree/main),
|
|
152
|
+
[DAEHN](https://github.com/SOULS-TAMU/dae-hardnet/tree/main) and
|
|
153
|
+
[NLPOPTNet](https://github.com/SOULS-TAMU/nlpoptnet)** supply problem formulations
|
|
154
|
+
and framework-specific processing.
|
|
155
|
+
- **[OHAGI](https://github.com/SOULS-TAMU/Ohagi/tree/main)** composes models,
|
|
156
|
+
runs the shared learning engine, and handles checkpoints and JAX deployment.
|
|
157
|
+
- **[PURIN](https://github.com/SOULS-TAMU/Purin/tree/main)** owns projection
|
|
158
|
+
problems, numerical solvers, sparse kernels and projection differentiation.
|
|
159
|
+
|
|
160
|
+
## Compatibility and validation
|
|
161
|
+
|
|
162
|
+
The PyPI CPU installation matrix covers **Python 3.10–3.15** on Linux, Windows and macOS,
|
|
163
|
+
plus Linux ARM64 on Python 3.13. It uses current compatible JAX releases;
|
|
164
|
+
regular CI additionally tests JAX 0.6.2 on Python 3.12. See the [release workflow](https://github.com/SOULS-TAMU/Purin/blob/main/.github/workflows/release.yml)
|
|
165
|
+
for exact environments; accelerator installation follows the
|
|
166
|
+
[JAX guide](https://docs.jax.dev/en/latest/installation.html).
|
|
167
|
+
|
|
168
|
+
- **CI:** tests, distribution builds and installation checks.
|
|
169
|
+
- **Validation:** public APIs, numerical references, documentation and code quality.
|
|
170
|
+
- **Coverage:** at least **90% combined statement and branch coverage**; the badge
|
|
171
|
+
links to the measured report for this branch.
|
|
172
|
+
- **Security:** CodeQL analysis and dependency review.
|
|
173
|
+
|
|
174
|
+
## Documentation
|
|
175
|
+
|
|
176
|
+
**[Read the full documentation](https://purin.readthedocs.io/en/latest/)** — installation, tutorials, user guide and API reference.
|
|
177
|
+
|
|
178
|
+
The full Sphinx guide follows the Read the Docs style: [contents](https://github.com/SOULS-TAMU/Purin/blob/main/docs/index.rst),
|
|
179
|
+
[runnable examples](https://github.com/SOULS-TAMU/Purin/blob/main/docs/examples/index.rst), [API reference](https://github.com/SOULS-TAMU/Purin/blob/main/docs/api/index.rst)
|
|
180
|
+
and [build instructions](https://github.com/SOULS-TAMU/Purin/blob/main/docs/BUILD.md).
|
|
181
|
+
|
|
182
|
+
| Resource | Contents |
|
|
183
|
+
| --- | --- |
|
|
184
|
+
| [Projection methods](#projection-methods) | Algorithm names, suitable problems and formulation choices |
|
|
185
|
+
| [Contribution guide](https://github.com/SOULS-TAMU/Purin/blob/main/CONTRIBUTING.md) | Solver boundaries, numerical validation and packaging |
|
|
186
|
+
| [Validation policy](https://github.com/SOULS-TAMU/Purin/blob/main/.github/validation/README.md) | API, gradient, sparse-kernel and quality checks |
|
|
187
|
+
| [Changelog](https://github.com/SOULS-TAMU/Purin/blob/main/CHANGELOG.md) | Initial release scope and changes |
|
|
188
|
+
|
|
189
|
+
## Contributing
|
|
190
|
+
|
|
191
|
+
Bug reports, examples and focused pull requests are welcome. Read
|
|
192
|
+
[CONTRIBUTING.md](https://github.com/SOULS-TAMU/Purin/blob/main/CONTRIBUTING.md) for setup, numerical checks and compatibility
|
|
193
|
+
requirements. Keep generated results, environments and checkpoints out of Git.
|
|
194
|
+
|
|
195
|
+
## Citation
|
|
196
|
+
|
|
197
|
+
Use [CITATION.bib](https://github.com/SOULS-TAMU/Purin/blob/main/CITATION.bib) for a copyable BibTeX entry or GitHub's
|
|
198
|
+
**Cite this repository** menu for [citation metadata](https://github.com/SOULS-TAMU/Purin/blob/main/CITATION.cff).
|
|
199
|
+
|
|
200
|
+
## License
|
|
201
|
+
|
|
202
|
+
[Apache License 2.0](https://github.com/SOULS-TAMU/Purin/blob/main/LICENSE). Authorship and upstream attribution are recorded
|
|
203
|
+
in [AUTHORS](https://github.com/SOULS-TAMU/Purin/blob/main/AUTHORS) and [NOTICE](https://github.com/SOULS-TAMU/Purin/blob/main/NOTICE).
|
|
204
|
+
|
|
205
|
+
[Changelog](https://github.com/SOULS-TAMU/Purin/blob/main/CHANGELOG.md) · [Report an issue](https://github.com/SOULS-TAMU/Purin/issues)
|