ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
cadical_config.cpp
Go to the documentation of this file.
1#include "global.h"
2
3#include "internal.hpp"
4
6
7namespace CaDiCaL {
8
9/*------------------------------------------------------------------------*/
10
11struct NameVal {
12 const char *name;
13 int val;
14};
15
16/*------------------------------------------------------------------------*/
17
18// These are dummy configurations, which require additional code.
19
20static NameVal default_config[1]; // With '-pedantic' just '[]' or
21static NameVal plain_config[1]; // '[0]' gave a warning.
22
23/*------------------------------------------------------------------------*/
24
25// Here we have the pre-defined default configurations.
26
27static NameVal sat_config[] = {
28 {"elimeffort", 10},
29 {"stabilizeonly", 1},
30 {"subsumeeffort", 60},
31};
32
33static NameVal unsat_config[] = {
34 {"stabilize", 0},
35 {"walk", 0},
36};
37
38/*------------------------------------------------------------------------*/
39
40#define CONFIGS \
41\
42 CONFIG (default, "set default advanced internal options") \
43 CONFIG (plain, "disable all internal preprocessing options") \
44 CONFIG (sat, "set internal options to target satisfiable instances") \
45 CONFIG (unsat, "set internal options to target unsatisfiable instances")
46
47static const char *configs[] = {
48#define CONFIG(N, D) #N,
50#undef CONFIG
51};
52
53static size_t num_configs = sizeof configs / sizeof *configs;
54
55/*------------------------------------------------------------------------*/
56
57bool Config::has (const char *name) {
58#define CONFIG(N, D) \
59 if (!strcmp (name, #N)) \
60 return true;
62#undef CONFIG
63 return false;
64}
65
66bool Config::set (Options &opts, const char *name) {
67 if (!strcmp (name, "default")) {
68 opts.reset_default_values ();
69 return true;
70 }
71 if (!strcmp (name, "plain")) {
72 opts.disable_preprocessing ();
73 return true;
74 }
75#define CONFIG(N, D) \
76 do { \
77 if (strcmp (name, #N)) \
78 break; \
79 const NameVal *BEGIN = N##_config; \
80 const NameVal *END = BEGIN + sizeof N##_config / sizeof (NameVal); \
81 for (const NameVal *P = BEGIN; P != END; P++) { \
82 CADICAL_assert (Options::has (P->name)); \
83 opts.set (P->name, P->val); \
84 } \
85 return true; \
86 } while (0);
88#undef CONFIG
89 return false;
90}
91
92/*------------------------------------------------------------------------*/
93
95#define CONFIG(N, D) printf (" %-14s " D "\n", "--" #N);
97#undef CONFIG
98}
99
100/*------------------------------------------------------------------------*/
101
102const char **Config::begin () { return configs; }
103const char **Config::end () { return &configs[num_configs]; }
104
105} // namespace CaDiCaL
106
#define ABC_NAMESPACE_IMPL_START
#define ABC_NAMESPACE_IMPL_END
#define CONFIGS
char * name
Definition main.h:24
static const char ** end()
static void usage()
static bool has(const char *)
static bool set(Options &, const char *)
static const char ** begin()
int strcmp()