Skip to main content

dsuni

纯 Rust 模块化约束求解器 / Modular Constraint Solver in Pure Rust

Rust Python License Tests

覆盖 8 个求解器模块,全部纯 Rust 实现,无外部求解器依赖。提供 Rust 库、CLI 命令行和 Python wheel 三种使用方式。

求解器模块

模块 算法 输入格式
SAT CDCL + Two-Watched Literals + VSIDS DIMACS CNF
LP 两阶段单纯形法(精确有理数) 自定义文本格式
SMT CDCL(T) + Congruence Closure(QF_UF) SMT-LIB
MILP 分支定界(LP Relaxation + McCormick) 自定义文本格式
CP 传播 + 回溯(First-Fail 搜索) 自定义文本格式
MINLP 区间传播 + McCormick 松弛 自定义文本格式

安装

Rust

git clone https://github.com/MBpanzz/dsuni.git
cd dsuni
cargo build --release
cargo test  # 150 tests

Python(从源码)

pip install maturin
maturin build --release
pip install target/wheels/dsuni-*.whl

Python(从 PyPI)

pip install dsuni

快速开始

CLI

# SAT
dsuni sat test_data/unsat_unit.cnf
# → UNSAT

# LP
dsuni lp test_data/simple.lp
# → OPTIMAL (obj=-5) / Model: [x0 -> 5]

# MILP
dsuni milp test_data/simple_milp.lp
# → OPTIMAL (obj=-5) / Model: [x0 -> 5]

Python

import dsuni

# SAT (DIMACS CNF)
r = dsuni.solve_sat("p cnf 1 2\n1 0\n-1 0\n")
print(r)  # {'status': 'UNSAT'}

# LP
r = dsuni.solve_lp_text("min -1*x0\nx0 <= 5\nx0 >= 0\n")
print(r)  # {'status': 'OPTIMAL', 'model': {'x0': 5}, 'objective': -5.0}

# MILP
r = dsuni.solve_milp_text("int x0\nmin -1*x0\nx0 <= 5\nx0 >= 0\n")
print(r)  # {'status': 'OPTIMAL', 'model': {'x0': 5}, 'objective': -5.0}

# CP
r = dsuni.solve_cp_text("var x 0 10\nvar y 0 10\neq x y\n")
print(r)  # {'status': 'SAT', 'model': {'x0': 0, 'x1': 0}}

项目结构

src/
├── core/     → 基础类型(Var / Term / Config / SolverResult)
├── sat/      → CDCL SAT 求解器
├── linear/   → Rational / 线性表达式 / 线性系统
├── lp/       → 两阶段单纯形法
├── milp/     → 分支定界 MILP
├── smt/      → CDCL(T) + QF_UF / QF_LRA
├── cp/       → 传播 + 回溯 CP
├── minlp/    → 区间传播 + McCormick 松弛
├── parser/   → DIMACS / LP / SMT-LIB / CP 格式解析器
├── cli/      → CLI 命令定义
└── python.rs → PyO3 Python 绑定
test_data/    → 14 个测试输入文件

许可证

MIT License © 2025 MBpanzz

Metadata

Release files for dsuni 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for dsuni 0.1.1
File Size Uploaded Provenance Actions
dsuni-0.1.1.tar.gz 67.6 kB Without provenance Details for dsuni-0.1.1.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for dsuni 0.1.1
File Interpreter ABI Platform Actions
dsuni-0.1.1-cp310-cp310-win_amd64.whl CPython 3.10 CPython 3.10 Windows x86-64 Details for dsuni-0.1.1-cp310-cp310-win_amd64.whl
dsuni-0.1.1-cp310-cp310-manylinux_2_34_x86_64.whl CPython 3.10 CPython 3.10 Linux glibc 2.34+ x86-64 Details for dsuni-0.1.1-cp310-cp310-manylinux_2_34_x86_64.whl
dsuni-0.1.1-cp310-cp310-macosx_10_12_x86_64.whl CPython 3.10 CPython 3.10 macOS 10.12+ x86-64 Details for dsuni-0.1.1-cp310-cp310-macosx_10_12_x86_64.whl

Total release size: 843.6 kB

Release files / dsuni-0.1.1.tar.gz

Download URL dsuni-0.1.1.tar.gz
Size 67.6 kB
Tags Source
SHA-256 checksum
How to use checksums
19953c1bbd506196181707a9a643aaf3aaa24bb9595cac35cdda9a1149a64e20
BLAKE2b-256 checksum
How to use checksums
fbe58f7e67fe3270f58fcac2019efa30aa448e8c8fecdacfa69b67d8c71509a3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.13.3

Release files / dsuni-0.1.1-cp310-cp310-win_amd64.whl

Download URL dsuni-0.1.1-cp310-cp310-win_amd64.whl
Size 188.5 kB
Tags CPython 3.10 Windows x86-64
SHA-256 checksum
How to use checksums
1bc72da3223a5b576b749e4d39fa054934176937276596022ec72f247792a694
BLAKE2b-256 checksum
How to use checksums
13c166a87e3dee9ec166d8ec1dfaa4f501ff5cb7b85e07163ac074413966055d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.13.3

Release files / dsuni-0.1.1-cp310-cp310-manylinux_2_34_x86_64.whl

Download URL dsuni-0.1.1-cp310-cp310-manylinux_2_34_x86_64.whl
Size 301.6 kB
Tags CPython 3.10 Linux glibc 2.34+ x86-64
SHA-256 checksum
How to use checksums
4d6aed2d5b062cc0e6d8bfe8239196d2b49c3abd1eba14aca963928a55698c08
BLAKE2b-256 checksum
How to use checksums
ce038c34cc40f05ef451136e97a3ac86609bbca69e2229e4dd43c4c4bf3eb004
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.13.3

Release files / dsuni-0.1.1-cp310-cp310-macosx_10_12_x86_64.whl

Download URL dsuni-0.1.1-cp310-cp310-macosx_10_12_x86_64.whl
Size 286.0 kB
Tags CPython 3.10 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
a05b52af99ccad7c37913cf2ad41c2b01f447e7bf5f7fbcd4bdbce6555adedfc
BLAKE2b-256 checksum
How to use checksums
46143aa84fd6aacb9f66a9850e39c4f82997ace0ebeb679ad0d5ee5ef984fbb7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.13.3

Security for dsuni 0.1.1

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

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.

Release history Release notifications | RSS feed

This release

0.1.1 This release

4 release files No provenance

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