Skip to main content

Geometric constraint snapping — resolve overlapping constraints, snap to feasible points

Project description

constraint-snap

Geometric constraint snapping. Define ranges, snap values to satisfy all constraints, detect conflicts. Like snapping to a grid, but for behavior spaces.

Usage

from constraint_snap import ConstraintSnap, Constraint

cs = ConstraintSnap()
cs.add(Constraint("max_speed", 0, 100))
cs.add(Constraint("safe_speed", 0, 60))

result = cs.snap(75)
# snapped=60, violations=["safe_speed"], feasible=False (was clamped)

lo, hi = cs.feasible_range()  # (0, 60) — intersection
conflicts = cs.conflicts()    # [] — no impossible pairs

Zero deps. pip install constraint-snap

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

constraint_snap-0.1.0.tar.gz (3.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

constraint_snap-0.1.0-py3-none-any.whl (3.4 kB view details)

Uploaded Python 3

File details

Details for the file constraint_snap-0.1.0.tar.gz.

File metadata

  • Download URL: constraint_snap-0.1.0.tar.gz
  • Upload date:
  • Size: 3.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.12

File hashes

Hashes for constraint_snap-0.1.0.tar.gz
Algorithm Hash digest
SHA256 a708a433f9461574a4b95c5875539411ade586e2a44dc83c552dcebf4f70da6c
MD5 9a4123fd5a8651d99009902f5b82d483
BLAKE2b-256 206590d6a0cc6db9ae24dec90b4945f8de1f724c01ee069bc623ae4ed4abf060

See more details on using hashes here.

File details

Details for the file constraint_snap-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for constraint_snap-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 497c8ee69734f27ddcb02cca54b539d270375d8897f8309460f4ef29873ee90b
MD5 06a7cd6310ec658a5cc182bc5d96bde8
BLAKE2b-256 89850c087b34b2abf51fe4c304e2f70fcd23f10e5c59b2aaf9f5f0ff4d11463a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page