A SAT solver implemented in Java using the DPLL algorithm with some optimizations. This project can be run via the CLI and includes a few tests to validate its functionality and correctness.
Note: Around 5,000 benchmark files are bundled with the project. As a result, installation or cloning may take a few minutes.
Make sure Java (16+) and Maven are installed on your system.
cd SATSolver/
To build the project and generate the .jar file, use:
mvn clean
mvn package
Once the .jar file is built, you can run the solver with:
java -jar path/to/solver/SATSolver-1.0.jar path/to/input.cnf
For example:
java -jar target/SATSolver-1.0.jar benchmarks/20vars/sat/0.cnf
java -jar target/SATSolver-1.0.jar --export
filepath, to output results in the command line
--export, to generate results.html, which contains benchmarked results of the solver from the benchmarks folder
Note: Only one of filepath or --export can be used at the same time.
The output is structured as follows:
SATorUNSAT- List of true literals, sorted in ascending order by the variable number, or a newline if UNSAT
- Time taken to initialize the solver
- Time taken to solve
- Number of unit propagations that happened during the entire run
- Depth of the decision tree (number of decision variables)
Project supports the DIMACS CNF format only
- The
benchmarksare located insrc/main/resources/benchmarks - The tests are located in
src/test/java/SimpleSATSolverTest.java - In
src/main/java/org/solver:CircularBuffer,IntQueue, andIntStackcontain data structures for better performanceDimacsParserparses.cnffiles (streams)SATInfocontains information printed after the solver finishesSimpleSATSolvercontains the solver logicExportResultsexports benchmarks
- Time is measured in nanoseconds, but the output displays the times in milliseconds.
- If you need the time in nanoseconds, remove the division by
1_000_000inSATInfoto output time in nanoseconds.