Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/msakai/glucose-pybind11
https://github.com/msakai/glucose-pybind11
python sat-solver
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/msakai/glucose-pybind11
- Owner: msakai
- License: other
- Created: 2018-02-06T08:32:25.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2019-04-14T07:51:34.000Z (over 5 years ago)
- Last Synced: 2024-10-13T23:49:01.600Z (3 months ago)
- Topics: python, sat-solver
- Language: C++
- Size: 162 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# pyglucose
[![pypi](https://img.shields.io/pypi/v/pyglucose.svg)](https://pypi.python.org/pypi/pyglucose)
[![Build Status (Travis-CI)](https://secure.travis-ci.org/msakai/glucose-pybind11.png?branch=master)](http://travis-ci.org/msakai/glucose-pybind11)
[![Build status (AppVeyor)](https://ci.appveyor.com/api/projects/status/c3dve9477wgs49c1?svg=true)](https://ci.appveyor.com/project/msakai/glucose-pybind11)
[![License](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)[pybind11](https://github.com/pybind/pybind11)-based binding of [glucose SAT solver](http://www.labri.fr/perso/lsimon/glucose/).
## Installation
```
pip install git+https://github.com/msakai/glucose-pybind11/
```## Basic Usage
The `pyglucose` module exports `Solver` and `Lit`.
A SAT problem can be solved as follows:
1. Construct a solver instance using `solver = Solver()`.
2. Allocate variables using `var = solver.new_var()`.
A variable is returned as integer value and can be converted to `Lit` by `Lit(var)`.
A literal `lit` can be negated as `~lit`.
3. Add clauses using `solver.add_clause(clause)`. A clause is represented as `Iterable[Lit]`.
4. Solve the problem using `solver.solve()`
5. If `solver.okay` property is `True` then the problem is `SATISFIABLE`, and
satisfying assignment can be retrieved using `solver.model` property.
Otherwise, the problem is `UNSATISFIABLE`.
## License[MIT License](LICENSE)