69 lines
1.5 KiB
C++
69 lines
1.5 KiB
C++
#include "basekissat.hpp"
|
|
|
|
extern "C" {
|
|
#include "src/application.h"
|
|
#include "src/parse.h"
|
|
#include "src/internal.h"
|
|
#include "src/witness.h"
|
|
#include "src/import.h"
|
|
}
|
|
|
|
basekissat::basekissat(int id, light* light) : basesolver(id, light) {
|
|
solver = kissat_init();
|
|
}
|
|
|
|
basekissat::~basekissat(){
|
|
delete solver;
|
|
}
|
|
|
|
void basekissat::parse_dimacs(char* filename) {
|
|
kissat_mab_parse(solver);
|
|
strictness strict = NORMAL_PARSING;
|
|
file in;
|
|
uint64_t lineno;
|
|
kissat_open_to_read_file(&in, filename);
|
|
kissat_parse_dimacs(solver, strict, &in, &lineno, &solver->max_var);
|
|
kissat_close_file(&in);
|
|
}
|
|
|
|
void basekissat::import_original_clause(preprocess* pre) {
|
|
solver->max_var = pre->vars;
|
|
kissat_mab_parse(solver);
|
|
kissat_reserve(solver, pre->vars);
|
|
for (int i = 1; i <= pre->clauses; i++) {
|
|
int l = pre->clause[i].size();
|
|
for (int j = 0; j < l; j++)
|
|
kissat_add(solver, pre->clause[i][j]);
|
|
kissat_add(solver, 0);
|
|
}
|
|
}
|
|
|
|
void basekissat::diversity(int id) {
|
|
if (id) solver->order_reset = id;
|
|
}
|
|
|
|
int basekissat::solve() {
|
|
return kissat_solve(solver);
|
|
}
|
|
|
|
void basekissat::terminate() {
|
|
kissat_terminate(solver);
|
|
}
|
|
|
|
void basekissat::get_model(vec<int> &model) {
|
|
model.clear();
|
|
for (int i = 1; i <= solver->max_var; i++) {
|
|
int tmp = kissat_value(solver, i);
|
|
if (!tmp) tmp = i;
|
|
model.push(tmp);
|
|
}
|
|
}
|
|
|
|
int basekissat::get_reset_data() {
|
|
return solver->best_assigned;
|
|
}
|
|
|
|
|
|
void basekissat::reset() {
|
|
solver->reseting = 1;
|
|
} |