A SAT-based optimization solver
Project description
Aperture Python API
Aperture is a SAT-based optimization solver providing a Python interface for:
- SAT solving – check satisfiability of CNF Boolean formulas
- MaxSAT solving – minimize satisfied (weighted) soft literals
- OBV solving – optimize modulo bit-vector problems
- Black-box optimization – optimize generic objective functions
All solving quiries can be called incrementally under assumptions.
Quick Start
import aperture as ap
solver = ap.Solver(sat_solver="topor")
x = solver.new_var()
y = solver.new_var()
solver.add_clause(ap.lits([x, y])) # x OR y
sat = solver.solve()
if sat:
print("SAT")
print(solver.get_latest_solution())
else:
print(solver.get_latest_solve_status())
Supported SAT Solvers
"topor""cadical""glucose"(default)"kissat"– initial SAT query only
Core Methods
| Method | Purpose |
|---|---|
new_var() |
Create a new Boolean variable |
add_clause(lits) |
Add a clause |
solve(assumptions=[]) |
Solve SAT |
solve_maxsat(assumptions, soft_lits, fix_model_value, callback_on_solution_found=None) |
Solve MaxSAT |
solve_weighted_maxsat(assumptions, soft_wlits, fix_model_value, callback_on_solution_found=None) |
Solve weighted MaxSAT |
solve_obv(assumptions, targets, callback_on_solution_found=None) |
Optimize bit-vectors |
solve_black_box(assumptions, observables, pb_func, callback_on_solution_found=None) |
Black-box optimization |
get_latest_solution() |
Get solution (assignment) of the last solve query |
get_latest_solve_status() |
Get status ("SAT", "UNSAT", "ERROR", "UNKNOWN") |
Constraints
Add cardinality and pseudo-Boolean constraints:
add_constraint_less_than((w)lits, rhs, selector=None)add_constraint_less_than_equal((w)lits, rhs, selector=None)add_constraint_equal(lits, rhs, selector=None)add_constraint_greater_than_equal(lits, rhs, selector=None)add_constraint_greater_than(lits, rhs, selector=None)
All methods return bool ans supports adding an optional selector to all the generated clauses.
Note that currently only < and <= constraints are supported for weighted literals (wlits).
Documentation
For further information and examples, see the notebook in the docs/ directory. ReadTheDocs documentation will be available in the future.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file aperture_solver-0.1.0.dev1.tar.gz.
File metadata
- Download URL: aperture_solver-0.1.0.dev1.tar.gz
- Upload date:
- Size: 3.6 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d169205e873ab94b854e8cb8c60b2a904dd74e0796f2ecde5361495f9923a09e
|
|
| MD5 |
d74e1d94ffb76ad3c3020949d1dfd86a
|
|
| BLAKE2b-256 |
ad7016728ea5ebbd6275a3325874ef315712970f3b88a45ac9ab84705a79a9ca
|
File details
Details for the file aperture_solver-0.1.0.dev1-py3-none-any.whl.
File metadata
- Download URL: aperture_solver-0.1.0.dev1-py3-none-any.whl
- Upload date:
- Size: 2.1 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6e9e48de90cc4603d81f7523443dc4275bd6c5f9ac41f38aeaebbe0f2199c8c0
|
|
| MD5 |
25b57d2426925133b2d278054e4c070e
|
|
| BLAKE2b-256 |
4cf9273dee891007b46f292336b89d61b79d65bebe24e55e9c9950ae9f71884a
|