Skip to main content

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


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.dev1.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.dev1-py3-none-any.whl (2.1 MB view details)

Uploaded Python 3

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

Hashes for aperture_solver-0.1.0.dev1.tar.gz
Algorithm Hash digest
SHA256 d169205e873ab94b854e8cb8c60b2a904dd74e0796f2ecde5361495f9923a09e
MD5 d74e1d94ffb76ad3c3020949d1dfd86a
BLAKE2b-256 ad7016728ea5ebbd6275a3325874ef315712970f3b88a45ac9ab84705a79a9ca

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for aperture_solver-0.1.0.dev1-py3-none-any.whl
Algorithm Hash digest
SHA256 6e9e48de90cc4603d81f7523443dc4275bd6c5f9ac41f38aeaebbe0f2199c8c0
MD5 25b57d2426925133b2d278054e4c070e
BLAKE2b-256 4cf9273dee891007b46f292336b89d61b79d65bebe24e55e9c9950ae9f71884a

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