Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Solution to issue #16 #1 on MacOX #31

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
config.mk
build

Makefile

CMakeCache.txt
CMakeFiles/
cmake_install.cmake
11 changes: 9 additions & 2 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,19 @@ Configuration
================================================================================
Building

[ TODO: describe seperate build modes ]
make all (the default if no target is provided): build static/shared library
and executable minisat_core/minisat
make install: make install + cp libminisat.a /usr/local/lib/libminisat.a

================================================================================
Install

[ TODO: ? ]
```
mkdir build
cd build
cmake ..
make
```

================================================================================
Directory Overview:
Expand Down
38 changes: 20 additions & 18 deletions minisat/core/SolverTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,24 +52,26 @@ struct Lit {
int x;

// Use this as a constructor:
friend Lit mkLit(Var var, bool sign = false);
// friend Lit mkLit(Var var, bool sign = false);

bool operator == (Lit p) const { return x == p.x; }
bool operator != (Lit p) const { return x != p.x; }
bool operator < (Lit p) const { return x < p.x; } // '<' makes p, ~p adjacent in the ordering.
};


inline Lit mkLit (Var var, bool sign) { Lit p; p.x = var + var + (int)sign; return p; }
// inline Lit mkLit (Var var, bool sign) { Lit p; p.x = var + var + (int)sign; return p; }
inline Lit mkLit (Var var, bool sign = false) { Lit p; p.x =
var + var + (int)sign; return p; }
inline Lit operator ~(Lit p) { Lit q; q.x = p.x ^ 1; return q; }
inline Lit operator ^(Lit p, bool b) { Lit q; q.x = p.x ^ (unsigned int)b; return q; }
inline bool sign (Lit p) { return p.x & 1; }
inline int var (Lit p) { return p.x >> 1; }

// Mapping Literals to and from compact integers suitable for array indexing:
inline int toInt (Var v) { return v; }
inline int toInt (Lit p) { return p.x; }
inline Lit toLit (int i) { Lit p; p.x = i; return p; }
inline int toInt (Var v) { return v; }
inline int toInt (Lit p) { return p.x; }
inline Lit toLit (int i) { Lit p; p.x = i; return p; }

//const Lit lit_Undef = mkLit(var_Undef, false); // }- Useful special constants.
//const Lit lit_Error = mkLit(var_Undef, true ); // }
Expand All @@ -87,7 +89,7 @@ class LSet : public IntSet<Lit, MkIndexLit>{};
// Lifted booleans:
//
// NOTE: this implementation is optimized for the case when comparisons between values are mostly
// between one variable and one constant. Some care had to be taken to make sure that gcc
// between one variable and one constant. Some care had to be taken to make sure that gcc
// does enough constant propagation to produce sensible code, and this appears to be somewhat
// fragile unfortunately.

Expand All @@ -104,7 +106,7 @@ class lbool {
bool operator != (lbool b) const { return !(*this == b); }
lbool operator ^ (bool b) const { return lbool((uint8_t)(value^(uint8_t)b)); }

lbool operator && (lbool b) const {
lbool operator && (lbool b) const {
uint8_t sel = (this->value << 1) | (b.value << 3);
uint8_t v = (0xF7F755F4 >> sel) & 3;
return lbool(v); }
Expand Down Expand Up @@ -156,7 +158,7 @@ class Clause {
header.reloced = 0;
header.size = ps.size();

for (int i = 0; i < ps.size(); i++)
for (int i = 0; i < ps.size(); i++)
data[i].lit = ps[i];

if (header.has_extra){
Expand All @@ -178,7 +180,7 @@ class Clause {
if (header.has_extra){
if (header.learnt)
data[header.size].act = from.data[header.size].act;
else
else
data[header.size].abs = from.data[header.size].abs;
}
}
Expand Down Expand Up @@ -279,9 +281,9 @@ class ClauseAllocator
void reloc(CRef& cr, ClauseAllocator& to)
{
Clause& c = operator[](cr);

if (c.reloced()) { cr = c.relocation(); return; }

cr = to.alloc(c);
c.relocate(cr);
}
Expand Down Expand Up @@ -331,10 +333,10 @@ class OccLists

public:
OccLists(const Deleted& d, MkIndex _index = MkIndex()) :
occs(_index),
dirty(_index),
occs(_index),
dirty(_index),
deleted(d){}

void init (const K& idx){ occs.reserve(idx); occs[idx].clear(); dirty.reserve(idx, 0); }
Vec& operator[](const K& idx){ return occs[idx]; }
Vec& lookup (const K& idx){ if (dirty[idx]) clean(idx); return occs[idx]; }
Expand Down Expand Up @@ -392,13 +394,13 @@ class CMap

typedef Map<CRef, T, CRefHash> HashTable;
HashTable map;

public:
// Size-operations:
void clear () { map.clear(); }
int size () const { return map.elems(); }


// Insert/Remove/Test mapping:
void insert (CRef cr, const T& t){ map.insert(cr, t); }
void growTo (CRef cr, const T& t){ map.insert(cr, t); } // NOTE: for compatibility
Expand All @@ -425,11 +427,11 @@ class CMap
/*_________________________________________________________________________________________________
|
| subsumes : (other : const Clause&) -> Lit
|
|
| Description:
| Checks if clause subsumes 'other', and at the same time, if it can be used to simplify 'other'
| by subsumption resolution.
|
|
| Result:
| lit_Error - No subsumption or simplification
| lit_Undef - Clause subsumes 'other'
Expand Down
4 changes: 2 additions & 2 deletions minisat/utils/System.cc
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ static inline int memReadPeak(void)
}

double Minisat::memUsed() { return (double)memReadStat(0) * (double)getpagesize() / (1024*1024); }
double Minisat::memUsedPeak(bool strictlyPeak) {
double Minisat::memUsedPeak(bool strictlyPeak) {
double peak = memReadPeak() / (double)1024;
return peak == 0 && !strictlyPeak ? memUsed() : peak; }

Expand All @@ -87,7 +87,7 @@ double Minisat::memUsed() {
malloc_statistics_t t;
malloc_zone_statistics(NULL, &t);
return (double)t.max_size_in_use / (1024*1024); }
double Minisat::memUsedPeak() { return memUsed(); }
double Minisat::memUsedPeak(bool strictlyPeak) { return memUsed(); }

#else
double Minisat::memUsed() { return 0; }
Expand Down