nysol-zdd 3.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/ext/zdd_so/BDD.cc +495 -0
- data/ext/zdd_so/BDD.h +356 -0
- data/ext/zdd_so/BDDDG.cc +1818 -0
- data/ext/zdd_so/BDDDG.h +107 -0
- data/ext/zdd_so/BDDHASH.cc +91 -0
- data/ext/zdd_so/BtoI.cc +503 -0
- data/ext/zdd_so/BtoI.h +144 -0
- data/ext/zdd_so/CtoI.cc +1072 -0
- data/ext/zdd_so/CtoI.h +186 -0
- data/ext/zdd_so/MLZBDDV.cc +153 -0
- data/ext/zdd_so/MLZBDDV.h +42 -0
- data/ext/zdd_so/SOP.cc +608 -0
- data/ext/zdd_so/SOP.h +199 -0
- data/ext/zdd_so/ZBDD.cc +1035 -0
- data/ext/zdd_so/ZBDD.h +243 -0
- data/ext/zdd_so/ZBDDDG.cc +1834 -0
- data/ext/zdd_so/ZBDDDG.h +105 -0
- data/ext/zdd_so/ZBDDHASH.cc +91 -0
- data/ext/zdd_so/bddc.c +2816 -0
- data/ext/zdd_so/bddc.h +132 -0
- data/ext/zdd_so/extconf.rb +25 -0
- data/ext/zdd_so/include/aheap.c +211 -0
- data/ext/zdd_so/include/aheap.h +111 -0
- data/ext/zdd_so/include/base.c +93 -0
- data/ext/zdd_so/include/base.h +60 -0
- data/ext/zdd_so/include/itemset.c +473 -0
- data/ext/zdd_so/include/itemset.h +153 -0
- data/ext/zdd_so/include/problem.c +371 -0
- data/ext/zdd_so/include/problem.h +160 -0
- data/ext/zdd_so/include/queue.c +518 -0
- data/ext/zdd_so/include/queue.h +177 -0
- data/ext/zdd_so/include/sgraph.c +331 -0
- data/ext/zdd_so/include/sgraph.h +170 -0
- data/ext/zdd_so/include/stdlib2.c +832 -0
- data/ext/zdd_so/include/stdlib2.h +746 -0
- data/ext/zdd_so/include/trsact.c +723 -0
- data/ext/zdd_so/include/trsact.h +167 -0
- data/ext/zdd_so/include/vec.c +583 -0
- data/ext/zdd_so/include/vec.h +159 -0
- data/ext/zdd_so/lcm-vsop.cc +596 -0
- data/ext/zdd_so/print.cc +683 -0
- data/ext/zdd_so/table.cc +330 -0
- data/ext/zdd_so/vsop.h +88 -0
- data/ext/zdd_so/zdd_so.cpp +3277 -0
- data/lib/nysol/zdd.rb +31 -0
- metadata +131 -0
@@ -0,0 +1,153 @@
|
|
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, do not forget to
|
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
|
+
For the commercial use, please make a contact to Takeaki Uno. */
|
12
|
+
|
13
|
+
/* routines for itemset mining */
|
14
|
+
|
15
|
+
#ifndef _itemset_h_
|
16
|
+
#define _itemset_h_
|
17
|
+
|
18
|
+
#include"stdlib2.h"
|
19
|
+
#include"queue.h"
|
20
|
+
#define AHEAP_KEY_WEIGHT
|
21
|
+
#include"aheap.h"
|
22
|
+
|
23
|
+
|
24
|
+
typedef struct {
|
25
|
+
int a;
|
26
|
+
QUEUE itemset; // current operating itemset
|
27
|
+
QUEUE add; // for equisupport (hypercube decomposition)
|
28
|
+
int ub, lb; // upper/lower bounds for the itemset size
|
29
|
+
WEIGHT frq, pfrq, frq_ub, frq_lb; // upper/lower bounds for the frequency
|
30
|
+
WEIGHT rposi_lb, rposi_ub, posi_lb, posi_ub, nega_ub, nega_lb; // upper/lower bounds for the sum of positive/negative weights
|
31
|
+
WEIGHT setrule_lb; // frequency lower bound for set rule
|
32
|
+
double ratio, prob; // confidence and independent probability of the current pattern
|
33
|
+
double ratio_ub, ratio_lb, prob_ub, prob_lb; // upper/lower bounds for confidence and independent probability
|
34
|
+
QUEUE_INT target; // target item for rule mining
|
35
|
+
char *itemflag; // 1 if it is include in the pattern (and 2 if included in add)
|
36
|
+
WEIGHT *item_frq; // frequency of each item
|
37
|
+
WEIGHT total_weight; // total weight of the input database
|
38
|
+
int len_ub, len_lb; // upper/lower bounds for the length of the pattern
|
39
|
+
int gap_ub, gap_lb; // upper/lower bounds for the gaps in the pattern
|
40
|
+
LONG *sc; // #itemsets classified by the sizes
|
41
|
+
QUEUE_INT item_max, item_max_org; // (original) maximum item
|
42
|
+
AHEAP topk; // heap for topk mining. valid if topk->h is not NULL
|
43
|
+
int flag; // flag for various functions
|
44
|
+
PERM *perm; // permutation array for output itemset: item => original item
|
45
|
+
FILE *fp; // file pointer to the output file
|
46
|
+
LONG iters, iters2, iters3; //iterations
|
47
|
+
LONG solutions, solutions2; // number of solutions output
|
48
|
+
LONG outputs, outputs2; // #calls of ITEMSET_output_itemset or ITEMSET_solusion
|
49
|
+
LONG max_solutions; // maximum solutions to be output
|
50
|
+
void *X; // pointer to the original data
|
51
|
+
int dir; // direction flag for AGRAPH & SGRAPH
|
52
|
+
|
53
|
+
int multi_core; // number of processors
|
54
|
+
LONG *multi_iters, *multi_iters2, *multi_iters3; //iterations
|
55
|
+
LONG *multi_solutions, *multi_solutions2; // number of solutions output
|
56
|
+
LONG *multi_outputs, *multi_outputs2; // #calls of ITEMSET_output_itemset or ITEMSET_solusion
|
57
|
+
FILE2 *multi_fp; // output file2 pointer for multi-core mode
|
58
|
+
WEIGHT *set_weight; // the frequency of each prefix of current itemset
|
59
|
+
QUEUE **set_occ; // the occurrence of each prefix of current itemset
|
60
|
+
|
61
|
+
#ifdef MULTI_CORE
|
62
|
+
pthread_spinlock_t lock_counter; // couneter locker for jump counter
|
63
|
+
pthread_spinlock_t lock_sc; // couneter locker for
|
64
|
+
pthread_spinlock_t lock_output; // couneter locker for output
|
65
|
+
#endif
|
66
|
+
} ITEMSET;
|
67
|
+
|
68
|
+
/* parameters for ITEMSET.flag */
|
69
|
+
|
70
|
+
#define ITEMSET_ITERS2 4 // output #iters2
|
71
|
+
#define ITEMSET_PRE_FREQ 8 // output frequency preceding to each itemset
|
72
|
+
#define ITEMSET_FREQ 16 // output frequency following to each itemset
|
73
|
+
#define ITEMSET_ALL 32 // concat all combinations of "add" to each itemset
|
74
|
+
|
75
|
+
#define ITEMSET_TRSACT_ID 64 // output transaction ID's in occurrences
|
76
|
+
#define ITEMSET_OUTPUT_EDGE 128 // output itemset as edge set (refer AGRAPH)
|
77
|
+
#define ITEMSET_IGNORE_BOUND 256 // ignore constraint for frequency
|
78
|
+
#define ITEMSET_RM_DUP_TRSACT 512 // remove duplicated transaction ID's
|
79
|
+
#define ITEMSET_MULTI_OCC_PRINT 1024 //print each component of occ
|
80
|
+
// TRSACT_ID+MULTI_OCC_PRINT means print first two components of occ
|
81
|
+
#define ITEMSET_NOT_ITEMSET 2048 // do not print itemset to the output file
|
82
|
+
#define ITEMSET_RULE_SUPP 4096 // output confidence and item frquency by abusolute value
|
83
|
+
#define ITEMSET_OUTPUT_POSINEGA 8192 // output negative/positive frequencies
|
84
|
+
#define ITEMSET_MULTI_OUTPUT 16384 // for multi-core mode
|
85
|
+
#define ITEMSET_USE_ORG 32768 // use item_max_org to the size of use
|
86
|
+
#define ITEMSET_ITEMFRQ 65536 // allocate item_frq
|
87
|
+
#define ITEMSET_ADD 131072 // allocate add
|
88
|
+
|
89
|
+
#define ITEMSET_RULE_FRQ 262144
|
90
|
+
#define ITEMSET_RULE_INFRQ 524288
|
91
|
+
#define ITEMSET_RULE_RFRQ 1048576
|
92
|
+
#define ITEMSET_RULE_RINFRQ 2097152
|
93
|
+
#define ITEMSET_RFRQ 4194304
|
94
|
+
#define ITEMSET_RINFRQ 8388608
|
95
|
+
#define ITEMSET_POSI_RATIO 16777216
|
96
|
+
#define ITEMSET_SET_RULE 134217728
|
97
|
+
|
98
|
+
//#define ITEMSET_RULE (ITEMSET_RULE_FRQ + ITEMSET_RULE_INFRQ + ITEMSET_RULE_RFRQ + ITEMSET_RULE_RINFRQ + ITEMSET_RFRQ + ITEMSET_RINFRQ + ITEMSET_SET_RULE) // for check any rule is true
|
99
|
+
#define ITEMSET_RULE (ITEMSET_RULE_FRQ + ITEMSET_RULE_INFRQ + ITEMSET_RULE_RFRQ + ITEMSET_RULE_RINFRQ + ITEMSET_SET_RULE) // for check any rule is true
|
100
|
+
|
101
|
+
#ifndef ITEMSET_INTERVAL
|
102
|
+
#define ITEMSET_INTERVAL 500000
|
103
|
+
#endif
|
104
|
+
|
105
|
+
/* Output information about ITEMSET structure. flag&1: print frequency constraint */
|
106
|
+
void ITEMSET_print ( ITEMSET *II, int flag);
|
107
|
+
|
108
|
+
/* topk.end>0 => initialize heap for topk mining */
|
109
|
+
/* all pointers will be set to 0, but not for */
|
110
|
+
/* if topK mining, set topk.end to "K" */
|
111
|
+
void ITEMSET_init (ITEMSET *I);
|
112
|
+
void ITEMSET_init2 (ITEMSET *I, char *fname, PERM *perm, QUEUE_INT item_max, size_t item_max_org);
|
113
|
+
void ITEMSET_end (ITEMSET *I);
|
114
|
+
|
115
|
+
/* sum the counters computed by each thread */
|
116
|
+
void ITEMSET_merge_counters (ITEMSET *I);
|
117
|
+
|
118
|
+
/*******************************************************************/
|
119
|
+
/* output at the termination of the algorithm */
|
120
|
+
/* print #of itemsets of size k, for each k */
|
121
|
+
/*******************************************************************/
|
122
|
+
void ITEMSET_last_output (ITEMSET *I);
|
123
|
+
|
124
|
+
/* output frequency, coverage */
|
125
|
+
void ITEMSET_output_frequency (ITEMSET *I, int core_id);
|
126
|
+
|
127
|
+
/* output an itemset to the output file */
|
128
|
+
void ITEMSET_output_itemset (ITEMSET *I, QUEUE *occ, int core_id);
|
129
|
+
|
130
|
+
/* output itemsets with adding all combination of "add"
|
131
|
+
at the first call, i has to be "add->t" */
|
132
|
+
void ITEMSET_solution (ITEMSET *I, QUEUE *occ, int core_id);
|
133
|
+
|
134
|
+
/*************************************************************************/
|
135
|
+
/* ourput a rule */
|
136
|
+
/*************************************************************************/
|
137
|
+
void ITEMSET_output_rule (ITEMSET *I, QUEUE *occ, double p1, double p2, size_t item, int core_id);
|
138
|
+
|
139
|
+
/*************************************************************************/
|
140
|
+
/* check all rules for a pair of itemset and item */
|
141
|
+
/*************************************************************************/
|
142
|
+
void ITEMSET_check_rule (ITEMSET *I, WEIGHT *w, QUEUE *occ, size_t item, int core_id);
|
143
|
+
|
144
|
+
/*************************************************************************/
|
145
|
+
/* check all rules for an itemset and all items */
|
146
|
+
/*************************************************************************/
|
147
|
+
void ITEMSET_check_all_rule (ITEMSET *I, WEIGHT *w, QUEUE *occ, QUEUE *jump, WEIGHT total, int core_id);
|
148
|
+
|
149
|
+
#endif
|
150
|
+
|
151
|
+
|
152
|
+
|
153
|
+
|
@@ -0,0 +1,371 @@
|
|
1
|
+
/* Common problem input/output routines /structure
|
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, do not forget to
|
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
|
+
For the commercial use, please make a contact to Takeaki Uno. */
|
12
|
+
|
13
|
+
/***************************************************/
|
14
|
+
|
15
|
+
#ifndef _problem_c_
|
16
|
+
#define _problem_c_
|
17
|
+
|
18
|
+
#include"problem.h"
|
19
|
+
|
20
|
+
#include"stdlib2.c"
|
21
|
+
#include"queue.c"
|
22
|
+
#include"itemset.c"
|
23
|
+
|
24
|
+
void PROBLEM_error (){
|
25
|
+
ERROR_MES = "command explanation";
|
26
|
+
EXIT;
|
27
|
+
}
|
28
|
+
|
29
|
+
/*************************************************************************/
|
30
|
+
/* PROBLEM and ITEMSET initialization */
|
31
|
+
/*************************************************************************/
|
32
|
+
void PROBLEM_init (PROBLEM *P){
|
33
|
+
P->start_time = clock();
|
34
|
+
RAND_INIT;
|
35
|
+
P->problem = 0;
|
36
|
+
P->prog = 0;
|
37
|
+
P->prog2 = 0;
|
38
|
+
P->input_fname = P->output_fname = P->weight_fname = NULL;
|
39
|
+
P->table_fname = P->position_fname = NULL;
|
40
|
+
|
41
|
+
P->sgraph_fname = P->sgraph2_fname = NULL;
|
42
|
+
P->sgraph_wfname = P->sgraph2_wfname = NULL;
|
43
|
+
P->agraph_fname = P->agraph2_fname = NULL;
|
44
|
+
P->trsact_fname = P->trsact2_fname = NULL;
|
45
|
+
P->trsact_fname2 = P->trsact2_fname2 = NULL;
|
46
|
+
P->trsact_wfname = P->trsact2_wfname = NULL;
|
47
|
+
P->trsact_wfname2 = P->trsact2_wfname2 = NULL;
|
48
|
+
P->trsact_pfname = P->trsact2_pfname = NULL;
|
49
|
+
P->seq_fname = P->seq2_fname = NULL;
|
50
|
+
P->fstar_fname = P->fstar2_fname = NULL;
|
51
|
+
P->mat_fname = P->mat2_fname = NULL;
|
52
|
+
P->smat_fname = P->smat2_fname = NULL;
|
53
|
+
P->setfamily_fname = P->setfamily2_fname = NULL;
|
54
|
+
P->setfamily_wfname = P->setfamily2_wfname = NULL;
|
55
|
+
|
56
|
+
P->root = 0;
|
57
|
+
P->dir = P->edge_dir = 0;
|
58
|
+
P->th = P->th2 = P->th3 = 0;
|
59
|
+
P->ratio = P->ratio2 = 0;
|
60
|
+
P->num = P->siz = P->dim = P->len = 0;
|
61
|
+
P->rows = 0;
|
62
|
+
P->clms = 0;
|
63
|
+
|
64
|
+
ITEMSET_init (&P->II);
|
65
|
+
ITEMSET_init (&P->II2);
|
66
|
+
|
67
|
+
P->vf = P->dep = NULL;
|
68
|
+
P->ff = INIT_QUEUE;
|
69
|
+
|
70
|
+
P->shift = NULL;
|
71
|
+
P->occ_w = P->occ_pw = P->occ_w2 = P->occ_pw2 = NULL;
|
72
|
+
|
73
|
+
P->itemjump = P->itemcand = P->vecjump = P->veccand = INIT_QUEUE; // for delivery
|
74
|
+
P->OQ = P->OQ2 = P->VQ = P->VQ2 = NULL; // for delivery
|
75
|
+
P->itemary = NULL;
|
76
|
+
P->itemmark = P->itemflag = P->vecmark = P->vecflag = NULL; // mark for vector
|
77
|
+
P->occ_t = P->vecary = NULL;
|
78
|
+
P->oo = INIT_QUEUE;
|
79
|
+
|
80
|
+
P->pat = NULL;
|
81
|
+
P->plen = P->perr = 0;
|
82
|
+
|
83
|
+
#ifdef _alist_h_
|
84
|
+
P->occ = INIT_MALIST;
|
85
|
+
#endif
|
86
|
+
|
87
|
+
#ifdef _trsact_h_
|
88
|
+
TRSACT_init (&P->TT);
|
89
|
+
TRSACT_init (&P->TT2);
|
90
|
+
#endif
|
91
|
+
#ifdef _sgraph_h_
|
92
|
+
P->SG = INIT_SGRAPH;
|
93
|
+
P->SG2 = INIT_SGRAPH;
|
94
|
+
#endif
|
95
|
+
#ifdef _agraph_h_
|
96
|
+
P->AG = INIT_AGRAPH;
|
97
|
+
P->AG2 = INIT_AGRAPH;
|
98
|
+
#endif
|
99
|
+
#ifdef _seq_h_
|
100
|
+
SEQ_init (&P->SS);
|
101
|
+
SEQ_init (&P->SS2);
|
102
|
+
#endif
|
103
|
+
#ifdef _fstar_h_
|
104
|
+
P->FS = INIT_FSTAR;
|
105
|
+
P->FS2 = INIT_FSTAR;
|
106
|
+
#endif
|
107
|
+
|
108
|
+
#ifdef _vec_h_
|
109
|
+
P->MM = INIT_MAT;
|
110
|
+
P->MM2 = INIT_MAT;
|
111
|
+
P->SM = INIT_SMAT;
|
112
|
+
P->SM2 = INIT_SMAT;
|
113
|
+
P->FF = INIT_SETFAMILY;
|
114
|
+
P->FF2 = INIT_SETFAMILY;
|
115
|
+
#endif
|
116
|
+
}
|
117
|
+
|
118
|
+
/*************************************************************************/
|
119
|
+
/* PROBLEM initialization */
|
120
|
+
/* all pointers are set to NULL, but don't touch filenames */
|
121
|
+
/* load_flag, flag to give TRSACT_load */
|
122
|
+
/* II->item_max will be item_max when do not load problem */
|
123
|
+
/* II-> */
|
124
|
+
/*************************************************************************/
|
125
|
+
void PROBLEM_init2 (PROBLEM *P, int flag){
|
126
|
+
int f=0;
|
127
|
+
/******************************/
|
128
|
+
#ifdef _trsact_h_
|
129
|
+
if ( P->trsact_fname ){
|
130
|
+
TRSACT_load (&P->TT, P->trsact_fname, P->trsact_fname2, P->trsact_wfname, P->trsact_wfname2, P->trsact_pfname); if (ERROR_MES) goto ERR;
|
131
|
+
if ( P->TT.flag & SHOW_MESSAGE ){
|
132
|
+
print_err ("trsact: %s", P->trsact_fname);
|
133
|
+
if ( P->trsact2_fname2 ) print_err (" ,2nd-trsact2 %s (from ID %d)", P->trsact_fname2, P->TT.end1);
|
134
|
+
print_err (" ,#transactions %d ,#items %d ,size %d", P->TT.rows_org, P->TT.clms_org, P->TT.eles_org);
|
135
|
+
print_err (" extracted database: #transactions %d ,#items %d ,size %zd", P->TT.T.t, P->TT.T.clms, P->TT.T.eles);
|
136
|
+
if ( P->trsact_wfname ) print_err (" ,weightfile %s", P->trsact_wfname);
|
137
|
+
if ( P->trsact_wfname2 ) print_err (" ,2nd-weightfile %s", P->trsact_wfname2);
|
138
|
+
if ( P->trsact_pfname ) print_err (" ,item-order-file %s", P->trsact_pfname);
|
139
|
+
print_err ("\n");
|
140
|
+
}
|
141
|
+
}
|
142
|
+
if ( P->trsact2_fname ){
|
143
|
+
TRSACT_load (&P->TT2, P->trsact2_fname, P->trsact2_fname2, P->trsact2_wfname, P->trsact2_wfname2, P->trsact2_pfname); if (ERROR_MES) goto ERR;
|
144
|
+
if ( P->TT2.flag & SHOW_MESSAGE ){
|
145
|
+
print_err ("trsact2: %s", P->trsact2_fname);
|
146
|
+
if ( P->trsact2_fname2 ) print_err (" ,2nd-trsact2 %s (from ID %d)", P->trsact2_fname2, P->TT.end1);
|
147
|
+
print_err (" ,#transactions %d ,#items %d ,size %zd", P->TT2.rows_org, P->TT2.clms_org, P->TT2.eles_org);
|
148
|
+
print_err (" extracted database: #transactions %d ,#items %d ,size %zd", P->TT2.T.t, P->TT2.T.clms, P->TT2.T.eles);
|
149
|
+
if ( P->trsact2_wfname ) print_err (" ,weightfile2 %s", P->trsact2_wfname);
|
150
|
+
if ( P->trsact2_wfname2 ) print_err (" ,2nd-weightfile2 %s", P->trsact2_wfname2);
|
151
|
+
if ( P->trsact2_pfname ) print_err (" ,item-order-file2 %s", P->trsact2_pfname);
|
152
|
+
print_err ("\n");
|
153
|
+
}
|
154
|
+
}
|
155
|
+
#endif
|
156
|
+
#ifdef _sgraph_h_
|
157
|
+
if ( P->sgraph_fname ){
|
158
|
+
SGRAPH_load (&P->SG, P->sgraph_fname, P->sgraph_wfname); if (ERROR_MES) goto ERR;
|
159
|
+
print_mes (P->SG.flag, "sgraph: %s ,#nodes %d ,#edges %zd ,#arcs %zd\n", P->sgraph_fname, SGRAPH_NODE_NUM(P->SG), P->SG.edge.eles/2, P->SG.in.eles);
|
160
|
+
}
|
161
|
+
if ( P->sgraph2_fname ){
|
162
|
+
SGRAPH_load (&P->SG, P->sgraph2_fname, P->sgraph2_wfname); if (ERROR_MES) goto ERR;
|
163
|
+
print_mes (P->SG2.flag, "sgraph: %s ,#nodes %d ,#edges %zd ,#arcs %zd\n", P->sgraph2_fname, SGRAPH_NODE_NUM(P->SG2), P->SG2.edge.eles/2, P->SG2.in.eles);
|
164
|
+
}
|
165
|
+
#endif
|
166
|
+
#ifdef _agraph_h_
|
167
|
+
if ( P->agraph_fname ){
|
168
|
+
AGRAPH_load (&P->AG, P->agraph_fname); if (ERROR_MES) goto ERR;
|
169
|
+
print_mes (P->AG.flag, "agraph: %s ,#nodes %d ,#edges %zd ,#arcs %zd\n", P->agraph_fname, P->AG.node_num, P->AG.edge_num, P->AG.arc_num);
|
170
|
+
}
|
171
|
+
if ( P->agraph2_fname ){
|
172
|
+
AGRAPH_load (&P->AG2, P->agraph_fname); if (ERROR_MES) goto ERR;
|
173
|
+
print_mes (P->AG2.flag, "agraph: %s ,#nodes %d ,#edges %zd ,#arcs %zd\n", P->agraph2_fname, P->AG2.node_num, P->AG2.edge_num, P->AG2.arc_num);
|
174
|
+
}
|
175
|
+
#endif
|
176
|
+
#ifdef _fstar_h_
|
177
|
+
if ( P->fstar_fname ){
|
178
|
+
FSTAR_load (&P->FS, P->fstar_fname); if (ERROR_MES) goto ERR;
|
179
|
+
print_mes (P->FS.flag, "agraph: %s ,#nodes %d(%d,%d) ,#edges %zd\n", P->fstar_fname, P->FS.node_num, P->FS.in_node_num, P->FS.out_node_num, P->FS.edge_num);
|
180
|
+
}
|
181
|
+
if ( P->fstar2_fname ){
|
182
|
+
FSTAR_load (&P->FS2, P->fstar2_fname); if (ERROR_MES) goto ERR;
|
183
|
+
print_mes (P->FS2.flag, "agraph2: %s ,#nodes %d(%d,%d) ,#edges %zd\n", P->fstar2_fname, P->FS2.node_num, P->FS2.in_node_num, P->FS2.out_node_num, P->FS2.edge_num);
|
184
|
+
}
|
185
|
+
|
186
|
+
#endif
|
187
|
+
#ifdef _vec_h_
|
188
|
+
if ( P->mat_fname ){
|
189
|
+
MAT_load (&P->MM, P->mat_fname); if (ERROR_MES) goto ERR;
|
190
|
+
print_mes (P->MM.flag, "mat: %s ,#rows %d ,#clms %d\n", P->mat_fname, P->MM.t, P->MM.clms);
|
191
|
+
}
|
192
|
+
if ( P->mat2_fname ){
|
193
|
+
MAT_load (&P->MM2, P->mat2_fname); if (ERROR_MES) goto ERR;
|
194
|
+
print_mes (P->MM2.flag, "mat2: %s ,#rows %d ,#clms %d\n", P->mat2_fname, P->MM2.t, P->MM2.clms);
|
195
|
+
}
|
196
|
+
if ( P->smat_fname ){
|
197
|
+
SMAT_load (&P->SM, P->smat_fname); if (ERROR_MES) goto ERR;
|
198
|
+
print_mes (P->SM.flag, "smat: %s ,#rows %d ,#clms %d ,#eles %zd\n", P->smat_fname, P->SM.t, P->SM.clms, P->SM.eles);
|
199
|
+
}
|
200
|
+
if ( P->smat2_fname ){
|
201
|
+
SMAT_load (&P->SM2, P->smat2_fname); if (ERROR_MES) goto ERR;
|
202
|
+
print_mes (P->SM2.flag, "smat2: %s ,#rows %d ,#clms %d ,#eles %zd\n", P->smat2_fname, P->SM2.t, P->SM2.clms, P->SM2.eles);
|
203
|
+
}
|
204
|
+
if ( P->setfamily_fname ){
|
205
|
+
SETFAMILY_load (&P->FF, P->setfamily_fname, P->setfamily_wfname); if (ERROR_MES) goto ERR;
|
206
|
+
print_mes (P->FF.flag, "setfamily: %s ,#rows %d ,#clms %d ,#eles %zd", P->setfamily_fname, P->FF.t, P->FF.clms, P->FF.eles);
|
207
|
+
if ( P->setfamily_wfname ) print_mes (P->FF.flag, " ,weightfile %s", P->setfamily_wfname);
|
208
|
+
print_mes (P->FF.flag, "\n");
|
209
|
+
}
|
210
|
+
if ( P->setfamily2_fname ){
|
211
|
+
SETFAMILY_load (&P->FF2, P->setfamily2_fname, P->setfamily2_wfname); if (ERROR_MES) goto ERR;
|
212
|
+
print_mes (P->FF2.flag, "setfamily2: %s ,#rows %d ,#clms %d ,#eles %zd", P->setfamily2_fname, P->FF2.t, P->FF2.clms, P->FF2.eles);
|
213
|
+
if ( P->setfamily2_wfname ) print_mes (P->FF2.flag, " ,weightfile %s", P->setfamily2_wfname);
|
214
|
+
print_mes (P->FF2.flag, "\n");
|
215
|
+
}
|
216
|
+
#endif
|
217
|
+
if (P->input_fname){ f=1; print_err (" input: %s", P->input_fname); }
|
218
|
+
if (P->weight_fname){ f=1; print_err (" weight: %s", P->weight_fname); }
|
219
|
+
if (P->output_fname){ f=1; print_err (" output to: %s",P->output_fname); }
|
220
|
+
if ( f )print_err ("\n");
|
221
|
+
|
222
|
+
/******************************/
|
223
|
+
|
224
|
+
if ( flag&SHOW_MESSAGE ){
|
225
|
+
ITEMSET_print (&P->II, (flag&PROBLEM_PRINT_FRQ)? 1: 0);
|
226
|
+
if ( flag&PROBLEM_PRINT_DENSE ){
|
227
|
+
print_err ("density threshold");
|
228
|
+
fprint_real (stderr, P->dense);
|
229
|
+
print_err ("\n");
|
230
|
+
}
|
231
|
+
}
|
232
|
+
|
233
|
+
if ( !ERROR_MES ) return;
|
234
|
+
ERR:;
|
235
|
+
PROBLEM_end (P);
|
236
|
+
EXIT;
|
237
|
+
}
|
238
|
+
|
239
|
+
/* termination of problem */
|
240
|
+
void PROBLEM_end (PROBLEM *P){
|
241
|
+
ITEMSET *II = &P->II;
|
242
|
+
|
243
|
+
#ifdef _trsact_h_
|
244
|
+
TRSACT_end (&P->TT);
|
245
|
+
TRSACT_end (&P->TT2);
|
246
|
+
#endif
|
247
|
+
#ifdef _sgraph_h_
|
248
|
+
SGRAPH_end (&P->SG);
|
249
|
+
SGRAPH_end (&P->SG2);
|
250
|
+
#endif
|
251
|
+
#ifdef _agraph_h_
|
252
|
+
AGRAPH_end (&P->AG);
|
253
|
+
AGRAPH_end (&P->AG2);
|
254
|
+
#endif
|
255
|
+
#ifdef _seq_h_
|
256
|
+
SEQ_end (&P->SS);
|
257
|
+
SEQ_end (&P->SS2);
|
258
|
+
#endif
|
259
|
+
#ifdef _fstar_h_
|
260
|
+
FSTAR_end (&P->FS);
|
261
|
+
FSTAR_end (&P->FS2);
|
262
|
+
#endif
|
263
|
+
#ifdef _vec_h_
|
264
|
+
MAT_end (&P->MM);
|
265
|
+
MAT_end (&P->MM2);
|
266
|
+
SMAT_end (&P->SM);
|
267
|
+
SMAT_end (&P->SM2);
|
268
|
+
SETFAMILY_end (&P->FF);
|
269
|
+
SETFAMILY_end (&P->FF2);
|
270
|
+
#endif
|
271
|
+
|
272
|
+
/******************************/
|
273
|
+
|
274
|
+
mfree (P->vf, P->dep);
|
275
|
+
QUEUE_end (&P->ff);
|
276
|
+
|
277
|
+
ITEMSET_end (II);
|
278
|
+
ITEMSET_end (&P->II2);
|
279
|
+
|
280
|
+
if ( P->occ_pw2 != P->occ_pw && P->occ_pw2 != P->occ_w2 ) free2 (P->occ_pw2);
|
281
|
+
if ( P->occ_w2 != P->occ_w ) free2 (P->occ_w2);
|
282
|
+
if ( P->occ_pw != P->occ_w ) free2 (P->occ_pw);
|
283
|
+
mfree (P->shift, P->occ_t, P->occ_w);
|
284
|
+
|
285
|
+
if ( P->OQ ) free2 (P->OQ[0].v);
|
286
|
+
if ( P->OQ2 ) free2 (P->OQ2[0].v);
|
287
|
+
if ( P->VQ ) free2 (P->VQ[0].v);
|
288
|
+
if ( P->VQ2 ) free2 (P->VQ2[0].v);
|
289
|
+
mfree (P->OQ, P->OQ2, P->VQ, P->VQ2);
|
290
|
+
|
291
|
+
|
292
|
+
mfree (P->itemary, P->itemflag, P->itemmark, P->vecary, P->vecflag, P->vecmark);
|
293
|
+
QUEUE_end (&P->itemcand);
|
294
|
+
QUEUE_end (&P->itemjump);
|
295
|
+
|
296
|
+
QUEUE_end (&P->veccand);
|
297
|
+
QUEUE_end (&P->vecjump);
|
298
|
+
QUEUE_end (&P->oo);
|
299
|
+
|
300
|
+
|
301
|
+
#ifdef _alist_h_
|
302
|
+
MALIST_end (&P->occ);
|
303
|
+
#endif
|
304
|
+
|
305
|
+
#ifdef _undo_h_
|
306
|
+
ALISTundo_end ();
|
307
|
+
#endif
|
308
|
+
|
309
|
+
P->end_time = clock();
|
310
|
+
if ( print_time_flag )
|
311
|
+
print_err ("computation_time= %3f\n", ((double)(P->end_time - P->start_time))/CLOCKS_PER_SEC);
|
312
|
+
|
313
|
+
PROBLEM_init (P);
|
314
|
+
}
|
315
|
+
|
316
|
+
/* allocate arrays and structures */
|
317
|
+
void PROBLEM_alloc (PROBLEM *P, QUEUE_ID siz, QUEUE_ID siz2, size_t siz3, PERM *perm, int f){
|
318
|
+
#ifdef _alist_h_
|
319
|
+
ALIST_ID i;
|
320
|
+
#endif
|
321
|
+
|
322
|
+
if ( f&PROBLEM_SHIFT ) calloc2 (P->shift, siz+2, "PROBLEM_alloc: shift", goto ERR);
|
323
|
+
if ( f&PROBLEM_OCC_T ) calloc2 (P->occ_t, siz+2, "PROBLEM_alloc:occ_t", goto ERR);
|
324
|
+
if ( f&(PROBLEM_OCC_W+PROBLEM_OCC_PW) ) calloc2 (P->occ_w, siz+2, "PROBLEM_alloc:occ_w", goto ERR);
|
325
|
+
if ( f&PROBLEM_OCC_PW ){
|
326
|
+
calloc2 (P->occ_pw, siz+2, "PROBLEM_alloc:occ_pw", goto ERR);
|
327
|
+
} else P->occ_pw = P->occ_w;
|
328
|
+
if ( f&PROBLEM_OCC_W2 ){
|
329
|
+
calloc2 (P->occ_w2, siz+2, "PROBLEM_alloc:occ_w", goto ERR);
|
330
|
+
if ( f&PROBLEM_OCC_PW ){
|
331
|
+
calloc2 (P->occ_pw2, siz+2, "PROBLEM_alloc:occ_pw", goto ERR);
|
332
|
+
} else P->occ_pw2 = P->occ_w2;
|
333
|
+
} else { P->occ_w2 = P->occ_w; P->occ_pw2 = P->occ_pw; }
|
334
|
+
|
335
|
+
if ( f&PROBLEM_ITEMFLAG ) calloc2 (P->itemflag, siz+2, "PROBLEM_alloc:itemflag", goto ERR);
|
336
|
+
if ( f&PROBLEM_ITEMMARK ) calloc2 (P->itemmark, siz+2, "PROBLEM_alloc:itemmark", goto ERR);
|
337
|
+
if ( f&PROBLEM_ITEMARY ) calloc2(P->itemary, siz+2,"PROBLEM_alloc:itemary", goto ERR);
|
338
|
+
if ( f&PROBLEM_ITEMJUMP ) QUEUE_alloc (&P->itemjump, siz+2);
|
339
|
+
if ( f&PROBLEM_ITEMCAND ) QUEUE_alloc (&P->itemcand, siz+2);
|
340
|
+
|
341
|
+
if ( f&PROBLEM_VECFLAG ) calloc2 (P->vecflag, siz+2, "PROBLEM_alloc:vecflag", goto ERR);
|
342
|
+
if ( f&PROBLEM_VECMARK ) calloc2 (P->vecmark, siz2+2, "PROBLEM_alloc:vecmark", goto ERR);
|
343
|
+
if ( f&PROBLEM_VECARY ) calloc2 (P->vecary, siz2+2, "PROBLEM_alloc:vecary", goto ERR);
|
344
|
+
if ( f&PROBLEM_VECJUMP ) QUEUE_alloc (&P->vecjump, siz2+2);
|
345
|
+
if ( f&PROBLEM_VECCAND ) QUEUE_alloc (&P->veccand, siz2+2);
|
346
|
+
|
347
|
+
#ifdef _alist_h_
|
348
|
+
if ( f&PROBLEM_OCC3){
|
349
|
+
MALIST_alloc (&P->occ, siz, siz2+2); // element=>
|
350
|
+
if ( ERROR_MES ) goto ERR;
|
351
|
+
if ( f&PROBLEM_OCC2 )
|
352
|
+
FLOOP (i, 0, siz) MALIST_ins_tail (&P->occ, (f&PROBLEM_OCC1)?siz: 0, i, 0);
|
353
|
+
}
|
354
|
+
#endif
|
355
|
+
|
356
|
+
ITEMSET_init2 (&P->II, P->output_fname, perm, siz, siz3);
|
357
|
+
if ( P->II.target<siz && P->II.perm ) P->II.target = P->II.perm[P->II.target];
|
358
|
+
|
359
|
+
#ifdef _undo_h_
|
360
|
+
ALISTundo_init ();
|
361
|
+
#endif
|
362
|
+
|
363
|
+
return;
|
364
|
+
ERR:;
|
365
|
+
PROBLEM_end (P);
|
366
|
+
EXIT;
|
367
|
+
}
|
368
|
+
|
369
|
+
#endif
|
370
|
+
|
371
|
+
|