forked from vprover/vampire
-
Notifications
You must be signed in to change notification settings - Fork 0
/
RestartStrategy.hpp
134 lines (112 loc) · 3.56 KB
/
RestartStrategy.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
/*
* File RestartStrategy.hpp.
*
* This file is part of the source code of the software program
* Vampire. It is protected by applicable
* copyright laws.
*
* This source code is distributed under the licence found here
* https://vprover.github.io/license.html
* and in the source directory
*
* In summary, you are allowed to use Vampire for non-commercial
* purposes but not allowed to distribute, modify, copy, create derivatives,
* or use in competitions.
* For other uses of Vampire please contact developers for a different
* licence, which we will make an effort to provide.
*/
/**
* @file RestartStrategy.hpp
* Defines class RestartStrategy.
*/
#ifndef __RestartStrategy__
#define __RestartStrategy__
#include "Forwards.hpp"
namespace SAT {
class RestartStrategy {
public:
virtual ~RestartStrategy() {}
virtual size_t getNextConflictCount() = 0;
virtual void reset() = 0;
protected:
static size_t increase(size_t val, float quotient);
};
class FixedRestartStrategy : public RestartStrategy {
public:
CLASS_NAME(FixedRestartStrategy);
USE_ALLOCATOR(FixedRestartStrategy);
/**
* Create restart strategy with specified number of conflicts between
* restarts
*
* The default value 16,000 belong to the best-performing fixed strategy
* in the "Jinbo Huang, The Effect of Restarts on the Efficiency of Clause
* Learning, 2007" paper.
*/
FixedRestartStrategy(size_t conflictCnt = 16000)
: _conflictCnt(conflictCnt) {}
virtual size_t getNextConflictCount() { return _conflictCnt; }
virtual void reset() {}
private:
size_t _conflictCnt;
};
class GeometricRestartStrategy : public RestartStrategy {
public:
CLASS_NAME(GeometricRestartStrategy);
USE_ALLOCATOR(GeometricRestartStrategy);
/**
* Create a geometric restart strategy with specified parameters
*
* The default values belong to the best-performing geometric strategy
* in the "Jinbo Huang, The Effect of Restarts on the Efficiency of Clause
* Learning, 2007" paper.
*/
GeometricRestartStrategy(size_t initCnt = 32, float increase=1.1f)
: _initConflictCnt(initCnt), _conflictCnt(initCnt), _increase(increase) {}
virtual size_t getNextConflictCount();
virtual void reset() { _conflictCnt = _initConflictCnt; }
private:
size_t _initConflictCnt;
size_t _conflictCnt;
float _increase;
};
class LubyRestartStrategy : public RestartStrategy {
public:
CLASS_NAME(LubyRestartStrategy);
USE_ALLOCATOR(LubyRestartStrategy);
/**
* Create a Luby restart strategy with specified factor
*
* The algorithm from Luby numbers and the factor default value is based on
* http://www.satcompetition.org/gorydetails/?p=3
*/
LubyRestartStrategy(size_t factor = 512)
: _index(1), _factor(factor) {}
virtual size_t getNextConflictCount() { return getLubyNumber(_index++)*_factor; }
virtual void reset() { _index = 1; }
private:
static size_t getLubyNumber(size_t i);
size_t _index;
size_t _factor;
};
class MinisatRestartStrategy : public RestartStrategy {
public:
CLASS_NAME(MinisatRestartStrategy);
USE_ALLOCATOR(MinisatRestartStrategy);
/**
* Create a Minisat restart strategy with specified parameters
*
* According to "Armin Biere, PicoSAT Essentials" paper.
*/
MinisatRestartStrategy(size_t initCnt = 100, float increase=1.1f)
: _initConflictCnt(initCnt), _increase(increase) { reset(); }
virtual size_t getNextConflictCount();
virtual void reset() { _innerCnt = _outerCnt = _initConflictCnt; }
private:
size_t _initConflictCnt;
size_t _innerCnt;
size_t _outerCnt;
float _increase;
};
}
#endif // __RestartStrategy__