effspm 0.1.7__cp311-cp311-macosx_11_0_arm64.whl → 0.2.6__cp311-cp311-macosx_11_0_arm64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- effspm/__init__.py +10 -2
- effspm/_effspm.cpp +609 -0
- effspm/_effspm.cpython-311-darwin.so +0 -0
- effspm/btminer/src/build_mdd.cpp +63 -0
- effspm/btminer/src/build_mdd.hpp +40 -0
- effspm/btminer/src/freq_miner.cpp +179 -0
- effspm/btminer/src/freq_miner.hpp +39 -0
- effspm/btminer/src/load_inst.cpp +200 -0
- effspm/btminer/src/load_inst.hpp +25 -0
- effspm/btminer/src/utility.cpp +65 -0
- effspm/btminer/src/utility.hpp +40 -0
- effspm/freq_miner.hpp +4 -1
- effspm/htminer/src/build_mdd.cpp +192 -0
- effspm/htminer/src/build_mdd.hpp +64 -0
- effspm/htminer/src/freq_miner.cpp +350 -0
- effspm/htminer/src/freq_miner.hpp +60 -0
- effspm/htminer/src/load_inst.cpp +394 -0
- effspm/htminer/src/load_inst.hpp +23 -0
- effspm/htminer/src/utility.cpp +72 -0
- effspm/htminer/src/utility.hpp +77 -0
- effspm/largebm/src/build_mdd.cpp +137 -0
- effspm/largebm/src/build_mdd.hpp +47 -0
- effspm/largebm/src/freq_miner.cpp +349 -0
- effspm/largebm/src/freq_miner.hpp +48 -0
- effspm/largebm/src/load_inst.cpp +230 -0
- effspm/largebm/src/load_inst.hpp +45 -0
- effspm/largebm/src/utility.cpp +45 -0
- effspm/largebm/src/utility.hpp +18 -0
- effspm/largehm/src/build_mdd.cpp +174 -0
- effspm/largehm/src/build_mdd.hpp +93 -0
- effspm/largehm/src/freq_miner.cpp +445 -0
- effspm/largehm/src/freq_miner.hpp +77 -0
- effspm/largehm/src/load_inst.cpp +357 -0
- effspm/largehm/src/load_inst.hpp +64 -0
- effspm/largehm/src/utility.cpp +38 -0
- effspm/largehm/src/utility.hpp +29 -0
- effspm/largepp/src/freq_miner.cpp +170 -0
- effspm/largepp/src/freq_miner.hpp +43 -0
- effspm/largepp/src/load_inst.cpp +219 -0
- effspm/largepp/src/load_inst.hpp +28 -0
- effspm/largepp/src/utility.cpp +34 -0
- effspm/largepp/src/utility.hpp +21 -0
- effspm/load_inst.hpp +2 -1
- effspm-0.2.6.dist-info/METADATA +237 -0
- effspm-0.2.6.dist-info/RECORD +53 -0
- {effspm-0.1.7.dist-info → effspm-0.2.6.dist-info}/WHEEL +1 -2
- effspm/_core.cpython-311-darwin.so +0 -0
- effspm-0.1.7.dist-info/METADATA +0 -38
- effspm-0.1.7.dist-info/RECORD +0 -14
- {effspm-0.1.7.dist-info → effspm-0.2.6.dist-info}/licenses/LICENSE +0 -0
- {effspm-0.1.7.dist-info → effspm-0.2.6.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,445 @@
|
|
|
1
|
+
|
|
2
|
+
#include <cstdint>
|
|
3
|
+
#include <vector>
|
|
4
|
+
|
|
5
|
+
#include <iostream>
|
|
6
|
+
#include <time.h>
|
|
7
|
+
// for std::vector
|
|
8
|
+
#include <cmath> // for std::ceil
|
|
9
|
+
|
|
10
|
+
#include "freq_miner.hpp"
|
|
11
|
+
#include "build_mdd.hpp"
|
|
12
|
+
#include "utility.hpp"
|
|
13
|
+
std::vector<std::uint64_t> ancest_base;
|
|
14
|
+
namespace largehm {
|
|
15
|
+
|
|
16
|
+
void Out_patt(std::vector<int>& seq, unsigned int freq);
|
|
17
|
+
void Extend_patt(Pattern& _patt);
|
|
18
|
+
void Mine_vec(unsigned long long int seq_ID,
|
|
19
|
+
int pos,
|
|
20
|
+
int num_found,
|
|
21
|
+
|
|
22
|
+
std::vector<int>& items,
|
|
23
|
+
unsigned long long int inod,
|
|
24
|
+
int sgn);
|
|
25
|
+
|
|
26
|
+
unsigned long long int num_patt = 0;
|
|
27
|
+
|
|
28
|
+
std::vector<bool> ilist;
|
|
29
|
+
std::vector<bool> slist;
|
|
30
|
+
|
|
31
|
+
std::vector<Pattern> pot_patt;
|
|
32
|
+
std::vector<VPattern> pot_vpatt;
|
|
33
|
+
std::vector<unsigned long long int> last_strpnt;
|
|
34
|
+
|
|
35
|
+
std::vector<int> DFS_numfound;
|
|
36
|
+
|
|
37
|
+
Pattern _patt;
|
|
38
|
+
VPattern _vpatt;
|
|
39
|
+
|
|
40
|
+
int itmset_size;
|
|
41
|
+
int last_neg;
|
|
42
|
+
|
|
43
|
+
bool ilist_nempty;
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
void Freq_miner() {
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
// ─── Make sure DFS and VDFS are at least size L ─────────────────────────────
|
|
50
|
+
if (DFS.size() < static_cast<size_t>(L)) {
|
|
51
|
+
size_t old = DFS.size();
|
|
52
|
+
DFS.resize(static_cast<size_t>(L));
|
|
53
|
+
for (size_t i = old; i < DFS.size(); ++i) {
|
|
54
|
+
DFS[i] = Pattern(-static_cast<int>(i) - 1);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
if (VDFS.size() < static_cast<size_t>(L)) {
|
|
58
|
+
size_t old = VDFS.size();
|
|
59
|
+
VDFS.resize(static_cast<size_t>(L));
|
|
60
|
+
for (size_t i = old; i < VDFS.size(); ++i) {
|
|
61
|
+
VDFS[i] = VPattern(static_cast<int>(i));
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
if (!Tree.empty()) {
|
|
68
|
+
// std::cout << ", Tree[0].chld=" << Tree[0].chld
|
|
69
|
+
// << ", Tree[0].sibl=" << Tree[0].sibl
|
|
70
|
+
// << ", Tree[0].freq=" << Tree[0].freq;
|
|
71
|
+
}
|
|
72
|
+
// std::cout << ", DFS.size()=" << DFS.size()
|
|
73
|
+
// << ", theta=" << theta
|
|
74
|
+
// << ", M=" << M
|
|
75
|
+
// << ", E=" << E
|
|
76
|
+
// << std::endl;
|
|
77
|
+
|
|
78
|
+
std::vector<int> tmp_list;
|
|
79
|
+
for (int i = 0; i < static_cast<int>(L); ++i) {
|
|
80
|
+
if (DFS[i].freq >= theta) {
|
|
81
|
+
tmp_list.push_back(-i - 1);
|
|
82
|
+
if (itmset_exists) {
|
|
83
|
+
tmp_list.push_back(i + 1);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
for (int i = 0; i < static_cast<int>(DFS.size()); ++i) {
|
|
89
|
+
DFS[i].list = tmp_list;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
while (!DFS.empty() && give_time(std::clock() - start_time) < time_limit) {
|
|
93
|
+
if (DFS.back().freq >= theta) {
|
|
94
|
+
Extend_patt(DFS.back());
|
|
95
|
+
}
|
|
96
|
+
else {
|
|
97
|
+
DFS.pop_back();
|
|
98
|
+
if (!VDFS.empty() && VDFS.back().ass_patt == static_cast<int>(DFS.size())) {
|
|
99
|
+
VDFS.pop_back();
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
void Extend_patt(Pattern& _pattern) {
|
|
107
|
+
swap(_patt, _pattern);
|
|
108
|
+
DFS.pop_back();
|
|
109
|
+
|
|
110
|
+
slist = std::vector<bool>(L, false);
|
|
111
|
+
ilist_nempty = false;
|
|
112
|
+
|
|
113
|
+
if (itmset_exists) {
|
|
114
|
+
ilist = std::vector<bool>(L, false);
|
|
115
|
+
for (auto it = _patt.list.begin(); it != _patt.list.end(); ++it) {
|
|
116
|
+
if (*it < 0)
|
|
117
|
+
slist[-(*it) - 1] = true;
|
|
118
|
+
else {
|
|
119
|
+
ilist[(*it) - 1] = true;
|
|
120
|
+
ilist_nempty = true;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
else {
|
|
125
|
+
for (auto it = _patt.list.begin(); it != _patt.list.end(); ++it)
|
|
126
|
+
slist[-(*it) - 1] = true;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
last_neg = _patt.seq.size() - 1;
|
|
130
|
+
while (_patt.seq[last_neg] > 0)
|
|
131
|
+
--last_neg;
|
|
132
|
+
itmset_size = _patt.seq.size() - last_neg;
|
|
133
|
+
|
|
134
|
+
pot_patt = std::vector<Pattern>(L + L * (ilist_nempty ? 1 : 0));
|
|
135
|
+
if (!CTree.empty())
|
|
136
|
+
pot_vpatt = std::vector<VPattern>(L + L * (ilist_nempty ? 1 : 0));
|
|
137
|
+
|
|
138
|
+
last_strpnt = std::vector<unsigned long long int>(L, 0ULL);
|
|
139
|
+
|
|
140
|
+
if (!VDFS.empty() && VDFS.back().ass_patt == static_cast<int>(DFS.size())) {
|
|
141
|
+
swap(_vpatt, VDFS.back());
|
|
142
|
+
VDFS.pop_back();
|
|
143
|
+
for (unsigned long long int pnt = 0; pnt < _vpatt.str_pnt.size(); ++pnt) {
|
|
144
|
+
if (_vpatt.str_pnt[pnt] < 0) {
|
|
145
|
+
Mine_vec(_vpatt.seq_ID[pnt],
|
|
146
|
+
-_vpatt.str_pnt[pnt],
|
|
147
|
+
-1,
|
|
148
|
+
ancest_base,
|
|
149
|
+
CTree[_vpatt.seq_ID[pnt]].seq,
|
|
150
|
+
0,
|
|
151
|
+
-1);
|
|
152
|
+
}
|
|
153
|
+
else {
|
|
154
|
+
Mine_vec(_vpatt.seq_ID[pnt],
|
|
155
|
+
_vpatt.str_pnt[pnt],
|
|
156
|
+
-1,
|
|
157
|
+
ancest_base,
|
|
158
|
+
VTree[_vpatt.seq_ID[pnt]].seq,
|
|
159
|
+
0,
|
|
160
|
+
1);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
std::vector<unsigned long long int> DFS_itm;
|
|
166
|
+
std::vector<unsigned long long int> DFS_seq;
|
|
167
|
+
if (ilist_nempty)
|
|
168
|
+
DFS_numfound.clear();
|
|
169
|
+
|
|
170
|
+
for (unsigned long long int pnt = 0; pnt < _patt.str_pnt.size(); ++pnt) {
|
|
171
|
+
DFS_itm.push_back(_patt.str_pnt[pnt]);
|
|
172
|
+
while (!DFS_itm.empty()) {
|
|
173
|
+
unsigned long long int cur_sibl = DFS_itm.back();
|
|
174
|
+
DFS_itm.pop_back();
|
|
175
|
+
if (Tree[cur_sibl].itmset < 0) {
|
|
176
|
+
unsigned int carc = Tree[cur_sibl].chld;
|
|
177
|
+
Mine_vec(carc,
|
|
178
|
+
0,
|
|
179
|
+
-1,
|
|
180
|
+
CTree[carc].ancest,
|
|
181
|
+
CTree[carc].seq,
|
|
182
|
+
_patt.str_pnt[pnt],
|
|
183
|
+
-1);
|
|
184
|
+
cur_sibl = CTree[carc].ancest.back();
|
|
185
|
+
while (cur_sibl != 0) {
|
|
186
|
+
Mine_vec(cur_sibl - 1,
|
|
187
|
+
0,
|
|
188
|
+
-1,
|
|
189
|
+
CTree[carc].ancest,
|
|
190
|
+
VTree[cur_sibl - 1].seq,
|
|
191
|
+
_patt.str_pnt[pnt],
|
|
192
|
+
1);
|
|
193
|
+
cur_sibl = VTree[cur_sibl - 1].sibl;
|
|
194
|
+
}
|
|
195
|
+
continue;
|
|
196
|
+
}
|
|
197
|
+
cur_sibl = Tree[cur_sibl].chld;
|
|
198
|
+
while (cur_sibl != 0) {
|
|
199
|
+
int cur_itm = Tree[cur_sibl].item;
|
|
200
|
+
if (cur_itm < 0) {
|
|
201
|
+
cur_itm = -cur_itm;
|
|
202
|
+
if (slist[cur_itm - 1]) {
|
|
203
|
+
pot_patt[cur_itm - 1].freq += Tree[cur_sibl].freq;
|
|
204
|
+
if (Tree[cur_sibl].chld != 0 || Tree[cur_sibl].itmset < 0)
|
|
205
|
+
pot_patt[cur_itm - 1].str_pnt.push_back(cur_sibl);
|
|
206
|
+
}
|
|
207
|
+
if (Tree[cur_sibl].chld != 0 || Tree[cur_sibl].itmset < 0) {
|
|
208
|
+
DFS_seq.push_back(cur_sibl);
|
|
209
|
+
if (ilist_nempty) {
|
|
210
|
+
if (cur_itm == -_patt.seq[last_neg])
|
|
211
|
+
DFS_numfound.push_back(1);
|
|
212
|
+
else
|
|
213
|
+
DFS_numfound.push_back(0);
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
else {
|
|
218
|
+
if (ilist[cur_itm - 1]) {
|
|
219
|
+
pot_patt[cur_itm + L - 1].freq += Tree[cur_sibl].freq;
|
|
220
|
+
if (Tree[cur_sibl].chld != 0 || Tree[cur_sibl].itmset < 0)
|
|
221
|
+
pot_patt[cur_itm + L - 1].str_pnt.push_back(cur_sibl);
|
|
222
|
+
}
|
|
223
|
+
if (Tree[cur_sibl].chld != 0 || Tree[cur_sibl].itmset < 0)
|
|
224
|
+
DFS_itm.push_back(cur_sibl);
|
|
225
|
+
}
|
|
226
|
+
cur_sibl = Tree[cur_sibl].sibl;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
if (ilist_nempty) {
|
|
230
|
+
for (int i = 0; i < (int)L; ++i) {
|
|
231
|
+
if (ilist[i])
|
|
232
|
+
last_strpnt[i] = pot_patt[i + L].str_pnt.size();
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
while(!DFS_seq.empty()) {
|
|
236
|
+
unsigned long long int cur_sibl = DFS_seq.back();
|
|
237
|
+
DFS_seq.pop_back();
|
|
238
|
+
int num_found = 0;
|
|
239
|
+
if (ilist_nempty) {
|
|
240
|
+
num_found = DFS_numfound.back();
|
|
241
|
+
DFS_numfound.pop_back();
|
|
242
|
+
}
|
|
243
|
+
if (Tree[cur_sibl].itmset < 0) {
|
|
244
|
+
unsigned int carc = Tree[cur_sibl].chld;
|
|
245
|
+
Mine_vec(carc,
|
|
246
|
+
0,
|
|
247
|
+
num_found,
|
|
248
|
+
CTree[carc].ancest,
|
|
249
|
+
CTree[carc].seq,
|
|
250
|
+
_patt.str_pnt[pnt],
|
|
251
|
+
-1);
|
|
252
|
+
cur_sibl = CTree[carc].ancest.back();
|
|
253
|
+
while (cur_sibl != 0) {
|
|
254
|
+
Mine_vec(cur_sibl - 1,
|
|
255
|
+
0,
|
|
256
|
+
num_found,
|
|
257
|
+
CTree[carc].ancest,
|
|
258
|
+
VTree[cur_sibl - 1].seq,
|
|
259
|
+
_patt.str_pnt[pnt],
|
|
260
|
+
1);
|
|
261
|
+
cur_sibl = VTree[cur_sibl - 1].sibl;
|
|
262
|
+
}
|
|
263
|
+
continue;
|
|
264
|
+
}
|
|
265
|
+
cur_sibl = Tree[cur_sibl].chld;
|
|
266
|
+
while (cur_sibl != 0) {
|
|
267
|
+
int cur_itm = Tree[cur_sibl].item;
|
|
268
|
+
if (cur_itm > 0) {
|
|
269
|
+
if (num_found == itmset_size &&
|
|
270
|
+
ilist[cur_itm - 1] &&
|
|
271
|
+
(std::abs(Tree[Tree[cur_sibl].anct].itmset) < std::abs(Tree[_patt.str_pnt[pnt]].itmset)
|
|
272
|
+
|| !check_parent(Tree[cur_sibl].anct,
|
|
273
|
+
_patt.str_pnt[pnt],
|
|
274
|
+
last_strpnt[cur_itm - 1],
|
|
275
|
+
pot_patt[cur_itm + L - 1].str_pnt)))
|
|
276
|
+
{
|
|
277
|
+
pot_patt[cur_itm + L - 1].freq += Tree[cur_sibl].freq;
|
|
278
|
+
if (Tree[cur_sibl].chld != 0 || Tree[cur_sibl].itmset < 0)
|
|
279
|
+
pot_patt[cur_itm + L - 1].str_pnt.push_back(cur_sibl);
|
|
280
|
+
}
|
|
281
|
+
if (slist[cur_itm - 1] &&
|
|
282
|
+
std::abs(Tree[Tree[cur_sibl].anct].itmset) <= std::abs(Tree[_patt.str_pnt[pnt]].itmset))
|
|
283
|
+
{
|
|
284
|
+
pot_patt[cur_itm - 1].freq += Tree[cur_sibl].freq;
|
|
285
|
+
if (Tree[cur_sibl].chld != 0 || Tree[cur_sibl].itmset < 0)
|
|
286
|
+
pot_patt[cur_itm - 1].str_pnt.push_back(cur_sibl);
|
|
287
|
+
}
|
|
288
|
+
if (Tree[cur_sibl].chld != 0 || Tree[cur_sibl].itmset < 0) {
|
|
289
|
+
DFS_seq.push_back(cur_sibl);
|
|
290
|
+
if (ilist_nempty) {
|
|
291
|
+
if (num_found < itmset_size
|
|
292
|
+
&& cur_itm == std::abs(_patt.seq[last_neg + num_found]))
|
|
293
|
+
DFS_numfound.push_back(num_found + 1);
|
|
294
|
+
else
|
|
295
|
+
DFS_numfound.push_back(num_found);
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
else {
|
|
300
|
+
cur_itm = -cur_itm;
|
|
301
|
+
if (slist[cur_itm - 1] &&
|
|
302
|
+
std::abs(Tree[Tree[cur_sibl].anct].itmset) <= std::abs(Tree[_patt.str_pnt[pnt]].itmset))
|
|
303
|
+
{
|
|
304
|
+
pot_patt[cur_itm - 1].freq += Tree[cur_sibl].freq;
|
|
305
|
+
if (Tree[cur_sibl].chld != 0 || Tree[cur_sibl].itmset < 0)
|
|
306
|
+
pot_patt[cur_itm - 1].str_pnt.push_back(cur_sibl);
|
|
307
|
+
}
|
|
308
|
+
if (Tree[cur_sibl].chld != 0 || Tree[cur_sibl].itmset < 0) {
|
|
309
|
+
DFS_seq.push_back(cur_sibl);
|
|
310
|
+
if (ilist_nempty) {
|
|
311
|
+
if (cur_itm == -_patt.seq[last_neg])
|
|
312
|
+
DFS_numfound.push_back(1);
|
|
313
|
+
else
|
|
314
|
+
DFS_numfound.push_back(0);
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
cur_sibl = Tree[cur_sibl].sibl;
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
std::vector<int> ilistp;
|
|
324
|
+
std::vector<int> slistp;
|
|
325
|
+
for (auto it = _patt.list.begin(); it != _patt.list.end(); ++it) {
|
|
326
|
+
if (*it > 0 && pot_patt[(*it) + L - 1].freq >= theta)
|
|
327
|
+
ilistp.push_back(*it);
|
|
328
|
+
else if (*it < 0 && pot_patt[-(*it) - 1].freq >= theta) {
|
|
329
|
+
if (itmset_exists)
|
|
330
|
+
slistp.push_back(-(*it));
|
|
331
|
+
ilistp.push_back(*it);
|
|
332
|
+
slistp.push_back(*it);
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
for (auto it = ilistp.begin(); it != ilistp.end(); ++it) {
|
|
337
|
+
int p;
|
|
338
|
+
if (*it < 0)
|
|
339
|
+
p = -(*it) - 1;
|
|
340
|
+
else
|
|
341
|
+
p = (*it) - 1 + L;
|
|
342
|
+
pot_patt[p].str_pnt.shrink_to_fit();
|
|
343
|
+
DFS.push_back(pot_patt[p]);
|
|
344
|
+
DFS.back().seq = _patt.seq;
|
|
345
|
+
DFS.back().seq.push_back(*it);
|
|
346
|
+
if (*it < 0)
|
|
347
|
+
DFS.back().list = slistp;
|
|
348
|
+
else
|
|
349
|
+
DFS.back().list = ilistp;
|
|
350
|
+
if (!CTree.empty() && !pot_vpatt[p].str_pnt.empty()) {
|
|
351
|
+
pot_vpatt[p].ass_patt = static_cast<int>(DFS.size()) - 1;
|
|
352
|
+
VDFS.push_back(pot_vpatt[p]);
|
|
353
|
+
}
|
|
354
|
+
if (b_disp || b_write)
|
|
355
|
+
Out_patt(DFS.back().seq, DFS.back().freq);
|
|
356
|
+
++num_patt;
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
|
|
361
|
+
void Mine_vec(std::uint64_t seq_ID,
|
|
362
|
+
int pos,
|
|
363
|
+
int num_found,
|
|
364
|
+
std::vector<std::uint64_t>& ancest,
|
|
365
|
+
std::vector<int>& items,
|
|
366
|
+
std::uint64_t pnt,
|
|
367
|
+
int sgn)
|
|
368
|
+
{
|
|
369
|
+
std::vector<bool> found(L + L * (ilist_nempty ? 1 : 0), false);
|
|
370
|
+
|
|
371
|
+
if (num_found == -1) {
|
|
372
|
+
while (pos < static_cast<int>(items.size()) && items[pos] > 0) {
|
|
373
|
+
int cur_itm = items[pos];
|
|
374
|
+
if (ilist[cur_itm - 1] && !found[cur_itm + L - 1]) {
|
|
375
|
+
if (pos + 1 < static_cast<int>(items.size())) {
|
|
376
|
+
pot_vpatt[cur_itm + L - 1].seq_ID.push_back(seq_ID);
|
|
377
|
+
pot_vpatt[cur_itm + L - 1].str_pnt.push_back(sgn * (pos + 1));
|
|
378
|
+
}
|
|
379
|
+
++pot_patt[cur_itm + L - 1].freq;
|
|
380
|
+
found[cur_itm + L - 1] = true;
|
|
381
|
+
}
|
|
382
|
+
++pos;
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
for (unsigned int k = pos; k < items.size(); ++k) {
|
|
387
|
+
int cur_itm = std::abs(items[k]);
|
|
388
|
+
if (items[k] < 0)
|
|
389
|
+
num_found = 0;
|
|
390
|
+
if (slist[cur_itm - 1] && !found[cur_itm - 1]) {
|
|
391
|
+
if (ancest.empty() || std::abs(Tree[ancest[cur_itm - 1]].itmset) <= std::abs(Tree[pnt].itmset)) {
|
|
392
|
+
if (k + 1 < static_cast<int>(items.size())) {
|
|
393
|
+
pot_vpatt[cur_itm - 1].seq_ID.push_back(seq_ID);
|
|
394
|
+
pot_vpatt[cur_itm - 1].str_pnt.push_back(sgn * (k + 1));
|
|
395
|
+
}
|
|
396
|
+
++pot_patt[cur_itm - 1].freq;
|
|
397
|
+
}
|
|
398
|
+
found[cur_itm - 1] = true;
|
|
399
|
+
}
|
|
400
|
+
if (num_found == itmset_size) {
|
|
401
|
+
if (ilist[cur_itm - 1] && !found[cur_itm + L - 1]) {
|
|
402
|
+
if (ancest.empty() ||
|
|
403
|
+
std::abs(Tree[ancest[cur_itm - 1]].itmset) < std::abs(Tree[pnt].itmset)
|
|
404
|
+
|| !check_parent(ancest[cur_itm - 1], pnt, last_strpnt[cur_itm - 1], pot_patt[cur_itm + L - 1].str_pnt))
|
|
405
|
+
{
|
|
406
|
+
if (k + 1 < static_cast<int>(items.size())) {
|
|
407
|
+
pot_vpatt[cur_itm + L - 1].seq_ID.push_back(seq_ID);
|
|
408
|
+
pot_vpatt[cur_itm + L - 1].str_pnt.push_back(sgn * (k + 1));
|
|
409
|
+
}
|
|
410
|
+
++pot_patt[cur_itm + L - 1].freq;
|
|
411
|
+
}
|
|
412
|
+
found[cur_itm + L - 1] = true;
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
else if (cur_itm == std::abs(_patt.seq[last_neg + num_found])) {
|
|
416
|
+
++num_found;
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
|
|
422
|
+
void Out_patt(std::vector<int>& seq, unsigned int freq) {
|
|
423
|
+
largehm::collected.push_back(seq);
|
|
424
|
+
std::ofstream file_o;
|
|
425
|
+
if (b_write)
|
|
426
|
+
file_o.open(out_file, std::ios::app);
|
|
427
|
+
|
|
428
|
+
for (int ii = 0; ii < static_cast<int>(seq.size()); ii++) {
|
|
429
|
+
if (b_disp)
|
|
430
|
+
std::cout << seq[ii] << " ";
|
|
431
|
+
if (b_write)
|
|
432
|
+
file_o << seq[ii] << " ";
|
|
433
|
+
}
|
|
434
|
+
if (b_disp)
|
|
435
|
+
std::cout << std::endl;
|
|
436
|
+
if (b_write) {
|
|
437
|
+
file_o << std::endl;
|
|
438
|
+
file_o << "************** Freq: " << freq << std::endl;
|
|
439
|
+
file_o.close();
|
|
440
|
+
}
|
|
441
|
+
if (b_disp)
|
|
442
|
+
std::cout << "************** Freq: " << freq << std::endl;
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
} // namespace largehm
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
#ifndef LARGEHM_FREQ_MINER_HPP
|
|
2
|
+
#define LARGEHM_FREQ_MINER_HPP
|
|
3
|
+
#include <cstdint>
|
|
4
|
+
#include <vector>
|
|
5
|
+
#include <string>
|
|
6
|
+
#include <fstream>
|
|
7
|
+
#include <ctime> // for clock_t
|
|
8
|
+
extern std::vector<std::uint64_t> ancest_base;
|
|
9
|
+
namespace largehm {
|
|
10
|
+
|
|
11
|
+
//
|
|
12
|
+
// ─── Pattern & VPattern ──────────────────────────────────────────────────────
|
|
13
|
+
//
|
|
14
|
+
|
|
15
|
+
class Pattern {
|
|
16
|
+
public:
|
|
17
|
+
std::vector<int> seq;
|
|
18
|
+
unsigned int freq;
|
|
19
|
+
std::vector<int> list;
|
|
20
|
+
std::vector<unsigned long long int> str_pnt;
|
|
21
|
+
|
|
22
|
+
Pattern(int start_code = 0) : freq(0) {
|
|
23
|
+
if (start_code != 0)
|
|
24
|
+
seq.push_back(start_code);
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
class VPattern {
|
|
29
|
+
public:
|
|
30
|
+
std::vector<unsigned long long int> str_pnt;
|
|
31
|
+
std::vector<unsigned long long int> seq_ID;
|
|
32
|
+
int ass_patt;
|
|
33
|
+
|
|
34
|
+
VPattern(int assoc = -1) : ass_patt(assoc) {}
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
//
|
|
38
|
+
// ─── Globals used by Freq_miner ──────────────────────────────────────────────
|
|
39
|
+
//
|
|
40
|
+
extern std::vector<Pattern> DFS;
|
|
41
|
+
extern std::vector<VPattern> VDFS;
|
|
42
|
+
|
|
43
|
+
extern unsigned long long int num_patt;
|
|
44
|
+
|
|
45
|
+
extern std::vector<bool> ilist;
|
|
46
|
+
extern std::vector<bool> slist;
|
|
47
|
+
|
|
48
|
+
extern std::vector<Pattern> pot_patt;
|
|
49
|
+
extern std::vector<VPattern> pot_vpatt;
|
|
50
|
+
extern std::vector<unsigned long long int> last_strpnt;
|
|
51
|
+
|
|
52
|
+
extern std::vector<int> DFS_numfound;
|
|
53
|
+
|
|
54
|
+
extern Pattern _patt;
|
|
55
|
+
extern VPattern _vpatt;
|
|
56
|
+
|
|
57
|
+
extern int itmset_size;
|
|
58
|
+
extern int last_neg;
|
|
59
|
+
extern bool ilist_nempty;
|
|
60
|
+
|
|
61
|
+
//
|
|
62
|
+
// ─── Function Prototypes ─────────────────────────────────────────────────────
|
|
63
|
+
//
|
|
64
|
+
void Freq_miner();
|
|
65
|
+
void Extend_patt(Pattern& _patt);
|
|
66
|
+
void Mine_vec(std::uint64_t seq_ID,
|
|
67
|
+
int pos,
|
|
68
|
+
int num_found,
|
|
69
|
+
std::vector<std::uint64_t>& ancest,
|
|
70
|
+
std::vector<int>& items,
|
|
71
|
+
std::uint64_t pnt,
|
|
72
|
+
int sgn);
|
|
73
|
+
void Out_patt(std::vector<int>& seq, unsigned int freq);
|
|
74
|
+
|
|
75
|
+
} // namespace largehm
|
|
76
|
+
|
|
77
|
+
#endif // LARGEHM_FREQ_MINER_HPP
|