ABC: A System for Sequential Synthesis and Verification
Loading...
Searching...
No Matches
cadical_queue.cpp
Go to the documentation of this file.
1
#include "
global.h
"
2
3
#include "
internal.hpp
"
4
5
ABC_NAMESPACE_IMPL_START
6
7
namespace
CaDiCaL
{
8
9
// Slightly different than 'bump_variable' since the variable is not
10
// enqueued at all.
11
12
inline
void
Internal::init_enqueue
(
int
idx) {
13
Link
&l =
links
[idx];
14
if
(
opts
.reverse) {
15
l.
prev
= 0;
16
if
(
queue
.first) {
17
CADICAL_assert
(!
links
[
queue
.first].prev);
18
links
[
queue
.first].prev = idx;
19
btab
[idx] =
btab
[
queue
.first] - 1;
20
}
else
{
21
CADICAL_assert
(!
queue
.last);
22
queue
.last = idx;
23
btab
[idx] = 0;
24
}
25
CADICAL_assert
(
btab
[idx] <=
stats
.bumped);
26
l.
next
=
queue
.first;
27
queue
.first = idx;
28
if
(!
queue
.unassigned)
29
update_queue_unassigned
(
queue
.last);
30
}
else
{
31
l.
next
= 0;
32
if
(
queue
.last) {
33
CADICAL_assert
(!
links
[
queue
.last].next);
34
links
[
queue
.last].next = idx;
35
}
else
{
36
CADICAL_assert
(!
queue
.first);
37
queue
.first = idx;
38
}
39
btab
[idx] = ++
stats
.bumped;
40
l.
prev
=
queue
.last;
41
queue
.last = idx;
42
update_queue_unassigned
(
queue
.last);
43
}
44
}
45
46
// Initialize VMTF queue from current 'old_max_var + 1' to 'new_max_var'.
47
// This incorporates an initial variable order. We currently simply assume
48
// that variables with smaller index are more important. This is the same
49
// as in MiniSAT (implicitly) and also matches the 'scores' initialization.
50
//
51
void
Internal::init_queue
(
int
old_max_var,
int
new_max_var) {
52
LOG
(
"initializing VMTF queue from %d to %d"
, old_max_var + 1,
53
new_max_var);
54
CADICAL_assert
(old_max_var < new_max_var);
55
// New variables can be created that can invoke enlarge anytime (eg via
56
// calls during ipasir-up call-backs), thus assuming (!level) is not
57
// correct
58
for
(
int
idx = old_max_var; idx < new_max_var; idx++)
59
init_enqueue
(idx + 1);
60
}
61
62
// Shuffle the VMTF queue.
63
64
void
Internal::shuffle_queue
() {
65
if
(!
opts
.shuffle)
66
return
;
67
if
(!
opts
.shufflequeue)
68
return
;
69
stats
.shuffled++;
70
LOG
(
"shuffling queue"
);
71
vector<int>
shuffle;
72
if
(
opts
.shufflerandom) {
73
for
(
int
idx =
max_var
; idx; idx--)
74
shuffle.push_back (idx);
75
Random
random
(
opts
.seed);
// global seed
76
random
+=
stats
.shuffled;
// different every time
77
for
(
int
i = 0; i <=
max_var
- 2; i++) {
78
const
int
j =
random
.pick_int (i,
max_var
- 1);
79
swap (shuffle[i], shuffle[j]);
80
}
81
}
else
{
82
for
(
int
idx =
queue
.last; idx; idx =
links
[idx].prev)
83
shuffle.push_back (idx);
84
}
85
queue
.first =
queue
.last = 0;
86
for
(
const
int
idx : shuffle)
87
queue
.enqueue (
links
, idx);
88
int64_t
bumped
=
queue
.bumped;
89
for
(
int
idx =
queue
.last; idx; idx =
links
[idx].prev)
90
btab
[idx] =
bumped
--;
91
queue
.unassigned =
queue
.last;
92
}
93
94
}
// namespace CaDiCaL
95
96
ABC_NAMESPACE_IMPL_END
ABC_NAMESPACE_IMPL_START
#define ABC_NAMESPACE_IMPL_START
Definition
abc_namespaces.h:54
ABC_NAMESPACE_IMPL_END
#define ABC_NAMESPACE_IMPL_END
Definition
abc_namespaces.h:55
global.h
CADICAL_assert
#define CADICAL_assert(ignore)
Definition
global.h:14
LOG
#define LOG(...)
Definition
cadical_kitten.c:368
CaDiCaL::Random
Definition
random.hpp:14
internal.hpp
CaDiCaL
Definition
arena.hpp:8
CaDiCaL::Internal::max_var
int max_var
Definition
internal.hpp:200
CaDiCaL::Internal::update_queue_unassigned
void update_queue_unassigned(int idx)
Definition
internal.hpp:652
CaDiCaL::Internal::links
Links links
Definition
internal.hpp:227
CaDiCaL::Internal::stats
Stats stats
Definition
internal.hpp:302
CaDiCaL::Internal::init_queue
void init_queue(int old_max_var, int new_max_var)
Definition
cadical_queue.cpp:51
CaDiCaL::Internal::queue
Queue queue
Definition
internal.hpp:226
CaDiCaL::Internal::shuffle_queue
void shuffle_queue()
Definition
cadical_queue.cpp:64
CaDiCaL::Internal::opts
Options opts
Definition
internal.hpp:301
CaDiCaL::Internal::btab
vector< int64_t > btab
Definition
internal.hpp:234
CaDiCaL::Internal::init_enqueue
void init_enqueue(int idx)
Definition
cadical_queue.cpp:12
CaDiCaL::Internal::bumped
int64_t & bumped(int lit)
Definition
internal.hpp:455
CaDiCaL::Link
Definition
queue.hpp:14
CaDiCaL::Link::next
int next
Definition
queue.hpp:16
CaDiCaL::Link::prev
int prev
Definition
queue.hpp:16
vector
Definition
vector.h:32
random
long random()
src
sat
cadical
cadical_queue.cpp
Generated by Doxygen 1.13.2 © 2025 EPTansuo. All rights reserved.
鲁ICP备2021046540号