Skip to main content

Python port of the Meta-CSP Framework: meta-CSP based hybrid temporal, spatial, and resource constraint reasoning

Project description

metacsp

Python port of the Meta-CSP Framework by Federico Pecora — a library for meta-CSP based hybrid constraint reasoning: simple temporal problems (STP), Allen interval algebra (crisp and fuzzy), resource scheduling, spatial reasoning (DE9IM, RCC, rectangle/block algebra), Boolean satisfiability, trajectory envelopes and spatio-temporal path scheduling, plus online sensing and dispatching.

Backed by native-code libraries: numpy (temporal propagation), Shapely/GEOS (geometry — GEOS is itself the C++ port of the JTS library the Java original used), PySAT (SAT solving), and sympy (CNF conversion).

Install

pip install -e ".[dev]"      # development (tests, formatter, viz server deps)
pip install -e ".[viz]"      # optional live viewer only

Quickstart

from metacsp.time.apsp_solver import APSPSolver
from metacsp.time.simple_distance_constraint import SimpleDistanceConstraint

solver = APSPSolver(0, 1000)
a, b = solver.create_variables(2)
c = SimpleDistanceConstraint()
c.minimum, c.maximum = 10, 20
c.from_ = a
c.to = b
print("Consistent?", solver.add_constraint(c))

Runnable demos live in examples/ — plain, standalone Python scripts, e.g.:

python examples/test_apsp_solver.py
python examples/tutorial/dispatching/simple_dispatching_example.py  # interactive

examples/tutorial/ ports the demos of the separate meta-csp-tutorial repo — end-to-end trajectory-envelope coordination, dispatching, and proactive-planning scenarios that exercise the library the way a robot integration would.

examples/SKIPPED.md lists the handful of upstream Java examples that could not be meaningfully ported (Swing-only, dead upstream code, or missing fixtures), each with a one-line reason.

Live viewer

MetaCSP Viewer screenshot

A browser-based live Gantt view of any solver's activity timelines, backed by a websocket server (see docs/VIZ.md for the wire protocol):

from metacsp.viz import serve

server = serve(solver, ["Robot1", "Robot2"])  # opens a browser tab
pip install metacsp[viz]
python examples/viz_timeline_demo.py

Status

Feature area Java package Python module
Utilities (logging, math, graph) utility/ metacsp.utility
Framework core & meta-CSP search framework/ metacsp.framework
Simple temporal problems (STP/APSP) time/ metacsp.time
Allen interval algebra (crisp & fuzzy) multi/allenInterval/, fuzzyAllenInterval/ metacsp.multi.allen_interval, metacsp.fuzzy_allen_interval
Activities & timelines multi/activity/ metacsp.multi.activity
Symbolic variables & Boolean SAT multi/symbols/, booleanSAT/ metacsp.multi.symbols, metacsp.boolean_sat
Spatial geometry & constraint solving spatial/geometry/ metacsp.spatial.geometry
RCC, cardinal direction, reachability spatial/{RCC,cardinal,reachability}/ metacsp.spatial.{rcc,cardinal,reachability}
DE9IM spatial relations multi/spatial/DE9IM/ metacsp.multi.spatial.de9im
Rectangle/block/temporal-rectangle algebras multi/spatial/{rectangleAlgebra,blockAlgebra}/ metacsp.multi.spatial.{rectangle_algebra,block_algebra}
Trajectory envelopes multi/spatioTemporal/ metacsp.multi.spatio_temporal
Meta TCSP & resource schedulers meta/TCSP/, meta/symbolsAndTime/ metacsp.meta.tcsp, metacsp.meta.symbols_and_time
Simple planner & hybrid planner meta/simplePlanner/, meta/hybridPlanner/ metacsp.meta.simple_planner, metacsp.meta.hybrid_planner
Trajectory envelope scheduler meta/spatioTemporal/paths/ metacsp.meta.spatio_temporal.paths
Sensing & dispatching sensing/, dispatching/ metacsp.sensing, metacsp.dispatching
Online monitoring (fuzzy hypothesis inference) onLineMonitoring/ metacsp.online_monitoring
JSON serialization (snapshot/delta) — (new) metacsp.serialization
Live viewer (browser-based, replaces Swing) utility/UI/, utility/timelinePlotting/ metacsp.viz (viz extra)

Full milestone-by-milestone status, architecture decisions, and porting conventions are in PLAN.md.

License

MIT — see LICENSE. Original Java framework © Federico Pecora.

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

metacsp-1.1.1.tar.gz (929.5 kB view details)

Uploaded Source

Built Distribution

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

metacsp-1.1.1-py3-none-any.whl (598.3 kB view details)

Uploaded Python 3

File details

Details for the file metacsp-1.1.1.tar.gz.

File metadata

  • Download URL: metacsp-1.1.1.tar.gz
  • Upload date:
  • Size: 929.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for metacsp-1.1.1.tar.gz
Algorithm Hash digest
SHA256 f37080c48a15fb18144c0444a2193f6a038890866b8534cfc2caf8cd00f2a7f4
MD5 fda3a50c3ac1ba2342a00728d29e869e
BLAKE2b-256 9624464d7f0df81139b24012d12ba94e1b409ffe1f3a849d57a26a9ca3498d8f

See more details on using hashes here.

File details

Details for the file metacsp-1.1.1-py3-none-any.whl.

File metadata

  • Download URL: metacsp-1.1.1-py3-none-any.whl
  • Upload date:
  • Size: 598.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for metacsp-1.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a907f1b42bf5a21528bc022d18a9b838bd475d1b1fa5fb8ccce19c77901701ac
MD5 de8d534ddb5ed1f1ce754b973ff6a60a
BLAKE2b-256 38fde7a565fab583eef33f6fcdf95e2ec417de9217899048dd93b98a69e03b99

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