-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathsolver.h
More file actions
165 lines (157 loc) · 3.3 KB
/
solver.h
File metadata and controls
165 lines (157 loc) · 3.3 KB
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
#define NDEBUG
#define BCP_QUEUE_SIZE 800
#define BCPSTATSIZE 5000
#define DEFAULT_PHASE true
#define DEFAULT_INSPECTS 50000
//#define DEFAULT_INSPECTS 500000
#define DECISIONS_LIMIT 5000000
#define DEFAULT_CYCLES 500000000
#define DEFAULT_KERNEL_RUNS 1
#define VARS_SIZE 10000
//typedef int trailword;
#define BJ
typedef unsigned short shadowword;
typedef int varind;
typedef struct {
uint var;
#ifdef BJ
int reason;
#endif
} trailword;
typedef struct {
double start;
int level_count;
double average;
double last;
double sum;
} lstats;
typedef unsigned int uint;
#define NO_LITIND 0xffffffff
#define END_LITIND 0xfffffffe
#define SEEN_FLAG 0x40000000
#define DECISION_FLAG 0x80000000
#define VARINDEX_MASK 0x0fffffff
typedef unsigned int litind;
struct uintx {
uint x;
uint y;
#ifdef LITCACHE
uint x1;
uint y1;
uint x2;
uint y2;
uint x3;
uint y3;
#endif
/*
uint z;
uint w;
uint a;
uint b;
uint c;
uint d;
uint e;
uint f;
uint g;
uint h;
uint l;
uint k;
uint m;
uint n;
uint x1;
uint y1;
uint z1;
uint w1;
uint a1;
uint b1;
uint c1;
uint d1;
uint e1;
uint f1;
uint g1;
uint h1;
uint l1;
uint k1;
uint m1;
uint n1;
*/
};
typedef struct {
int x;
int y;
} litind2;
//typedef unsigned int varcont;
typedef bool varcont;
typedef bool wscont;
typedef uint var_word;
typedef enum {SAT, UNSAT, CONFLICT, ERROR, OK, STOPPED, FORCED_DECISION, DEFAULT_DECISION, BCP_OK, BCP_STALL} RESULT;
typedef enum {BACKTRACKING=0, BACKJUMPING=1, BACKJUMPING_FAST=2} CONFLICT_RESOLUTION_METHOD;
typedef enum {FREE=1, NONFREE=2, SOLVING=4, PENDING=16, UNKNOWN=0} LIT_STATE;
enum { WORD_SIZE = sizeof(var_word) * 8 };
struct Rlit{
litind nextlit;
litind var;
};
struct Rcnf{
uintx* lits; //
litind* pl; // номера окончания фаз
int lits_size;
int pl_size;
//int vote_threshold;
};
struct Rsolverstate{
// var_word* vars;
// varcont* var_set;//массив состояния переменных - присвоенность
// varcont* var_phase;//массив состояния переменных - фаза
int vars_size;
int model_size;
// var_word* ws;//состояние watched literals
// int* trail; //последовательность присвоенных переменных
int trail_end;
int ws_size;
double propagations;
uint bogus_bcp;
uint bogus_bcp_sat;
int vars_set;
int decision_var_index;
int top_decision_var_index;
int levels_size;
int var_index;
int BCP_queue_front;
double stat_inspects_last;
double stat_inspects;
double stat_inspects_bogus;
double stat_inspects_single;
};
struct gpusolverdata{
gpusolverdata(): c(), trail(NULL), trail_end(NULL), decision_var_index(NULL), ws(NULL), vars(NULL), out(NULL), inspects(NULL){}
Rcnf c;
trailword* trail;
int* trail_end;
int* decision_var_index;
int* top_decision_var_index;
var_word* ws;
var_word* vars;
RESULT* out;
int4* inspects;
int multi;
int stride;
int* blocks_complete;
varind (*BCP_queue)[BCP_QUEUE_SIZE];
int *BCP_queue_front, *BCP_queue_back;
int *conflict_count_old;
int *stall_count;
int (*bcpstat)[BCPSTATSIZE];
varind* vars_heap;
};
RESULT SolverSolve(
Rcnf &c,
Rsolverstate &s,
var_word* vars,
var_word* ws,
trailword* trail,
int multi,
int inspects_limit =DEFAULT_INSPECTS,
int kernel_runs_limit =DEFAULT_KERNEL_RUNS,
bool truncate =false,
const int subproblem=0);