1 #include "internal.hpp"
2
3 namespace CaDiCaL {
4
5 /*------------------------------------------------------------------------*/
6
7 struct NameVal { const char * name; int val; };
8
9 static NameVal sat_config[] = {
10 { "elimreleff", 10 },
11 { "stabilizeonly", 1 },
12 { "subsumereleff", 60 },
13 };
14
15 static NameVal unsat_config[] = {
16 { "stabilize", 0 },
17 { "walk", 0 },
18 };
19
20 /*------------------------------------------------------------------------*/
21
22 #define CONFIGS \
23 \
24 CONFIG(sat,"target satisfiable instances") \
25 CONFIG(unsat,"target unsatisfiable instances") \
26
27 /*------------------------------------------------------------------------*/
28
has(const char * name)29 bool Config::has (const char * name) {
30 if (!strcmp (name, "default")) return true;
31 #define CONFIG(N,D) \
32 if (!strcmp (name, #N)) return true;
33 CONFIGS
34 #undef CONFIG
35 return false;
36 }
37
set(Solver & solver,const char * name)38 bool Config::set (Solver & solver, const char * name) {
39 if (!strcmp (name, "default")) return true;
40 #define CONFIG(N,D) \
41 do { \
42 if (strcmp (name, #N)) break; \
43 const NameVal * BEGIN = N ## _config; \
44 const NameVal * END = BEGIN + sizeof N ##_config / sizeof (NameVal); \
45 for (const NameVal * P = BEGIN; P != END; P++) { \
46 assert (solver.is_valid_option (P->name)); \
47 solver.set (P->name, P->val); \
48 } \
49 return true; \
50 } while (0);
51 CONFIGS
52 #undef CONFIG
53 return false;
54 }
55
description(const char * name)56 const char * Config::description (const char * name) {
57 if (!strcmp (name, "default"))
58 return "should work in most situations";
59 #define CONFIG(N,D) \
60 if (!strcmp (name, #N)) return D;
61 CONFIGS
62 #undef CONFIG
63 return 0;
64 }
65
usage()66 void Config::usage () {
67 #define CONFIG(N,D) \
68 printf (" %-26s " D "\n", "--" #N);
69 CONFIGS
70 #undef CONFIG
71 }
72
73 }
74