ruby-minisat 1.14.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +24 -0
- data/LICENSE +21 -0
- data/README.rdoc +56 -0
- data/Rakefile +48 -0
- data/VERSION +1 -0
- data/examples/compat18.rb +65 -0
- data/examples/example.rb +26 -0
- data/examples/example2.rb +60 -0
- data/examples/kakuro.rb +178 -0
- data/examples/kakuro.sample +13 -0
- data/examples/lonely7.rb +302 -0
- data/examples/nonogram.rb +254 -0
- data/examples/nonogram.sample +26 -0
- data/examples/numberlink.rb +489 -0
- data/examples/numberlink.sample +11 -0
- data/examples/shikaku.rb +190 -0
- data/examples/shikaku.sample +11 -0
- data/examples/slitherlink.rb +279 -0
- data/examples/slitherlink.sample +11 -0
- data/examples/sudoku.rb +216 -0
- data/examples/sudoku.sample +11 -0
- data/ext/minisat/extconf.rb +9 -0
- data/ext/minisat/minisat-wrap.cpp +88 -0
- data/ext/minisat/minisat.c +497 -0
- data/ext/minisat/minisat.h +53 -0
- data/minisat/MiniSat_v1.14.2006-Aug-29.src.zip +0 -0
- data/minisat/MiniSat_v1.14/Global.h +274 -0
- data/minisat/MiniSat_v1.14/Heap.h +100 -0
- data/minisat/MiniSat_v1.14/LICENSE +20 -0
- data/minisat/MiniSat_v1.14/Main.C +244 -0
- data/minisat/MiniSat_v1.14/Makefile +88 -0
- data/minisat/MiniSat_v1.14/README +30 -0
- data/minisat/MiniSat_v1.14/Solver.C +781 -0
- data/minisat/MiniSat_v1.14/Solver.h +206 -0
- data/minisat/MiniSat_v1.14/Solver.o +0 -0
- data/minisat/MiniSat_v1.14/SolverTypes.h +130 -0
- data/minisat/MiniSat_v1.14/Sort.h +131 -0
- data/minisat/MiniSat_v1.14/TODO +73 -0
- data/minisat/MiniSat_v1.14/VarOrder.h +96 -0
- data/test/test_minisat.rb +143 -0
- metadata +114 -0
@@ -0,0 +1,53 @@
|
|
1
|
+
/******************************************************************************
|
2
|
+
|
3
|
+
ruby-minisat -- ruby binding for MiniSat
|
4
|
+
|
5
|
+
*******************************************************************************
|
6
|
+
|
7
|
+
The MIT License
|
8
|
+
|
9
|
+
Copyright (c) 2007 Yusuke Endoh
|
10
|
+
|
11
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
12
|
+
of this software and associated documentation files (the "Software"), to deal
|
13
|
+
in the Software without restriction, including without limitation the rights
|
14
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
15
|
+
copies of the Software, and to permit persons to whom the Software is
|
16
|
+
furnished to do so, subject to the following conditions:
|
17
|
+
|
18
|
+
The above copyright notice and this permission notice shall be included in
|
19
|
+
all copies or substantial portions of the Software.
|
20
|
+
|
21
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
22
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
23
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
24
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
25
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
26
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
27
|
+
THE SOFTWARE.
|
28
|
+
|
29
|
+
******************************************************************************/
|
30
|
+
|
31
|
+
|
32
|
+
#ifdef __cplusplus
|
33
|
+
extern "C" {
|
34
|
+
#endif
|
35
|
+
|
36
|
+
typedef void* wrap_solver;
|
37
|
+
|
38
|
+
extern int wrap_lit_pos_var(int v);
|
39
|
+
extern int wrap_lit_neg_var(int v);
|
40
|
+
|
41
|
+
extern wrap_solver wrap_solver_new();
|
42
|
+
extern void wrap_solver_free(wrap_solver slv);
|
43
|
+
extern int wrap_solver_new_var(wrap_solver slv);
|
44
|
+
extern int wrap_solver_add_clause(wrap_solver slv, int *lits, int len);
|
45
|
+
extern int wrap_solver_ref_var(wrap_solver slv, int var);
|
46
|
+
extern int wrap_solver_solve(wrap_solver slv, int *lits, int len);
|
47
|
+
extern int wrap_solver_simplify_db(wrap_solver slv);
|
48
|
+
extern int wrap_solver_var_size(wrap_solver slv);
|
49
|
+
extern int wrap_solver_clause_size(wrap_solver slv);
|
50
|
+
|
51
|
+
#ifdef __cplusplus
|
52
|
+
}
|
53
|
+
#endif
|
Binary file
|
@@ -0,0 +1,274 @@
|
|
1
|
+
/****************************************************************************************[Global.h]
|
2
|
+
MiniSat -- Copyright (c) 2003-2005, Niklas Een, Niklas Sorensson
|
3
|
+
|
4
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
|
5
|
+
associated documentation files (the "Software"), to deal in the Software without restriction,
|
6
|
+
including without limitation the rights to use, copy, modify, merge, publish, distribute,
|
7
|
+
sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
|
8
|
+
furnished to do so, subject to the following conditions:
|
9
|
+
|
10
|
+
The above copyright notice and this permission notice shall be included in all copies or
|
11
|
+
substantial portions of the Software.
|
12
|
+
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
|
14
|
+
NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
15
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
16
|
+
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT
|
17
|
+
OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
18
|
+
**************************************************************************************************/
|
19
|
+
|
20
|
+
#ifndef Global_h
|
21
|
+
#define Global_h
|
22
|
+
|
23
|
+
#include <cassert>
|
24
|
+
#include <cstdio>
|
25
|
+
#include <cstdlib>
|
26
|
+
#include <cstring>
|
27
|
+
#include <climits>
|
28
|
+
#include <cfloat>
|
29
|
+
#include <new>
|
30
|
+
|
31
|
+
|
32
|
+
//=================================================================================================
|
33
|
+
// Basic Types & Minor Things:
|
34
|
+
|
35
|
+
|
36
|
+
#ifdef _MSC_VER
|
37
|
+
typedef INT64 int64;
|
38
|
+
typedef UINT64 uint64;
|
39
|
+
typedef INT_PTR intp;
|
40
|
+
typedef UINT_PTR uintp;
|
41
|
+
#define I64_fmt "I64d"
|
42
|
+
#else
|
43
|
+
typedef long long int64;
|
44
|
+
typedef unsigned long long uint64;
|
45
|
+
typedef __PTRDIFF_TYPE__ intp;
|
46
|
+
typedef unsigned __PTRDIFF_TYPE__ uintp;
|
47
|
+
#define I64_fmt "lld"
|
48
|
+
#endif
|
49
|
+
typedef unsigned char uchar;
|
50
|
+
typedef const char cchar;
|
51
|
+
|
52
|
+
|
53
|
+
template<class T> static inline T min(T x, T y) { return (x < y) ? x : y; }
|
54
|
+
template<class T> static inline T max(T x, T y) { return (x > y) ? x : y; }
|
55
|
+
|
56
|
+
template <bool> struct STATIC_ASSERTION_FAILURE;
|
57
|
+
template <> struct STATIC_ASSERTION_FAILURE<true>{};
|
58
|
+
#define TEMPLATE_FAIL STATIC_ASSERTION_FAILURE<false>()
|
59
|
+
|
60
|
+
|
61
|
+
//=================================================================================================
|
62
|
+
// 'malloc()'-style memory allocation -- never returns NULL; aborts instead:
|
63
|
+
|
64
|
+
|
65
|
+
template<class T> static inline T* xmalloc(size_t size) {
|
66
|
+
T* tmp = (T*)malloc(size * sizeof(T));
|
67
|
+
assert(size == 0 || tmp != NULL);
|
68
|
+
return tmp; }
|
69
|
+
|
70
|
+
template<class T> static inline T* xrealloc(T* ptr, size_t size) {
|
71
|
+
T* tmp = (T*)realloc((void*)ptr, size * sizeof(T));
|
72
|
+
assert(size == 0 || tmp != NULL);
|
73
|
+
return tmp; }
|
74
|
+
|
75
|
+
template<class T> static inline void xfree(T *ptr) {
|
76
|
+
if (ptr != NULL) free((void*)ptr); }
|
77
|
+
|
78
|
+
|
79
|
+
//=================================================================================================
|
80
|
+
// Random numbers:
|
81
|
+
|
82
|
+
|
83
|
+
// Returns a random float 0 <= x < 1. Seed must never be 0.
|
84
|
+
static inline double drand(double& seed) {
|
85
|
+
seed *= 1389796;
|
86
|
+
int q = (int)(seed / 2147483647);
|
87
|
+
seed -= (double)q * 2147483647;
|
88
|
+
return seed / 2147483647; }
|
89
|
+
|
90
|
+
// Returns a random integer 0 <= x < size. Seed must never be 0.
|
91
|
+
static inline int irand(double& seed, int size) {
|
92
|
+
return (int)(drand(seed) * size); }
|
93
|
+
|
94
|
+
|
95
|
+
//=================================================================================================
|
96
|
+
// Time and Memory:
|
97
|
+
|
98
|
+
|
99
|
+
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
100
|
+
#ifdef _MSC_VER
|
101
|
+
|
102
|
+
#include <ctime>
|
103
|
+
|
104
|
+
static inline double cpuTime(void) {
|
105
|
+
return (double)clock() / CLOCKS_PER_SEC; }
|
106
|
+
|
107
|
+
static inline int64 memUsed() {
|
108
|
+
return 0; }
|
109
|
+
|
110
|
+
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
111
|
+
#else
|
112
|
+
|
113
|
+
#include <sys/time.h>
|
114
|
+
#include <sys/resource.h>
|
115
|
+
#include <unistd.h>
|
116
|
+
|
117
|
+
static inline double cpuTime(void) {
|
118
|
+
struct rusage ru;
|
119
|
+
getrusage(RUSAGE_SELF, &ru);
|
120
|
+
return (double)ru.ru_utime.tv_sec + (double)ru.ru_utime.tv_usec / 1000000; }
|
121
|
+
|
122
|
+
static inline int memReadStat(int field)
|
123
|
+
{
|
124
|
+
char name[256];
|
125
|
+
pid_t pid = getpid();
|
126
|
+
sprintf(name, "/proc/%d/statm", pid);
|
127
|
+
FILE* in = fopen(name, "rb");
|
128
|
+
if (in == NULL) return 0;
|
129
|
+
int value;
|
130
|
+
for (; field >= 0; field--)
|
131
|
+
fscanf(in, "%d", &value);
|
132
|
+
fclose(in);
|
133
|
+
return value;
|
134
|
+
}
|
135
|
+
|
136
|
+
static inline int64 memUsed() { return (int64)memReadStat(0) * (int64)getpagesize(); }
|
137
|
+
|
138
|
+
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
139
|
+
#endif
|
140
|
+
|
141
|
+
|
142
|
+
|
143
|
+
//=================================================================================================
|
144
|
+
// 'vec' -- automatically resizable arrays (via 'push()' method):
|
145
|
+
|
146
|
+
|
147
|
+
// NOTE! Don't use this vector on datatypes that cannot be re-located in memory (with realloc)
|
148
|
+
|
149
|
+
template<class T>
|
150
|
+
class vec {
|
151
|
+
T* data;
|
152
|
+
int sz;
|
153
|
+
int cap;
|
154
|
+
|
155
|
+
void init(int size, const T& pad);
|
156
|
+
void grow(int min_cap);
|
157
|
+
|
158
|
+
public:
|
159
|
+
// Types:
|
160
|
+
typedef int Key;
|
161
|
+
typedef T Datum;
|
162
|
+
|
163
|
+
// Constructors:
|
164
|
+
vec(void) : data(NULL) , sz(0) , cap(0) { }
|
165
|
+
vec(int size) : data(NULL) , sz(0) , cap(0) { growTo(size); }
|
166
|
+
vec(int size, const T& pad) : data(NULL) , sz(0) , cap(0) { growTo(size, pad); }
|
167
|
+
vec(T* array, int size) : data(array), sz(size), cap(size) { } // (takes ownership of array -- will be deallocated with 'xfree()')
|
168
|
+
~vec(void) { clear(true); }
|
169
|
+
|
170
|
+
// Ownership of underlying array:
|
171
|
+
T* release (void) { T* ret = data; data = NULL; sz = 0; cap = 0; return ret; }
|
172
|
+
operator T* (void) { return data; } // (unsafe but convenient)
|
173
|
+
operator const T* (void) const { return data; }
|
174
|
+
|
175
|
+
// Size operations:
|
176
|
+
int size (void) const { return sz; }
|
177
|
+
void shrink (int nelems) { assert(nelems <= sz); for (int i = 0; i < nelems; i++) sz--, data[sz].~T(); }
|
178
|
+
void pop (void) { sz--, data[sz].~T(); }
|
179
|
+
void growTo (int size);
|
180
|
+
void growTo (int size, const T& pad);
|
181
|
+
void clear (bool dealloc = false);
|
182
|
+
void capacity (int size) { grow(size); }
|
183
|
+
|
184
|
+
// Stack interface:
|
185
|
+
void push (void) { if (sz == cap) grow(sz+1); new (&data[sz]) T() ; sz++; }
|
186
|
+
void push (const T& elem) { if (sz == cap) grow(sz+1); new (&data[sz]) T(elem); sz++; }
|
187
|
+
const T& last (void) const { return data[sz-1]; }
|
188
|
+
T& last (void) { return data[sz-1]; }
|
189
|
+
|
190
|
+
// Vector interface:
|
191
|
+
const T& operator [] (int index) const { return data[index]; }
|
192
|
+
T& operator [] (int index) { return data[index]; }
|
193
|
+
|
194
|
+
// Don't allow copying (error prone):
|
195
|
+
vec<T>& operator = (vec<T>& other) { TEMPLATE_FAIL; }
|
196
|
+
vec (vec<T>& other) { TEMPLATE_FAIL; }
|
197
|
+
|
198
|
+
// Duplicatation (preferred instead):
|
199
|
+
void copyTo(vec<T>& copy) const { copy.clear(); copy.growTo(sz); for (int i = 0; i < sz; i++) new (©[i]) T(data[i]); }
|
200
|
+
void moveTo(vec<T>& dest) { dest.clear(true); dest.data = data; dest.sz = sz; dest.cap = cap; data = NULL; sz = 0; cap = 0; }
|
201
|
+
};
|
202
|
+
|
203
|
+
template<class T>
|
204
|
+
void vec<T>::grow(int min_cap) {
|
205
|
+
if (min_cap <= cap) return;
|
206
|
+
if (cap == 0) cap = (min_cap >= 2) ? min_cap : 2;
|
207
|
+
else do cap = (cap*3+1) >> 1; while (cap < min_cap);
|
208
|
+
data = xrealloc(data, cap); }
|
209
|
+
|
210
|
+
template<class T>
|
211
|
+
void vec<T>::growTo(int size, const T& pad) {
|
212
|
+
if (sz >= size) return;
|
213
|
+
grow(size);
|
214
|
+
for (int i = sz; i < size; i++) new (&data[i]) T(pad);
|
215
|
+
sz = size; }
|
216
|
+
|
217
|
+
template<class T>
|
218
|
+
void vec<T>::growTo(int size) {
|
219
|
+
if (sz >= size) return;
|
220
|
+
grow(size);
|
221
|
+
for (int i = sz; i < size; i++) new (&data[i]) T();
|
222
|
+
sz = size; }
|
223
|
+
|
224
|
+
template<class T>
|
225
|
+
void vec<T>::clear(bool dealloc) {
|
226
|
+
if (data != NULL){
|
227
|
+
for (int i = 0; i < sz; i++) data[i].~T();
|
228
|
+
sz = 0;
|
229
|
+
if (dealloc) xfree(data), data = NULL, cap = 0; } }
|
230
|
+
|
231
|
+
|
232
|
+
//=================================================================================================
|
233
|
+
// Lifted booleans:
|
234
|
+
|
235
|
+
|
236
|
+
class lbool {
|
237
|
+
int value;
|
238
|
+
explicit lbool(int v) : value(v) { }
|
239
|
+
|
240
|
+
public:
|
241
|
+
lbool() : value(0) { }
|
242
|
+
lbool(bool x) : value((int)x*2-1) { }
|
243
|
+
int toInt(void) const { return value; }
|
244
|
+
|
245
|
+
bool operator == (const lbool& other) const { return value == other.value; }
|
246
|
+
bool operator != (const lbool& other) const { return value != other.value; }
|
247
|
+
lbool operator ~ (void) const { return lbool(-value); }
|
248
|
+
|
249
|
+
friend int toInt (lbool l);
|
250
|
+
friend lbool toLbool(int v);
|
251
|
+
};
|
252
|
+
inline int toInt (lbool l) { return l.toInt(); }
|
253
|
+
inline lbool toLbool(int v) { return lbool(v); }
|
254
|
+
|
255
|
+
const lbool l_True = toLbool( 1);
|
256
|
+
const lbool l_False = toLbool(-1);
|
257
|
+
const lbool l_Undef = toLbool( 0);
|
258
|
+
|
259
|
+
|
260
|
+
//=================================================================================================
|
261
|
+
// Relation operators -- extend definitions from '==' and '<'
|
262
|
+
|
263
|
+
|
264
|
+
#ifndef __SGI_STL_INTERNAL_RELOPS // (be aware of SGI's STL implementation...)
|
265
|
+
#define __SGI_STL_INTERNAL_RELOPS
|
266
|
+
template <class T> static inline bool operator != (const T& x, const T& y) { return !(x == y); }
|
267
|
+
template <class T> static inline bool operator > (const T& x, const T& y) { return y < x; }
|
268
|
+
template <class T> static inline bool operator <= (const T& x, const T& y) { return !(y < x); }
|
269
|
+
template <class T> static inline bool operator >= (const T& x, const T& y) { return !(x < y); }
|
270
|
+
#endif
|
271
|
+
|
272
|
+
|
273
|
+
//=================================================================================================
|
274
|
+
#endif
|
@@ -0,0 +1,100 @@
|
|
1
|
+
/******************************************************************************************[Heap.h]
|
2
|
+
MiniSat -- Copyright (c) 2003-2005, Niklas Een, Niklas Sorensson
|
3
|
+
|
4
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
|
5
|
+
associated documentation files (the "Software"), to deal in the Software without restriction,
|
6
|
+
including without limitation the rights to use, copy, modify, merge, publish, distribute,
|
7
|
+
sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
|
8
|
+
furnished to do so, subject to the following conditions:
|
9
|
+
|
10
|
+
The above copyright notice and this permission notice shall be included in all copies or
|
11
|
+
substantial portions of the Software.
|
12
|
+
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
|
14
|
+
NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
15
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
16
|
+
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT
|
17
|
+
OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
18
|
+
**************************************************************************************************/
|
19
|
+
|
20
|
+
#ifndef Heap_h
|
21
|
+
#define Heap_h
|
22
|
+
|
23
|
+
|
24
|
+
//=================================================================================================
|
25
|
+
|
26
|
+
|
27
|
+
static inline int left (int i) { return i+i; }
|
28
|
+
static inline int right (int i) { return i+i + 1; }
|
29
|
+
static inline int parent(int i) { return i >> 1; }
|
30
|
+
|
31
|
+
template<class C>
|
32
|
+
class Heap {
|
33
|
+
public:
|
34
|
+
C comp;
|
35
|
+
vec<int> heap; // heap of ints
|
36
|
+
vec<int> indices; // int -> index in heap
|
37
|
+
|
38
|
+
inline void percolateUp(int i)
|
39
|
+
{
|
40
|
+
int x = heap[i];
|
41
|
+
while (parent(i) != 0 && comp(x,heap[parent(i)])){
|
42
|
+
heap[i] = heap[parent(i)];
|
43
|
+
indices[heap[i]] = i;
|
44
|
+
i = parent(i);
|
45
|
+
}
|
46
|
+
heap [i] = x;
|
47
|
+
indices[x] = i;
|
48
|
+
}
|
49
|
+
|
50
|
+
inline void percolateDown(int i)
|
51
|
+
{
|
52
|
+
int x = heap[i];
|
53
|
+
while (left(i) < heap.size()){
|
54
|
+
int child = right(i) < heap.size() && comp(heap[right(i)],heap[left(i)]) ? right(i) : left(i);
|
55
|
+
if (!comp(heap[child],x)) break;
|
56
|
+
heap[i] = heap[child];
|
57
|
+
indices[heap[i]] = i;
|
58
|
+
i = child;
|
59
|
+
}
|
60
|
+
heap [i] = x;
|
61
|
+
indices[x] = i;
|
62
|
+
}
|
63
|
+
|
64
|
+
bool ok(int n) { return n >= 0 && n < (int)indices.size(); }
|
65
|
+
|
66
|
+
public:
|
67
|
+
Heap(C c) : comp(c) { heap.push(-1); }
|
68
|
+
|
69
|
+
void setBounds (int size) { assert(size >= 0); indices.growTo(size,0); }
|
70
|
+
bool inHeap (int n) { assert(ok(n)); return indices[n] != 0; }
|
71
|
+
void increase (int n) { assert(ok(n)); assert(inHeap(n)); percolateUp(indices[n]); }
|
72
|
+
bool empty () { return heap.size() == 1; }
|
73
|
+
|
74
|
+
void insert(int n) {
|
75
|
+
assert(ok(n));
|
76
|
+
indices[n] = heap.size();
|
77
|
+
heap.push(n);
|
78
|
+
percolateUp(indices[n]); }
|
79
|
+
|
80
|
+
int getmin() {
|
81
|
+
int r = heap[1];
|
82
|
+
heap[1] = heap.last();
|
83
|
+
indices[heap[1]] = 1;
|
84
|
+
indices[r] = 0;
|
85
|
+
heap.pop();
|
86
|
+
if (heap.size() > 1)
|
87
|
+
percolateDown(1);
|
88
|
+
return r; }
|
89
|
+
|
90
|
+
bool heapProperty() {
|
91
|
+
return heapProperty(1); }
|
92
|
+
|
93
|
+
bool heapProperty(int i) {
|
94
|
+
return (size_t)i >= heap.size()
|
95
|
+
|| ((parent(i) == 0 || !comp(heap[i],heap[parent(i)])) && heapProperty(left(i)) && heapProperty(right(i))); }
|
96
|
+
};
|
97
|
+
|
98
|
+
|
99
|
+
//=================================================================================================
|
100
|
+
#endif
|
@@ -0,0 +1,20 @@
|
|
1
|
+
MiniSat -- Copyright (c) 2003-2005, Niklas Een, Niklas Sorensson
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a
|
4
|
+
copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be included
|
12
|
+
in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
15
|
+
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|