Repository navigation
Releases: process-intelligence-research/ENFORCE
Release list
v2.0.0
ENFORCE 2.0.0 is a modular redesign of the package. The projection method and its results are unchanged; the API is new.
Breaking changes. Code written for 1.x needs to be ported. Start from the README quick start and the tutorial notebooks in
notebooks/tutorials/.
Highlights
- Any PyTorch backbone.
ENFORCEConstrainedModelwraps anynn.Module; the test suite trains Transformer and GNN backbones through the sameTrainer/Evaluator. - Modular package.
enforce.core(Scaler,Constraint,Constraints),enforce.layers(theENFORCEprojection layer),enforce.losses,enforce.models,enforce.engines(Trainer,Evaluator) andenforce.data, each with its own config. - Vectorised constraint blocks.
Constraint(fn, size, jac)holds many equations in one block, with an optional analytical Jacobian. Equalities go inc=, inequalities ing=; inequalities can be vectorised too. - Faster Jacobians. With many constraints written one per equation, or with inequalities, the Jacobian is about 12-19x faster than in 1.0.4. Vectorised constraints and analytical Jacobians are as fast as before.
- Simpler behaviour. Supervised or self-supervised mode follows from the loss, adaptive activation is handled inside the layer, prediction works under
torch.no_grad(), andScalerfollows the device of its inputs, so models run on GPU without extra steps.
Reproducibility
The paper benchmarks reproduce 1.0.4: loss curves and test predictions are bitwise identical for function fitting, sin_ineq, pooling, extraction column and nonconvex linear; nonconvex nonlinear differs by about 1e-8 (rounding).
Installation
Install the PyTorch build for your hardware first, then:
pip install enforce-nn
pip install "enforce-nn[examples]" # matplotlib and pandas for the notebooks and benchmark scripts
Also in this release
- Clearer validation errors (constraint shapes,
max_it, empty constraint sets). - Documentation: contributing guide, code of conduct, issue and pull request templates,
CITATION.cff("Cite this repository"), andAGENTS.mdfor coding agents. - CI: the README quick start runs as a test, and the built wheel is installed and tested in a clean environment.
Known limitations
Trainer and Evaluator batch by slicing one input tensor: backbones need a batch-first tensor input and flat outputs. DataLoaders, dict inputs and variable-size graph batches are planned.
Contributors
Giacomo Lastrucci, Daniel Schicksnus.
Resolved issues: #20, #24, #26, #27, #28.
Full changelog: v1.0.4...v2.0.0
v1.0.4
What's Changed
- Fix import paths for ENFORCE in README by @giacomolastrucci in #12
- Update GitHub repository link in README by @giacomolastrucci in #13
- fix: replace shared hidden layer with nn.ModuleList by @giacomolastrucci in #16
- chore: bump version to 1.0.4 by @giacomolastrucci in #17
Full Changelog: v1.0.3...v1.0.4
v1.0.3
What's Changed
- refactor: restructure src/ → enforce/ with core/, data/, engines/ sub… by @giacomolastrucci in #11
Full Changelog: v1.0.2...v1.0.3
v1.0.2
What's Changed
- init by @giacomolastrucci in #9
- chore: bump version to 1.0.2 by @giacomolastrucci in #10
Full Changelog: v1.0.1...v1.0.2
v1.0.1 - Fix image rendering on PyPI
Fixes broken images in the README (graphical abstract and contributor profile picture) by replacing relative paths with absolute GitHub raw URLs. No code changes.
Initial public release of ENFORCE v1.0.0
ENFORCE is a hard-constrained neural network framework for nonlinear constrained learning. It combines a neural network backbone with AdaNP (Adaptive-depth Neural Projection), an SQP-inspired Gauss-Newton correction module that drives predictions to feasibility with respect to nonlinear equality and inequality constraints at inference time, no constrained solvers needed during training and inference.
Highlights:
- Exact feasibility for affine constraints in a single projection step
- ε-feasibility for general nonlinear constraints with linear convergence
- Inequality constraints handled via a Fischer-Burmeister reformulation
- Train with standard unconstrained optimizers (Adam)