Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

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.

Download files

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

Source Distribution

aperture_solver-0.1.0.dev2.tar.gz (3.6 MB view details)

Uploaded Source

Built Distribution

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

aperture_solver-0.1.0.dev2-py3-none-any.whl (2.1 MB view details)

Uploaded Python 3

File details

Details for the file aperture_solver-0.1.0.dev2.tar.gz.

File metadata

  • Download URL: aperture_solver-0.1.0.dev2.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

Hashes for aperture_solver-0.1.0.dev2.tar.gz
Algorithm Hash digest
SHA256 b9014f973ccec9001ea19dce32625bf2ea41902acf4bd9896b16e486736fad05
MD5 ede34e7af06ec5bc809bec0b33fecc15
BLAKE2b-256 67b45c763101605b6a92de01259fde7f062ec323a1a0f87245dd1d57992425e2

See more details on using hashes here.

File details

Details for the file aperture_solver-0.1.0.dev2-py3-none-any.whl.

File metadata

File hashes

Hashes for aperture_solver-0.1.0.dev2-py3-none-any.whl
Algorithm Hash digest
SHA256 d9af30900d8a6048654a6d9cdfa84d58a77bc7808b9d764edfd16dbbeba69864
MD5 ddf86c93423fa0d3f1bfe2f86a217e22
BLAKE2b-256 96847fa963dddb98650a224493b99744429dbaef134fd1f58de8f01756dc6fc3

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.1.0.dev2 This release

2 files

Supported by

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