101 std::vector<std::vector<int>> clause, res_clause;
105 int flag, epcec_out, maxvar, nxors, rins;
106 int *psign, *psum, *fixed, *cell, *used, *model, *topo_counter;
107 std::vector<int> epcec_in, epcec_rin, *inv_C;
108 std::vector<type_gate> gate;
110 int maxlen, orivars, oriclauses, res_clauses, resolutions;
111 int *f, nlit, *a, *val, *color, *varval, *q, *seen, *resseen, *clean, *mapto, *mapfrom, *mapval;
113 std::vector<int>*occurp, *occurn, clause_delete, nxtc, resolution;
116 bool res_is_empty(
int var);
117 void update_var_clause_label();
118 void preprocess_init();
119 bool preprocess_resolution();
120 bool preprocess_binary();
121 bool preprocess_up();
122 void get_complete_model();
124 std::vector<std::vector<int>> card_one;
125 std::vector<std::vector<double>> mat;
126 std::vector<int>* occur;
127 std::vector<int> cdel;
128 int check_card(
int id);
129 int preprocess_card();
130 int search_almost_one();
131 int card_elimination();
132 int scc_almost_one();
133 void upd_occur(
int v,
int s);
137 int gauss_eli_binary;
138 std::vector<xorgate> xors;
139 std::vector<int> scc_id;
140 std::vector<std::vector<int>> scc;
141 std::vector<std::vector<int>> xor_scc;
142 bool preprocess_gauss();
144 int cal_dup_val(
int i);
147 int gauss_elimination();
149 int rematch_eql(
int x);
150 int rematch_and(
int x);
151 int rematch_xor(
int x);
154 int preprocess_circuit();
155 void epcec_preprocess();
157 bool _simulate(
Bitset** result,
int bit_size);
164 for (
int i = 1; i <= this->orivars; i++)
166 this->mapval[i] = (model[abs(this->mapto[i]) - 1] > 0 ? 1 : -1) * (this->mapto[i] > 0 ? 1 : -1);
167 this->get_complete_model();
169 for (
int i = 1; i <= this->orivars; i++) {
170 model.push_back(i * this->mapval[i]);
173 LOG1(
"[PRS %d] restored model of size %d, vars: %d, orivars: %d",
188 int maxClauseSizeXor;
189 int maxClauseCircuit;
194 std::vector<std::function<int()>> preprocessors;
196 int preprocess_circuit_wrapper()
199 auto init = std::chrono::high_resolution_clock::now();
201 if (vars <= this->maxVarCircuit && clauses <= this->maxClauseCircuit) {
202 res = preprocess_circuit();
209 auto circuit = std::chrono::high_resolution_clock::now();
210 LOG1(
"[PRS %d] Circuit Check took %.3lfs",
212 std::chrono::duration_cast<std::chrono::milliseconds>(circuit - init).count() / 1000.0);
216 int preprocess_gauss_wrapper()
219 auto init = std::chrono::high_resolution_clock::now();
221 if (vars <= this->maxVarGauss && clauses <= this->maxClauseGauss) {
222 res = preprocess_gauss();
230 auto gauss = std::chrono::high_resolution_clock::now();
231 LOG1(
"[PRS %d] Gauss Elimination (xor-limit=%d) took %.3lfs",
233 this->maxClauseSizeXor,
234 std::chrono::duration_cast<std::chrono::milliseconds>(gauss - init).count() / 1000.0);
238 int preprocess_propagation_wrapper()
240 auto init = std::chrono::high_resolution_clock::now();
241 int res = preprocess_up();
252 auto up = std::chrono::high_resolution_clock::now();
253 LOG1(
"[PRS %d] Unit Propagation took %.3lfs",
255 std::chrono::duration_cast<std::chrono::milliseconds>(up - init).count() / 1000.0);
259 int preprocess_card_wrapper()
262 auto init = std::chrono::high_resolution_clock::now();
264 if (vars <= this->maxVarCard && clauses <= this->maxClauseCard) {
265 res = preprocess_card();
278 auto card = std::chrono::high_resolution_clock::now();
279 LOG1(
"[PRS %d] Card Elimination took %.3lfs",
281 std::chrono::duration_cast<std::chrono::milliseconds>(card - init).count() / 1000.0);
285 int preprocess_resolution_wrapper()
287 auto init = std::chrono::high_resolution_clock::now();
288 int res = preprocess_resolution();
298 auto resol = std::chrono::high_resolution_clock::now();
299 LOG1(
"[PRS %d] Resolution took %.3lfs",
301 std::chrono::duration_cast<std::chrono::milliseconds>(resol - init).count() / 1000.0);
305 int preprocess_binary_wrapper()
307 auto init = std::chrono::high_resolution_clock::now();
309 if (clauses <= this->maxClauseBinary) {
310 res = preprocess_binary();
320 auto binary = std::chrono::high_resolution_clock::now();
321 LOG1(
"[PRS %d] Binary took %.3lfs",
323 std::chrono::duration_cast<std::chrono::milliseconds>(binary - init).count() / 1000.0);
333 exit(PERR_NOT_SUPPORTED);
339 exit(PERR_NOT_SUPPORTED);
353 exit(PERR_NOT_SUPPORTED);
359 exit(PERR_NOT_SUPPORTED);
365 clause.erase(clause.begin());
369 std::size_t getClausesCount() {
return clauses; }
371 void diversify(
const SeedGenerator& getSeed) {
LOGWARN(
"preprocess has no diversification, yet"); }
375 if(this->clauses < 0 || this->vars < 0) std::abort();
376 return { (unsigned)this->clauses, (
unsigned)(this->oriclauses - this->clauses), 0, 0, (
unsigned)(this->orivars - this->vars) };
382 void addClauses(
const std::vector<ClauseExchangePtr>& clauses) {
return; }