Git Product home page Git Product logo

maxsat-solver's Introduction

MaxSAT Solver

Build Status

A unweighted MaxSAT Solver that uses Minisat2.2 as its backbone.

This solver implements Sequential Encoding to encode cardinality constraints and uses the LUS search algorithm.

Installation

Prerequisites

  • g++ (or any other C++ compiler)
  • minisat2.2 (included as a submodule)
  • GNU make

Building the project

  • Clone the repository
$ git clone --recurse-submodules https://github.com/sukrutrao/MaxSAT-Solver.git
$ cd MaxSAT-Solver
  • Compile the program
$ make

If you use a different compiler, please edit the Makefile accordingly.

Running the solver

The solver accepts input from standard input (STDIN) and sends output to the standard output (STDOUT).

Input format

The input is a SAT formula is DIMACS format. A detailed description can be found here.

Output format

The first line of the output is a single integer that specifies the number of clauses that could be satisfied. The second line is any assignment that satisfies the maximum number of clauses satisfiable. It consists of space separated boolean variables in ascending order, where the variables have a negative sign if assigned false and no negative sign if assigned true. The last variable is followed by a space and then a 0.

Running the solver

If the input is in a file input.cnf, use

$ ./solver < input.cnf

Example

Let the input be

c 3 variables, 6 clauses
p cnf 3 6
1 2 0
1 -2 0
3 2 0
-3 1 0
1 2 3 0
-1 0

The output is

5
-1 2 -3 0

Here, the 5 clauses in the formula are satisfiable. Variable 2 is assigned true, and variables 1 and 3 are assigned false. This is one possible assignment.

License

This project is licensed under the MIT License. This project uses Minisat2.2, whose license can be found here.

Author

Sukrut Rao

For any issues, queries, or suggestions, please open an issue.


This project was created as a part of the course CS6403: Constraint Solving at IIT Hyderabad.

maxsat-solver's People

Contributors

gooddeeds avatar sukrutrao avatar

Stargazers

 avatar  avatar  avatar

Watchers

 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.