version 1.1 (add dynamically reseting)
This commit is contained in:
parent
7de16e7e96
commit
1f4c019aad
5
build.sh
Executable file
5
build.sh
Executable file
@ -0,0 +1,5 @@
|
|||||||
|
cd /home/chenzh/solvers/Light/solvers/kissat-inc;
|
||||||
|
./configure && make;
|
||||||
|
cd ..;
|
||||||
|
cd ..;
|
||||||
|
make clean; make;
|
@ -16,8 +16,8 @@ light::light():
|
|||||||
}
|
}
|
||||||
|
|
||||||
light::~light() {
|
light::~light() {
|
||||||
for (int i = 0; i < solvers.size(); i++) delete(solvers[i]);
|
for (int i = 0; i < workers.size(); i++) delete(workers[i]);
|
||||||
solvers.clear(true);
|
workers.clear(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void light::arg_parse(int argc, char **argv) {
|
void light::arg_parse(int argc, char **argv) {
|
||||||
|
16
light.hpp
16
light.hpp
@ -10,6 +10,14 @@ typedef long long ll;
|
|||||||
|
|
||||||
class basesolver;
|
class basesolver;
|
||||||
|
|
||||||
|
struct thread_inf{
|
||||||
|
int id, inf;
|
||||||
|
bool operator < ( const thread_inf &other ) const
|
||||||
|
{
|
||||||
|
return inf > other.inf;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
struct light
|
struct light
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -19,7 +27,7 @@ public:
|
|||||||
char *filename;
|
char *filename;
|
||||||
paras *opt;
|
paras *opt;
|
||||||
preprocess *pre;
|
preprocess *pre;
|
||||||
vec<basesolver *> solvers;
|
vec<basesolver *> workers;
|
||||||
|
|
||||||
int finalResult;
|
int finalResult;
|
||||||
int winner;
|
int winner;
|
||||||
@ -27,12 +35,12 @@ public:
|
|||||||
atomic<bool> globalEnding;
|
atomic<bool> globalEnding;
|
||||||
|
|
||||||
void arg_parse(int argc, char **argv);
|
void arg_parse(int argc, char **argv);
|
||||||
void init_solvers();
|
void init_workers();
|
||||||
void diversity_solvers();
|
void diversity_workers();
|
||||||
void parse_input();
|
void parse_input();
|
||||||
int run();
|
int run();
|
||||||
int solve();
|
int solve();
|
||||||
void terminate_solvers();
|
void terminate_workers();
|
||||||
void print_model();
|
void print_model();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -246,7 +246,7 @@ bool preprocess::preprocess_binary() {
|
|||||||
for (int j = 0; j < l; j++)
|
for (int j = 0; j < l; j++)
|
||||||
clause[i][j] = tolit(clause[i][j]);
|
clause[i][j] = tolit(clause[i][j]);
|
||||||
}
|
}
|
||||||
nlit = vars << 1;
|
nlit = (vars << 1) + 2;
|
||||||
for (int i = 1; i <= vars; i++) f[i] = i, val[i] = 1, color[i] = 0;
|
for (int i = 1; i <= vars; i++) f[i] = i, val[i] = 1, color[i] = 0;
|
||||||
for (int i = 1; i <= clauses; i++) clause_delete[i] = 0;
|
for (int i = 1; i <= clauses; i++) clause_delete[i] = 0;
|
||||||
int len = 0;
|
int len = 0;
|
||||||
@ -284,6 +284,8 @@ bool preprocess::preprocess_binary() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (int i = 1; i <= vars; i++) find(i);
|
||||||
|
|
||||||
for (int i = 1; i <= clauses; i++) {
|
for (int i = 1; i <= clauses; i++) {
|
||||||
if (clause_delete[i]) continue;
|
if (clause_delete[i]) continue;
|
||||||
int l = clause[i].size(), oril = l;
|
int l = clause[i].size(), oril = l;
|
||||||
@ -296,15 +298,17 @@ bool preprocess::preprocess_binary() {
|
|||||||
if (resseen[a[j]] == i) continue;
|
if (resseen[a[j]] == i) continue;
|
||||||
resseen[a[j]] = i, a[t++] = a[j];
|
resseen[a[j]] = i, a[t++] = a[j];
|
||||||
}
|
}
|
||||||
if (t != l) l = t;
|
if (t != l) {l = t;}
|
||||||
for (int j = 0; j < l; j++)
|
for (int j = 0; j < l; j++)
|
||||||
if (resseen[negative(a[j])] == i)
|
if (resseen[negative(a[j])] == i) {
|
||||||
clause_delete[i] = 1;
|
clause_delete[i] = 1;
|
||||||
|
}
|
||||||
for (int j = 0; j < l; j++) resseen[a[j]] = 0;
|
for (int j = 0; j < l; j++) resseen[a[j]] = 0;
|
||||||
clause[i].clear();
|
clause[i].clear();
|
||||||
for (int j = 0; j < l; j++)
|
for (int j = 0; j < l; j++)
|
||||||
clause[i].push(a[j]);
|
clause[i].push(a[j]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
for (int i = 1; i <= clauses; i++) {
|
for (int i = 1; i <= clauses; i++) {
|
||||||
if (clause_delete[i]) continue;
|
if (clause_delete[i]) continue;
|
||||||
@ -313,6 +317,7 @@ bool preprocess::preprocess_binary() {
|
|||||||
clause[i][j] = toeidx(clause[i][j]);
|
clause[i][j] = toeidx(clause[i][j]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
update_var_clause_label();
|
update_var_clause_label();
|
||||||
for (int i = 1; i <= orivars; i++) {
|
for (int i = 1; i <= orivars; i++) {
|
||||||
if (mapval[i]) continue;
|
if (mapval[i]) continue;
|
||||||
@ -420,7 +425,6 @@ bool preprocess::preprocess_easy_clause() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
update_var_clause_label();
|
update_var_clause_label();
|
||||||
|
|
||||||
for (int i = 1; i <= tail; i++) {
|
for (int i = 1; i <= tail; i++) {
|
||||||
int v = q[i];
|
int v = q[i];
|
||||||
mapval[v] = varval[v];
|
mapval[v] = varval[v];
|
||||||
|
BIN
preprocess.o
BIN
preprocess.o
Binary file not shown.
52
solve.cpp
52
solve.cpp
@ -2,6 +2,7 @@
|
|||||||
#include "workers/basekissat.hpp"
|
#include "workers/basekissat.hpp"
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
|
#include <algorithm>
|
||||||
char* worker_sign = "";
|
char* worker_sign = "";
|
||||||
atomic<int> terminated;
|
atomic<int> terminated;
|
||||||
auto clk_st = std::chrono::high_resolution_clock::now();
|
auto clk_st = std::chrono::high_resolution_clock::now();
|
||||||
@ -27,7 +28,7 @@ void * solve_worker(void *arg) {
|
|||||||
sq->get_model(seq_model);
|
sq->get_model(seq_model);
|
||||||
}
|
}
|
||||||
if (res && !terminated) {
|
if (res && !terminated) {
|
||||||
sq->controller->terminate_solvers();
|
sq->controller->terminate_workers();
|
||||||
terminated = 1;
|
terminated = 1;
|
||||||
result = res;
|
result = res;
|
||||||
winner = sq->id;
|
winner = sq->id;
|
||||||
@ -38,29 +39,29 @@ void * solve_worker(void *arg) {
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void light::init_solvers() {
|
void light::init_workers() {
|
||||||
for (int i = 0; i < OPT(threads); i++) {
|
for (int i = 0; i < OPT(threads); i++) {
|
||||||
basekissat* kissat = new basekissat(i, this);
|
basekissat* kissat = new basekissat(i, this);
|
||||||
solvers.push(kissat);
|
workers.push(kissat);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void light::diversity_solvers() {
|
void light::diversity_workers() {
|
||||||
for (int i = 0; i < OPT(threads); i++) {
|
for (int i = 0; i < OPT(threads); i++) {
|
||||||
solvers[i]->diversity(i);
|
workers[i]->diversity(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void light::terminate_solvers() {
|
void light::terminate_workers() {
|
||||||
for (int i = 0; i < OPT(threads); i++) {
|
for (int i = 0; i < OPT(threads); i++) {
|
||||||
solvers[i]->terminate();
|
workers[i]->terminate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void light::parse_input() {
|
void light::parse_input() {
|
||||||
pthread_t *ptr = new pthread_t[OPT(threads)];
|
pthread_t *ptr = new pthread_t[OPT(threads)];
|
||||||
for (int i = 0; i < OPT(threads); i++) {
|
for (int i = 0; i < OPT(threads); i++) {
|
||||||
pthread_create(&ptr[i], NULL, read_worker, solvers[i]);
|
pthread_create(&ptr[i], NULL, read_worker, workers[i]);
|
||||||
}
|
}
|
||||||
for (int i = 0; i < OPT(threads); i++) {
|
for (int i = 0; i < OPT(threads); i++) {
|
||||||
pthread_join(ptr[i], NULL);
|
pthread_join(ptr[i], NULL);
|
||||||
@ -73,27 +74,48 @@ int light::solve() {
|
|||||||
terminated = 0;
|
terminated = 0;
|
||||||
pthread_t *ptr = new pthread_t[OPT(threads)];
|
pthread_t *ptr = new pthread_t[OPT(threads)];
|
||||||
for (int i = 0; i < OPT(threads); i++) {
|
for (int i = 0; i < OPT(threads); i++) {
|
||||||
pthread_create(&ptr[i], NULL, solve_worker, solvers[i]);
|
pthread_create(&ptr[i], NULL, solve_worker, workers[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
thread_inf unimprove[OPT(threads)];
|
||||||
|
auto clk_sol_st = std::chrono::high_resolution_clock::now();
|
||||||
|
int pre_time = std::chrono::duration_cast<std::chrono::seconds>(clk_sol_st - clk_st).count();
|
||||||
|
int sol_thd = 0, intv_time = OPT(reset_time);
|
||||||
while (!terminated) {
|
while (!terminated) {
|
||||||
usleep(100000);
|
usleep(100000);
|
||||||
auto clk_now = std::chrono::high_resolution_clock::now();
|
auto clk_now = std::chrono::high_resolution_clock::now();
|
||||||
int solve_time = std::chrono::duration_cast<std::chrono::seconds>(clk_now - clk_st).count();
|
int solve_time = std::chrono::duration_cast<std::chrono::seconds>(clk_now - clk_st).count();
|
||||||
if (solve_time >= OPT(times)) {
|
if (solve_time >= OPT(times)) {
|
||||||
terminated = 1;
|
terminated = 1;
|
||||||
terminate_solvers();
|
terminate_workers();
|
||||||
|
}
|
||||||
|
if (OPT(reset) && solve_time >= pre_time + intv_time) {
|
||||||
|
pre_time = solve_time;
|
||||||
|
intv_time += OPT(reset_time);
|
||||||
|
sol_thd = 0;
|
||||||
|
for (int i = 0; i < OPT(threads); i++) {
|
||||||
|
unimprove[sol_thd++] = (thread_inf) {i, workers[i]->get_reset_data()};
|
||||||
|
}
|
||||||
|
std::sort(unimprove, unimprove + sol_thd);
|
||||||
|
printf("Reset thread (%d): ", solve_time);
|
||||||
|
for (int i = 0; i < sol_thd / 2; i++) {
|
||||||
|
workers[i]->reset();
|
||||||
|
printf("%d(%d) ", unimprove[i].id, unimprove[i].inf);
|
||||||
|
}
|
||||||
|
puts("\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < OPT(threads); i++) {
|
for (int i = 0; i < OPT(threads); i++) {
|
||||||
pthread_join(ptr[i], NULL);
|
pthread_join(ptr[i], NULL);
|
||||||
}
|
}
|
||||||
delete []ptr;
|
delete []ptr;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
int light::run() {
|
int light::run() {
|
||||||
init_solvers();
|
init_workers();
|
||||||
diversity_solvers();
|
diversity_workers();
|
||||||
if (OPT(simplify)) {
|
if (OPT(simplify)) {
|
||||||
pre = new preprocess();
|
pre = new preprocess();
|
||||||
int res = pre->do_preprocess(filename);
|
int res = pre->do_preprocess(filename);
|
||||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,5 +1,5 @@
|
|||||||
#define VERSION "1.0.3"
|
#define VERSION "1.0.3"
|
||||||
#define COMPILER "gcc (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0 -W -Wall -O3 -DNEMBEDDED -DNDEBUG -DNMETRICS -DNSTATISTICS"
|
#define COMPILER "gcc (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0 -W -Wall -O3 -DNEMBEDDED -DNDEBUG -DNMETRICS -DNSTATISTICS"
|
||||||
#define ID "79d8d8f20465e71fd2b0f193b468898cd803a59a"
|
#define ID "79d8d8f20465e71fd2b0f193b468898cd803a59a"
|
||||||
#define BUILD "Thu Aug 25 15:41:16 CST 2022 Linux seed1 5.4.0-120-generic x86_64"
|
#define BUILD "Wed Aug 31 12:28:43 CST 2022 Linux seed1 5.4.0-120-generic x86_64"
|
||||||
#define DIR "/home/chenzh/solvers/Light/kissat-inc/build"
|
#define DIR "/home/chenzh/solvers/Light/solvers/kissat-inc/build"
|
||||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,17 +1,17 @@
|
|||||||
all:
|
all:
|
||||||
$(MAKE) -C "/home/chenzh/solvers/Light/kissat-inc/build"
|
$(MAKE) -C "/home/chenzh/solvers/Light/solvers/kissat-inc/build"
|
||||||
kissat:
|
kissat:
|
||||||
$(MAKE) -C "/home/chenzh/solvers/Light/kissat-inc/build" kissat
|
$(MAKE) -C "/home/chenzh/solvers/Light/solvers/kissat-inc/build" kissat
|
||||||
tissat:
|
tissat:
|
||||||
$(MAKE) -C "/home/chenzh/solvers/Light/kissat-inc/build" tissat
|
$(MAKE) -C "/home/chenzh/solvers/Light/solvers/kissat-inc/build" tissat
|
||||||
clean:
|
clean:
|
||||||
rm -f "/home/chenzh/solvers/Light/kissat-inc"/makefile
|
rm -f "/home/chenzh/solvers/Light/solvers/kissat-inc"/makefile
|
||||||
-$(MAKE) -C "/home/chenzh/solvers/Light/kissat-inc/build" clean
|
-$(MAKE) -C "/home/chenzh/solvers/Light/solvers/kissat-inc/build" clean
|
||||||
rm -rf "/home/chenzh/solvers/Light/kissat-inc/build"
|
rm -rf "/home/chenzh/solvers/Light/solvers/kissat-inc/build"
|
||||||
coverage:
|
coverage:
|
||||||
$(MAKE) -C "/home/chenzh/solvers/Light/kissat-inc/build" coverage
|
$(MAKE) -C "/home/chenzh/solvers/Light/solvers/kissat-inc/build" coverage
|
||||||
indent:
|
indent:
|
||||||
$(MAKE) -C "/home/chenzh/solvers/Light/kissat-inc/build" indent
|
$(MAKE) -C "/home/chenzh/solvers/Light/solvers/kissat-inc/build" indent
|
||||||
test:
|
test:
|
||||||
$(MAKE) -C "/home/chenzh/solvers/Light/kissat-inc/build" test
|
$(MAKE) -C "/home/chenzh/solvers/Light/solvers/kissat-inc/build" test
|
||||||
.PHONY: all clean coverage indent kissat test tissat
|
.PHONY: all clean coverage indent kissat test tissat
|
||||||
|
@ -53,6 +53,36 @@ rescale_scores (kissat * solver, heap * scores)
|
|||||||
GET (rescaled), "rescaled by factor %g", factor);
|
GET (rescaled), "rescaled by factor %g", factor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void kissat_shuffle_score(kissat * solver) {
|
||||||
|
heap *scores = &solver->scores;
|
||||||
|
heap *scores_chb = &solver->scores_chb;
|
||||||
|
flags *flags = solver->flags;
|
||||||
|
int *id = (int *)malloc(sizeof(int) * (VARS));
|
||||||
|
for (int i = 0; i < VARS; i++) id[i] = i;
|
||||||
|
for (int i = 0; i < VARS; i++)
|
||||||
|
{
|
||||||
|
int j = (rand() % VARS);
|
||||||
|
int x = id[i];
|
||||||
|
id[i] = id[j];
|
||||||
|
id[j] = x;
|
||||||
|
}
|
||||||
|
for (int i = 0; i < VARS; i++) {
|
||||||
|
int idx = id[i];
|
||||||
|
if (flags[idx].active) {
|
||||||
|
double new_score = 1.0 * i / VARS;
|
||||||
|
kissat_update_heap (solver, scores, idx, new_score);
|
||||||
|
kissat_update_heap (solver, scores_chb, idx, new_score);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (int i = 0; i < VARS; i++) {
|
||||||
|
int idx = id[i];
|
||||||
|
if (flags[idx].active)
|
||||||
|
kissat_move_to_front(solver, idx);
|
||||||
|
}
|
||||||
|
solver->scinc = 1.0;
|
||||||
|
free(id);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
bump_score_increment (kissat * solver, heap * scores)
|
bump_score_increment (kissat * solver, heap * scores)
|
||||||
{
|
{
|
||||||
|
@ -6,6 +6,7 @@ struct kissat;
|
|||||||
void kissat_bump_variables (struct kissat *);
|
void kissat_bump_variables (struct kissat *);
|
||||||
void kissat_bump_chb (struct kissat *, unsigned idx, double multiplier);
|
void kissat_bump_chb (struct kissat *, unsigned idx, double multiplier);
|
||||||
void kissat_decay_chb (struct kissat *);
|
void kissat_decay_chb (struct kissat *);
|
||||||
|
void kissat_shuffle_score(struct kissat *);
|
||||||
void kissat_update_conflicted_chb (struct kissat *);
|
void kissat_update_conflicted_chb (struct kissat *);
|
||||||
|
|
||||||
#define MAX_SCORE 1e150
|
#define MAX_SCORE 1e150
|
||||||
|
@ -45,6 +45,7 @@ kissat_init (void)
|
|||||||
solver-> mab_decisions = 0;
|
solver-> mab_decisions = 0;
|
||||||
solver-> mab_chosen_tot = 0;
|
solver-> mab_chosen_tot = 0;
|
||||||
solver-> order_reset = -1;
|
solver-> order_reset = -1;
|
||||||
|
solver-> reseting = 0;
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
kissat_init_checker (solver);
|
kissat_init_checker (solver);
|
||||||
#endif
|
#endif
|
||||||
|
@ -72,6 +72,7 @@ typedef STACK (watch *) patches;
|
|||||||
|
|
||||||
struct kissat
|
struct kissat
|
||||||
{
|
{
|
||||||
|
int reseting;
|
||||||
int order_reset;
|
int order_reset;
|
||||||
int max_var;
|
int max_var;
|
||||||
#ifdef LOGGING
|
#ifdef LOGGING
|
||||||
|
@ -18,185 +18,188 @@
|
|||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
|
|
||||||
static void
|
static void
|
||||||
start_search (kissat * solver)
|
start_search(kissat *solver)
|
||||||
{
|
{
|
||||||
START (search);
|
START(search);
|
||||||
INC (searches);
|
INC(searches);
|
||||||
|
|
||||||
REPORT (0, '*');
|
REPORT(0, '*');
|
||||||
|
|
||||||
bool stable = (GET_OPTION (stable) == 2);
|
bool stable = (GET_OPTION(stable) == 2);
|
||||||
|
|
||||||
solver->stable = stable;
|
solver->stable = stable;
|
||||||
kissat_phase (solver, "search", GET (searches),
|
kissat_phase(solver, "search", GET(searches),
|
||||||
"initializing %s search after %" PRIu64 " conflicts",
|
"initializing %s search after %" PRIu64 " conflicts",
|
||||||
(stable ? "stable" : "focus"), CONFLICTS);
|
(stable ? "stable" : "focus"), CONFLICTS);
|
||||||
|
|
||||||
kissat_init_averages (solver, &AVERAGES);
|
kissat_init_averages(solver, &AVERAGES);
|
||||||
|
|
||||||
if (solver->stable)
|
if (solver->stable)
|
||||||
kissat_init_reluctant (solver);
|
kissat_init_reluctant(solver);
|
||||||
|
|
||||||
kissat_init_limits (solver);
|
kissat_init_limits(solver);
|
||||||
|
|
||||||
unsigned seed = GET_OPTION (seed);
|
unsigned seed = GET_OPTION(seed);
|
||||||
solver->random = seed;
|
solver->random = seed;
|
||||||
LOG ("initialized random number generator with seed %u", seed);
|
LOG("initialized random number generator with seed %u", seed);
|
||||||
|
|
||||||
kissat_reset_rephased (solver);
|
kissat_reset_rephased(solver);
|
||||||
|
|
||||||
const unsigned eagersubsume = GET_OPTION (eagersubsume);
|
const unsigned eagersubsume = GET_OPTION(eagersubsume);
|
||||||
if (eagersubsume && !solver->clueue.elements)
|
if (eagersubsume && !solver->clueue.elements)
|
||||||
kissat_init_clueue (solver, &solver->clueue, eagersubsume);
|
kissat_init_clueue(solver, &solver->clueue, eagersubsume);
|
||||||
#ifndef QUIET
|
#ifndef QUIET
|
||||||
limits *limits = &solver->limits;
|
limits *limits = &solver->limits;
|
||||||
limited *limited = &solver->limited;
|
limited *limited = &solver->limited;
|
||||||
if (!limited->conflicts && !limited->decisions)
|
if (!limited->conflicts && !limited->decisions)
|
||||||
kissat_very_verbose (solver, "starting unlimited search");
|
kissat_very_verbose(solver, "starting unlimited search");
|
||||||
else if (limited->conflicts && !limited->decisions)
|
else if (limited->conflicts && !limited->decisions)
|
||||||
kissat_very_verbose (solver,
|
kissat_very_verbose(solver,
|
||||||
"starting search with conflicts limited to %" PRIu64,
|
"starting search with conflicts limited to %" PRIu64,
|
||||||
limits->conflicts);
|
limits->conflicts);
|
||||||
else if (!limited->conflicts && limited->decisions)
|
else if (!limited->conflicts && limited->decisions)
|
||||||
kissat_very_verbose (solver,
|
kissat_very_verbose(solver,
|
||||||
"starting search with decisions limited to %" PRIu64,
|
"starting search with decisions limited to %" PRIu64,
|
||||||
limits->decisions);
|
limits->decisions);
|
||||||
else
|
else
|
||||||
kissat_very_verbose (solver,
|
kissat_very_verbose(solver,
|
||||||
"starting search with decisions limited to %" PRIu64
|
"starting search with decisions limited to %" PRIu64
|
||||||
" and conflicts limited to %" PRIu64,
|
" and conflicts limited to %" PRIu64,
|
||||||
limits->decisions, limits->conflicts);
|
limits->decisions, limits->conflicts);
|
||||||
if (stable)
|
if (stable)
|
||||||
{
|
{
|
||||||
START (stable);
|
START(stable);
|
||||||
REPORT (0, '[');
|
REPORT(0, '[');
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
START (focused);
|
START(focused);
|
||||||
REPORT (0, '{');
|
REPORT(0, '{');
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
stop_search (kissat * solver, int res)
|
stop_search(kissat *solver, int res)
|
||||||
{
|
{
|
||||||
if (solver->limited.conflicts)
|
if (solver->limited.conflicts)
|
||||||
{
|
{
|
||||||
LOG ("reset conflict limit");
|
LOG("reset conflict limit");
|
||||||
solver->limited.conflicts = false;
|
solver->limited.conflicts = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (solver->limited.decisions)
|
if (solver->limited.decisions)
|
||||||
{
|
{
|
||||||
LOG ("reset decision limit");
|
LOG("reset decision limit");
|
||||||
solver->limited.decisions = false;
|
solver->limited.decisions = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (solver->terminate)
|
if (solver->terminate)
|
||||||
{
|
{
|
||||||
kissat_very_verbose (solver, "termination forced externally");
|
kissat_very_verbose(solver, "termination forced externally");
|
||||||
solver->terminate = 0;
|
solver->terminate = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef QUIET
|
#ifndef QUIET
|
||||||
LOG ("search result %d", res);
|
LOG("search result %d", res);
|
||||||
if (solver->stable)
|
if (solver->stable)
|
||||||
{
|
{
|
||||||
REPORT (0, ']');
|
REPORT(0, ']');
|
||||||
STOP (stable);
|
STOP(stable);
|
||||||
solver->stable = false;
|
solver->stable = false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
REPORT (0, '}');
|
REPORT(0, '}');
|
||||||
STOP (focused);
|
STOP(focused);
|
||||||
}
|
}
|
||||||
char type = (res == 10 ? '1' : res == 20 ? '0' : '?');
|
char type = (res == 10 ? '1' : res == 20 ? '0'
|
||||||
REPORT (0, type);
|
: '?');
|
||||||
|
REPORT(0, type);
|
||||||
#else
|
#else
|
||||||
(void) res;
|
(void)res;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
STOP (search);
|
STOP(search);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
iterate (kissat * solver)
|
iterate(kissat *solver)
|
||||||
{
|
{
|
||||||
assert (solver->iterating);
|
assert(solver->iterating);
|
||||||
solver->iterating = false;
|
solver->iterating = false;
|
||||||
REPORT (0, 'i');
|
REPORT(0, 'i');
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
conflict_limit_hit (kissat * solver)
|
conflict_limit_hit(kissat *solver)
|
||||||
{
|
{
|
||||||
if (!solver->limited.conflicts)
|
if (!solver->limited.conflicts)
|
||||||
return false;
|
return false;
|
||||||
if (solver->limits.conflicts > solver->statistics.conflicts)
|
if (solver->limits.conflicts > solver->statistics.conflicts)
|
||||||
return false;
|
return false;
|
||||||
kissat_very_verbose (solver, "conflict limit %" PRIu64
|
kissat_very_verbose(solver, "conflict limit %" PRIu64 " hit after %" PRIu64 " conflicts",
|
||||||
" hit after %" PRIu64 " conflicts",
|
solver->limits.conflicts,
|
||||||
solver->limits.conflicts,
|
solver->statistics.conflicts);
|
||||||
solver->statistics.conflicts);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
decision_limit_hit (kissat * solver)
|
decision_limit_hit(kissat *solver)
|
||||||
{
|
{
|
||||||
if (!solver->limited.decisions)
|
if (!solver->limited.decisions)
|
||||||
return false;
|
return false;
|
||||||
if (solver->limits.decisions > solver->statistics.decisions)
|
if (solver->limits.decisions > solver->statistics.decisions)
|
||||||
return false;
|
return false;
|
||||||
kissat_very_verbose (solver, "decision limit %" PRIu64
|
kissat_very_verbose(solver, "decision limit %" PRIu64 " hit after %" PRIu64 " decisions",
|
||||||
" hit after %" PRIu64 " decisions",
|
solver->limits.decisions,
|
||||||
solver->limits.decisions,
|
solver->statistics.decisions);
|
||||||
solver->statistics.decisions);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int kissat_search(kissat *solver)
|
||||||
kissat_search (kissat * solver)
|
|
||||||
{
|
{
|
||||||
start_search (solver);
|
start_search(solver);
|
||||||
|
|
||||||
int res = kissat_walk_initially (solver);
|
int res = kissat_walk_initially(solver);
|
||||||
|
|
||||||
while (!res)
|
while (!res)
|
||||||
|
{
|
||||||
|
if (!solver->level && solver->reseting)
|
||||||
{
|
{
|
||||||
clause *conflict = kissat_search_propagate (solver);
|
kissat_shuffle_score(solver);
|
||||||
if (conflict)
|
solver->reseting = 0;
|
||||||
res = kissat_analyze (solver, conflict);
|
|
||||||
else if (solver->iterating)
|
|
||||||
iterate (solver);
|
|
||||||
else if (!solver->unassigned)
|
|
||||||
res = 10;
|
|
||||||
else if (TERMINATED (11))
|
|
||||||
break;
|
|
||||||
else if (conflict_limit_hit (solver))
|
|
||||||
break;
|
|
||||||
else if (kissat_reducing (solver))
|
|
||||||
res = kissat_reduce (solver);
|
|
||||||
else if (kissat_restarting (solver))
|
|
||||||
kissat_restart (solver);
|
|
||||||
else if (kissat_rephasing (solver))
|
|
||||||
kissat_rephase (solver);
|
|
||||||
else if (kissat_eliminating (solver))
|
|
||||||
res = kissat_eliminate (solver);
|
|
||||||
else if (kissat_probing (solver))
|
|
||||||
res = kissat_probe (solver);
|
|
||||||
else if (!solver->level && solver->unflushed)
|
|
||||||
kissat_flush_trail (solver);
|
|
||||||
else if (decision_limit_hit (solver))
|
|
||||||
break;
|
|
||||||
else
|
|
||||||
kissat_decide (solver);
|
|
||||||
}
|
}
|
||||||
|
clause *conflict = kissat_search_propagate(solver);
|
||||||
|
if (conflict)
|
||||||
|
res = kissat_analyze(solver, conflict);
|
||||||
|
else if (solver->iterating)
|
||||||
|
iterate(solver);
|
||||||
|
else if (!solver->unassigned)
|
||||||
|
res = 10;
|
||||||
|
else if (TERMINATED(11))
|
||||||
|
break;
|
||||||
|
else if (conflict_limit_hit(solver))
|
||||||
|
break;
|
||||||
|
else if (kissat_reducing(solver))
|
||||||
|
res = kissat_reduce(solver);
|
||||||
|
else if (kissat_restarting(solver))
|
||||||
|
kissat_restart(solver);
|
||||||
|
else if (kissat_rephasing(solver))
|
||||||
|
kissat_rephase(solver);
|
||||||
|
else if (kissat_eliminating(solver))
|
||||||
|
res = kissat_eliminate(solver);
|
||||||
|
else if (kissat_probing(solver))
|
||||||
|
res = kissat_probe(solver);
|
||||||
|
else if (!solver->level && solver->unflushed)
|
||||||
|
kissat_flush_trail(solver);
|
||||||
|
else if (decision_limit_hit(solver))
|
||||||
|
break;
|
||||||
|
else
|
||||||
|
kissat_decide(solver);
|
||||||
|
}
|
||||||
|
|
||||||
stop_search (solver, res);
|
stop_search(solver, res);
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
@ -6,10 +6,12 @@
|
|||||||
|
|
||||||
// name, type, default, low, high, comments
|
// name, type, default, low, high, comments
|
||||||
#define PARAS \
|
#define PARAS \
|
||||||
PARA( mode , int , 0 , 0 , 2 , "SAT=1, UNSAT=2") \
|
PARA( mode , int , 0 , 0 , 2 , "SAT=1, UNSAT=2") \
|
||||||
PARA( simplify , int , 1 , 0 , 1 , "Use Simplify(only preprocess)") \
|
PARA( reset , int , 0 , 0 , 1 , "Dynamically reseting") \
|
||||||
PARA( times , double , 5000 , 0 , 1e8 , "Cutoff time") \
|
PARA( reset_time , int , 10 , 1 , 1e5 , "Reseting base interval (seconds)") \
|
||||||
PARA( threads , int , 32 , 1 , 128 , "Thread number") \
|
PARA( simplify , int , 1 , 0 , 1 , "Use Simplify(only preprocess)") \
|
||||||
|
PARA( times , double , 5000 , 0 , 1e8 , "Cutoff time") \
|
||||||
|
PARA( threads , int , 32 , 1 , 128 , "Thread number") \
|
||||||
|
|
||||||
|
|
||||||
struct paras
|
struct paras
|
||||||
|
BIN
utils/paras.o
BIN
utils/paras.o
Binary file not shown.
5
version.md
Normal file
5
version.md
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
### 1.0
|
||||||
|
base Framework
|
||||||
|
RS
|
||||||
|
#### 1.1
|
||||||
|
Dynamically reseting
|
@ -57,4 +57,13 @@ void basekissat::get_model(vec<int> &model) {
|
|||||||
if (!tmp) tmp = i;
|
if (!tmp) tmp = i;
|
||||||
model.push(tmp);
|
model.push(tmp);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int basekissat::get_reset_data() {
|
||||||
|
return solver->best_assigned;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void basekissat::reset() {
|
||||||
|
solver->reseting = 1;
|
||||||
}
|
}
|
@ -10,6 +10,8 @@ public:
|
|||||||
void terminate();
|
void terminate();
|
||||||
int solve();
|
int solve();
|
||||||
void get_model(vec<int> &model);
|
void get_model(vec<int> &model);
|
||||||
|
int get_reset_data();
|
||||||
|
void reset();
|
||||||
|
|
||||||
basekissat(int id, light *light);
|
basekissat(int id, light *light);
|
||||||
~basekissat();
|
~basekissat();
|
||||||
|
Binary file not shown.
@ -11,6 +11,8 @@ public:
|
|||||||
virtual int solve() = 0;
|
virtual int solve() = 0;
|
||||||
virtual void terminate() = 0;
|
virtual void terminate() = 0;
|
||||||
virtual void get_model(vec<int> &model) = 0;
|
virtual void get_model(vec<int> &model) = 0;
|
||||||
|
virtual int get_reset_data() = 0;
|
||||||
|
virtual void reset() = 0;
|
||||||
light * controller;
|
light * controller;
|
||||||
int id;
|
int id;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user