-
Notifications
You must be signed in to change notification settings - Fork 0
/
sat.h
58 lines (49 loc) · 1.03 KB
/
sat.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
//
// Created by admin on 15/04/2017.
//
#ifndef GRAD_SAT_H
#define GRAD_SAT_H
#include "common.h"
#include <queue>
struct nodeSat{
int reason;
int var;
};
struct nodeQueue{
int lit;
int reasonClause;
};
struct clause{
vector<int> data;
inline int size(){return data.size();}
inline void push_back(int n){data.push_back(n);}
int alive;
bool sat;
bool relax;
};
class Sat {
public:
Sat(int vNum){
nodes = vNum;
posWatches.resize(vNum);
negWatches.resize(vNum);
alive.resize(vNum);
}
void addClause(vector<int> &t, bool rlx = false);
void init(bool firstTime);
bool up(int n);
void relax(int upLit);
inline int size(){return data.size();}
void debug();
private:
int nodes;
int failed, failed_index;
int aliveClauses;
int newVar();
vector<vector<int>> posWatches, negWatches;
vector<clause> data;
vector<bool> alive;
vector<int> reason;
inline int toVar(int p) {return abs(p) - 1;}
};
#endif //GRAD_SAT_H