All Projects → togatoga → togasat

togatoga / togasat

Licence: MIT license
A Header-Only CDCL SAT Solver for Programming Contest

Programming Languages

C++
36643 projects - #6 most used programming language
python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to togasat

Programming Contest
My solutions of some problems from different online judges
Stars: ✭ 158 (+209.8%)
Mutual labels:  competitive-programming, programming-contests
minisat-rust
Experimental minisat SAT solver reimplementation in Rust
Stars: ✭ 68 (+33.33%)
Mutual labels:  sat-solver, minisat
AtCoderClans
【非公式】AtCoderがもっと楽しくなるリンク集です。有志による非公式サービス・ツール・ライブラリ・記事などをまとめています。
Stars: ✭ 74 (+45.1%)
Mutual labels:  competitive-programming, programming-contests
Usaco
General Resources for Competitive Programming
Stars: ✭ 1,152 (+2158.82%)
Mutual labels:  competitive-programming, programming-contests
cp
Solutions to competitive programming problems.
Stars: ✭ 15 (-70.59%)
Mutual labels:  competitive-programming, programming-contests
E Maxx Eng
Translation of http://e-maxx.ru into English
Stars: ✭ 1,238 (+2327.45%)
Mutual labels:  competitive-programming, programming-contests
batsat
A (parametrized) Rust SAT solver originally based on MiniSat
Stars: ✭ 26 (-49.02%)
Mutual labels:  sat-solver, minisat
Oj
Tools for various online judges. Downloading sample cases, generating additional test cases, testing your code, and submitting it.
Stars: ✭ 517 (+913.73%)
Mutual labels:  competitive-programming, programming-contests
Jikka
an automated solver for problems of competitive programming
Stars: ✭ 143 (+180.39%)
Mutual labels:  competitive-programming, programming-contests
USACO
Algorithms, data structures, and problems in competitive programming up to USACO Platinum
Stars: ✭ 34 (-33.33%)
Mutual labels:  competitive-programming, programming-contests
Awesome Competitive Programming
💎 A curated list of awesome Competitive Programming, Algorithm and Data Structure resources
Stars: ✭ 9,119 (+17780.39%)
Mutual labels:  competitive-programming, programming-contests
GoogleCodeJam-2016
🏃 Python Solutions of All 26 Problems of GCJ 2016
Stars: ✭ 18 (-64.71%)
Mutual labels:  competitive-programming, programming-contests
Atcoderproblems
Extend your AtCoder
Stars: ✭ 713 (+1298.04%)
Mutual labels:  competitive-programming, programming-contests
Competitive Programming
My solutions to problems from various competitive programming websites.
Stars: ✭ 93 (+82.35%)
Mutual labels:  competitive-programming, programming-contests
Cpeditor
The IDE for competitive programming 🎉 | Fetch, Code, Compile, Run, Check, Submit 🚀
Stars: ✭ 562 (+1001.96%)
Mutual labels:  competitive-programming, programming-contests
BAPCtools
Tools for developing ICPC-style programming contest problems.
Stars: ✭ 36 (-29.41%)
Mutual labels:  competitive-programming, programming-contests
Usaco Guide
A free collection of curated, high-quality resources to take you from Bronze to Platinum and beyond.
Stars: ✭ 439 (+760.78%)
Mutual labels:  competitive-programming, programming-contests
Domjudge
DOMjudge programming contest jury system
Stars: ✭ 484 (+849.02%)
Mutual labels:  competitive-programming, programming-contests
GoogleCodeJam-2017
🏃 Python Solutions of All 27 Probelms in GCJ 2017
Stars: ✭ 53 (+3.92%)
Mutual labels:  competitive-programming, programming-contests
verification-helper
a testing framework for snippet libraries used in competitive programming
Stars: ✭ 137 (+168.63%)
Mutual labels:  competitive-programming, programming-contests

togasat

togasat based on minisat is a header-only CDCL SAT Solver for programming contests.

Minimum requirement C++ version

  • C++11

How to use togasat as a library

At first, include the header (or do copy & paste):

#include "togasat.hpp"

Make a solver object.

   togasat::Solver solver;

If you want to add a (x1 v x2 v not x3) clause

    std::vector<int> clause;
    clause.push_back(1);  // x1
    clause.push_back(2);  // x2
    clause.push_back(-3);  // not x3

    solver.addClause(clause);  // add (x1 v x2 v not x3)

YOU MUST NOT ADD CLAUSES THAT CONTAIN 0, IT WILL CAUSE A SAT SOLVER ABORTION

After adding all clauses, call .solve() method.

    togasat::lbool status = solver.solve();

The return value:

  • status is 0, SATISFIABLE
  • status is 1, UNSATSFIABLE
  • status is 2, UNKNOWN

Also, you can get the assignments, e.g.

   solver.assigns[0] = 0;  // X_1 = True
   solver.assigns[1] = 1;  // X_2 = False
   solver.assigns[i] = 0;  // X_{i + 1} = True

You should take care that 0 denotes true and 1 denotes false.

How to solve cnf

$ ./togasat <cnf problem>
int main(int argc, char *argv[]) {
    togasat::Solver solver;
    std::string problem_name = argv[1];
    solver.parseDimacsProblem(problem_name);  // parse problem
    togasat::lbool status = solver.solve();  // solve sat problem
    solver.printAnswer();  // print answer
}

SATISFIABLE

If Sat Solver proves a given problem is SATISFIABLE(SAT), it prints SAT and a model for the problem.

SAT
-1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 13 -14 15 16 0

The model is separated by a space and ended with zero(0).

  • A positive integer represents True.
  • A negative integer represents False.

For example,-1 represents X1=False,13 represents X13=True.

UNSATISFIABLE

It only prints UNSAT.

UNSAT

Algorithms

  • DPLL
  • Clause learning
  • Two literal watching
  • Back jump
  • Phase saving
  • Luby restart
  • VSIDS

Problems solved by togasat

Codeforces

Contributors

Note

Welcome any pull requests, fix of typo, refactoring, correction of documents and so on. If you can solve a competitive programming problem by togasat, please let me know and you make a pull request. It's very helpful for me.

Your star makes me motivated

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].