Last active
December 12, 2019 10:02
-
-
Save WillyPillow/a5b4f12faefd66c7ce42690668c002b5 to your computer and use it in GitHub Desktop.
Revisions
-
WillyPillow revised this gist
Dec 12, 2019 . No changes.There are no files selected for viewing
-
WillyPillow revised this gist
Dec 12, 2019 . No changes.There are no files selected for viewing
-
WillyPillow revised this gist
Dec 12, 2019 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -50,6 +50,6 @@ bool Solve() { int GetResult(int id) { return 0; } #endif // DIMACS } // namespace sat -
WillyPillow revised this gist
Dec 12, 2019 . 1 changed file with 2 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -2,6 +2,7 @@ #include <cryptominisat5/cryptominisat.h> #else #include <fstream> #include <vector> #endif namespace sat { @@ -29,7 +30,7 @@ int GetResult(int id) { #else std::vector<std::vector<int>> clauses; int n_vars; void Init(int n) { n_vars = n; } -
WillyPillow revised this gist
Dec 10, 2019 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -32,7 +32,7 @@ int GetResult(int id) { std::vector<std::vector<int> > clauses; int n_vars; void Init(int n) { n_vars = n; } void AddClause(std::vector<int> v) { clauses.emplace_back(std::move(v)); } -
WillyPillow created this gist
Dec 9, 2019 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,54 @@ #ifndef DIMACS #include <cryptominisat5/cryptominisat.h> #else #include <fstream> #endif namespace sat { #ifndef DIMACS CMSat::SATSolver solver; std::vector<CMSat::Lit> lit_buf; void Init(int n) { solver.new_vars(n + 1); } void AddClause(std::vector<int> v) { lit_buf.clear(); lit_buf.reserve(v.size()); for (int x : v) lit_buf.emplace_back(abs(x), x < 0); solver.add_clause(lit_buf); } bool Solve() { return solver.solve() == CMSat::l_True; } int GetResult(int id) { auto r = solver.get_model()[id]; return r == CMSat::l_True ? 1 : r == CMSat::l_False ? -1 : 0; } #else std::vector<std::vector<int> > clauses; int n_vars; void Init(int n) {} void AddClause(std::vector<int> v) { clauses.emplace_back(std::move(v)); } bool Solve() { std::fstream fs("out.dimacs", fs.trunc | fs.out); fs << "p cnf " << n_vars << ' ' << clauses.size() << '\n'; for (auto &v : clauses) { for (auto x : v) fs << x << ' '; fs << "0\n"; } fs.close(); exit(0); } int GetResult(int id) { return 0; } #endif } // namespace sat