修改参数为 cmdline 方式
This commit is contained in:
parent
a9b0ae0f00
commit
104267a0a7
3
.gitignore
vendored
3
.gitignore
vendored
@ -1 +1,2 @@
|
|||||||
build
|
build
|
||||||
|
.nfs*
|
4
.vscode/settings.json
vendored
4
.vscode/settings.json
vendored
@ -1,5 +1,6 @@
|
|||||||
{
|
{
|
||||||
"files.associations": {
|
"files.associations": {
|
||||||
|
"*.ejs": "html",
|
||||||
"cstring": "cpp",
|
"cstring": "cpp",
|
||||||
"typeinfo": "cpp",
|
"typeinfo": "cpp",
|
||||||
"iostream": "cpp",
|
"iostream": "cpp",
|
||||||
@ -74,6 +75,7 @@
|
|||||||
"regex": "cpp",
|
"regex": "cpp",
|
||||||
"scoped_allocator": "cpp",
|
"scoped_allocator": "cpp",
|
||||||
"shared_mutex": "cpp",
|
"shared_mutex": "cpp",
|
||||||
"valarray": "cpp"
|
"valarray": "cpp",
|
||||||
|
"strstream": "cpp"
|
||||||
}
|
}
|
||||||
}
|
}
|
12
build.sh
12
build.sh
@ -6,17 +6,15 @@ COMPILE_THREADS=16
|
|||||||
|
|
||||||
# build kissat
|
# build kissat
|
||||||
|
|
||||||
cd kissat-inc
|
# cd kissat-inc
|
||||||
./configure
|
# ./configure
|
||||||
make -j $COMPILE_THREADS
|
# make -j $COMPILE_THREADS
|
||||||
cd ..
|
# cd ..
|
||||||
|
|
||||||
# build and copy light-solver
|
# build and copy light-solver
|
||||||
|
|
||||||
make -C src-light-solver -j $COMPILE_THREADS
|
make -C src-light-solver -j $COMPILE_THREADS
|
||||||
cp src-light-solver/build/light-solver .
|
|
||||||
|
|
||||||
# build and copy light-master
|
# build and copy light-master
|
||||||
|
|
||||||
make -C src-light-master -j $COMPILE_THREADS
|
make -C src-light-master -j $COMPILE_THREADS
|
||||||
cp src-light-master/build/light-master .
|
|
BIN
light-master
BIN
light-master
Binary file not shown.
1
light-master
Symbolic link
1
light-master
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
./src-light-master/build/light-master
|
BIN
light-solver
BIN
light-solver
Binary file not shown.
1
light-solver
Symbolic link
1
light-solver
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
./src-light-solver/build/light-solver
|
18
makefile
18
makefile
@ -1,18 +0,0 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
build-kissat:
|
|
||||||
cd kissat-inc
|
|
||||||
ls
|
|
||||||
sh ./configure
|
|
||||||
make
|
|
||||||
|
|
||||||
|
|
||||||
all: build-kissat
|
|
||||||
make -C src-light-master
|
|
||||||
make -C src-light-solver
|
|
||||||
cp src-light-master/build/light-master .
|
|
||||||
cp src-light-solver/build/light-solver .
|
|
||||||
|
|
@ -2,28 +2,9 @@
|
|||||||
|
|
||||||
#include "master.h"
|
#include "master.h"
|
||||||
|
|
||||||
// struct {
|
|
||||||
// std::string ip_addr;
|
|
||||||
// std::vector<std::string> solver_ip_addrs;
|
|
||||||
// std::string instance;
|
|
||||||
// }opt;
|
|
||||||
|
|
||||||
// void parse_input(const nlohmann::json& config) {
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
|
||||||
// void run_master(const nlohmann::json& config) {
|
|
||||||
// parse_input(config);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// }
|
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
printf("This is master!\n");
|
printf("=====================================\n");
|
||||||
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
@ -4,6 +4,8 @@
|
|||||||
#include <thread>
|
#include <thread>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
|
#include "utils/cmdline.h"
|
||||||
|
|
||||||
light::light():
|
light::light():
|
||||||
finalResult (0),
|
finalResult (0),
|
||||||
winner_period (1e9),
|
winner_period (1e9),
|
||||||
@ -19,7 +21,6 @@ light::~light() {
|
|||||||
workers.clear(true);
|
workers.clear(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void light::configure_from_file(const char* file) {
|
void light::configure_from_file(const char* file) {
|
||||||
if (!strcmp(file, "")) {
|
if (!strcmp(file, "")) {
|
||||||
configure_name = new vec<char*>[OPT(threads)];
|
configure_name = new vec<char*>[OPT(threads)];
|
||||||
@ -64,28 +65,43 @@ void light::configure_from_file(const char* file) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void light::arg_parse(int argc, char **argv) {
|
void light::arg_parse(int argc, char **argv) {
|
||||||
for (int i = 1; i < argc; i++) {
|
cmdline::parser parser;
|
||||||
char *arg = argv[i];
|
|
||||||
if (arg[0] != '-' || arg[1] != '-') {
|
// define argument list
|
||||||
filename = arg; continue;
|
parser.add<std::string>("inst", 'i', "CNF format instance", true, "");
|
||||||
}
|
|
||||||
int l = strlen(arg), pos = 0;
|
#define PARA(N, T, D, L, H, C) \
|
||||||
for (int i = 2; i < l; i++)
|
if (!strcmp(#T, "int")) parser.add<int>(#N, '\0', C, false, D, cmdline::range((int)L, (int)H)); \
|
||||||
if (arg[i] == '=') pos = i;
|
else parser.add<double>(#N, '\0', C, false, D, cmdline::range((double)L, (double)H));
|
||||||
if (!pos) continue;
|
PARAS
|
||||||
char name[50];
|
#undef PARA
|
||||||
strncpy(name, arg + 2, pos - 2);
|
|
||||||
name[pos - 2] = '\0';
|
parser.parse_check(argc, argv);
|
||||||
char* val = arg + pos + 1;
|
|
||||||
if (opt->map_int.count(name)) opt->set_para(name, atoi(val));
|
// set cnf filename
|
||||||
else if (opt->map_double.count(name)) opt->set_para(name, atof(val));
|
std::string file_string = parser.get<std::string>("inst");
|
||||||
else opt->set_para(name, val);
|
filename = new char[file_string.size() + 1];
|
||||||
}
|
memcpy(filename, file_string.c_str(), file_string.length());
|
||||||
opt->sync_paras();
|
filename[file_string.length()] = '\0';
|
||||||
printf("%s\n", OPT(config).c_str());
|
|
||||||
|
#define PARA(N, T, D, L, H, C) \
|
||||||
|
if (!strcmp(#T, "int")) OPT(N) = parser.get<int>(#N); \
|
||||||
|
else OPT(N) = parser.get<double>(#N);
|
||||||
|
PARAS
|
||||||
|
#undef PARA
|
||||||
|
|
||||||
|
// print arguments
|
||||||
|
printf("------------ arguments ------------\n");
|
||||||
|
|
||||||
|
printf("%-20s: %s\n", "inst", filename);
|
||||||
|
|
||||||
|
#define PARA(N, T, D, L, H, C) \
|
||||||
|
if (!strcmp(#T, "int")) printf("%-20s: %-10d\n", #N, OPT(N)); \
|
||||||
|
else printf("%-20s: %-10.2f\n", #N, OPT(N));
|
||||||
|
PARAS
|
||||||
|
#undef PARA
|
||||||
|
|
||||||
|
printf("-----------------------------------\n");
|
||||||
|
|
||||||
configure_from_file(OPT(config).c_str());
|
configure_from_file(OPT(config).c_str());
|
||||||
printf("444\n");
|
|
||||||
opt->sync_paras();
|
|
||||||
opt->print_change();
|
|
||||||
printf("c filename: %s\n", filename);
|
|
||||||
}
|
}
|
@ -7,14 +7,6 @@
|
|||||||
#include "utils/cmdline.h"
|
#include "utils/cmdline.h"
|
||||||
|
|
||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
||||||
|
|
||||||
cmdline::parser a;
|
|
||||||
|
|
||||||
a.add<std::string>("inst", 'i', "CNF format instance", true, "");
|
|
||||||
|
|
||||||
a.parse_check(argc, argv);
|
|
||||||
|
|
||||||
solve(argc, argv);
|
solve(argc, argv);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
@ -6,7 +6,7 @@ OBJECTS := $(addprefix build/,$(SOURCES:%=%.o))
|
|||||||
|
|
||||||
# 声明编译器和编译选项
|
# 声明编译器和编译选项
|
||||||
CXX := g++
|
CXX := g++
|
||||||
CXXFLAGS := -O3 -Wall -Wextra -MMD -MP -flto
|
CXXFLAGS := -O0 -Wall -Wextra -MMD -MP -g
|
||||||
|
|
||||||
LIBS := -lkissat -L../kissat-inc/build -I ../kissat-inc/ \
|
LIBS := -lkissat -L../kissat-inc/build -I ../kissat-inc/ \
|
||||||
-lm4ri -Lpreprocess/m4ri-20140914/.libs -I preprocess/m4ri-20140914/ \
|
-lm4ri -Lpreprocess/m4ri-20140914/.libs -I preprocess/m4ri-20140914/ \
|
||||||
|
@ -176,14 +176,17 @@ int light::solve() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int light::run() {
|
int light::run() {
|
||||||
|
|
||||||
init_workers();
|
init_workers();
|
||||||
diversity_workers();
|
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);
|
||||||
if (!res) return 20;
|
if (!res) return 20;
|
||||||
}
|
}
|
||||||
else worker_sign = filename;
|
else worker_sign = filename;
|
||||||
|
|
||||||
parse_input();
|
parse_input();
|
||||||
if (OPT(share)) share();
|
if (OPT(share)) share();
|
||||||
int res = solve();
|
int res = solve();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user