ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
cadical_limit.cpp
Go to the documentation of this file.
1#include "global.h"
2
3#include "internal.hpp"
4
6
7namespace CaDiCaL {
8
9Limit::Limit () { memset (this, 0, sizeof *this); }
10
11/*------------------------------------------------------------------------*/
12
13double Internal::scale (double v) const {
14 const double ratio = clause_variable_ratio ();
15 const double factor = (ratio <= 2) ? 1.0 : log (ratio) / log (2);
16 double res = factor * v;
17 if (res < 1)
18 res = 1;
19 return res;
20}
21
22/*------------------------------------------------------------------------*/
23
24Last::Last () { memset (this, 0, sizeof *this); }
25
26/*------------------------------------------------------------------------*/
27
29 memset (this, 0, sizeof *this);
30 decisions = conflicts = -1; // unlimited
31}
32
34 if (l <= 0 && !lim.terminate.forced) {
35 LOG ("keeping unbounded terminate limit");
36 } else if (l <= 0) {
37 LOG ("reset terminate limit to be unbounded");
38 lim.terminate.forced = 0;
39 } else {
40 lim.terminate.forced = l;
41 LOG ("new terminate limit of %d calls", l);
42 }
43}
44
46 if (l < 0 && inc.conflicts < 0) {
47 LOG ("keeping unbounded conflict limit");
48 } else if (l < 0) {
49 LOG ("reset conflict limit to be unbounded");
50 inc.conflicts = -1;
51 } else {
52 inc.conflicts = l;
53 LOG ("new conflict limit of %d conflicts", l);
54 }
55}
56
58 if (l < 0 && inc.decisions < 0) {
59 LOG ("keeping unbounded decision limit");
60 } else if (l < 0) {
61 LOG ("reset decision limit to be unbounded");
62 inc.decisions = -1;
63 } else {
64 inc.decisions = l;
65 LOG ("new decision limit of %d decisions", l);
66 }
67}
68
70 if (l < 0) {
71 LOG ("ignoring invalid preprocessing limit %d", l);
72 } else if (!l) {
73 LOG ("reset preprocessing limit to no preprocessing");
74 inc.preprocessing = 0;
75 } else {
76 inc.preprocessing = l;
77 LOG ("new preprocessing limit of %d preprocessing rounds", l);
78 }
79}
80
82 if (l < 0) {
83 LOG ("ignoring invalid local search limit %d", l);
84 } else if (!l) {
85 LOG ("reset local search limit to no local search");
86 inc.localsearch = 0;
87 } else {
88 inc.localsearch = l;
89 LOG ("new local search limit of %d local search rounds", l);
90 }
91}
92
93bool Internal::is_valid_limit (const char *name) {
94 if (!strcmp (name, "terminate"))
95 return true;
96 if (!strcmp (name, "conflicts"))
97 return true;
98 if (!strcmp (name, "decisions"))
99 return true;
100 if (!strcmp (name, "preprocessing"))
101 return true;
102 if (!strcmp (name, "localsearch"))
103 return true;
104 return false;
105}
106
107bool Internal::limit (const char *name, int l) {
108 bool res = true;
109 if (!strcmp (name, "terminate"))
110 limit_terminate (l);
111 else if (!strcmp (name, "conflicts"))
112 limit_conflicts (l);
113 else if (!strcmp (name, "decisions"))
114 limit_decisions (l);
115 else if (!strcmp (name, "preprocessing"))
117 else if (!strcmp (name, "localsearch"))
119 else
120 res = false;
121 return res;
122}
123
125 LOG ("reset limits");
126 limit_terminate (0);
127 limit_conflicts (-1);
128 limit_decisions (-1);
131}
132
133} // namespace CaDiCaL
134
#define ABC_NAMESPACE_IMPL_START
#define ABC_NAMESPACE_IMPL_END
#define LOG(...)
char * name
Definition main.h:24
int64_t decisions
Definition limit.hpp:125
int64_t conflicts
Definition limit.hpp:124
double clause_variable_ratio() const
Definition internal.hpp:385
double scale(double v) const
static bool is_valid_limit(const char *name)
void limit_local_search(int)
void limit_terminate(int)
bool limit(const char *name, int)
void limit_preprocessing(int)
void limit_decisions(int)
void limit_conflicts(int)
char * memset()
int strcmp()