Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/Lipen/backdoor-solver

Backdoor-based SAT solver
https://github.com/Lipen/backdoor-solver

backdoor rust sat-solver

Last synced: 16 days ago
JSON representation

Backdoor-based SAT solver

Awesome Lists containing this project

README

        

# Backdoor-based SAT Solver

> SAT solver based on rho-backdoors.

[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.13375121.svg)](https://doi.org/10.5281/zenodo.13375121)
[![Build Status](https://github.com/Lipen/backdoor-solver/actions/workflows/ci.yml/badge.svg)](https://github.com/Lipen/backdoor-solver/actions)

- For ECAI-2024 related code, please refer to the [`ecai-2024`](https://github.com/Lipen/backdoor-solver/tree/ecai-2024) branch.
- For SAT Competition 2024 related code, please refer to the [`sc2024`](https://github.com/Lipen/backdoor-solver/tree/sc2024) branch.

## Setup

```sh
git clone --recurse-submodules -j4 https://github.com/Lipen/backdoor-solver
cd backdoor-solver
cargo check --workspace --lib --bins --tests
```

Do not forget to update submodules every time you switch branches!

```sh
git submodule update --init --recursive --progress
```

Below, you can find instructions on how to use different components provided in this repository, for example, SAT solver and backdoor searcher.

## SAT solver

> SAT solver that interleaves CaDiCaL with clauses derivation procedures utilizing rho-backdoors.

### CLI Usage

```
Usage: interleave [OPTIONS] --backdoor-size --num-iters --max-product --budget-filter --budget-solve

Arguments:
Input file with CNF in DIMACS format

Options:
-o, --output
Path to output file in DIMACS format. If the problem is SAT, contains two lines: "s SATISFIABLE\nv 1 2 ... 0\n", else contains a single line: "s UNSATISFIABLE" or "s INDET"
--results
Path to a file with results
--seed
Random seed [default: 42]
--backdoor-size
Backdoor size
--num-iters
Number of EA iterations
--stagnation-limit
Number of stagnated iterations before re-initialization
--ban-used
Do ban variables used in the best backdoors on previous runs?
--reset-used-vars
Reset banned used variables on empty product
--allow
Comma-separated list of allowed variables (1-based indices)
--ban
Comma-separated list of banned variables (1-based indices)
--derive-ternary
Derive ternary clauses
--max-product
Maximum product size
--use-sorted-filtering
Use novel sorted filtering method
--num-conflicts
Number of conflicts (budget per task in filtering) [default: 1000]
--budget-filter
Initial budget (in conflicts) for filtering
--factor-budget-filter
Multiplicative factor for filtering budget [default: 1]
--budget-solve
Initial budget (in conflicts) for solving
--factor-budget-solve
Multiplicative factor for solving budget [default: 1]
--budget-presolve
Budget (in conflicts) for pre-solve [default: 0]
--compute-cores
Do compute cores for easy tasks and invalid cubes
--add-cores
Do add lemmas from cores
--max-core-size
Maximum core size to be added (0 = unlimited) [default: 0]
--cadical-options
Comma-separated list of Cadical options ('key=value' pairs, e.g. 'elim=0,ilb=0,check=1')
-h, --help
Print help
-V, --version
Print version
```

### Example

```sh
cargo run --release --bin interleave -- data/mult/lec_CvK_12x12.cnf --backdoor-size 10 --num-iters 10000 --ban-used --max-product 10000 --budget-filter 10000 --factor-budget-filter 1.1 --budget-solve 100000 --factor-budget-solve 1.1 --budget-presolve 10000 --output out.txt
```

## Backdoor Searcher

> Evolutionary algorithm for searching rho-backdoors for a given SAT formula.

### CLI Usage

```
Usage: search [OPTIONS] --backdoor-size --num-iters

Arguments:
Input file with CNF in DIMACS format

Options:
--backdoor-size Backdoor size
--num-iters Number of EA iterations
--num-runs Number of EA runs [default: 1]
-o, --output Path to a output file with backdoors
--seed Random seed [default: 42]
--allow Comma-separated list of allowed variables (1-based indices)
--ban Comma-separated list of banned variables (1-based indices)
--ban-used Do ban variables used in best backdoors on previous runs?
--stagnation-limit Number of stagnated iterations before re-initialization
--max-rho Maximum required rho value (break EA upon reaching) [default: 1]
--min-iter Minimum number of EA iterations [default: 0]
--dump-records Do dump records for each EA run?
--derive Do derive clauses from backdoors?
--dump-derived Do dump derived clauses after each EA run?
--probe Do probe the backdoor variables?
--probe-derive Do try to probe-derive all units and binary clauses?
--derive-ternary Derive ternary clauses
--budget-presolve Budget (in conflicts) for pre-solve [default: 0]
-h, --help Print help
-V, --version Print version

```

### Example

Search for 3 backdoors, each of size 10, using 1000 iterations of EA and the random seed 42 (default):

```sh
cargo run --release --bin search -- data/mult/lec_CvK_12.cnf --backdoor-size 10 --num-iters 1000 --num-runs 3 --seed 42 --output output.txt
```

`output.txt` might look like:
```
Backdoor [4242, 4919, 2082, 1920, 4969, 5082, 4903, 2163, 2154, 4071] of size 10 on iter 829 with fitness = 0.029296875, rho = 0.970703125, hard = 30 in 120.671 ms
Backdoor [5089, 3989, 3375, 4265, 2163, 4273, 2648, 4158, 2082, 3133] of size 10 on iter 935 with fitness = 0.009765625, rho = 0.990234375, hard = 10 in 99.219 ms
Backdoor [4022, 4034, 4475, 4383, 2606, 4902, 1895, 960, 3538, 2471] of size 10 on iter 884 with fitness = 0.013671875, rho = 0.986328125, hard = 14 in 70.435 ms
```

Note: variables in the reported backdoors (in file/console) are 1-based.