Skip to content

Commit

Permalink
Merge pull request #769 from m-fleury/idrup
Browse files Browse the repository at this point in the history
 IDRUP Support
msoos authored Aug 29, 2024
2 parents f5969f2 + 2b49b77 commit 78c852e
Showing 20 changed files with 724 additions and 19 deletions.
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -81,6 +81,7 @@ def gen_modules(version):
"src/gaussian.cpp",
"src/get_clause_query.cpp",
"src/hyperengine.cpp",
"src/idrup.cpp",
"src/intree.cpp",
"src/lucky.cpp",
"src/matrixfinder.cpp",
8 changes: 8 additions & 0 deletions src/cnf.cpp
Original file line number Diff line number Diff line change
@@ -675,6 +675,14 @@ void CNF::add_frat(FILE* os) {
frat->set_sqlstats_ptr(sqlStats);
}

void CNF::add_idrup(FILE* os) {
if (frat) delete frat;
frat = new IdrupFile<false>(inter_to_outerMain);
frat->setFile(os);
frat->set_sumconflicts_ptr(&sumConflicts);
frat->set_sqlstats_ptr(sqlStats);
}

vector<uint32_t> CNF::get_outside_lit_incidence()
{
vector<uint32_t> inc;
2 changes: 2 additions & 0 deletions src/cnf.h
Original file line number Diff line number Diff line change
@@ -34,6 +34,7 @@ THE SOFTWARE.
#include "solvertypes.h"
#include "watcharray.h"
#include "frat.h"
#include "idrup.h"
#include "clauseallocator.h"
#include "varupdatehelper.h"
#include "gausswatched.h"
@@ -135,6 +136,7 @@ class CNF
//frat
Frat* frat;
void add_frat(FILE* os);
void add_idrup(FILE* os);

//Clauses
vector<ClOffset> longIrredCls;
19 changes: 19 additions & 0 deletions src/cryptominisat.cpp
Original file line number Diff line number Diff line change
@@ -938,6 +938,7 @@ lbool calc(
}
data->okay = data->solvers[0]->okay();
data->cpu_times[0] = cpuTime();
data->solvers[0]->conclude_idrup(ret);
return ret;
}

@@ -1141,6 +1142,24 @@ DLL_PUBLIC void SATSolver::set_frat(FILE* os)
data->solvers[0]->conf.do_hyperbin_and_transred = true;
}

DLL_PUBLIC void SATSolver::set_idrup(FILE* os)
{
if (data->solvers.size() > 1) {
std::cerr << "ERROR: IDRUP cannot be used in multi-threaded mode" << endl;
exit(-1);
}
if (nVars() > 0) {
std::cerr << "ERROR: IDRUP cannot be set after variables have been added" << endl;
exit(-1);
}
data->solvers[0]->conf.doBreakid = false;
data->solvers[0]->conf.doFindXors = false;
data->solvers[0]->add_idrup(os);
data->solvers[0]->conf.gaussconf.max_matrix_rows = 0;
data->solvers[0]->conf.gaussconf.max_matrix_columns = 0;
data->solvers[0]->conf.do_hyperbin_and_transred = true;
}

DLL_PUBLIC void SATSolver::interrupt_asap()
{
data->must_interrupt->store(true, std::memory_order_relaxed);
2 changes: 2 additions & 0 deletions src/cryptominisat.h
Original file line number Diff line number Diff line change
@@ -205,6 +205,8 @@ namespace CMSat {

void print_stats(double wallclock_time_started = 0) const; //print solving stats. Call after solve()/simplify()
void set_frat(FILE* os); //set frat to ostream, e.g. stdout or a file
void set_idrup(FILE* os); //set idrup to ostream, e.g. stdout or a file
void add_empty_cl_to_frat(); // allows to treat SAT as UNSAT and perform learning
void interrupt_asap(); //call this asynchronously, and the solver will try to cleanly abort asap
void add_in_partial_solving_stats(); //used only by Ctrl+C handler. Ignore.

10 changes: 9 additions & 1 deletion src/frat.h
Original file line number Diff line number Diff line change
@@ -48,7 +48,8 @@ using std::vector;

namespace CMSat {

enum FratFlag{fin, deldelay, deldelayx, del, delx, findelay, add, addx, origcl, origclx, fratchain, finalcl, finalx, reloc, implyclfromx, implyxfromcls};
enum FratFlag{fin, deldelay, deldelayx, del, delx, findelay, add, addx, origcl, origclx, fratchain, finalcl, finalx, reloc, implyclfromx, implyxfromcls, weakencl, restorecl, assump, unsatcore, modelF};
enum FratOutcome{satisfiable, unsatisfiable, unknown};

class Frat
{
@@ -67,10 +68,12 @@ class Frat
virtual Frat& operator<<(const Xor&) { return *this; }
virtual Frat& operator<<(const vector<Lit>&) { return *this; }
virtual Frat& operator<<(const char*) { return *this; }
virtual Frat& operator<<(const FratOutcome) { return *this; }
virtual Frat& operator<<(const FratFlag) { return *this; }
virtual void setFile(FILE*) { }
virtual FILE* getFile() { return nullptr; }
virtual void flush();
virtual bool incremental() {return false;}

int buf_len;
unsigned char* drup_buf = nullptr;
@@ -275,6 +278,7 @@ class FratFile: public Frat
}
break;

case FratFlag::weakencl:
case FratFlag::del:
adding = false;
buf_add('d');
@@ -327,6 +331,10 @@ class FratFile: public Frat
buf_add('x');
buf_nonbin_move();
break;

default:
__builtin_unreachable();
break;
}

return *this;
25 changes: 25 additions & 0 deletions src/idrup.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/******************************************
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
***********************************************/

#include "idrup.h"

namespace CMSat {
void Drat::flush() {}
}
Loading

0 comments on commit 78c852e

Please sign in to comment.