Giter Site home page Giter Site logo

liffiton / pyminisolvers Goto Github PK

View Code? Open in Web Editor NEW
20.0 3.0 6.0 2.41 MB

A Python API for the MiniSat and MiniCard constraint solvers.

License: Other

Makefile 2.33% C++ 91.05% C 0.55% Python 5.63% CMake 0.44%
solver minisat python-api constraints

pyminisolvers's Introduction

PyMiniSolvers

PyMiniSolvers is a Python API for the MiniSat and MiniCard constraint solvers. It accesses the solvers via shared libraries, reducing overhead and allowing for efficient incremental solving. Its interfaces closely match the interfaces of each tool's Solver class, providing flexible and powerful access to most of the solvers' standard capabilities. Additionally, an extended "SubsetSolver" interface is provided for each tool, simplifying reasoning about subsets of a constraint set (e.g., solving arbitrary subsets of the added constraints, extracting UNSAT cores, etc.).

Basic usage:

>>> import minisolvers
>>> S = minisolvers.MinisatSolver()
>>> for i in range(4):
...     S.new_var()  
>>> for clause in [1], [-2], [-1, 2, -3], [3, 4]:
...     S.add_clause(clause)  

>>> S.solve()
True

>>> list(S.get_model())
[1, 0, 0, 1]

>>> S.add_clause([-1, 2, 3, -4])

>>> S.solve()
False

For further examples, see the documentation.

API Documentation

https://pyminisolvers.readthedocs.io/

Setup

Requirements:

  • Python 2.7 or 3.x
  • A standard build environment (make, gcc, etc.)
  • zlib development libraries (e.g., zlib1g-dev or zlib-devel packages)

Tested Platforms:

  • Linux
  • Cygwin
  • OS X

To build the shared libraries:

$ make

To test the API (automatically tests w/ Python 2 and/or 3 as available):

$ make test

Or manually run the tests:

$ python -m doctest -v minisolvers.py
$ python test_minisolvers.py

and/or

$ python3 -m doctest -v minisolvers.py
$ python3 test_minisolvers.py

License

This code is licensed under the MIT license. See LICENSE for details.

pyminisolvers's People

Contributors

dmeoli avatar liffiton avatar wenting-zhao avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.