Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/chrjabs/rustsat
This library aims to provide implementations of elements commonly used in the development on software in the area of satisfiability solving. The focus of the library is to provide as much ease of use without giving up on performance.
https://github.com/chrjabs/rustsat
Last synced: 3 months ago
JSON representation
This library aims to provide implementations of elements commonly used in the development on software in the area of satisfiability solving. The focus of the library is to provide as much ease of use without giving up on performance.
- Host: GitHub
- URL: https://github.com/chrjabs/rustsat
- Owner: chrjabs
- License: mit
- Created: 2022-07-01T12:37:39.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-04-12T14:49:12.000Z (7 months ago)
- Last Synced: 2024-04-14T10:49:14.212Z (7 months ago)
- Language: Rust
- Homepage: https://crates.io/crates/rustsat
- Size: 6.99 MB
- Stars: 8
- Watchers: 1
- Forks: 5
- Open Issues: 12
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
- awesome-rust-formalized-reasoning - rustsat - batsat)[:package:](https://crates.io/crates/rustsat-cadical)[:package:](https://crates.io/crates/rustsat-glucose)[:package:](https://crates.io/crates/rustsat-ipasir)[:package:](https://crates.io/crates/rustsat-kissat)[:package:](https://crates.io/crates/rustsat-minisat)[:package:](https://crates.io/crates/rustsat-tools) - provide elements commonly used in satisfiability solving software. (Projects / Libraries)
README
[![Build & Test](https://github.com/chrjabs/rustsat/actions/workflows/rustsat.yml/badge.svg)](https://github.com/chrjabs/rustsat/actions/workflows/rustsat.yml)
[![crates.io](https://img.shields.io/crates/v/rustsat)](https://crates.io/crates/rustsat)
[![docs.rs](https://img.shields.io/docsrs/rustsat)](https://docs.rs/rustsat)
[![PyPI](https://img.shields.io/pypi/v/rustsat)](https://pypi.org/project/rustsat)
[![License](https://img.shields.io/crates/l/rustsat)](./LICENSE)# rustsat - A Comprehensive SAT Library for Rust
`rustsat` is a collection of interfaces and utilities for working with the boolean satisfiability problem in Rust.
This library aims to provide implementations of elements commonly used in the development of software in the area of satisfiability solving.
The focus of the library is to provide as much ease of use without giving up on performance.## Example
```rust
let mut instance: SatInstance = SatInstance::new();
let l1 = instance.new_lit();
let l2 = instance.new_lit();
instance.add_binary(l1, l2);
instance.add_binary(!l1, l2);
instance.add_unit(l1);
let mut solver = rustsat_minisat::core::Minisat::default();
solver.add_cnf(instance.as_cnf().0).unwrap();
let res = solver.solve().unwrap();
assert_eq!(res, SolverResult::Sat);
let sol = solver.full_solution().unwrap();
assert_eq!(sol[l1.var()], TernaryVal::True);
assert_eq!(sol[l2.var()], TernaryVal::True);
```## Crates
The RustSAT project is split up into multiple crates that are all contained in [this repository](https://github.com/chrjabs/rustsat/).
These are the crates the project consists of:| Crate | Description |
| --- | --- |
| `rustsat` | The main library, containing basic types, traits, encodings, parsers, and more. |
| `rustsat-tools` | A collection of small helpful tools based on RustSAT that can be installed as binaries. For a list of available tools, see [this directory](https://github.com/chrjabs/rustsat/tree/main/tools/src/bin) with short descriptions of the tools in the headers of the files. |
| `rustsat-` | Interfaces to SAT solvers that can be used alongside `rustsat`. Currently interfaces are available for `cadical`, `kissat`, `glucose`, and `minisat`. |
| `rustsat-ipasir` | [IPASIR](https://github.com/biotomas/ipasir) bindings to use any compliant solver with `rustsat`. |## Installation
To use the RustSAT library as a dependency in your project, simply run `cargo add rustsat`.
To use an SAT solver interface in your project, run `cargo add rustsat-`.
Typically, the version of the SAT solver can be selected via crate features, refer to the documentation of the respective SAT solver crate for details.To install the binary tools in `rustsat-tools` run `cargo install rustsat-tools`.
## Features
| Feature name | Description |
| --- | --- |
| `optimization` | Include optimization (MaxSAT) data structures etc. |
| `multiopt` | Include data structures etc. for multi-objective optimization. |
| `compression` | Enable parsing and writing compressed input. |
| `fxhash` | Use the faster firefox hash function from `rustc-hash` in `rustsat`. |
| `rand` | Enable randomization features. (Shuffling clauses etc.) |
| `ipasir-display` | Changes `Display` trait for `Lit` and `Var` types to follow IPASIR variables indexing. |
| `bench` | Enable benchmark tests. Behind feature flag since it requires unstable Rust. |
| `internals` | Make some internal data structures for e.g. encodings public. This is useful when basing a more complex encoding on the `rustsat` implementation of another encoding. Note that the internal API might change between releases. |## Examples
For example usage refer to the small example tools in the [`rustsat-tools`
crate](https://crates.io/crates/rustsat_tools) at `tools/src/bin`. For a bigger
example you can look at this [multi-objective optimization
solver](https://github.com/chrjabs/scuttle).## Python Bindings
This library also comes with experimental Python bindings to use its encodings
from Python. The Python bindings are available at
[PyPI](https://pypi.org/project/rustsat/). For more details see the [Python API
documentation](https://christophjabs.info/rustsat/pyapi/).## Contributing
We are welcoming contributions in the form of pull requests and suggestions.
Kindly make sure to read
[`CONTRIBUTING.md`](https://github.com/chrjabs/rustsat/blob/main/CONTRIBUTING.md)
first.