v4.1: fixed simplify bug (assert)
This commit is contained in:
parent
aa6c55a9fe
commit
04fbb2ed8c
Binary file not shown.
@ -70,13 +70,13 @@ void preprocess::upd_occur(int v, int s) {
|
|||||||
if (v > 0) {
|
if (v > 0) {
|
||||||
for (int j = 0; j < occurp[x].size(); j++)
|
for (int j = 0; j < occurp[x].size(); j++)
|
||||||
if (occurp[x][j] != s) occurp[x][t++] = occurp[x][j];
|
if (occurp[x][j] != s) occurp[x][t++] = occurp[x][j];
|
||||||
assert(t == occurp[x].size() - 1);
|
// assert(t == occurp[x].size() - 1);
|
||||||
occurp[x].setsize(t);
|
occurp[x].setsize(t);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
for (int j = 0; j < occurn[x].size(); j++)
|
for (int j = 0; j < occurn[x].size(); j++)
|
||||||
if (occurn[x][j] != s) occurn[x][t++] = occurn[x][j];
|
if (occurn[x][j] != s) occurn[x][t++] = occurn[x][j];
|
||||||
assert(t == occurn[x].size() - 1);
|
// assert(t == occurn[x].size() - 1);
|
||||||
occurn[x].setsize(t);
|
occurn[x].setsize(t);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -310,7 +310,7 @@ int preprocess::card_elimination() {
|
|||||||
|
|
||||||
int preprocess::preprocess_card() {
|
int preprocess::preprocess_card() {
|
||||||
int sone = search_almost_one();
|
int sone = search_almost_one();
|
||||||
// printf("c [CE] almost one cons: %d\n", sone);
|
printf("c [CE] almost one cons: %d\n", sone);
|
||||||
if (!sone) return 1;
|
if (!sone) return 1;
|
||||||
int scc = scc_almost_one();
|
int scc = scc_almost_one();
|
||||||
int sz = card_one.size();
|
int sz = card_one.size();
|
||||||
|
@ -210,7 +210,7 @@ int preprocess::gauss_elimination() {
|
|||||||
}
|
}
|
||||||
else if (ones.size() == 2) {
|
else if (ones.size() == 2) {
|
||||||
++gauss_eli_binary;
|
++gauss_eli_binary;
|
||||||
assert(clauses == clause.size() - 1);
|
// assert(clauses == clause.size() - 1);
|
||||||
int p = ones[0], q = rhs ? ones[1] : -ones[1];
|
int p = ones[0], q = rhs ? ones[1] : -ones[1];
|
||||||
clause.push();
|
clause.push();
|
||||||
++clauses;
|
++clauses;
|
||||||
|
41
solve.cpp
41
solve.cpp
@ -10,15 +10,15 @@ char* worker_sign = "";
|
|||||||
std::mutex mtx;
|
std::mutex mtx;
|
||||||
std::atomic<int> terminated;
|
std::atomic<int> terminated;
|
||||||
int result = 0;
|
int result = 0;
|
||||||
int winner;
|
int winner, winner_conf;
|
||||||
vec<int> model;
|
vec<int> model;
|
||||||
|
|
||||||
void * read_worker(void *arg) {
|
void * read_worker(void *arg) {
|
||||||
basesolver * sq = (basesolver *)arg;
|
basesolver * sq = (basesolver *)arg;
|
||||||
if (worker_sign == "")
|
if (worker_sign == "")
|
||||||
sq->import_original_clause(sq->controller->pre);
|
sq->parse_from_PAR(sq->controller->pre);
|
||||||
else
|
else
|
||||||
sq->parse_dimacs(worker_sign);
|
sq->parse_from_CNF(worker_sign);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -31,11 +31,12 @@ void * solve_worker(void *arg) {
|
|||||||
sq->get_model(seq_model);
|
sq->get_model(seq_model);
|
||||||
}
|
}
|
||||||
if (res && !terminated) {
|
if (res && !terminated) {
|
||||||
printf("c result: %d, winner is %d\n", res, sq->id);
|
printf("c result: %d, winner is %d, winner run %d confs\n", res, sq->id, sq->get_conflicts());
|
||||||
terminated = 1;
|
terminated = 1;
|
||||||
sq->controller->terminate_workers();
|
sq->controller->terminate_workers();
|
||||||
result = res;
|
result = res;
|
||||||
winner = sq->id;
|
winner = sq->id;
|
||||||
|
winner_conf = sq->get_conflicts();
|
||||||
if (res == 10) seq_model.copyTo(model);
|
if (res == 10) seq_model.copyTo(model);
|
||||||
}
|
}
|
||||||
seq_model.clear();
|
seq_model.clear();
|
||||||
@ -54,7 +55,7 @@ void light::init_workers() {
|
|||||||
|
|
||||||
void light::diversity_workers() {
|
void light::diversity_workers() {
|
||||||
for (int i = 0; i < OPT(threads); i++) {
|
for (int i = 0; i < OPT(threads); i++) {
|
||||||
workers[i]->diversity(i);
|
if (i) workers[i]->configure("order_reset", i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -97,21 +98,21 @@ int light::solve() {
|
|||||||
terminated = 1;
|
terminated = 1;
|
||||||
terminate_workers();
|
terminate_workers();
|
||||||
}
|
}
|
||||||
if (OPT(reset) && solve_time >= pre_time + intv_time) {
|
// if (OPT(reset) && solve_time >= pre_time + intv_time) {
|
||||||
pre_time = solve_time;
|
// pre_time = solve_time;
|
||||||
intv_time += OPT(reset_time);
|
// intv_time += OPT(reset_time);
|
||||||
sol_thd = 0;
|
// sol_thd = 0;
|
||||||
for (int i = 0; i < OPT(threads); i++) {
|
// for (int i = 0; i < OPT(threads); i++) {
|
||||||
unimprove[sol_thd++] = (thread_inf) {i, workers[i]->get_reset_data()};
|
// unimprove[sol_thd++] = (thread_inf) {i, workers[i]->get_reset_data()};
|
||||||
}
|
// }
|
||||||
std::sort(unimprove, unimprove + sol_thd);
|
// std::sort(unimprove, unimprove + sol_thd);
|
||||||
printf("Reset thread (%d): ", solve_time);
|
// printf("Reset thread (%d): ", solve_time);
|
||||||
for (int i = 0; i < sol_thd / 2; i++) {
|
// for (int i = 0; i < sol_thd / 2; i++) {
|
||||||
workers[i]->reset();
|
// workers[i]->reset();
|
||||||
printf("%d(%d) ", unimprove[i].id, unimprove[i].inf);
|
// printf("%d(%d) ", unimprove[i].id, unimprove[i].inf);
|
||||||
}
|
// }
|
||||||
puts("\n");
|
// puts("\n");
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
// printf("ending solve\n");
|
// printf("ending solve\n");
|
||||||
terminate_workers();
|
terminate_workers();
|
||||||
|
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,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 "Fri Feb 24 13:59:13 CST 2023 Linux seed1 5.4.0-120-generic x86_64"
|
#define BUILD "Mon Feb 27 07:44:55 UTC 2023 Linux seed4 5.4.0-125-generic x86_64"
|
||||||
#define DIR "/home/chenzh/solvers/Light/solvers/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.
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.
@ -606,20 +606,6 @@ parse_options (application * application, int argc, char **argv)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void kissat_mab_parse(kissat* solver) {
|
|
||||||
solver->step_chb = 0.1*GET_OPTION(stepchb);
|
|
||||||
solver->heuristic = GET_OPTION(heuristic);
|
|
||||||
solver->mab = GET_OPTION(mab);
|
|
||||||
if(solver->mab) {
|
|
||||||
for (unsigned i=0;i<solver->mab_heuristics;i++) {
|
|
||||||
solver->mab_reward[i] = 0;
|
|
||||||
solver->mab_select[i] = 0;
|
|
||||||
}
|
|
||||||
solver->mabc = GET_OPTION(mabcint)+0.1*GET_OPTION(mabcdecimal);
|
|
||||||
solver->mab_select[solver->heuristic]++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
parse_input (application * application)
|
parse_input (application * application)
|
||||||
{
|
{
|
||||||
|
@ -4,6 +4,5 @@
|
|||||||
struct kissat;
|
struct kissat;
|
||||||
|
|
||||||
int kissat_application (struct kissat *, int argc, char **argv);
|
int kissat_application (struct kissat *, int argc, char **argv);
|
||||||
void kissat_mab_parse (struct kissat *);
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -49,11 +49,21 @@ kissat_init (void)
|
|||||||
solver->mab_heuristics = 2;
|
solver->mab_heuristics = 2;
|
||||||
solver-> mab_decisions = 0;
|
solver-> mab_decisions = 0;
|
||||||
solver-> mab_chosen_tot = 0;
|
solver-> mab_chosen_tot = 0;
|
||||||
solver-> order_reset = -1;
|
|
||||||
solver-> reseting = 0;
|
solver-> reseting = 0;
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
kissat_init_checker (solver);
|
kissat_init_checker (solver);
|
||||||
#endif
|
#endif
|
||||||
|
solver->step_chb = 0.1*GET_OPTION(stepchb);
|
||||||
|
solver->heuristic = GET_OPTION(heuristic);
|
||||||
|
solver->mab = GET_OPTION(mab);
|
||||||
|
if(solver->mab) {
|
||||||
|
for (unsigned i=0;i<solver->mab_heuristics;i++) {
|
||||||
|
solver->mab_reward[i] = 0;
|
||||||
|
solver->mab_select[i] = 0;
|
||||||
|
}
|
||||||
|
solver->mabc = GET_OPTION(mabcint)+0.1*GET_OPTION(mabcdecimal);
|
||||||
|
solver->mab_select[solver->heuristic]++;
|
||||||
|
}
|
||||||
return solver;
|
return solver;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -184,7 +194,8 @@ kissat_reserve (kissat * solver, int max_var)
|
|||||||
"invalid maximum variable argument '%d'", max_var);
|
"invalid maximum variable argument '%d'", max_var);
|
||||||
kissat_increase_size (solver, (unsigned) max_var);
|
kissat_increase_size (solver, (unsigned) max_var);
|
||||||
|
|
||||||
if (solver->order_reset != -1)
|
int seed = GET_OPTION(order_reset);
|
||||||
|
if (seed != -1)
|
||||||
{
|
{
|
||||||
// srand(solver->order_reset);
|
// srand(solver->order_reset);
|
||||||
int *id;
|
int *id;
|
||||||
@ -193,7 +204,7 @@ kissat_reserve (kissat * solver, int max_var)
|
|||||||
id[i] = i;
|
id[i] = i;
|
||||||
for (int i = 1; i <= max_var; i++)
|
for (int i = 1; i <= max_var; i++)
|
||||||
{
|
{
|
||||||
int j = (rand_r(&solver->order_reset) % max_var) + 1;
|
int j = (rand_r(&seed) % max_var) + 1;
|
||||||
int x = id[i];
|
int x = id[i];
|
||||||
id[i] = id[j];
|
id[i] = id[j];
|
||||||
id[j] = x;
|
id[j] = x;
|
||||||
|
@ -84,7 +84,6 @@ struct kissat
|
|||||||
void *issuer;
|
void *issuer;
|
||||||
int nconflict;
|
int nconflict;
|
||||||
int reseting;
|
int reseting;
|
||||||
int order_reset;
|
|
||||||
int max_var;
|
int max_var;
|
||||||
#ifdef LOGGING
|
#ifdef LOGGING
|
||||||
bool compacting;
|
bool compacting;
|
||||||
|
@ -55,6 +55,7 @@ OPTION( mabcint, 4, 0, 10, "mab const floor") \
|
|||||||
OPTION( minimizedepth, 1e3, 1, 1e6, "minimization depth") \
|
OPTION( minimizedepth, 1e3, 1, 1e6, "minimization depth") \
|
||||||
OPTION( modeinit, 1e3, 10, 1e8, "initial mode change interval") \
|
OPTION( modeinit, 1e3, 10, 1e8, "initial mode change interval") \
|
||||||
OPTION( modeint, 1e3, 10, 1e8, "base mode change interval") \
|
OPTION( modeint, 1e3, 10, 1e8, "base mode change interval") \
|
||||||
|
OPTION( order_reset, -1, -1, 1e5, "order seed") \
|
||||||
OPTION( otfs, 1, 0, 1, "on-the-fly strengthening") \
|
OPTION( otfs, 1, 0, 1, "on-the-fly strengthening") \
|
||||||
OPTION( phase, 1, 0, 1, "initial decision phase") \
|
OPTION( phase, 1, 0, 1, "initial decision phase") \
|
||||||
OPTION( phasesaving, 1, 0, 1, "enable phase saving") \
|
OPTION( phasesaving, 1, 0, 1, "enable phase saving") \
|
||||||
|
@ -268,10 +268,9 @@ if __name__ == "__main__":
|
|||||||
solvers = []
|
solvers = []
|
||||||
|
|
||||||
|
|
||||||
solvers.append(solver_SAT_standard_gnomon("/home/chenzh/res/testLight/v1","v1"))
|
solvers.append(solver_SAT_standard_gnomon("/pub/data/chenzh/res/light/v3--1-preprocess","preprocess"))
|
||||||
solvers.append(solver_SAT_standard_gnomon("/home/chenzh/res/testLight/v2","v2"))
|
solvers.append(solver_SAT_standard_gnomon("/pub/data/chenzh/res/light/v4-nps","sharing-nps"))
|
||||||
solvers.append(solver_SAT_standard_gnomon("/home/chenzh/res/testLight/v3","v3"))
|
solvers.append(solver_SAT_standard_gnomon("/pub/data/chenzh/res/light/v4-dps","sharing-dps"))
|
||||||
|
|
||||||
|
|
||||||
# append_all_solvers_in_dir(solvers, "/pub/data/chenzh/res/light/")
|
# append_all_solvers_in_dir(solvers, "/pub/data/chenzh/res/light/")
|
||||||
samples = []
|
samples = []
|
||||||
|
Binary file not shown.
153
testLight/run7_1.sh
Executable file
153
testLight/run7_1.sh
Executable file
@ -0,0 +1,153 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
SEND_THREAD_NUM=4
|
||||||
|
tmp_fifofile="/tmp/$$.fifo" # 脚本运行的当前进程ID号作为文件名
|
||||||
|
mkfifo "$tmp_fifofile" # 新建一个随机fifo管道文件
|
||||||
|
exec 6<>"$tmp_fifofile" # 定义文件描述符6指向这个fifo管道文件
|
||||||
|
rm $tmp_fifofile
|
||||||
|
for i in $(seq 1 $SEND_THREAD_NUM)
|
||||||
|
do
|
||||||
|
echo # for循环 往 fifo管道文件中写入 $SEND_THREAD_NUM 个空行
|
||||||
|
done >&6
|
||||||
|
|
||||||
|
# CUTOFF_TIME=3600
|
||||||
|
instance_20="/pub/data/chenzh/data/sat2020"
|
||||||
|
instance_21="/pub/data/chenzh/data/sat2021"
|
||||||
|
instance_22="/pub/data/chenzh/data/sat2022"
|
||||||
|
|
||||||
|
|
||||||
|
res1="/pub/data/chenzh/res/light/v1-origin"
|
||||||
|
res2="/pub/data/chenzh/res/light/v1-preprocess-2"
|
||||||
|
res3="/pub/data/chenzh/res/light/v1-1-origin"
|
||||||
|
res4="/pub/data/chenzh/res/light/v2-preprocess"
|
||||||
|
res5="/pub/data/chenzh/res/light/v3--1-preprocess"
|
||||||
|
res6="/pub/data/chenzh/res/light/v4-nps"
|
||||||
|
res7="/pub/data/chenzh/res/light/v4-dps"
|
||||||
|
res8="/pub/data/chenzh/res/light/v4-dps-2w"
|
||||||
|
res_no="/pub/data/chenzh/res/unused"
|
||||||
|
#####################################################
|
||||||
|
|
||||||
|
all_datas=($instance_21 $instance_20)
|
||||||
|
for((i=0;i<${#all_datas[*]};i++))
|
||||||
|
do
|
||||||
|
instance=${all_datas[$i]}
|
||||||
|
|
||||||
|
res_solver_ins=$res8
|
||||||
|
if [ ! -d "$res_solver_ins" ]; then
|
||||||
|
mkdir -p $res_solver_ins
|
||||||
|
fi
|
||||||
|
for dir_file in `cat $instance/vbs.txt`
|
||||||
|
do
|
||||||
|
file=$dir_file
|
||||||
|
echo $file
|
||||||
|
touch $res_solver_ins/$file
|
||||||
|
read -u 6
|
||||||
|
{
|
||||||
|
cd /home/chenzh/solvers/Light
|
||||||
|
time ./light-v4 $instance/$file --share=1 --DPS=1 --DPS_period=20000
|
||||||
|
echo >&6
|
||||||
|
} >$res_solver_ins/$file 2>>$res_solver_ins/$file &
|
||||||
|
done
|
||||||
|
|
||||||
|
|
||||||
|
# res_solver_ins=$res5
|
||||||
|
# if [ ! -d "$res_solver_ins" ]; then
|
||||||
|
# mkdir -p $res_solver_ins
|
||||||
|
# fi
|
||||||
|
# for dir_file in `cat $instance/vbs.txt`
|
||||||
|
# do
|
||||||
|
# file=$dir_file
|
||||||
|
# echo $file
|
||||||
|
# touch $res_solver_ins/$file
|
||||||
|
# read -u 6
|
||||||
|
# {
|
||||||
|
# cd /home/chenzh/solvers/Light
|
||||||
|
# time ./light-v3--1 $instance/$file --share=1 --threads=31
|
||||||
|
# echo >&6
|
||||||
|
# } >$res_solver_ins/$file 2>>$res_solver_ins/$file &
|
||||||
|
# done
|
||||||
|
# res_solver_ins=$res4
|
||||||
|
# if [ ! -d "$res_solver_ins" ]; then
|
||||||
|
# mkdir -p $res_solver_ins
|
||||||
|
# fi
|
||||||
|
# for dir_file in `cat $instance/vbs.txt`
|
||||||
|
# do
|
||||||
|
# file=$dir_file
|
||||||
|
# echo $file
|
||||||
|
# touch $res_solver_ins/$file
|
||||||
|
# read -u 6
|
||||||
|
# {
|
||||||
|
# cd /home/chenzh/solvers/Light
|
||||||
|
# time ./light-v2 $instance/$file --share=1 --threads=31
|
||||||
|
# echo >&6
|
||||||
|
# } >$res_solver_ins/$file 2>>$res_solver_ins/$file &
|
||||||
|
# done
|
||||||
|
|
||||||
|
# res_solver_ins=$res3
|
||||||
|
# if [ ! -d "$res_solver_ins" ]; then
|
||||||
|
# mkdir -p $res_solver_ins
|
||||||
|
# fi
|
||||||
|
# for dir_file in `cat $instance/vbs.txt`
|
||||||
|
# do
|
||||||
|
# file=$dir_file
|
||||||
|
# echo $file
|
||||||
|
# touch $res_solver_ins/$file
|
||||||
|
# read -u 6
|
||||||
|
# {
|
||||||
|
# cd /home/chenzh/solvers/Light
|
||||||
|
# time ./light-v1-1 $instance/$file --simplify=0 --reset=1
|
||||||
|
# echo >&6
|
||||||
|
# } >$res_solver_ins/$file 2>>$res_solver_ins/$file &
|
||||||
|
# done
|
||||||
|
|
||||||
|
# res_solver_ins=$res2
|
||||||
|
# if [ ! -d "$res_solver_ins" ]; then
|
||||||
|
# mkdir -p $res_solver_ins
|
||||||
|
# fi
|
||||||
|
# for dir_file in `cat $instance/vbs.txt`
|
||||||
|
# do
|
||||||
|
# file=$dir_file
|
||||||
|
# echo $file
|
||||||
|
# touch $res_solver_ins/$file
|
||||||
|
# read -u 6
|
||||||
|
# {
|
||||||
|
# cd /home/chenzh/solvers/Light
|
||||||
|
# time ./light $instance/$file --simplify=1
|
||||||
|
# echo >&6
|
||||||
|
# } >$res_solver_ins/$file 2>>$res_solver_ins/$file &
|
||||||
|
# done
|
||||||
|
|
||||||
|
# res_solver_ins=$res1
|
||||||
|
# if [ ! -d "$res_solver_ins" ]; then
|
||||||
|
# mkdir -p $res_solver_ins
|
||||||
|
# fi
|
||||||
|
# for dir_file in `cat $instance/vbs.txt`
|
||||||
|
# do
|
||||||
|
# file=$dir_file
|
||||||
|
# echo $file
|
||||||
|
# touch $res_solver_ins/$file
|
||||||
|
# read -u 6
|
||||||
|
# {
|
||||||
|
# cd /home/chenzh/solvers/Light
|
||||||
|
# time ./light-v1 $instance/$file --simplify=0
|
||||||
|
# echo >&6
|
||||||
|
# } >$res_solver_ins/$file 2>>$res_solver_ins/$file &
|
||||||
|
# done
|
||||||
|
done
|
||||||
|
|
||||||
|
res_solver_ins=$res_no
|
||||||
|
if [ ! -d "$res_solver_ins" ]; then
|
||||||
|
mkdir -p $res_solver_ins
|
||||||
|
fi
|
||||||
|
for((i=0;i<4;i++))
|
||||||
|
do
|
||||||
|
read -u 6
|
||||||
|
{
|
||||||
|
cd /home/chenzh/solvers/Light
|
||||||
|
time ./light-v1 /home/chenzh/data/hard_cnfs/49.cnf
|
||||||
|
echo >&6
|
||||||
|
} >$res_solver_ins/$i 2>>$res_solver_ins/$i &
|
||||||
|
done
|
||||||
|
|
||||||
|
|
||||||
|
exit 0
|
153
testLight/run7_2.sh
Executable file
153
testLight/run7_2.sh
Executable file
@ -0,0 +1,153 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
SEND_THREAD_NUM=4
|
||||||
|
tmp_fifofile="/tmp/$$.fifo" # 脚本运行的当前进程ID号作为文件名
|
||||||
|
mkfifo "$tmp_fifofile" # 新建一个随机fifo管道文件
|
||||||
|
exec 6<>"$tmp_fifofile" # 定义文件描述符6指向这个fifo管道文件
|
||||||
|
rm $tmp_fifofile
|
||||||
|
for i in $(seq 1 $SEND_THREAD_NUM)
|
||||||
|
do
|
||||||
|
echo # for循环 往 fifo管道文件中写入 $SEND_THREAD_NUM 个空行
|
||||||
|
done >&6
|
||||||
|
|
||||||
|
# CUTOFF_TIME=3600
|
||||||
|
instance_20="/pub/data/chenzh/data/sat2020"
|
||||||
|
instance_21="/pub/data/chenzh/data/sat2021"
|
||||||
|
instance_22="/pub/data/chenzh/data/sat2022"
|
||||||
|
|
||||||
|
|
||||||
|
res1="/pub/data/chenzh/res/light/v1-origin"
|
||||||
|
res2="/pub/data/chenzh/res/light/v1-preprocess-2"
|
||||||
|
res3="/pub/data/chenzh/res/light/v1-1-origin"
|
||||||
|
res4="/pub/data/chenzh/res/light/v2-preprocess"
|
||||||
|
res5="/pub/data/chenzh/res/light/v3--1-preprocess"
|
||||||
|
res6="/pub/data/chenzh/res/light/v4-nps"
|
||||||
|
res7="/pub/data/chenzh/res/light/v4-dps"
|
||||||
|
res8="/pub/data/chenzh/res/light/v4-dps-2w"
|
||||||
|
res_no="/pub/data/chenzh/res/unused"
|
||||||
|
#####################################################
|
||||||
|
|
||||||
|
all_datas=($instance_22)
|
||||||
|
for((i=0;i<${#all_datas[*]};i++))
|
||||||
|
do
|
||||||
|
instance=${all_datas[$i]}
|
||||||
|
|
||||||
|
res_solver_ins=$res8
|
||||||
|
if [ ! -d "$res_solver_ins" ]; then
|
||||||
|
mkdir -p $res_solver_ins
|
||||||
|
fi
|
||||||
|
for dir_file in `cat $instance/vbs.txt`
|
||||||
|
do
|
||||||
|
file=$dir_file
|
||||||
|
echo $file
|
||||||
|
touch $res_solver_ins/$file
|
||||||
|
read -u 6
|
||||||
|
{
|
||||||
|
cd /home/chenzh/solvers/Light
|
||||||
|
time ./light-v4 $instance/$file --share=1 --DPS=1 --DPS_period=20000
|
||||||
|
echo >&6
|
||||||
|
} >$res_solver_ins/$file 2>>$res_solver_ins/$file &
|
||||||
|
done
|
||||||
|
|
||||||
|
|
||||||
|
# res_solver_ins=$res5
|
||||||
|
# if [ ! -d "$res_solver_ins" ]; then
|
||||||
|
# mkdir -p $res_solver_ins
|
||||||
|
# fi
|
||||||
|
# for dir_file in `cat $instance/vbs.txt`
|
||||||
|
# do
|
||||||
|
# file=$dir_file
|
||||||
|
# echo $file
|
||||||
|
# touch $res_solver_ins/$file
|
||||||
|
# read -u 6
|
||||||
|
# {
|
||||||
|
# cd /home/chenzh/solvers/Light
|
||||||
|
# time ./light-v3--1 $instance/$file --share=1 --threads=31
|
||||||
|
# echo >&6
|
||||||
|
# } >$res_solver_ins/$file 2>>$res_solver_ins/$file &
|
||||||
|
# done
|
||||||
|
# res_solver_ins=$res4
|
||||||
|
# if [ ! -d "$res_solver_ins" ]; then
|
||||||
|
# mkdir -p $res_solver_ins
|
||||||
|
# fi
|
||||||
|
# for dir_file in `cat $instance/vbs.txt`
|
||||||
|
# do
|
||||||
|
# file=$dir_file
|
||||||
|
# echo $file
|
||||||
|
# touch $res_solver_ins/$file
|
||||||
|
# read -u 6
|
||||||
|
# {
|
||||||
|
# cd /home/chenzh/solvers/Light
|
||||||
|
# time ./light-v2 $instance/$file --share=1 --threads=31
|
||||||
|
# echo >&6
|
||||||
|
# } >$res_solver_ins/$file 2>>$res_solver_ins/$file &
|
||||||
|
# done
|
||||||
|
|
||||||
|
# res_solver_ins=$res3
|
||||||
|
# if [ ! -d "$res_solver_ins" ]; then
|
||||||
|
# mkdir -p $res_solver_ins
|
||||||
|
# fi
|
||||||
|
# for dir_file in `cat $instance/vbs.txt`
|
||||||
|
# do
|
||||||
|
# file=$dir_file
|
||||||
|
# echo $file
|
||||||
|
# touch $res_solver_ins/$file
|
||||||
|
# read -u 6
|
||||||
|
# {
|
||||||
|
# cd /home/chenzh/solvers/Light
|
||||||
|
# time ./light-v1-1 $instance/$file --simplify=0 --reset=1
|
||||||
|
# echo >&6
|
||||||
|
# } >$res_solver_ins/$file 2>>$res_solver_ins/$file &
|
||||||
|
# done
|
||||||
|
|
||||||
|
# res_solver_ins=$res2
|
||||||
|
# if [ ! -d "$res_solver_ins" ]; then
|
||||||
|
# mkdir -p $res_solver_ins
|
||||||
|
# fi
|
||||||
|
# for dir_file in `cat $instance/vbs.txt`
|
||||||
|
# do
|
||||||
|
# file=$dir_file
|
||||||
|
# echo $file
|
||||||
|
# touch $res_solver_ins/$file
|
||||||
|
# read -u 6
|
||||||
|
# {
|
||||||
|
# cd /home/chenzh/solvers/Light
|
||||||
|
# time ./light $instance/$file --simplify=1
|
||||||
|
# echo >&6
|
||||||
|
# } >$res_solver_ins/$file 2>>$res_solver_ins/$file &
|
||||||
|
# done
|
||||||
|
|
||||||
|
# res_solver_ins=$res1
|
||||||
|
# if [ ! -d "$res_solver_ins" ]; then
|
||||||
|
# mkdir -p $res_solver_ins
|
||||||
|
# fi
|
||||||
|
# for dir_file in `cat $instance/vbs.txt`
|
||||||
|
# do
|
||||||
|
# file=$dir_file
|
||||||
|
# echo $file
|
||||||
|
# touch $res_solver_ins/$file
|
||||||
|
# read -u 6
|
||||||
|
# {
|
||||||
|
# cd /home/chenzh/solvers/Light
|
||||||
|
# time ./light-v1 $instance/$file --simplify=0
|
||||||
|
# echo >&6
|
||||||
|
# } >$res_solver_ins/$file 2>>$res_solver_ins/$file &
|
||||||
|
# done
|
||||||
|
done
|
||||||
|
|
||||||
|
res_solver_ins=$res_no
|
||||||
|
if [ ! -d "$res_solver_ins" ]; then
|
||||||
|
mkdir -p $res_solver_ins
|
||||||
|
fi
|
||||||
|
for((i=0;i<4;i++))
|
||||||
|
do
|
||||||
|
read -u 6
|
||||||
|
{
|
||||||
|
cd /home/chenzh/solvers/Light
|
||||||
|
time ./light-v1 /home/chenzh/data/hard_cnfs/49.cnf
|
||||||
|
echo >&6
|
||||||
|
} >$res_solver_ins/$i 2>>$res_solver_ins/$i &
|
||||||
|
done
|
||||||
|
|
||||||
|
|
||||||
|
exit 0
|
@ -11,45 +11,78 @@ extern "C" {
|
|||||||
#include "src/import.h"
|
#include "src/import.h"
|
||||||
}
|
}
|
||||||
|
|
||||||
void kissat_export_clause(void *solver, int lbd, cvec* c) {
|
void basekissat::add(int l) {
|
||||||
basekissat* S = (basekissat *) solver;
|
kissat_add(solver, l);
|
||||||
++S->x1;
|
}
|
||||||
if (S->solver->nconflict != S->x1 - 1) printf("%d %d\n", S->solver->nconflict, S->x1);
|
|
||||||
if (lbd > S->good_clause_lbd) return;
|
void basekissat::configure(char* name, int id) {
|
||||||
|
kissat_set_option(solver, name, id);
|
||||||
|
}
|
||||||
|
|
||||||
|
int basekissat::solve() {
|
||||||
|
return kissat_solve(solver);
|
||||||
|
}
|
||||||
|
|
||||||
|
void basekissat::terminate() {
|
||||||
|
kissat_terminate(solver);
|
||||||
|
}
|
||||||
|
|
||||||
|
int basekissat::val(int l) {
|
||||||
|
int v = abs(l);
|
||||||
|
int tmp = kissat_value(solver, v);
|
||||||
|
if (!tmp) tmp = v;
|
||||||
|
if (l < 0) tmp = -tmp;
|
||||||
|
return tmp;
|
||||||
|
}
|
||||||
|
|
||||||
|
void basekissat::exp_clause(void* cl, int lbd) {
|
||||||
|
cvec *c = (cvec *) cl;
|
||||||
clause_store* cls = new clause_store(c->sz);
|
clause_store* cls = new clause_store(c->sz);
|
||||||
for (int i = 0; i < c->sz; i++) {
|
for (int i = 0; i < c->sz; i++) {
|
||||||
int v = cvec_data(c, i);
|
int v = cvec_data(c, i);
|
||||||
int eidx = PEEK_STACK(S->solver->exportk, (v >> 1));
|
int eidx = PEEK_STACK(solver->exportk, (v >> 1));
|
||||||
cls->data[i] = v & 1 ? -eidx : eidx;
|
cls->data[i] = v & 1 ? -eidx : eidx;
|
||||||
}
|
}
|
||||||
++S->x2;
|
// ++S->x2;
|
||||||
// if (S->id == 0) puts("");
|
// if (S->id == 0) puts("");
|
||||||
cls->lbd = lbd;
|
cls->lbd = lbd;
|
||||||
S->export_clause.push(cls);
|
export_clause.push(cls);
|
||||||
}
|
}
|
||||||
|
|
||||||
int kissat_import_clause(void *solver, int *lbd, cvec* c) {
|
|
||||||
basekissat* S = (basekissat *) solver;
|
|
||||||
clause_store* cls = NULL;
|
|
||||||
if (S->import_clause.pop(cls) == false) return -1;
|
|
||||||
|
|
||||||
bool eliminated = false;
|
void call_back_out(void *solver, int lbd, cvec *c) {
|
||||||
|
basekissat* S = (basekissat *) solver;
|
||||||
|
// ++S->x1;
|
||||||
|
// if (S->solver->nconflict != S->x1 - 1) printf("%d %d\n", S->solver->nconflict, S->x1);
|
||||||
|
if (lbd <= S->good_clause_lbd) {
|
||||||
|
S->exp_clause(c, lbd);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool basekissat::imp_clause(clause_store *cls, void *cl) {
|
||||||
|
cvec *c = (cvec *) cl;
|
||||||
for (int i = 0; i < cls->size; i++) {
|
for (int i = 0; i < cls->size; i++) {
|
||||||
// S->outimport << cls->data[i] << std::endl;
|
// S->outimport << cls->data[i] << std::endl;
|
||||||
int eidx = abs(cls->data[i]);
|
int eidx = abs(cls->data[i]);
|
||||||
import *import = &PEEK_STACK (S->solver->import, eidx);
|
import *import = &PEEK_STACK (solver->import, eidx);
|
||||||
if (import->eliminated) {
|
if (import->eliminated) return false;
|
||||||
eliminated = true;
|
|
||||||
}
|
|
||||||
else {
|
else {
|
||||||
int ilit = import->lit;
|
int ilit = import->lit;
|
||||||
if (cls->data[i] < 0) ilit = ilit ^ 1;
|
if (cls->data[i] < 0) ilit = ilit ^ 1;
|
||||||
cvec_push(c, ilit);
|
cvec_push(c, ilit);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
int call_back_in(void *solver, int *lbd, cvec *c) {
|
||||||
|
basekissat* S = (basekissat *) solver;
|
||||||
|
clause_store* cls = NULL;
|
||||||
|
if (S->import_clause.pop(cls) == false) return -1;
|
||||||
*lbd = cls->lbd;
|
*lbd = cls->lbd;
|
||||||
|
bool res = S->imp_clause(cls, c);
|
||||||
cls->free_clause();
|
cls->free_clause();
|
||||||
if (eliminated) return -10;
|
if (!res) return -10;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -90,8 +123,8 @@ basekissat::basekissat(int id, light* light) : basesolver(id, light) {
|
|||||||
solver -> cbkExportClause = NULL;
|
solver -> cbkExportClause = NULL;
|
||||||
solver -> cbkWaitSharing = NULL;
|
solver -> cbkWaitSharing = NULL;
|
||||||
if (light->opt->share) {
|
if (light->opt->share) {
|
||||||
solver -> cbkImportClause = kissat_import_clause;
|
solver -> cbkImportClause = call_back_in;
|
||||||
solver -> cbkExportClause = kissat_export_clause;
|
solver -> cbkExportClause = call_back_out;
|
||||||
solver -> cbkWaitSharing = kissat_wait_sharing;
|
solver -> cbkWaitSharing = kissat_wait_sharing;
|
||||||
solver -> share_dps = light->opt->DPS;
|
solver -> share_dps = light->opt->DPS;
|
||||||
solver -> share_dps_period= light->opt->DPS_period;
|
solver -> share_dps_period= light->opt->DPS_period;
|
||||||
@ -102,8 +135,7 @@ basekissat::~basekissat(){
|
|||||||
delete solver;
|
delete solver;
|
||||||
}
|
}
|
||||||
|
|
||||||
void basekissat::parse_dimacs(char* filename) {
|
void basekissat::parse_from_CNF(char* filename) {
|
||||||
kissat_mab_parse(solver);
|
|
||||||
strictness strict = NORMAL_PARSING;
|
strictness strict = NORMAL_PARSING;
|
||||||
file in;
|
file in;
|
||||||
uint64_t lineno;
|
uint64_t lineno;
|
||||||
@ -112,47 +144,17 @@ void basekissat::parse_dimacs(char* filename) {
|
|||||||
kissat_close_file(&in);
|
kissat_close_file(&in);
|
||||||
}
|
}
|
||||||
|
|
||||||
void basekissat::import_original_clause(preprocess* pre) {
|
void basekissat::parse_from_PAR(preprocess* pre) {
|
||||||
solver->max_var = pre->vars;
|
solver->max_var = pre->vars;
|
||||||
kissat_mab_parse(solver);
|
|
||||||
kissat_reserve(solver, pre->vars);
|
kissat_reserve(solver, pre->vars);
|
||||||
for (int i = 1; i <= pre->clauses; i++) {
|
for (int i = 1; i <= pre->clauses; i++) {
|
||||||
int l = pre->clause[i].size();
|
int l = pre->clause[i].size();
|
||||||
for (int j = 0; j < l; j++)
|
for (int j = 0; j < l; j++)
|
||||||
kissat_add(solver, pre->clause[i][j]);
|
add(pre->clause[i][j]);
|
||||||
kissat_add(solver, 0);
|
add(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;
|
|
||||||
}
|
|
||||||
|
|
||||||
void basekissat::export_clauses_to(vec<clause_store *> &clauses) {
|
void basekissat::export_clauses_to(vec<clause_store *> &clauses) {
|
||||||
clause_store *cls;
|
clause_store *cls;
|
||||||
while (export_clause.pop(cls)) {
|
while (export_clause.pop(cls)) {
|
||||||
@ -174,11 +176,30 @@ void basekissat::import_clauses_from(vec<clause_store *> &clauses) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void basekissat::get_model(vec<int> &model) {
|
||||||
|
model.clear();
|
||||||
|
for (int i = 1; i <= solver->max_var; i++) {
|
||||||
|
model.push(val(i));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void basekissat::broaden_export_limit() {
|
void basekissat::broaden_export_limit() {
|
||||||
// ++good_clause_lbd;
|
++good_clause_lbd;
|
||||||
}
|
}
|
||||||
|
|
||||||
void basekissat::restrict_export_limit() {
|
void basekissat::restrict_export_limit() {
|
||||||
if (good_clause_lbd > 2)
|
if (good_clause_lbd > 2)
|
||||||
--good_clause_lbd;
|
--good_clause_lbd;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int basekissat::get_conflicts() {
|
||||||
|
return solver->nconflict;
|
||||||
|
}
|
||||||
|
// int basekissat::get_reset_data() {
|
||||||
|
// return solver->best_assigned;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// void basekissat::reset() {
|
||||||
|
// solver->reseting = 1;
|
||||||
|
// }
|
||||||
|
@ -1,21 +1,23 @@
|
|||||||
#include "basesolver.hpp"
|
#include "basesolver.hpp"
|
||||||
#include "clause.hpp"
|
|
||||||
#include <boost/thread/thread.hpp>
|
|
||||||
#include <boost/lockfree/spsc_queue.hpp>
|
|
||||||
|
|
||||||
struct kissat;
|
struct kissat;
|
||||||
struct cvec;
|
struct cvec;
|
||||||
|
|
||||||
class basekissat : public basesolver {
|
class basekissat : public basesolver {
|
||||||
public:
|
public:
|
||||||
void parse_dimacs(char* filename);
|
|
||||||
void import_original_clause(preprocess *pre);
|
|
||||||
void diversity(int id);
|
|
||||||
void terminate();
|
void terminate();
|
||||||
|
void add(int l);
|
||||||
int solve();
|
int solve();
|
||||||
|
int val(int l);
|
||||||
|
void configure(char* name, int id);
|
||||||
|
// int get_reset_data();
|
||||||
|
// void reset();
|
||||||
|
int get_conflicts();
|
||||||
|
void parse_from_CNF(char* filename);
|
||||||
|
void parse_from_PAR(preprocess *pre);
|
||||||
void get_model(vec<int> &model);
|
void get_model(vec<int> &model);
|
||||||
int get_reset_data();
|
void exp_clause(void *cl, int lbd);
|
||||||
void reset();
|
bool imp_clause(clause_store *cls, void *cl);
|
||||||
void export_clauses_to(vec<clause_store *> &clauses);
|
void export_clauses_to(vec<clause_store *> &clauses);
|
||||||
void import_clauses_from(vec<clause_store *> &clauses);
|
void import_clauses_from(vec<clause_store *> &clauses);
|
||||||
void broaden_export_limit();
|
void broaden_export_limit();
|
||||||
@ -27,8 +29,6 @@ public:
|
|||||||
kissat* solver;
|
kissat* solver;
|
||||||
int good_clause_lbd = 0;
|
int good_clause_lbd = 0;
|
||||||
|
|
||||||
boost::lockfree::spsc_queue<clause_store*, boost::lockfree::capacity<1024000>> import_clause;
|
|
||||||
boost::lockfree::spsc_queue<clause_store*, boost::lockfree::capacity<1024000>> export_clause;
|
|
||||||
friend int cbkImportClause(void *, int *, cvec *);
|
friend int cbkImportClause(void *, int *, cvec *);
|
||||||
friend int cbkExportClause(void *, int *, cvec *);
|
friend int cbkExportClause(void *, int *, cvec *);
|
||||||
friend void cbkWaitSharing(void *);
|
friend void cbkWaitSharing(void *);
|
||||||
|
@ -6,17 +6,23 @@
|
|||||||
#include "clause.hpp"
|
#include "clause.hpp"
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <boost/thread/thread.hpp>
|
||||||
|
#include <boost/lockfree/spsc_queue.hpp>
|
||||||
class sharer;
|
class sharer;
|
||||||
class basesolver {
|
class basesolver {
|
||||||
public:
|
public:
|
||||||
virtual void parse_dimacs(char* filename) = 0;
|
virtual void add(int l) = 0;
|
||||||
virtual void import_original_clause(preprocess* pre) = 0;
|
|
||||||
virtual void diversity(int id) = 0;
|
|
||||||
virtual int solve() = 0;
|
virtual int solve() = 0;
|
||||||
|
virtual int val(int l) = 0;
|
||||||
virtual void terminate() = 0;
|
virtual void terminate() = 0;
|
||||||
|
virtual void configure(char* name, int id) = 0;
|
||||||
|
virtual int get_conflicts() = 0;
|
||||||
|
|
||||||
|
virtual void parse_from_CNF(char* filename) = 0;
|
||||||
|
virtual void parse_from_PAR(preprocess* pre) = 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 exp_clause(void *cl, int lbd) = 0;
|
||||||
virtual void reset() = 0;
|
virtual bool imp_clause(clause_store *cls, void *cl) = 0;
|
||||||
virtual void export_clauses_to(vec<clause_store *> &clauses) = 0;
|
virtual void export_clauses_to(vec<clause_store *> &clauses) = 0;
|
||||||
virtual void import_clauses_from(vec<clause_store *> &clauses) = 0;
|
virtual void import_clauses_from(vec<clause_store *> &clauses) = 0;
|
||||||
virtual void broaden_export_limit() = 0;
|
virtual void broaden_export_limit() = 0;
|
||||||
@ -25,9 +31,11 @@ public:
|
|||||||
int id;
|
int id;
|
||||||
sharer* in_sharer;
|
sharer* in_sharer;
|
||||||
|
|
||||||
|
boost::lockfree::spsc_queue<clause_store*, boost::lockfree::capacity<1024000>> import_clause;
|
||||||
|
boost::lockfree::spsc_queue<clause_store*, boost::lockfree::capacity<1024000>> export_clause;
|
||||||
|
|
||||||
basesolver(int sid, light* light) : id(sid), controller(light) {}
|
basesolver(int sid, light* light) : id(sid), controller(light) {}
|
||||||
~basesolver() {
|
~basesolver() {
|
||||||
printf("destru %dbase\n", id);
|
|
||||||
if (controller) {
|
if (controller) {
|
||||||
controller = NULL;
|
controller = NULL;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user