nysol-take 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/bin/mbiclique.rb +317 -0
- data/bin/mbipolish.rb +362 -0
- data/bin/mccomp.rb +235 -0
- data/bin/mclique.rb +295 -0
- data/bin/mclique2g.rb +105 -0
- data/bin/mcliqueInfo.rb +203 -0
- data/bin/mfriends.rb +202 -0
- data/bin/mgdiff.rb +252 -0
- data/bin/mhifriend.rb +456 -0
- data/bin/mhipolish.rb +465 -0
- data/bin/mitemset.rb +168 -0
- data/bin/mpal.rb +410 -0
- data/bin/mpolishing.rb +399 -0
- data/bin/msequence.rb +165 -0
- data/bin/mtra2g.rb +476 -0
- data/bin/mtra2gc.rb +360 -0
- data/ext/grhfilrun/extconf.rb +12 -0
- data/ext/grhfilrun/grhfilrun.c +85 -0
- data/ext/grhfilrun/src/_sspc.c +358 -0
- data/ext/grhfilrun/src/aheap.c +545 -0
- data/ext/grhfilrun/src/aheap.h +251 -0
- data/ext/grhfilrun/src/base.c +92 -0
- data/ext/grhfilrun/src/base.h +59 -0
- data/ext/grhfilrun/src/fstar.c +497 -0
- data/ext/grhfilrun/src/fstar.h +80 -0
- data/ext/grhfilrun/src/grhfil.c +214 -0
- data/ext/grhfilrun/src/itemset.c +713 -0
- data/ext/grhfilrun/src/itemset.h +170 -0
- data/ext/grhfilrun/src/problem.c +415 -0
- data/ext/grhfilrun/src/problem.h +179 -0
- data/ext/grhfilrun/src/queue.c +533 -0
- data/ext/grhfilrun/src/queue.h +182 -0
- data/ext/grhfilrun/src/sample.c +19 -0
- data/ext/grhfilrun/src/sspc.c +597 -0
- data/ext/grhfilrun/src/sspc2.c +491 -0
- data/ext/grhfilrun/src/stdlib2.c +1482 -0
- data/ext/grhfilrun/src/stdlib2.h +892 -0
- data/ext/grhfilrun/src/trsact.c +817 -0
- data/ext/grhfilrun/src/trsact.h +160 -0
- data/ext/grhfilrun/src/vec.c +745 -0
- data/ext/grhfilrun/src/vec.h +172 -0
- data/ext/lcmrun/extconf.rb +20 -0
- data/ext/lcmrun/lcmrun.cpp +99 -0
- data/ext/lcmrun/src/aheap.c +216 -0
- data/ext/lcmrun/src/aheap.h +111 -0
- data/ext/lcmrun/src/base.c +92 -0
- data/ext/lcmrun/src/base.h +59 -0
- data/ext/lcmrun/src/itemset.c +496 -0
- data/ext/lcmrun/src/itemset.h +157 -0
- data/ext/lcmrun/src/lcm.c +427 -0
- data/ext/lcmrun/src/problem.c +349 -0
- data/ext/lcmrun/src/problem.h +177 -0
- data/ext/lcmrun/src/queue.c +528 -0
- data/ext/lcmrun/src/queue.h +176 -0
- data/ext/lcmrun/src/sgraph.c +359 -0
- data/ext/lcmrun/src/sgraph.h +173 -0
- data/ext/lcmrun/src/stdlib2.c +1282 -0
- data/ext/lcmrun/src/stdlib2.h +823 -0
- data/ext/lcmrun/src/trsact.c +747 -0
- data/ext/lcmrun/src/trsact.h +159 -0
- data/ext/lcmrun/src/vec.c +731 -0
- data/ext/lcmrun/src/vec.h +171 -0
- data/ext/lcmseq0run/extconf.rb +20 -0
- data/ext/lcmseq0run/lcmseq0run.cpp +59 -0
- data/ext/lcmseq0run/src/aheap.c +216 -0
- data/ext/lcmseq0run/src/aheap.h +111 -0
- data/ext/lcmseq0run/src/base.c +92 -0
- data/ext/lcmseq0run/src/base.h +59 -0
- data/ext/lcmseq0run/src/itemset.c +518 -0
- data/ext/lcmseq0run/src/itemset.h +157 -0
- data/ext/lcmseq0run/src/itemset_zero.c +522 -0
- data/ext/lcmseq0run/src/lcm_seq.c +446 -0
- data/ext/lcmseq0run/src/lcm_seq_zero.c +446 -0
- data/ext/lcmseq0run/src/problem.c +439 -0
- data/ext/lcmseq0run/src/problem.h +179 -0
- data/ext/lcmseq0run/src/problem_zero.c +439 -0
- data/ext/lcmseq0run/src/queue.c +533 -0
- data/ext/lcmseq0run/src/queue.h +182 -0
- data/ext/lcmseq0run/src/stdlib2.c +1350 -0
- data/ext/lcmseq0run/src/stdlib2.h +864 -0
- data/ext/lcmseq0run/src/trsact.c +747 -0
- data/ext/lcmseq0run/src/trsact.h +159 -0
- data/ext/lcmseq0run/src/vec.c +779 -0
- data/ext/lcmseq0run/src/vec.h +172 -0
- data/ext/lcmseqrun/extconf.rb +20 -0
- data/ext/lcmseqrun/lcmseqrun.cpp +101 -0
- data/ext/lcmseqrun/src/aheap.c +216 -0
- data/ext/lcmseqrun/src/aheap.h +111 -0
- data/ext/lcmseqrun/src/base.c +92 -0
- data/ext/lcmseqrun/src/base.h +59 -0
- data/ext/lcmseqrun/src/itemset.c +518 -0
- data/ext/lcmseqrun/src/itemset.h +157 -0
- data/ext/lcmseqrun/src/itemset_zero.c +522 -0
- data/ext/lcmseqrun/src/lcm_seq.c +447 -0
- data/ext/lcmseqrun/src/lcm_seq_zero.c +446 -0
- data/ext/lcmseqrun/src/problem.c +439 -0
- data/ext/lcmseqrun/src/problem.h +179 -0
- data/ext/lcmseqrun/src/problem_zero.c +439 -0
- data/ext/lcmseqrun/src/queue.c +533 -0
- data/ext/lcmseqrun/src/queue.h +182 -0
- data/ext/lcmseqrun/src/stdlib2.c +1350 -0
- data/ext/lcmseqrun/src/stdlib2.h +864 -0
- data/ext/lcmseqrun/src/trsact.c +747 -0
- data/ext/lcmseqrun/src/trsact.h +159 -0
- data/ext/lcmseqrun/src/vec.c +779 -0
- data/ext/lcmseqrun/src/vec.h +172 -0
- data/ext/lcmtransrun/extconf.rb +18 -0
- data/ext/lcmtransrun/lcmtransrun.cpp +264 -0
- data/ext/macerun/extconf.rb +20 -0
- data/ext/macerun/macerun.cpp +57 -0
- data/ext/macerun/src/aheap.c +217 -0
- data/ext/macerun/src/aheap.h +112 -0
- data/ext/macerun/src/itemset.c +491 -0
- data/ext/macerun/src/itemset.h +158 -0
- data/ext/macerun/src/mace.c +503 -0
- data/ext/macerun/src/problem.c +346 -0
- data/ext/macerun/src/problem.h +174 -0
- data/ext/macerun/src/queue.c +529 -0
- data/ext/macerun/src/queue.h +177 -0
- data/ext/macerun/src/sgraph.c +360 -0
- data/ext/macerun/src/sgraph.h +174 -0
- data/ext/macerun/src/stdlib2.c +993 -0
- data/ext/macerun/src/stdlib2.h +811 -0
- data/ext/macerun/src/vec.c +634 -0
- data/ext/macerun/src/vec.h +170 -0
- data/ext/sspcrun/extconf.rb +20 -0
- data/ext/sspcrun/src/_sspc.c +358 -0
- data/ext/sspcrun/src/aheap.c +545 -0
- data/ext/sspcrun/src/aheap.h +251 -0
- data/ext/sspcrun/src/base.c +92 -0
- data/ext/sspcrun/src/base.h +59 -0
- data/ext/sspcrun/src/fstar.c +496 -0
- data/ext/sspcrun/src/fstar.h +80 -0
- data/ext/sspcrun/src/grhfil.c +213 -0
- data/ext/sspcrun/src/itemset.c +713 -0
- data/ext/sspcrun/src/itemset.h +170 -0
- data/ext/sspcrun/src/problem.c +415 -0
- data/ext/sspcrun/src/problem.h +179 -0
- data/ext/sspcrun/src/queue.c +533 -0
- data/ext/sspcrun/src/queue.h +182 -0
- data/ext/sspcrun/src/sample.c +19 -0
- data/ext/sspcrun/src/sspc.c +598 -0
- data/ext/sspcrun/src/sspc2.c +491 -0
- data/ext/sspcrun/src/stdlib2.c +1482 -0
- data/ext/sspcrun/src/stdlib2.h +892 -0
- data/ext/sspcrun/src/trsact.c +817 -0
- data/ext/sspcrun/src/trsact.h +160 -0
- data/ext/sspcrun/src/vec.c +745 -0
- data/ext/sspcrun/src/vec.h +172 -0
- data/ext/sspcrun/sspcrun.cpp +54 -0
- data/lib/nysol/enumLcmEp.rb +338 -0
- data/lib/nysol/enumLcmEsp.rb +284 -0
- data/lib/nysol/enumLcmIs.rb +275 -0
- data/lib/nysol/enumLcmSeq.rb +143 -0
- data/lib/nysol/items.rb +201 -0
- data/lib/nysol/seqDB.rb +256 -0
- data/lib/nysol/take.rb +39 -0
- data/lib/nysol/taxonomy.rb +113 -0
- data/lib/nysol/traDB.rb +257 -0
- metadata +239 -0
@@ -0,0 +1,713 @@
|
|
1
|
+
/* itemset search input/output common routines
|
2
|
+
25/Nov/2007 by Takeaki Uno e-mail:uno@nii.jp,
|
3
|
+
homepage: http://research.nii.ac.jp/~uno/index.html */
|
4
|
+
/* This program is available for only academic use, basically.
|
5
|
+
Anyone can modify this program, but he/she has to write down
|
6
|
+
the change of the modification on the top of the source code.
|
7
|
+
Neither contact nor appointment to Takeaki Uno is needed.
|
8
|
+
If one wants to re-distribute this code, please
|
9
|
+
refer the newest code, and show the link to homepage of
|
10
|
+
Takeaki Uno, to notify the news about the codes for the users. */
|
11
|
+
|
12
|
+
/* routines for itemset mining */
|
13
|
+
|
14
|
+
#ifndef _itemset_c_
|
15
|
+
#define _itemset_c_
|
16
|
+
|
17
|
+
#include"itemset.h"
|
18
|
+
#include"queue.c"
|
19
|
+
#include"aheap.c"
|
20
|
+
|
21
|
+
/* flush the write buffer, available for multi-core mode */
|
22
|
+
void ITEMSET_flush (ITEMSET *I, FILE2 *fp){
|
23
|
+
if ( !(I->flag&ITEMSET_MULTI_OUTPUT) || (fp->buf-fp->buf_org) > FILE2_BUFSIZ/2 ){
|
24
|
+
SPIN_LOCK(I->multi_core, I->lock_output);
|
25
|
+
FILE2_flush (fp);
|
26
|
+
SPIN_UNLOCK(I->multi_core, I->lock_output);
|
27
|
+
}
|
28
|
+
}
|
29
|
+
|
30
|
+
/* Output information about ITEMSET structure. flag&1: print frequency constraint */
|
31
|
+
void ITEMSET_print (ITEMSET *I, int flag){
|
32
|
+
if ( I->lb>0 || I->ub<INTHUGE ){
|
33
|
+
if ( I->lb > 0 ) print_err ("%d <= ", I->lb);
|
34
|
+
print_err ("itemsets ");
|
35
|
+
if ( I->ub < INTHUGE ) print_err (" <= %d\n", I->ub);
|
36
|
+
print_err ("\n");
|
37
|
+
}
|
38
|
+
if ( flag&1 ){
|
39
|
+
if ( I->frq_lb > -WEIGHTHUGE ) print_err (WEIGHTF" <=", I->frq_lb);
|
40
|
+
print_err (" frequency ");
|
41
|
+
if ( I->frq_ub < WEIGHTHUGE ) print_err (" <="WEIGHTF, I->frq_ub);
|
42
|
+
print_err ("\n");
|
43
|
+
}
|
44
|
+
}
|
45
|
+
|
46
|
+
/* ITEMSET initialization */
|
47
|
+
void ITEMSET_init (ITEMSET *I){
|
48
|
+
I->flag = I->flag2 = 0;
|
49
|
+
I->progress = 0;
|
50
|
+
I->iters = I->iters2 = I->iters3 = 0;
|
51
|
+
I->solutions = I->solutions2 = I->max_solutions = I->outputs = I->outputs2 = 0;
|
52
|
+
I->topk.end = 0;
|
53
|
+
I->item_max = I->item_max_org = 0;
|
54
|
+
I->ub = I->len_ub = I->gap_ub = INTHUGE;
|
55
|
+
I->lb = I->len_lb = I->gap_lb = 0;
|
56
|
+
I->frq = I->pfrq = I->total_weight = 0;
|
57
|
+
I->ratio = I->prob = I->th = 0.0;
|
58
|
+
I->posi_ub = I->nega_ub = I->frq_ub = WEIGHTHUGE;
|
59
|
+
I->posi_lb = I->nega_lb = I->frq_lb = I->setrule_lb = -WEIGHTHUGE;
|
60
|
+
I->dir = 0;
|
61
|
+
I->target = INTHUGE;
|
62
|
+
I->prob_ub = I->ratio_ub = I->rposi_ub = 1;
|
63
|
+
I->prob_lb = I->ratio_lb = I->rposi_lb = 0;
|
64
|
+
I->itemflag = NULL;
|
65
|
+
I->perm = NULL;
|
66
|
+
I->item_frq = NULL;
|
67
|
+
I->sc = I->sc2 = NULL;
|
68
|
+
I->X = NULL;
|
69
|
+
I->fp = NULL;
|
70
|
+
I->separator = ' ';
|
71
|
+
I->digits = 4;
|
72
|
+
I->topk = INIT_AHEAP;
|
73
|
+
I->itemtopk = NULL;
|
74
|
+
I->itemtopk_ary = NULL;
|
75
|
+
I->itemtopk_item = I->itemtopk_item2 = I->itemtopk_end = 0;
|
76
|
+
I->topk_k = I->topk_frq = 0;
|
77
|
+
I->topk_sign = I->itemtopk_sign = 1; // initialization ; max topk
|
78
|
+
I->itemset = I->add = INIT_QUEUE;
|
79
|
+
I->set_weight = NULL;
|
80
|
+
I->set_occ = NULL;
|
81
|
+
|
82
|
+
I->minh = I->maxh = INIT_IHEAP;
|
83
|
+
I->patn = NULL;
|
84
|
+
|
85
|
+
I->multi_iters = I->multi_iters2 = I->multi_iters3 = NULL;
|
86
|
+
I->multi_outputs = I->multi_outputs2 = NULL;
|
87
|
+
I->multi_solutions = I->multi_solutions2 = NULL;
|
88
|
+
I->multi_fp = NULL;
|
89
|
+
|
90
|
+
I->multi_core = 0;
|
91
|
+
}
|
92
|
+
|
93
|
+
|
94
|
+
/* second initialization
|
95
|
+
topk.end>0 => initialize heap for topk mining */
|
96
|
+
/* all pointers will be set to 0, but not for */
|
97
|
+
/* if topK mining, set topk.end to "K" */
|
98
|
+
void ITEMSET_alloc (ITEMSET *I, char *fname, PERM *perm, QUEUE_INT item_max, size_t item_max_org){
|
99
|
+
LONG i, ii;
|
100
|
+
size_t siz = (I->flag&ITEMSET_USE_ORG)?item_max_org+2: item_max+2;
|
101
|
+
int j;
|
102
|
+
|
103
|
+
I->prob = I->ratio = 1.0;
|
104
|
+
I->frq = 0;
|
105
|
+
I->perm = perm;
|
106
|
+
I->topk.v = NULL;
|
107
|
+
QUEUE_alloc (&I->itemset, (QUEUE_ID)siz); I->itemset.end = (QUEUE_ID)siz;
|
108
|
+
if ( I->flag&ITEMSET_ADD ) QUEUE_alloc (&I->add, (QUEUE_ID)siz);
|
109
|
+
calloc2 (I->sc, siz+2, goto ERR);
|
110
|
+
if ( I->flag&ITEMSET_SC2 ) calloc2 (I->sc2, I->frq_ub+2, goto ERR); // upper bound of frequency
|
111
|
+
if ( I->flag2 & ITEMSET_LAMP ) I->topk_frq = I->frq_lb = 1; // LAMP mode
|
112
|
+
if ( I->flag2 & ITEMSET_LAMP2 ){
|
113
|
+
I->topk_frq = I->frq_lb = -WEIGHTHUGE; // 2D LAMP mode
|
114
|
+
malloc2 (I->patn, 100, goto ERR);
|
115
|
+
FLOOP (i, 0, 100) I->minh.v[i] = i;
|
116
|
+
malloc2 (I->minh.x, 101, goto ERR);
|
117
|
+
IHEAP_alloc (&I->minh, 100, 1, I->minh.x);
|
118
|
+
IHEAP_alloc (&I->maxh, 100, 2, I->minh.x);
|
119
|
+
}
|
120
|
+
if ( I->topk_k > 0 ){ // allocate topk heap
|
121
|
+
if (I->flag & ITEMSET_SC2){
|
122
|
+
I->frq_lb = 1; I->topk_frq = 0;
|
123
|
+
I->sc2[I->topk_frq] = I->topk_k;
|
124
|
+
} else {
|
125
|
+
AHEAP_alloc (&I->topk, I->topk_k);
|
126
|
+
FLOOP (i, 0, I->topk_k) AHEAP_chg (&I->topk, (AHEAP_ID)i, -WEIGHTHUGE);
|
127
|
+
I->frq_lb = -WEIGHTHUGE * I->topk_sign;
|
128
|
+
}
|
129
|
+
}
|
130
|
+
if ( I->itemtopk_end > 0 ){ // allocate topkheap for each element
|
131
|
+
calloc2 (I->itemtopk, I->itemtopk_end, goto ERR);
|
132
|
+
if ( I->itemtopk_item2 > 0 )
|
133
|
+
calloc2 (I->itemtopk_ary, I->itemtopk_end, goto ERR); // allocate itemary
|
134
|
+
FLOOP (i, 0, I->itemtopk_end){
|
135
|
+
AHEAP_alloc (&I->itemtopk[i], I->itemtopk_item);
|
136
|
+
if ( I->itemtopk_item2 > 0 )
|
137
|
+
calloc2 (I->itemtopk_ary[i], I->itemtopk_item, goto ERR); // allocate each itemary
|
138
|
+
FLOOP (ii, 0, I->itemtopk_item)
|
139
|
+
AHEAP_chg (&I->itemtopk[i], (AHEAP_ID)ii, -WEIGHTHUGE);
|
140
|
+
}
|
141
|
+
}
|
142
|
+
|
143
|
+
if ( I->flag&ITEMSET_SET_RULE ){
|
144
|
+
calloc2 (I->set_weight, siz, goto ERR);
|
145
|
+
if ( I->flag&(ITEMSET_TRSACT_ID+ITEMSET_MULTI_OCC_PRINT) )
|
146
|
+
calloc2 (I->set_occ, siz, goto ERR);
|
147
|
+
}
|
148
|
+
I->iters = I->iters2 = I->solutions = 0;
|
149
|
+
I->item_max = item_max;
|
150
|
+
I->item_max_org = (QUEUE_INT)item_max_org;
|
151
|
+
if ( fname ){
|
152
|
+
#ifdef _FILE2_LOAD_FROM_MEMORY_
|
153
|
+
I->fp = (FILE *)1;
|
154
|
+
#else
|
155
|
+
if ( strcmp (fname, "-") == 0 ) I->fp = stdout;
|
156
|
+
else fopen2 (I->fp, fname, (I->flag&ITEMSET_APPEND)?"a":"w", goto ERR);
|
157
|
+
#endif
|
158
|
+
} else I->fp = 0;
|
159
|
+
if ( I->flag&ITEMSET_ITEMFRQ )
|
160
|
+
malloc2 (I->item_frq, item_max+2, goto ERR);
|
161
|
+
if ( I->flag&ITEMSET_RULE ){
|
162
|
+
calloc2 (I->itemflag, item_max+2, goto ERR);
|
163
|
+
}
|
164
|
+
I->total_weight = 1;
|
165
|
+
j = MAX(I->multi_core,1);
|
166
|
+
calloc2 (I->multi_iters, j*7, goto ERR);
|
167
|
+
I->multi_iters2 = I->multi_iters + j;
|
168
|
+
I->multi_iters3 = I->multi_iters2 + j;
|
169
|
+
I->multi_outputs = I->multi_iters3 + j;
|
170
|
+
I->multi_outputs2 = I->multi_outputs + j;
|
171
|
+
I->multi_solutions = I->multi_outputs2 + j;
|
172
|
+
I->multi_solutions2 = I->multi_solutions + j;
|
173
|
+
|
174
|
+
calloc2 (I->multi_fp, j, goto ERR);
|
175
|
+
FLOOP (i, 0, j)
|
176
|
+
FILE2_open_ (I->multi_fp[i], I->fp, goto ERR);
|
177
|
+
#ifdef MULTI_CORE
|
178
|
+
if ( I->multi_core > 0 ){
|
179
|
+
pthread_spin_init (&I->lock_counter, PTHREAD_PROCESS_PRIVATE);
|
180
|
+
pthread_spin_init (&I->lock_sc, PTHREAD_PROCESS_PRIVATE);
|
181
|
+
pthread_spin_init (&I->lock_output, PTHREAD_PROCESS_PRIVATE);
|
182
|
+
}
|
183
|
+
#endif
|
184
|
+
return;
|
185
|
+
ERR:;
|
186
|
+
ITEMSET_end (I);
|
187
|
+
EXIT;
|
188
|
+
}
|
189
|
+
|
190
|
+
/* sum the counters computed by each thread */
|
191
|
+
void ITEMSET_merge_counters (ITEMSET *I){
|
192
|
+
int i;
|
193
|
+
FLOOP (i, 0, MAX(I->multi_core,1)){
|
194
|
+
I->iters += I->multi_iters[i];
|
195
|
+
I->iters2 += I->multi_iters2[i];
|
196
|
+
I->iters3 += I->multi_iters3[i];
|
197
|
+
I->outputs += I->multi_outputs[i];
|
198
|
+
I->outputs2 += I->multi_outputs2[i];
|
199
|
+
I->solutions += I->multi_solutions[i];
|
200
|
+
I->solutions2 += I->multi_solutions2[i];
|
201
|
+
if ( I->multi_fp[i].buf ) FILE2_flush_last (&I->multi_fp[i]);
|
202
|
+
}
|
203
|
+
ARY_FILL (I->multi_iters, 0, MAX(I->multi_core,1)*7, 0);
|
204
|
+
}
|
205
|
+
|
206
|
+
/*******************************************************************/
|
207
|
+
/* termination of ITEMSET */
|
208
|
+
/*******************************************************************/
|
209
|
+
void ITEMSET_end (ITEMSET *I){
|
210
|
+
LONG i;
|
211
|
+
QUEUE_end (&I->itemset);
|
212
|
+
QUEUE_end (&I->add);
|
213
|
+
AHEAP_end (&I->topk); IHEAP_end (&I->minh); IHEAP_end (&I->maxh);
|
214
|
+
if ( I->flag2 & ITEMSET_LAMP2 ) free2 (I->minh.x); // for 2D LAMP
|
215
|
+
FLOOP (i, 0, I->itemtopk_end){
|
216
|
+
AHEAP_end (&I->itemtopk[i]);
|
217
|
+
if ( I->itemtopk_ary ) free2 (I->itemtopk_ary[i]);
|
218
|
+
}
|
219
|
+
|
220
|
+
#ifndef _FILE2_LOAD_FROM_MEMORY_
|
221
|
+
fclose2 (I->fp);
|
222
|
+
#endif
|
223
|
+
mfree (I->sc, I->sc2, I->item_frq, I->itemflag, I->perm, I->set_weight, I->set_occ, I->itemtopk_ary);
|
224
|
+
|
225
|
+
if ( I->multi_fp )
|
226
|
+
FLOOP (i, 0, MAX(I->multi_core,1)) free2 (I->multi_fp[i].buf_org);
|
227
|
+
mfree (I->multi_iters, I->multi_fp);
|
228
|
+
#ifdef MULTI_CORE
|
229
|
+
if ( I->multi_core>0 ){
|
230
|
+
pthread_spin_destroy(&I->lock_counter);
|
231
|
+
pthread_spin_destroy(&I->lock_sc);
|
232
|
+
pthread_spin_destroy(&I->lock_output);
|
233
|
+
}
|
234
|
+
#endif
|
235
|
+
|
236
|
+
ITEMSET_init (I);
|
237
|
+
}
|
238
|
+
|
239
|
+
/*******************************************************************/
|
240
|
+
/* output at the termination of the algorithm */
|
241
|
+
/* print #of itemsets of size k, for each k */
|
242
|
+
/*******************************************************************/
|
243
|
+
void ITEMSET_last_output (ITEMSET *I){
|
244
|
+
QUEUE_ID i;
|
245
|
+
LONG n=0, nn=0;
|
246
|
+
WEIGHT w;
|
247
|
+
|
248
|
+
ITEMSET_merge_counters (I);
|
249
|
+
if ( !(I->flag&SHOW_MESSAGE) ) return; // "no message" is specified
|
250
|
+
|
251
|
+
if ( I->flag2 & ITEMSET_LAMP ){
|
252
|
+
printf ("frq= %lld ,#sol.= %lld\n", I->topk_frq, I->topk_k);
|
253
|
+
print_err ("iters=" LONGF, I->iters);
|
254
|
+
if ( I->flag&ITEMSET_ITERS2 ) print_err (", iters2=" LONGF, I->iters2);
|
255
|
+
print_err ("\n");
|
256
|
+
return;
|
257
|
+
}
|
258
|
+
if ( I->flag2 & ITEMSET_LAMP2 ){ // to be constructed
|
259
|
+
///////// printf ("frq= %lld ,#sol.= %lld\n", I->topk_frq, I->topk_k);
|
260
|
+
print_err ("iters=" LONGF, I->iters);
|
261
|
+
if ( I->flag&ITEMSET_ITERS2 ) print_err (", iters2=" LONGF, I->iters2);
|
262
|
+
print_err ("\n");
|
263
|
+
return;
|
264
|
+
}
|
265
|
+
|
266
|
+
if ( I->itemtopk_end > 0 ){ // output values of the kth-best solution for each item
|
267
|
+
FLOOP (n, 0, I->itemtopk_end){
|
268
|
+
FLOOP (nn, 0, I->itemtopk[n].end){
|
269
|
+
i = AHEAP_findmin_head (&I->itemtopk[n]);
|
270
|
+
w = AHEAP_H (I->itemtopk[n], i);
|
271
|
+
if ( w == -WEIGHTHUGE*I->itemtopk_sign ) break;
|
272
|
+
if ( I->itemtopk_ary ) printf ("%d ", I->itemtopk_ary[n][i]);
|
273
|
+
fprint_WEIGHT (stdout, w);
|
274
|
+
printf (" ");
|
275
|
+
AHEAP_chg (&(I->itemtopk[n]), i, WEIGHTHUGE);
|
276
|
+
}
|
277
|
+
printf ("\n");
|
278
|
+
}
|
279
|
+
goto END;
|
280
|
+
}
|
281
|
+
|
282
|
+
if ( I->topk_k > 0 ){ // output value of the kth-best solution
|
283
|
+
if ( I->topk.v ){
|
284
|
+
i = AHEAP_findmin_head (&I->topk);
|
285
|
+
fprint_WEIGHT (stdout, AHEAP_H (I->topk, i)*I->topk_sign);
|
286
|
+
} else fprintf (stdout, LONGF, I->topk_frq);
|
287
|
+
printf ("\n");
|
288
|
+
|
289
|
+
goto END;
|
290
|
+
}
|
291
|
+
FLOOP (i, 0, I->itemset.end+1){
|
292
|
+
n += I->sc[i];
|
293
|
+
if ( I->sc[i] != 0 ) nn = i;
|
294
|
+
}
|
295
|
+
if ( n!=0 ){
|
296
|
+
printf (LONGF "\n", n);
|
297
|
+
FLOOP (i, 0, nn+1) printf (LONGF "\n", I->sc[i]);
|
298
|
+
}
|
299
|
+
|
300
|
+
END:;
|
301
|
+
print_err ("iters=" LONGF, I->iters);
|
302
|
+
if ( I->flag&ITEMSET_ITERS2 ) print_err (", iters2=" LONGF, I->iters2);
|
303
|
+
print_err ("\n");
|
304
|
+
|
305
|
+
if (I->flag & ITEMSET_SC2){ // count by frequency
|
306
|
+
FLOOP (i, 0, I->frq_ub+1){
|
307
|
+
if ( I->sc2[i] != 0 ) printf (QUEUE_INTF "," LONGF "\n", i, I->sc2[i]);
|
308
|
+
}
|
309
|
+
}
|
310
|
+
}
|
311
|
+
|
312
|
+
/* output frequency, coverage */
|
313
|
+
void ITEMSET_output_frequency (ITEMSET *I, int core_id){
|
314
|
+
FILE2 *fp = &I->multi_fp[core_id];
|
315
|
+
if ( I->flag&(ITEMSET_FREQ+ITEMSET_PRE_FREQ) ){
|
316
|
+
if ( I->flag&ITEMSET_FREQ ) FILE2_putc (fp, ' ');
|
317
|
+
FILE2_print_WEIGHT (fp, I->frq, I->digits, '(');
|
318
|
+
FILE2_putc (fp, ')');
|
319
|
+
if ( I->flag&ITEMSET_PRE_FREQ ) FILE2_putc (fp, ' ');
|
320
|
+
}
|
321
|
+
if ( I->flag&ITEMSET_OUTPUT_POSINEGA ){ // output positive sum, negative sum in the occurrence
|
322
|
+
FILE2_putc (fp, ' ');
|
323
|
+
FILE2_print_WEIGHT (fp, I->pfrq, I->digits, '(');
|
324
|
+
FILE2_print_WEIGHT (fp, I->pfrq-I->frq, I->digits, ',');
|
325
|
+
FILE2_print_WEIGHT (fp, I->pfrq/(2*I->pfrq-I->frq), I->digits, ',');
|
326
|
+
FILE2_putc (fp, ')');
|
327
|
+
}
|
328
|
+
}
|
329
|
+
|
330
|
+
// topk.end: #records, topk.base: #positive records, PP.th: \alpha, topk_k: #patterns found
|
331
|
+
void ITEMSET_lamp (ITEMSET *I, LONG s){
|
332
|
+
if ( I->frq >= I->topk_frq ){ // LAMP histogram version
|
333
|
+
I->topk_k += s;
|
334
|
+
//LONG i,j=0; FLOOP (i, I->topk_frq, I->topk.base+1) j+= I->sc2[i];
|
335
|
+
//printf ("#### %lld, %lld, %d\n", j, I->topk_k, j!=I->topk_k);
|
336
|
+
while ( I->topk_k >= I->th ){
|
337
|
+
I->topk_k -= I->sc2[I->topk_frq]; I->sc2[I->topk_frq] = 0;
|
338
|
+
//printf ("%d,%lld, %f ->", (int)I->frq_lb, I->topk_k, I->th);
|
339
|
+
I->th = I->th * (I->topk.base - I->topk_frq+1) / (I->topk.end - I->topk_frq+1);
|
340
|
+
//printf ("%f\n", I->th);
|
341
|
+
I->topk_frq++; I->frq_lb = I->topk_frq;
|
342
|
+
if ( I->topk_frq == I->topk.end ) I->frq_lb = I->topk.base+1;
|
343
|
+
//printf ("%f\n", I->frq_lb);
|
344
|
+
}
|
345
|
+
}
|
346
|
+
return;
|
347
|
+
}
|
348
|
+
|
349
|
+
////////////////////// to be constructed
|
350
|
+
// topk.end: #records, topk.base: #positive records, PP.th: \alpha, topk_k: #patterns found
|
351
|
+
void ITEMSET_lamp2 (ITEMSET *I, LONG s){
|
352
|
+
IHEAP_ID i, e;
|
353
|
+
if ( I->frq >= I->topk_frq ){ // LAMP2 double-heap version
|
354
|
+
I->topk_k += s;
|
355
|
+
if (I->minh.siz > I->topk_k/2 ){ // heaps reached maximum size
|
356
|
+
i = I->maxh.v[0];
|
357
|
+
if (I->frq >= I->minh.x[i]){ I->patn[i] += s; } // in the maximum group
|
358
|
+
else {
|
359
|
+
I->minh.x[i] = I->frq;
|
360
|
+
IHEAP_chg (&I->maxh, 0, i);
|
361
|
+
I->patn[I->maxh.v[0]] += I->patn[i]; // merge first&second maximum groups
|
362
|
+
I->patn[i] = s;
|
363
|
+
}
|
364
|
+
} else {
|
365
|
+
i = I->minh.v[I->minh.siz]; // set the value to the next cell
|
366
|
+
I->minh.x[i] = I->frq;
|
367
|
+
e = I->minh.end;
|
368
|
+
IHEAP_ins (&I->minh, i); IHEAP_ins (&I->maxh, i);
|
369
|
+
if (I->minh.siz == e){ // heap overflow
|
370
|
+
realloc2 (I->minh.x, I->minh.end+1, exit(1)); // enlarge the frequency pool
|
371
|
+
I->maxh.x = I->minh.x; // synchronize the keys for max/min heaps
|
372
|
+
FLOOP (i, e, I->minh.end) I->minh.v[i] = i; // initialize un-used cells
|
373
|
+
}
|
374
|
+
}
|
375
|
+
|
376
|
+
//////////////////// ���������͖�����
|
377
|
+
|
378
|
+
|
379
|
+
//LONG i,j=0; FLOOP (i, I->topk_frq, I->topk.base+1) j+= I->sc2[i];
|
380
|
+
//printf ("#### %lld, %lld, %d\n", j, I->topk_k, j!=I->topk_k);
|
381
|
+
while ( I->topk_k >= I->th ){
|
382
|
+
I->topk_k -= I->sc2[I->topk_frq]; I->sc2[I->topk_frq] = 0;
|
383
|
+
//printf ("%d,%lld, %f ->", (int)I->frq_lb, I->topk_k, I->th);
|
384
|
+
I->th = I->th * (I->topk.base - I->topk_frq+1) / (I->topk.end - I->topk_frq+1);
|
385
|
+
//printf ("%f\n", I->th);
|
386
|
+
I->topk_frq++; I->frq_lb = I->topk_frq;
|
387
|
+
if ( I->topk_frq == I->topk.end ) I->frq_lb = I->topk.base+1;
|
388
|
+
//printf ("%f\n", I->frq_lb);
|
389
|
+
}
|
390
|
+
}
|
391
|
+
return;
|
392
|
+
}
|
393
|
+
|
394
|
+
#ifdef _trsact_h_
|
395
|
+
void ITEMSET_output_occ (ITEMSET *I, QUEUE *occ, int core_id){
|
396
|
+
QUEUE_ID i;
|
397
|
+
QUEUE_INT *x;
|
398
|
+
FILE2 *fp = &I->multi_fp[core_id];
|
399
|
+
TRSACT *TT = (TRSACT *)(I->X);
|
400
|
+
VEC_ID j, ee = TT->rows_org;
|
401
|
+
int flag = I->flag&(ITEMSET_TRSACT_ID+ITEMSET_MULTI_OCC_PRINT);
|
402
|
+
|
403
|
+
i=0; MQUE_FLOOP_ (*occ, x, TT->occ_unit){
|
404
|
+
if ( (I->flag&ITEMSET_RM_DUP_TRSACT)==0 || *x != ee ){
|
405
|
+
FILE2_print_int (fp, TT->trperm? TT->trperm[*x]: *x, I->separator);
|
406
|
+
if (flag == ITEMSET_MULTI_OCC_PRINT ){
|
407
|
+
FLOOP (j, 1, (VEC_ID)(TT->occ_unit/sizeof(QUEUE_INT)))
|
408
|
+
FILE2_print_int (fp, *(x+j), I->separator);
|
409
|
+
} else if ( flag == (ITEMSET_MULTI_OCC_PRINT+ITEMSET_TRSACT_ID) ){
|
410
|
+
FILE2_print_int (fp, *(x+1), I->separator);
|
411
|
+
}
|
412
|
+
}
|
413
|
+
ee = *x;
|
414
|
+
if ( (++i)%256==0 ) ITEMSET_flush (I, fp);
|
415
|
+
}
|
416
|
+
#ifdef _FILE2_LOAD_FROM_MEMORY_
|
417
|
+
*((int *)__write_to_memory__) = INTHUGE;
|
418
|
+
__write_to_memory__ = (char *)(((int *)__write_to_memory__) + 1);
|
419
|
+
#else
|
420
|
+
FILE2_putc (fp, '\n');
|
421
|
+
#endif
|
422
|
+
}
|
423
|
+
#endif
|
424
|
+
|
425
|
+
/* output an itemset to the output file */
|
426
|
+
void ITEMSET_output_itemset (ITEMSET *I, QUEUE *occ, int core_id){
|
427
|
+
QUEUE_ID i;
|
428
|
+
QUEUE_INT e;
|
429
|
+
#ifdef _agraph_h_
|
430
|
+
QUEUE_INT ee;
|
431
|
+
#endif
|
432
|
+
|
433
|
+
FILE2 *fp = &I->multi_fp[core_id];
|
434
|
+
|
435
|
+
I->multi_outputs[core_id]++;
|
436
|
+
if ( (I->flag&SHOW_PROGRESS ) && (I->multi_outputs[core_id]%(ITEMSET_INTERVAL) == 0) )
|
437
|
+
print_err ("---- " LONGF " solutions in " LONGF " candidates\n",
|
438
|
+
I->multi_solutions[core_id], I->multi_outputs[core_id]);
|
439
|
+
if ( I->itemset.t < I->lb || I->itemset.t > I->ub ) return;
|
440
|
+
if ( (I->flag&ITEMSET_IGNORE_BOUND)==0 && (I->frq < I->frq_lb || I->frq > I->frq_ub) ) return;
|
441
|
+
if ( (I->flag&ITEMSET_IGNORE_BOUND)==0 && (I->pfrq < I->posi_lb || I->pfrq > I->posi_ub || (I->frq - I->pfrq) > I->nega_ub || (I->frq - I->pfrq) < I->nega_lb) ) return;
|
442
|
+
|
443
|
+
I->multi_solutions[core_id]++;
|
444
|
+
if ( I->max_solutions>0 && I->multi_solutions[core_id] > I->max_solutions ){
|
445
|
+
ITEMSET_last_output (I);
|
446
|
+
ERROR_MES = "reached to maximum number of solutions";
|
447
|
+
EXIT;
|
448
|
+
}
|
449
|
+
|
450
|
+
I->sc[I->itemset.t]++;
|
451
|
+
if (I->flag & ITEMSET_SC2) I->sc2[(QUEUE_INT)I->frq]++; // histogram for LAMP
|
452
|
+
|
453
|
+
if ( I->flag2 & ITEMSET_LAMP ){ ITEMSET_lamp (I, 1); return; } // LAMP mode
|
454
|
+
if ( I->flag2 & ITEMSET_LAMP2 ){ ITEMSET_lamp2 (I, 1); return; } // 2D LAMP mode
|
455
|
+
if ( I->itemtopk_end > 0 ){
|
456
|
+
e = AHEAP_findmin_head (&(I->itemtopk[I->itemtopk_item]));
|
457
|
+
if ( I->frq > AHEAP_H (I->itemtopk[I->itemtopk_item], e) ){
|
458
|
+
AHEAP_chg (&(I->itemtopk[I->itemtopk_item]), e, I->frq * I->itemtopk_sign);
|
459
|
+
if ( I->itemtopk_ary ) I->itemtopk_ary[I->itemtopk_item][e] = I->itemtopk_item2;
|
460
|
+
}
|
461
|
+
return;
|
462
|
+
}
|
463
|
+
|
464
|
+
if ( I->topk_k > 0 ){
|
465
|
+
if ( I->topk.v ){
|
466
|
+
e = AHEAP_findmin_head (&(I->topk));
|
467
|
+
if ( I->frq * I->topk_sign > AHEAP_H (I->topk, e) ){
|
468
|
+
AHEAP_chg (&(I->topk), e, I->frq * I->topk_sign);
|
469
|
+
e = AHEAP_findmin_head (&(I->topk));
|
470
|
+
I->frq_lb = AHEAP_H (I->topk, e) * I->topk_sign;
|
471
|
+
}
|
472
|
+
} else { // histogram version
|
473
|
+
if ( I->frq > I->topk_frq ){
|
474
|
+
I->sc2[I->topk_frq]--;
|
475
|
+
while (I->sc2[I->topk_frq]==0) I->topk_frq++;
|
476
|
+
I->frq_lb = I->topk_frq+1;
|
477
|
+
}
|
478
|
+
}
|
479
|
+
return;
|
480
|
+
}
|
481
|
+
|
482
|
+
if ( I->fp ){
|
483
|
+
if ( I->flag&ITEMSET_PRE_FREQ ) ITEMSET_output_frequency (I, core_id);
|
484
|
+
if ( (I->flag & ITEMSET_NOT_ITEMSET) == 0 ){
|
485
|
+
#ifdef _agraph_h_
|
486
|
+
if ( I->flag&ITEMSET_OUTPUT_EDGE ){
|
487
|
+
FLOOP (i, 0, I->itemset.t){
|
488
|
+
e = I->itemset.v[i];
|
489
|
+
ee = AGRAPH_INC_FROM(*((AGRAPH *)(I->X)), e, I->dir);
|
490
|
+
FILE2_print_int (fp, I->perm? I->perm[ee]: ee, '(' );
|
491
|
+
ee = AGRAPH_INC_TO(*((AGRAPH *)(I->X)), e, I->dir);
|
492
|
+
FILE2_print_int (fp, I->perm? I->perm[ee]: ee, I->separator);
|
493
|
+
#ifdef _FILE2_LOAD_FROM_MEMORY_
|
494
|
+
FILE2_putc (fp, ')');
|
495
|
+
#endif
|
496
|
+
if ( i<I->itemset.t-1 ) FILE2_putc (fp, I->separator);
|
497
|
+
if ( (i+1)%256==0 ) ITEMSET_flush (I, fp);
|
498
|
+
}
|
499
|
+
goto NEXT;
|
500
|
+
}
|
501
|
+
#endif
|
502
|
+
FLOOP (i, 0, I->itemset.t){
|
503
|
+
e = I->itemset.v[i];
|
504
|
+
FILE2_print_int (fp, I->perm? I->perm[e]: e, i==0? 0: I->separator);
|
505
|
+
if ( (i+1)%256==0 ) ITEMSET_flush (I, fp);
|
506
|
+
}
|
507
|
+
#ifdef _agraph_h_
|
508
|
+
NEXT:;
|
509
|
+
#endif
|
510
|
+
}
|
511
|
+
if ( !(I->flag&ITEMSET_PRE_FREQ) ) ITEMSET_output_frequency (I, core_id);
|
512
|
+
if ( ((I->flag & ITEMSET_NOT_ITEMSET) == 0) || (I->flag&ITEMSET_FREQ) || (I->flag&ITEMSET_PRE_FREQ) ){
|
513
|
+
#ifdef _FILE2_LOAD_FROM_MEMORY_
|
514
|
+
FILE2_WRITE_MEMORY (QUEUE_INT, FILE2_LOAD_FROM_MEMORY_END);
|
515
|
+
#else
|
516
|
+
FILE2_putc (fp, '\n');
|
517
|
+
#endif
|
518
|
+
}
|
519
|
+
#ifdef _trsact_h_
|
520
|
+
if (I->flag&(ITEMSET_TRSACT_ID+ITEMSET_MULTI_OCC_PRINT)) ITEMSET_output_occ (I, occ, core_id);
|
521
|
+
#endif
|
522
|
+
ITEMSET_flush (I, fp);
|
523
|
+
}
|
524
|
+
}
|
525
|
+
|
526
|
+
/* output itemsets with adding all combination of "add"
|
527
|
+
at the first call, i has to be "add->t" */
|
528
|
+
void ITEMSET_solution_iter (ITEMSET *I, QUEUE *occ, int core_id){
|
529
|
+
QUEUE_ID t=I->add.t;
|
530
|
+
if ( I->itemset.t > I->ub ) return;
|
531
|
+
ITEMSET_output_itemset (I, occ, core_id);
|
532
|
+
if ( ERROR_MES ) return;
|
533
|
+
BLOOP (I->add.t, I->add.t, 0){
|
534
|
+
QUE_INS (I->itemset, I->add.v[I->add.t]);
|
535
|
+
ITEMSET_solution_iter (I, occ, core_id);
|
536
|
+
if ( ERROR_MES ) return;
|
537
|
+
I->itemset.t--;
|
538
|
+
}
|
539
|
+
I->add.t = t;
|
540
|
+
}
|
541
|
+
|
542
|
+
void ITEMSET_solution (ITEMSET *I, QUEUE *occ, int core_id){
|
543
|
+
QUEUE_ID i;
|
544
|
+
LONG s;
|
545
|
+
if ( I->itemset.t > I->ub ) return;
|
546
|
+
if ( I->flag & ITEMSET_ALL ){
|
547
|
+
if ( I->fp || I->topk.v ) ITEMSET_solution_iter (I, occ, core_id);
|
548
|
+
else {
|
549
|
+
s=1; FLOOP (i, 0, I->add.t+1){
|
550
|
+
I->sc[I->itemset.t+i] += s;
|
551
|
+
s = s*(I->add.t-i)/(i+1);
|
552
|
+
}
|
553
|
+
if (I->flag & ITEMSET_SC2){
|
554
|
+
s = 1<<I->add.t;
|
555
|
+
I->sc2[(QUEUE_INT)I->frq] += s; // histogram for LAMP
|
556
|
+
if ( I->flag2 & ITEMSET_LAMP ) ITEMSET_lamp (I, s); // LAMP mode
|
557
|
+
if ( I->flag2 & ITEMSET_LAMP2 ) ITEMSET_lamp2 (I, s); // 2D LAMP mode
|
558
|
+
else if ( I->topk_k > 0 && I->frq > I->topk_frq ){ // top-k histogram version
|
559
|
+
while (1){
|
560
|
+
if ( I->sc2[I->topk_frq] > s ){ I->sc2[I->topk_frq] -= s; break; }
|
561
|
+
s -= I->sc2[I->topk_frq];
|
562
|
+
I->sc2[I->topk_frq++] = 0;
|
563
|
+
}
|
564
|
+
I->frq_lb = I->topk_frq+1;
|
565
|
+
}
|
566
|
+
}
|
567
|
+
}
|
568
|
+
} else {
|
569
|
+
FLOOP (i, 0, I->add.t) QUE_INS (I->itemset, I->add.v[i]);
|
570
|
+
ITEMSET_output_itemset (I, occ, core_id);
|
571
|
+
I->itemset.t -= I->add.t;
|
572
|
+
}
|
573
|
+
}
|
574
|
+
|
575
|
+
/*************************************************************************/
|
576
|
+
/* ourput a rule */
|
577
|
+
/*************************************************************************/
|
578
|
+
void ITEMSET_output_rule (ITEMSET *I, QUEUE *occ, double p1, double p2, size_t item, int core_id){
|
579
|
+
FILE2 *fp = &I->multi_fp[core_id];
|
580
|
+
if ( fp->fp && !(I->topk.v) ){
|
581
|
+
FILE2_print_real (fp, p1, I->digits, '(');
|
582
|
+
FILE2_print_real (fp, p2, I->digits, ',');
|
583
|
+
FILE2_putc (fp, ')');
|
584
|
+
FILE2_print_int (fp, I->perm[item], I->separator);
|
585
|
+
FILE2_puts (fp, " <= ");
|
586
|
+
}
|
587
|
+
if ( I->flag & ITEMSET_RULE ){
|
588
|
+
if ( I->flag & ITEMSET_RULE_ADD ) ITEMSET_solution (I, occ, core_id);
|
589
|
+
else ITEMSET_output_itemset (I, occ, core_id);
|
590
|
+
} else ITEMSET_solution (I, occ, core_id);
|
591
|
+
}
|
592
|
+
/*************************************************************************/
|
593
|
+
/* check all rules for a pair of itemset and item */
|
594
|
+
/*************************************************************************/
|
595
|
+
void ITEMSET_check_rule (ITEMSET *I, WEIGHT *w, QUEUE *occ, size_t item, int core_id){
|
596
|
+
double p = w[item]/I->frq, pp, ff;
|
597
|
+
// printf ("[ratio] %f, p=%f, (%f/ %f), %d(%d) <= ", I->ratio_lb, p, w[item], I->frq, I->perm[item], I->itemflag[item]);
|
598
|
+
if ( I->itemflag[item]==1 ) return;
|
599
|
+
if ( w[item] <= -WEIGHTHUGE ) p = 0;
|
600
|
+
pp = p; ff = I->item_frq[item];
|
601
|
+
if ( I->flag & ITEMSET_RULE_SUPP ){ pp = w[item]; ff *= I->total_weight; }
|
602
|
+
|
603
|
+
if ( I->flag & (ITEMSET_RULE_FRQ+ITEMSET_RULE_INFRQ)){
|
604
|
+
if ( (I->flag & ITEMSET_RULE_FRQ) && p < I->ratio_lb ) return;
|
605
|
+
if ( (I->flag & ITEMSET_RULE_INFRQ) && p > I->ratio_ub ) return;
|
606
|
+
ITEMSET_output_rule (I, occ, p, ff, item, core_id);
|
607
|
+
} else if ( I->flag & (ITEMSET_RULE_RFRQ+ITEMSET_RULE_RINFRQ) ){
|
608
|
+
if ( (I->flag & ITEMSET_RULE_RFRQ) && (1-p) > I->ratio_lb * (1-I->item_frq[item]) ) return;
|
609
|
+
if ( (I->flag & ITEMSET_RULE_RINFRQ) && p > I->ratio_ub * I->item_frq[item] ) return;
|
610
|
+
ITEMSET_output_rule (I, occ, pp, ff, item, core_id);
|
611
|
+
}
|
612
|
+
}
|
613
|
+
|
614
|
+
/*************************************************************************/
|
615
|
+
/* check all rules for an itemset and all items */
|
616
|
+
/*************************************************************************/
|
617
|
+
void ITEMSET_check_all_rule (ITEMSET *I, WEIGHT *w, QUEUE *occ, QUEUE *jump, WEIGHT total, int core_id){
|
618
|
+
QUEUE_ID i, t;
|
619
|
+
QUEUE_INT e, f=0, *x;
|
620
|
+
WEIGHT d = I->frq/total;
|
621
|
+
|
622
|
+
// checking out of range for itemset size and (posi/nega) frequency
|
623
|
+
if ( I->itemset.t+I->add.t < I->lb || I->itemset.t>I->ub || (!(I->flag&ITEMSET_ALL) && I->itemset.t+I->add.t>I->ub)) return;
|
624
|
+
if ( !(I->flag&ITEMSET_IGNORE_BOUND) && (I->frq < I->frq_lb || I->frq > I->frq_ub) ) return;
|
625
|
+
if ( !(I->flag&ITEMSET_IGNORE_BOUND) && (I->pfrq < I->posi_lb || I->pfrq > I->posi_ub || (I->frq - I->pfrq) > I->nega_ub || (I->frq - I->pfrq) < I->nega_lb) ) return;
|
626
|
+
|
627
|
+
if ( I->flag&ITEMSET_SET_RULE ){ // itemset->itemset rule for sequence mining
|
628
|
+
FLOOP (i, 0, I->itemset.t-1){
|
629
|
+
if ( I->frq/I->set_weight[i] >= I->setrule_lb && I->fp ){
|
630
|
+
I->sc[i]++;
|
631
|
+
if (I->flag & ITEMSET_SC2) I->sc2[(QUEUE_INT)I->frq]++; // histogram for LAMP
|
632
|
+
if ( I->flag2 & ITEMSET_LAMP ) ITEMSET_lamp (I, 1); // LAMP mode
|
633
|
+
if ( I->flag2 & ITEMSET_LAMP2 ) ITEMSET_lamp2 (I, 1); // 2D LAMP mode
|
634
|
+
if ( I->flag&ITEMSET_PRE_FREQ ) ITEMSET_output_frequency (I, core_id);
|
635
|
+
FLOOP (t, 0, I->itemset.t){
|
636
|
+
FILE2_print_int (&I->multi_fp[core_id], I->itemset.v[t], t?I->separator:0);
|
637
|
+
if ( t == i ){
|
638
|
+
FILE2_putc (&I->multi_fp[core_id], ' ');
|
639
|
+
FILE2_putc (&I->multi_fp[core_id], '=');
|
640
|
+
FILE2_putc (&I->multi_fp[core_id], '>');
|
641
|
+
}
|
642
|
+
}
|
643
|
+
if ( !(I->flag&ITEMSET_PRE_FREQ) ) ITEMSET_output_frequency ( I, core_id);
|
644
|
+
FILE2_putc (&I->multi_fp[core_id], ' ');
|
645
|
+
FILE2_print_real (&I->multi_fp[core_id], I->frq/I->set_weight[i], I->digits, '(');
|
646
|
+
FILE2_putc (&I->multi_fp[core_id], ')');
|
647
|
+
#ifdef _FILE2_LOAD_FROM_MEMORY_
|
648
|
+
FILE2_WRITE_MEMORY (QUEUE_INT, FILE2_LOAD_FROM_MEMORY_END);
|
649
|
+
#else
|
650
|
+
FILE2_putc (&I->multi_fp[core_id], '\n');
|
651
|
+
#endif
|
652
|
+
#ifdef _trsact_h_
|
653
|
+
if ( I->flag&(ITEMSET_TRSACT_ID+ITEMSET_MULTI_OCC_PRINT) ){
|
654
|
+
ITEMSET_output_occ (I, I->set_occ[i], core_id);
|
655
|
+
}
|
656
|
+
#endif
|
657
|
+
ITEMSET_flush (I, &I->multi_fp[core_id]);
|
658
|
+
}
|
659
|
+
}
|
660
|
+
}
|
661
|
+
// constraint of relational frequency
|
662
|
+
if ( ((I->flag&ITEMSET_RFRQ)==0 || d >= I->prob_lb * I->prob )
|
663
|
+
&& ((I->flag&ITEMSET_RINFRQ)==0 || d <= I->prob * I->prob_ub) ){
|
664
|
+
if ( I->flag&ITEMSET_RULE ){ // rule mining routines
|
665
|
+
if ( I->itemset.t == 0 ) return;
|
666
|
+
if ( I->target < I->item_max ){
|
667
|
+
MQUE_FLOOP (*jump, x){
|
668
|
+
if ( *x == I->target ){
|
669
|
+
ITEMSET_check_rule (I, w, occ, *x, core_id); if (ERROR_MES) return;
|
670
|
+
}
|
671
|
+
}
|
672
|
+
// ITEMSET_check_rule (I, w, occ, I->target, core_id); if (ERROR_MES) return;
|
673
|
+
} else {
|
674
|
+
if ( I->flag & (ITEMSET_RULE_FRQ + ITEMSET_RULE_RFRQ) ){
|
675
|
+
if ( I->add.t>0 ){
|
676
|
+
// if ( I->itemflag[I->add.v[0]] ) // for POSI_EQUISUPP (occ_w[e] may not be 100%, in the case)
|
677
|
+
f = I->add.v[I->add.t-1]; t = I->add.t; I->add.t--;
|
678
|
+
FLOOP (i, 0, t){
|
679
|
+
e = I->add.v[i];
|
680
|
+
I->add.v[i] = f;
|
681
|
+
ITEMSET_check_rule (I, w, occ, e, core_id); if (ERROR_MES) return;
|
682
|
+
I->add.v[i] = e;
|
683
|
+
}
|
684
|
+
I->add.t++;
|
685
|
+
}
|
686
|
+
MQUE_FLOOP (*jump, x)
|
687
|
+
ITEMSET_check_rule (I, w, occ, *x, core_id); if (ERROR_MES) return;
|
688
|
+
} else {
|
689
|
+
if ( I->flag & (ITEMSET_RULE_INFRQ + ITEMSET_RULE_RINFRQ) ){
|
690
|
+
// ARY_FLOOP ( *jump, i, e ) I->itemflag[e]--;
|
691
|
+
FLOOP (i, 0, I->item_max){
|
692
|
+
if ( I->itemflag[i] != 1 ){
|
693
|
+
ITEMSET_check_rule (I, w, occ, i, core_id); if (ERROR_MES) return;
|
694
|
+
}
|
695
|
+
}
|
696
|
+
// ARY_FLOOP ( *jump, i, e ) I->itemflag[e]++;
|
697
|
+
// }
|
698
|
+
// ARY_FLOOP ( *jump, i, e ) ITEMSET_check_rule (I, w, occ, e);
|
699
|
+
}
|
700
|
+
}
|
701
|
+
}
|
702
|
+
} else { // usual mining (not rule mining)
|
703
|
+
if ( I->fp && (I->flag&(ITEMSET_RFRQ+ITEMSET_RINFRQ))){
|
704
|
+
FILE2_print_real (&I->multi_fp[core_id], d, I->digits, '[');
|
705
|
+
FILE2_print_real (&I->multi_fp[core_id], I->prob, I->digits, ',');
|
706
|
+
FILE2_putc (&I->multi_fp[core_id], ']');
|
707
|
+
}
|
708
|
+
ITEMSET_solution (I, occ, core_id);
|
709
|
+
}
|
710
|
+
}
|
711
|
+
}
|
712
|
+
|
713
|
+
#endif
|