Skip to main content

No project description provided

Project description

OptiLog: A Framework for SAT-based Systems

OptiLog is a Python framework for rapid prototyping of SAT-based systems. OptiLog includes functionality for loading and creating formulas, state of the art SAT solvers, high level formula modelling, pseudo boolean and cardinality encodings, automatic configuration and experiment running and parsing.

OptiLog is designed to be simple and efficient. OptiLog can be used by field experts for tasks such as algorithm design, research and benchmarking, but it has also been successfully deployed in undergraduate Computational Logic courses. Moreover, OptiLog has been designed from the ground up to be modular and extensible through the abstract iSAT C++ interface.

Why OptiLog

OptiLog has a fully modular dynamic Python binding generator for SAT solvers. This means that integrating new SAT solvers into OptiLog is as simple as implementing a C++ interface, and doesn't require any Python C API knowledge!

On top of that, OptiLog provides all the functionality required to develop and deploy complete SAT-based systems. We provide access to state of the art automatic configuration tools to configure any kind of algorithm (not limited to SAT) as well as experiment-running and log-parsing modules.

Architecture

The main architecture of OptiLog is composed of the five main modules of the end-user OptiLog API that supports the creation of SAT based systems and the iSAT interface for SAT solver developers.

  • The Modelling module: The Modelling module provides a rich and compact formalism to model problems. In particular, this module allows modelling problems with non-CNF Boolean and Pseudo Boolean expressions that can be automatically transformed into the SAT formula provided by the Formulas module.

  • The Formula module: The Formulas module provides tools to load and manipulate SAT, MaxSAT, and QBF formulas.

  • The Solvers module: The Solvers module provides dynamic Python bindings for Python. It currently supports Solvers through the PyiSAT. These SAT solvers implement the iSAT interface.

  • The Encoders module: The Encoders module provides access to a set of encoders that can be used to translate constraints from one language to another. This module is currently composed of encoders for Pseudo-Boolean and Cardinality constraints into SAT.

  • The Tuning module: The Tuning module provides support to automatically configure Python functions.

  • The Running module: The Running module provides support to automatically generate execution scenarios that run experiments and collect logs.

  • The BlackBox module: The Blackbox module allows to encapsulate external applications into Python objects, which enables its interaction with the other modules from Optilog such as the Running module or the Tuning module.

SAT solver Examples

OptiLog deals with boolean variables represented by positive integers (DIMACS).

Here is an example using the well known Glucose41:

>>> from optilog.sat import Glucose41
>>> solver = Glucose41()
>>> solver.add_clause([1, 3])
>>> solver.add_clause([-1, -2])
>>> solver.solve(assumptions=[1])
True
>>> solver.model()
[1, -2, -3]

All SAT solvers are incremental, which means new clauses can be added after a solver has found a model:

>>> from optilog.sat import Glucose41
>>> solver = Glucose41()
>>> solver.add_clause([1, -2])
>>> solver.solve(assumptions=[1, 2])
True
>>> solver.model()
[1, 2]
>>> solver.add_clause([-1, -2])
>>> solver.solve(assumptions=[1, 2])
False
>>> solver.core()
[1]

CNF and WCNF formulas can also be directly loaded in to the solver:

>>> from optilog.sat import Glucose41
>>> solver = Glucose41()
>>> solver.load_cnf('./path/to/file')

Integrating a SAT solver

Adding a new SAT solver to OptiLog is super easy. Just create a class that implements your desired method of the iSAT interface. Here you can see an example of the Cadical wrapper implementing the addClause and solve methods:

CadicalWrapper::CadicalWrapper()
{
    solver = new CaDiCaL::Solver;
}

CadicalWrapper::~CadicalWrapper()
{
    delete solver;
}

void CadicalWrapper::addClause(const std::vector<int>& literals)
{
    for (auto i = literals.begin(); i != literals.end(); ++i)
    {
        solver->add(*i);
    }
    solver->add(0);
}

E_STATE CadicalWrapper::solve(const std::vector<int>& assumptions)
{
    for (auto i = assumptions.begin(); i != assumptions.end(); ++i)
    {
        solver->assume(*i);
    }
    return (solver->solve() == 10 ? E_STATE::SAT : E_STATE::UNSAT);
}

OPTILOG_C_INTERFACE(CadicalWrapper, "Cadical")

Then, the solver is compiled as a shared library and integrated into OptiLog by copying the library on the ~/.optilog_solvers/ directory. Please checkout the documentation for more details on how to integrate a SAT solver and add configurable parameters.

Installation

OptiLog requires Python 3.6+ and a Linux installation. Current wheels are distributed on PyPi for the latest release.

Simply run:

$ pip install optilog

Documentation is available online

License & Documentation

OptiLog is free to use for academic use cases. SatexBlackBox module depends on SAT Heritage and their docker images. If you use that module, you must also comply with their license For industrial use please contact the authors.

For more information you can find the full license here: License

Cite

@InProceedings{10.1007/978-3-030-80223-3_1,
author="Ans{\'o}tegui, Carlos
and Ojeda, Jes{\'u}s
and Pacheco, Antonio
and Pon, Josep
and Salvia, Josep M.
and Torres, Eduard",
editor="Li, Chu-Min
and Many{\`a}, Felip",
title="OptiLog: A Framework for SAT-based Systems",
booktitle="Theory and Applications of Satisfiability Testing -- SAT 2021",
year="2021",
publisher="Springer International Publishing",
address="Cham",
pages="1--10",
abstract="We present OptiLog, a new Python framework for rapid prototyping of SAT-based systems. OptiLog allows to use and integrate SAT solvers currently developed in C/C++ just by implementing the iSAT C++ interface. It also provides a Python binding to the PBLib C++ toolkit for encoding Pseudo Boolean and Cardinality constraints. Finally, it leverages thepower of automatic configurators by allowing to easily create configuration scenarios including multiple solvers and encoders.",
isbn="978-3-030-80223-3"
}

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

optilog-0.3.4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (11.2 MB view details)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

optilog-0.3.4-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (11.2 MB view details)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

optilog-0.3.4-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (11.2 MB view details)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

optilog-0.3.4-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (10.2 MB view details)

Uploaded CPython 3.7m manylinux: glibc 2.17+ x86-64

optilog-0.3.4-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (10.2 MB view details)

Uploaded CPython 3.6m manylinux: glibc 2.17+ x86-64

File details

Details for the file optilog-0.3.4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

  • Download URL: optilog-0.3.4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
  • Upload date:
  • Size: 11.2 MB
  • Tags: CPython 3.10, manylinux: glibc 2.17+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 colorama/0.4.4 importlib-metadata/4.6.4 keyring/23.5.0 pkginfo/1.8.2 readme-renderer/34.0 requests-toolbelt/0.9.1 requests/2.25.1 rfc3986/1.5.0 tqdm/4.57.0 urllib3/1.26.5 CPython/3.10.4

File hashes

Hashes for optilog-0.3.4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 d948a64a3af9f3ad063a3762a3ef4a54ce84b3910c23265c3e573f4607269ef2
MD5 dea0c178ec763234991543be3e1bea41
BLAKE2b-256 8f3eefec937991bc5ceca7722513b12bb0c3ad6089f115cd8e2b791609c5f73b

See more details on using hashes here.

File details

Details for the file optilog-0.3.4-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

  • Download URL: optilog-0.3.4-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
  • Upload date:
  • Size: 11.2 MB
  • Tags: CPython 3.9, manylinux: glibc 2.17+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 colorama/0.4.4 importlib-metadata/4.6.4 keyring/23.5.0 pkginfo/1.8.2 readme-renderer/34.0 requests-toolbelt/0.9.1 requests/2.25.1 rfc3986/1.5.0 tqdm/4.57.0 urllib3/1.26.5 CPython/3.10.4

File hashes

Hashes for optilog-0.3.4-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 92445a5c348eefbb706f295b947e47cc13454ff4ec8afbb74b8bd65f54ca1ac3
MD5 42b930cefd7cb0c4fdf475a05055f0e9
BLAKE2b-256 389c551c91b206a7dc52d5a5d916a5e31a924a0cc8a6391a89058d099329d8cc

See more details on using hashes here.

File details

Details for the file optilog-0.3.4-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

  • Download URL: optilog-0.3.4-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
  • Upload date:
  • Size: 11.2 MB
  • Tags: CPython 3.8, manylinux: glibc 2.17+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 colorama/0.4.4 importlib-metadata/4.6.4 keyring/23.5.0 pkginfo/1.8.2 readme-renderer/34.0 requests-toolbelt/0.9.1 requests/2.25.1 rfc3986/1.5.0 tqdm/4.57.0 urllib3/1.26.5 CPython/3.10.4

File hashes

Hashes for optilog-0.3.4-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ac42a7dbffc5a84a255d464c90f618b28d582c3962f2ae7265cd91b3110434be
MD5 f7c3546ebd5c7a07620c46bb647c36e3
BLAKE2b-256 6e389a55cfc1de7a1dd99fe25ab9253b9073e804bd04638375fb261851e70c41

See more details on using hashes here.

File details

Details for the file optilog-0.3.4-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

  • Download URL: optilog-0.3.4-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
  • Upload date:
  • Size: 10.2 MB
  • Tags: CPython 3.7m, manylinux: glibc 2.17+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 colorama/0.4.4 importlib-metadata/4.6.4 keyring/23.5.0 pkginfo/1.8.2 readme-renderer/34.0 requests-toolbelt/0.9.1 requests/2.25.1 rfc3986/1.5.0 tqdm/4.57.0 urllib3/1.26.5 CPython/3.10.4

File hashes

Hashes for optilog-0.3.4-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 2acac65782dafabaa78158f7edf3ec012854c08b4cd90ba6c75934648781d34a
MD5 ccd99c77e0a23b76f56b19ae3d585ef0
BLAKE2b-256 852f53fa9165db1cfdfbe26e9f8fee275160e22fc4032e85204c6fdb59012a7f

See more details on using hashes here.

File details

Details for the file optilog-0.3.4-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

  • Download URL: optilog-0.3.4-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
  • Upload date:
  • Size: 10.2 MB
  • Tags: CPython 3.6m, manylinux: glibc 2.17+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 colorama/0.4.4 importlib-metadata/4.6.4 keyring/23.5.0 pkginfo/1.8.2 readme-renderer/34.0 requests-toolbelt/0.9.1 requests/2.25.1 rfc3986/1.5.0 tqdm/4.57.0 urllib3/1.26.5 CPython/3.10.4

File hashes

Hashes for optilog-0.3.4-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 4f9ffdbaae19e6016194e0f2c4cef45042e076b8ca49a2b5b187092af0c2f8c0
MD5 0ad2db580e62d2766993881275411b72
BLAKE2b-256 56632aebb95c5be5316d8466077b4eb408ccc8d31d51ce415023c4f2e6370987

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page