Skip to content

Commit e1040c3

Browse files
committed
Making progress
1 parent d4e9d6a commit e1040c3

File tree

11 files changed

+38
-24
lines changed

11 files changed

+38
-24
lines changed

src/autarky.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include "constants.h"
3030

3131
using namespace ArjunNS;
32+
using namespace ArjunInt;
3233
using namespace CMSat;
3334
using std::vector;
3435
using std::fixed;

src/autarky.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,12 @@
3434
#include "src/formula.h"
3535

3636
using namespace CMSat;
37-
using namespace ArjunInt;
3837
using namespace ArjunNS;
3938
using std::vector;
4039
using std::set;
4140

41+
namespace ArjunInt {
42+
4243
class Autarky {
4344
public:
4445
Autarky(const Config& _conf);
@@ -59,3 +60,4 @@ class Autarky {
5960
const Config conf;
6061

6162
};
63+
}

src/formula.h

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ using CMSat::lit_Error;
4141
using CMSat::SATSolver;
4242
using std::map;
4343

44-
namespace ArjunNS {
44+
namespace ArjunInt {
4545

4646
struct CL {
4747
constexpr CL(const vector<Lit>& _lits) : lits(_lits) {}
@@ -63,12 +63,12 @@ class FHolder {
6363
// solver_train
6464
vector<CL> clauses;
6565
Lit out = lit_Error;
66-
aig_ptr aig = nullptr;
66+
ArjunNS::aig_ptr aig = nullptr;
6767
};
6868

6969
set<uint32_t> get_dependent_vars(const Formula& f, uint32_t v) const {
7070
set<uint32_t> ret;
71-
AIG::get_dependent_vars(f.aig, ret, v);
71+
ArjunNS::AIG::get_dependent_vars(f.aig, ret, v);
7272
return ret;
7373
}
7474

@@ -83,14 +83,14 @@ class FHolder {
8383
Formula ret;
8484
ret = compose_ite(fleft, fright, branch.out, helpers);
8585
ret.clauses.insert(ret.clauses.end(), branch.clauses.begin(), branch.clauses.end());
86-
ret.aig = AIG::new_ite(fleft.aig, fright.aig, branch.aig);
86+
ret.aig = ArjunNS::AIG::new_ite(fleft.aig, fright.aig, branch.aig);
8787
return ret;
8888
}
8989

9090
Formula neg(const Formula& f) {
9191
Formula ret = f;
9292
ret.out = ~f.out;
93-
ret.aig = AIG::new_not(f.aig);
93+
ret.aig = ArjunNS::AIG::new_not(f.aig);
9494
return ret;
9595
}
9696

@@ -114,7 +114,7 @@ class FHolder {
114114

115115
assert(fleft.aig != nullptr);
116116
assert(fright.aig != nullptr);
117-
ret.aig = AIG::new_or(fleft.aig, fright.aig);
117+
ret.aig = ArjunNS::AIG::new_or(fleft.aig, fright.aig);
118118
return ret;
119119
}
120120

@@ -145,7 +145,7 @@ class FHolder {
145145
ret.clauses.push_back(CL({b, fresh, ~r}));
146146
ret.clauses.push_back(CL({b, ~fresh, r}));
147147
ret.out = Lit(fresh_v, false);
148-
ret.aig = AIG::new_ite(fleft.aig, fright.aig, branch);
148+
ret.aig = ArjunNS::AIG::new_ite(fleft.aig, fright.aig, branch);
149149
return ret;
150150
}
151151

@@ -155,15 +155,12 @@ class FHolder {
155155
}
156156

157157
private:
158-
AIGManager aig_mng;
158+
ArjunNS::AIGManager aig_mng;
159159
T* solver = nullptr;
160160
Lit my_true_lit = lit_Error;
161161
};
162162

163-
}
164-
165-
166-
inline std::ostream& operator<<(std::ostream& os, const ArjunNS::FHolder<ArjunInt::MetaSolver2>::Formula& f) {
163+
inline std::ostream& operator<<(std::ostream& os, const FHolder<ArjunInt::MetaSolver2>::Formula& f) {
167164
os << " === Formula out: " << f.out << " === " << endl;
168165
for (const auto& cl : f.clauses) {
169166
for (const auto& l : cl.lits) os << std::setw(6) << l;
@@ -173,3 +170,5 @@ inline std::ostream& operator<<(std::ostream& os, const ArjunNS::FHolder<ArjunIn
173170
os << " === End Formula === ";
174171
return os;
175172
}
173+
174+
}

src/interpolant.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ extern "C" {
3232

3333
using namespace CMSat;
3434
using namespace CaDiCaL;
35+
using namespace ArjunInt;
3536

3637
void MyTracer::add_derived_clause(uint64_t id, bool /*red*/, const std::vector<int> & clause,
3738
const std::vector<uint64_t> & oantec) {

src/interpolant.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ using std::vector;
4242
using std::map;
4343
using namespace ArjunNS;
4444

45+
namespace ArjunInt {
46+
4547
struct MyTracer : public CaDiCaL::Tracer {
4648
MyTracer(const uint32_t _orig_num_vars, const set<uint32_t>& input_vars,
4749
const ArjunInt::Config& _conf, map<Lit, aig_ptr>& _lit_to_aig, const AIGManager& _aig_mng) :
@@ -139,4 +141,4 @@ class Interpolant {
139141
vector<uint32_t> var_to_indic; //maps an ORIG VAR to an INDICATOR VAR
140142
vector<aig_ptr> defs; //definition of variables in terms of AIG. ORIGINAL number space
141143
};
142-
144+
}

src/manthan.cpp

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
44
Copyright (c) 2020, Mate Soos and Kuldeep S. Meel. All rights reserved.
55
6-
Permission is hereby granted, free of charge, to any person obtaining a copy
7-
of this software and associated documentation files (the "Software"), to deal
6+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal
87
in the Software without restriction, including without limitation the rights
98
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
109
copies of the Software, and to permit persons to whom the Software is
@@ -73,13 +72,6 @@ using namespace CMSat;
7372
// no repair, learning/mbve does it: benchmarks-qdimacs/rankfunc57_unsigned_64.qdimacs.cnf
7473
// interesting, does not finish, but fast: benchmarks-qdimacs/query48_exquery_1344n.qdimacs.cnf
7574

76-
vector<int> lits_to_ints(const vector<Lit>& lits) {
77-
vector<int> ret;
78-
ret.reserve(lits.size());
79-
for(const auto& l: lits) ret.push_back(lit_to_pl(l));
80-
return ret;
81-
}
82-
8375
template<typename S>
8476
void Manthan::inject_cnf(S& s) const {
8577
s.new_vars(cnf.nVars());

src/manthan.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ using sample = vector<lbool>;
5151
using namespace ArjunInt;
5252
using namespace ArjunNS;
5353

54+
namespace ArjunInt {
5455
class ManthanLearn;
5556

5657
class Manthan {
@@ -169,6 +170,12 @@ class Manthan {
169170
assert(val != l_Undef);
170171
return val == l_True;
171172
}
173+
vector<int> lits_to_ints(const vector<Lit>& lits) {
174+
vector<int> ret;
175+
ret.reserve(lits.size());
176+
for(const auto& l: lits) ret.push_back(lit_to_pl(l));
177+
return ret;
178+
}
172179

173180
// debug
174181
bool verify_final_cnf(const SimplifiedCNF& fcnf) const;
@@ -200,3 +207,4 @@ class Manthan {
200207
SimplifiedCNF cnf;
201208
AIGManager aig_mng;
202209
};
210+
}

src/manthan_learn.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
using std::setprecision;
3232
using std::fixed;
3333
using std::setw;
34+
using namespace ArjunInt;
3435

3536
void ManthanLearn::full_train() {
3637
// Sampling

src/manthan_learn.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ using sample = vector<lbool>;
3939
//#define MLPACK_PRINT_WARN
4040
#include <mlpack.hpp>
4141

42+
namespace ArjunInt {
43+
4244
class ManthanLearn {
4345
public:
4446
ManthanLearn(Manthan& _manthan, const Config& _conf, const ArjunNS::Arjun::ManthanConf& _mconf) :
@@ -58,3 +60,4 @@ class ManthanLearn {
5860
const Config& conf;
5961
const ArjunNS::Arjun::ManthanConf& mconf;
6062
};
63+
}

src/metasolver.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,12 @@ class MetaSolver {
4848
if (solver_type == SolverType::cms) {
4949
cms = std::make_unique<CMSat::SATSolver>();
5050
cms->set_prefix("c o ");
51-
} else {
51+
} else if (solver_type == SolverType::cadical) {
5252
cadical = std::make_unique<CaDiCaL::Solver>();
5353
cadical_nvars = 0;
5454
cadical->prefix("c o ");
55+
} else {
56+
throw std::invalid_argument("Unsupported solver type");
5557
}
5658
}
5759

0 commit comments

Comments
 (0)