ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
queue.hpp
Go to the documentation of this file.
1#ifndef _queue_hpp_INCLUDED
2#define _queue_hpp_INCLUDED
3
4#include "global.h"
5
6#include <vector>
7
9
10namespace CaDiCaL {
11
12// Links for double linked decision queue.
13
14struct Link {
15
16 int prev, next; // variable indices
17
18 // initialized explicitly in 'init_queue'
19};
20
21typedef std::vector<Link> Links;
22
23// Variable move to front (VMTF) decision queue ordered by 'bumped'. See
24// our SAT'15 paper for an explanation on how this works.
25
26struct Queue {
27
28 // We use integers instead of variable pointers. This is more compact and
29 // also avoids issues due to moving the variable table during 'resize'.
30
31 int first, last; // anchors (head/tail) for doubly linked list
32 int unassigned; // all variables after this one are assigned
33 int64_t bumped; // see 'Internal.update_queue_unassigned'
34
35 Queue () : first (0), last (0), unassigned (0), bumped (0) {}
36
37 // We explicitly provide the mapping of integer indices to links to the
38 // following two (inlined) functions. This avoids including
39 // 'internal.hpp' and breaks a cyclic dependency, so we can keep their
40 // code here in this header file. Otherwise they are just ordinary doubly
41 // linked list 'dequeue' and 'enqueue' operations.
42
43 inline void dequeue (Links &links, int idx) {
44 Link &l = links[idx];
45 if (l.prev)
46 links[l.prev].next = l.next;
47 else
48 first = l.next;
49 if (l.next)
50 links[l.next].prev = l.prev;
51 else
52 last = l.prev;
53 }
54
55 inline void enqueue (Links &links, int idx) {
56 Link &l = links[idx];
57 if ((l.prev = last))
58 links[last].next = idx;
59 else
60 first = idx;
61 last = idx;
62 l.next = 0;
63 }
64};
65
66} // namespace CaDiCaL
67
69
70#endif
#define ABC_NAMESPACE_CXX_HEADER_START
#define ABC_NAMESPACE_CXX_HEADER_END
std::vector< Link > Links
Definition queue.hpp:21
void dequeue(Links &links, int idx)
Definition queue.hpp:43
int64_t bumped
Definition queue.hpp:33
void enqueue(Links &links, int idx)
Definition queue.hpp:55