nysol-take 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (161) hide show
  1. checksums.yaml +7 -0
  2. data/bin/mbiclique.rb +317 -0
  3. data/bin/mbipolish.rb +362 -0
  4. data/bin/mccomp.rb +235 -0
  5. data/bin/mclique.rb +295 -0
  6. data/bin/mclique2g.rb +105 -0
  7. data/bin/mcliqueInfo.rb +203 -0
  8. data/bin/mfriends.rb +202 -0
  9. data/bin/mgdiff.rb +252 -0
  10. data/bin/mhifriend.rb +456 -0
  11. data/bin/mhipolish.rb +465 -0
  12. data/bin/mitemset.rb +168 -0
  13. data/bin/mpal.rb +410 -0
  14. data/bin/mpolishing.rb +399 -0
  15. data/bin/msequence.rb +165 -0
  16. data/bin/mtra2g.rb +476 -0
  17. data/bin/mtra2gc.rb +360 -0
  18. data/ext/grhfilrun/extconf.rb +12 -0
  19. data/ext/grhfilrun/grhfilrun.c +85 -0
  20. data/ext/grhfilrun/src/_sspc.c +358 -0
  21. data/ext/grhfilrun/src/aheap.c +545 -0
  22. data/ext/grhfilrun/src/aheap.h +251 -0
  23. data/ext/grhfilrun/src/base.c +92 -0
  24. data/ext/grhfilrun/src/base.h +59 -0
  25. data/ext/grhfilrun/src/fstar.c +497 -0
  26. data/ext/grhfilrun/src/fstar.h +80 -0
  27. data/ext/grhfilrun/src/grhfil.c +214 -0
  28. data/ext/grhfilrun/src/itemset.c +713 -0
  29. data/ext/grhfilrun/src/itemset.h +170 -0
  30. data/ext/grhfilrun/src/problem.c +415 -0
  31. data/ext/grhfilrun/src/problem.h +179 -0
  32. data/ext/grhfilrun/src/queue.c +533 -0
  33. data/ext/grhfilrun/src/queue.h +182 -0
  34. data/ext/grhfilrun/src/sample.c +19 -0
  35. data/ext/grhfilrun/src/sspc.c +597 -0
  36. data/ext/grhfilrun/src/sspc2.c +491 -0
  37. data/ext/grhfilrun/src/stdlib2.c +1482 -0
  38. data/ext/grhfilrun/src/stdlib2.h +892 -0
  39. data/ext/grhfilrun/src/trsact.c +817 -0
  40. data/ext/grhfilrun/src/trsact.h +160 -0
  41. data/ext/grhfilrun/src/vec.c +745 -0
  42. data/ext/grhfilrun/src/vec.h +172 -0
  43. data/ext/lcmrun/extconf.rb +20 -0
  44. data/ext/lcmrun/lcmrun.cpp +99 -0
  45. data/ext/lcmrun/src/aheap.c +216 -0
  46. data/ext/lcmrun/src/aheap.h +111 -0
  47. data/ext/lcmrun/src/base.c +92 -0
  48. data/ext/lcmrun/src/base.h +59 -0
  49. data/ext/lcmrun/src/itemset.c +496 -0
  50. data/ext/lcmrun/src/itemset.h +157 -0
  51. data/ext/lcmrun/src/lcm.c +427 -0
  52. data/ext/lcmrun/src/problem.c +349 -0
  53. data/ext/lcmrun/src/problem.h +177 -0
  54. data/ext/lcmrun/src/queue.c +528 -0
  55. data/ext/lcmrun/src/queue.h +176 -0
  56. data/ext/lcmrun/src/sgraph.c +359 -0
  57. data/ext/lcmrun/src/sgraph.h +173 -0
  58. data/ext/lcmrun/src/stdlib2.c +1282 -0
  59. data/ext/lcmrun/src/stdlib2.h +823 -0
  60. data/ext/lcmrun/src/trsact.c +747 -0
  61. data/ext/lcmrun/src/trsact.h +159 -0
  62. data/ext/lcmrun/src/vec.c +731 -0
  63. data/ext/lcmrun/src/vec.h +171 -0
  64. data/ext/lcmseq0run/extconf.rb +20 -0
  65. data/ext/lcmseq0run/lcmseq0run.cpp +59 -0
  66. data/ext/lcmseq0run/src/aheap.c +216 -0
  67. data/ext/lcmseq0run/src/aheap.h +111 -0
  68. data/ext/lcmseq0run/src/base.c +92 -0
  69. data/ext/lcmseq0run/src/base.h +59 -0
  70. data/ext/lcmseq0run/src/itemset.c +518 -0
  71. data/ext/lcmseq0run/src/itemset.h +157 -0
  72. data/ext/lcmseq0run/src/itemset_zero.c +522 -0
  73. data/ext/lcmseq0run/src/lcm_seq.c +446 -0
  74. data/ext/lcmseq0run/src/lcm_seq_zero.c +446 -0
  75. data/ext/lcmseq0run/src/problem.c +439 -0
  76. data/ext/lcmseq0run/src/problem.h +179 -0
  77. data/ext/lcmseq0run/src/problem_zero.c +439 -0
  78. data/ext/lcmseq0run/src/queue.c +533 -0
  79. data/ext/lcmseq0run/src/queue.h +182 -0
  80. data/ext/lcmseq0run/src/stdlib2.c +1350 -0
  81. data/ext/lcmseq0run/src/stdlib2.h +864 -0
  82. data/ext/lcmseq0run/src/trsact.c +747 -0
  83. data/ext/lcmseq0run/src/trsact.h +159 -0
  84. data/ext/lcmseq0run/src/vec.c +779 -0
  85. data/ext/lcmseq0run/src/vec.h +172 -0
  86. data/ext/lcmseqrun/extconf.rb +20 -0
  87. data/ext/lcmseqrun/lcmseqrun.cpp +101 -0
  88. data/ext/lcmseqrun/src/aheap.c +216 -0
  89. data/ext/lcmseqrun/src/aheap.h +111 -0
  90. data/ext/lcmseqrun/src/base.c +92 -0
  91. data/ext/lcmseqrun/src/base.h +59 -0
  92. data/ext/lcmseqrun/src/itemset.c +518 -0
  93. data/ext/lcmseqrun/src/itemset.h +157 -0
  94. data/ext/lcmseqrun/src/itemset_zero.c +522 -0
  95. data/ext/lcmseqrun/src/lcm_seq.c +447 -0
  96. data/ext/lcmseqrun/src/lcm_seq_zero.c +446 -0
  97. data/ext/lcmseqrun/src/problem.c +439 -0
  98. data/ext/lcmseqrun/src/problem.h +179 -0
  99. data/ext/lcmseqrun/src/problem_zero.c +439 -0
  100. data/ext/lcmseqrun/src/queue.c +533 -0
  101. data/ext/lcmseqrun/src/queue.h +182 -0
  102. data/ext/lcmseqrun/src/stdlib2.c +1350 -0
  103. data/ext/lcmseqrun/src/stdlib2.h +864 -0
  104. data/ext/lcmseqrun/src/trsact.c +747 -0
  105. data/ext/lcmseqrun/src/trsact.h +159 -0
  106. data/ext/lcmseqrun/src/vec.c +779 -0
  107. data/ext/lcmseqrun/src/vec.h +172 -0
  108. data/ext/lcmtransrun/extconf.rb +18 -0
  109. data/ext/lcmtransrun/lcmtransrun.cpp +264 -0
  110. data/ext/macerun/extconf.rb +20 -0
  111. data/ext/macerun/macerun.cpp +57 -0
  112. data/ext/macerun/src/aheap.c +217 -0
  113. data/ext/macerun/src/aheap.h +112 -0
  114. data/ext/macerun/src/itemset.c +491 -0
  115. data/ext/macerun/src/itemset.h +158 -0
  116. data/ext/macerun/src/mace.c +503 -0
  117. data/ext/macerun/src/problem.c +346 -0
  118. data/ext/macerun/src/problem.h +174 -0
  119. data/ext/macerun/src/queue.c +529 -0
  120. data/ext/macerun/src/queue.h +177 -0
  121. data/ext/macerun/src/sgraph.c +360 -0
  122. data/ext/macerun/src/sgraph.h +174 -0
  123. data/ext/macerun/src/stdlib2.c +993 -0
  124. data/ext/macerun/src/stdlib2.h +811 -0
  125. data/ext/macerun/src/vec.c +634 -0
  126. data/ext/macerun/src/vec.h +170 -0
  127. data/ext/sspcrun/extconf.rb +20 -0
  128. data/ext/sspcrun/src/_sspc.c +358 -0
  129. data/ext/sspcrun/src/aheap.c +545 -0
  130. data/ext/sspcrun/src/aheap.h +251 -0
  131. data/ext/sspcrun/src/base.c +92 -0
  132. data/ext/sspcrun/src/base.h +59 -0
  133. data/ext/sspcrun/src/fstar.c +496 -0
  134. data/ext/sspcrun/src/fstar.h +80 -0
  135. data/ext/sspcrun/src/grhfil.c +213 -0
  136. data/ext/sspcrun/src/itemset.c +713 -0
  137. data/ext/sspcrun/src/itemset.h +170 -0
  138. data/ext/sspcrun/src/problem.c +415 -0
  139. data/ext/sspcrun/src/problem.h +179 -0
  140. data/ext/sspcrun/src/queue.c +533 -0
  141. data/ext/sspcrun/src/queue.h +182 -0
  142. data/ext/sspcrun/src/sample.c +19 -0
  143. data/ext/sspcrun/src/sspc.c +598 -0
  144. data/ext/sspcrun/src/sspc2.c +491 -0
  145. data/ext/sspcrun/src/stdlib2.c +1482 -0
  146. data/ext/sspcrun/src/stdlib2.h +892 -0
  147. data/ext/sspcrun/src/trsact.c +817 -0
  148. data/ext/sspcrun/src/trsact.h +160 -0
  149. data/ext/sspcrun/src/vec.c +745 -0
  150. data/ext/sspcrun/src/vec.h +172 -0
  151. data/ext/sspcrun/sspcrun.cpp +54 -0
  152. data/lib/nysol/enumLcmEp.rb +338 -0
  153. data/lib/nysol/enumLcmEsp.rb +284 -0
  154. data/lib/nysol/enumLcmIs.rb +275 -0
  155. data/lib/nysol/enumLcmSeq.rb +143 -0
  156. data/lib/nysol/items.rb +201 -0
  157. data/lib/nysol/seqDB.rb +256 -0
  158. data/lib/nysol/take.rb +39 -0
  159. data/lib/nysol/taxonomy.rb +113 -0
  160. data/lib/nysol/traDB.rb +257 -0
  161. metadata +239 -0
@@ -0,0 +1,170 @@
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_h_
15
+ #define _itemset_h_
16
+
17
+ #include"stdlib2.h"
18
+ #include"queue.h"
19
+ #define AHEAP_KEY_WEIGHT
20
+ #include"aheap.h"
21
+
22
+
23
+ typedef struct {
24
+ // int a;
25
+ QUEUE itemset; // current operating itemset
26
+ QUEUE add; // for equisupport (hypercube decomposition)
27
+ int ub, lb; // upper/lower bounds for the itemset size
28
+ WEIGHT frq, pfrq, frq_ub, frq_lb; // upper/lower bounds for the frequency
29
+ WEIGHT rposi_lb, rposi_ub, posi_lb, posi_ub, nega_ub, nega_lb; // upper/lower bounds for the sum of positive/negative weights
30
+ WEIGHT setrule_lb; // frequency lower bound for set rule
31
+ double ratio, prob, th; // confidence and independent probability of the current pattern
32
+ double ratio_ub, ratio_lb, prob_ub, prob_lb; // upper/lower bounds for confidence and independent probability
33
+ QUEUE_INT target; // target item for rule mining
34
+ char *itemflag; // 1 if it is include in the pattern (and 2 if included in add)
35
+ WEIGHT *item_frq; // frequency of each item
36
+ WEIGHT total_weight; // total weight of the input database
37
+ int len_ub, len_lb; // upper/lower bounds for the length of the pattern
38
+ int gap_ub, gap_lb; // upper/lower bounds for the gaps in the pattern
39
+ LONG *sc, *sc2; // #itemsets classified by the sizes / frequencies
40
+ QUEUE_INT item_max, item_max_org; // (original) maximum item
41
+ AHEAP topk, *itemtopk; // heap for topk mining. valid if topk->h is not NULL
42
+ LONG itemtopk_end, itemtopk_item, itemtopk_item2; // the size of itemtopk heaps; specify topkheap to be used/the size of each in the initiaization
43
+ char topk_sign, itemtopk_sign; // determine min/max (1, -1) for topk/itemtopk heaps
44
+ QUEUE_INT **itemtopk_ary; // topk solutions for each item
45
+ LONG topk_k, topk_frq; // counter for topk bucket and #remainings
46
+ int flag, flag2; // flag for various functions
47
+ PERM *perm; // permutation array for output itemset: item => original item
48
+ FILE *fp; // file pointer to the output file
49
+ char separator; // separator of items output
50
+ int digits; // #decimals to be output, for non-natural numbers
51
+ int progress;
52
+ LONG iters, iters2, iters3; //iterations
53
+ LONG solutions, solutions2; // number of solutions output
54
+ LONG outputs, outputs2; // #calls of ITEMSET_output_itemse3t or ITEMSET_solusion
55
+ LONG max_solutions; // maximum solutions to be output
56
+ void *X; // pointer to the original data
57
+ int dir; // direction flag for AGRAPH & SGRAPH
58
+
59
+ int multi_core; // number of processors
60
+ LONG *multi_iters, *multi_iters2, *multi_iters3; //iterations
61
+ LONG *multi_solutions, *multi_solutions2; // number of solutions output
62
+ LONG *multi_outputs, *multi_outputs2; // #calls of ITEMSET_output_itemset or ITEMSET_solusion
63
+ FILE2 *multi_fp; // output file2 pointer for multi-core mode
64
+ WEIGHT *set_weight; // the frequency of each prefix of current itemset
65
+ QUEUE **set_occ; // the occurrence of each prefix of current itemset
66
+
67
+ IHEAP minh, maxh; // for 2D LAMP mode
68
+ LONG *patn; // cardinarity of each patten group
69
+
70
+ #ifdef MULTI_CORE
71
+ pthread_spinlock_t lock_counter; // couneter locker for jump counter
72
+ pthread_spinlock_t lock_sc; // couneter locker for score counter
73
+ pthread_spinlock_t lock_output; // couneter locker for #output
74
+ #endif
75
+ } ITEMSET;
76
+
77
+ /* parameters for ITEMSET.flag */
78
+
79
+ #define ITEMSET_ITERS2 4 // output #iters2
80
+ #define ITEMSET_PRE_FREQ 8 // output frequency preceding to each itemset
81
+ #define ITEMSET_FREQ 16 // output frequency following to each itemset
82
+ #define ITEMSET_ALL 32 // concat all combinations of "add" to each itemset
83
+
84
+ #define ITEMSET_TRSACT_ID 64 // output transaction ID's in occurrences
85
+ #define ITEMSET_OUTPUT_EDGE 128 // output itemset as edge set (refer AGRAPH)
86
+ #define ITEMSET_IGNORE_BOUND 256 // ignore constraint for frequency
87
+ #define ITEMSET_RM_DUP_TRSACT 512 // remove duplicated transaction ID's
88
+ #define ITEMSET_MULTI_OCC_PRINT 1024 //print each component of occ
89
+ // TRSACT_ID+MULTI_OCC_PRINT means print first two components of occ
90
+ #define ITEMSET_NOT_ITEMSET 2048 // do not print itemset to the output file
91
+ #define ITEMSET_RULE_SUPP 4096 // output confidence and item frquency by abusolute value
92
+ #define ITEMSET_OUTPUT_POSINEGA 8192 // output negative/positive frequencies
93
+ #define ITEMSET_MULTI_OUTPUT 16384 // for multi-core mode
94
+ #define ITEMSET_USE_ORG 32768 // use item_max_org to the size of use
95
+ #define ITEMSET_ITEMFRQ 65536 // allocate item_frq
96
+ #define ITEMSET_ADD 131072 // allocate add
97
+
98
+ #define ITEMSET_RULE_FRQ 262144
99
+ #define ITEMSET_RULE_INFRQ 524288
100
+ #define ITEMSET_RULE_RFRQ 1048576
101
+ #define ITEMSET_RULE_RINFRQ 2097152
102
+ #define ITEMSET_RFRQ 4194304
103
+ #define ITEMSET_RINFRQ 8388608
104
+ #define ITEMSET_POSI_RATIO 16777216
105
+ #define ITEMSET_SET_RULE 134217728
106
+
107
+ #define ITEMSET_APPEND 268435456 // append the output to the fiile
108
+ #define ITEMSET_RULE_ADD 536870912 // append items in add to the solution, for rule output
109
+ #define ITEMSET_SC2 1073741824 // count #items classified by frequencies
110
+
111
+
112
+ #define ITEMSET_LAMP 256 // LAMP mode
113
+ #define ITEMSET_LAMP2 512 // 2D LAMP mode
114
+
115
+ //#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
116
+ #define ITEMSET_RULE (ITEMSET_RULE_FRQ + ITEMSET_RULE_INFRQ + ITEMSET_RULE_RFRQ + ITEMSET_RULE_RINFRQ + ITEMSET_SET_RULE) // for check any rule is true
117
+
118
+ #ifndef ITEMSET_INTERVAL
119
+ #define ITEMSET_INTERVAL 500000
120
+ #endif
121
+
122
+ /* Output information about ITEMSET structure. flag&1: print frequency constraint */
123
+ void ITEMSET_print (ITEMSET *II, int flag);
124
+
125
+ /* topk.end>0 => initialize heap for topk mining */
126
+ /* all pointers will be set to 0, but not for */
127
+ /* if topK mining, set topk.end to "K" */
128
+ void ITEMSET_init (ITEMSET *I);
129
+ void ITEMSET_alloc (ITEMSET *I, char *fname, PERM *perm, QUEUE_INT item_max, size_t item_max_org);
130
+ void ITEMSET_end (ITEMSET *I);
131
+
132
+ /* sum the counters computed by each thread */
133
+ void ITEMSET_merge_counters (ITEMSET *I);
134
+
135
+ /*******************************************************************/
136
+ /* output at the termination of the algorithm */
137
+ /* print #of itemsets of size k, for each k */
138
+ /*******************************************************************/
139
+ void ITEMSET_last_output (ITEMSET *I);
140
+
141
+ /* output frequency, coverage */
142
+ void ITEMSET_output_frequency (ITEMSET *I, int core_id);
143
+
144
+ /* output an itemset to the output file */
145
+ void ITEMSET_output_itemset (ITEMSET *I, QUEUE *occ, int core_id);
146
+
147
+ /* output itemsets with adding all combination of "add"
148
+ at the first call, i has to be "add->t" */
149
+ void ITEMSET_solution (ITEMSET *I, QUEUE *occ, int core_id);
150
+
151
+ /*************************************************************************/
152
+ /* ourput a rule */
153
+ /*************************************************************************/
154
+ void ITEMSET_output_rule (ITEMSET *I, QUEUE *occ, double p1, double p2, size_t item, int core_id);
155
+
156
+ /*************************************************************************/
157
+ /* check all rules for a pair of itemset and item */
158
+ /*************************************************************************/
159
+ void ITEMSET_check_rule (ITEMSET *I, WEIGHT *w, QUEUE *occ, size_t item, int core_id);
160
+
161
+ /*************************************************************************/
162
+ /* check all rules for an itemset and all items */
163
+ /*************************************************************************/
164
+ void ITEMSET_check_all_rule (ITEMSET *I, WEIGHT *w, QUEUE *occ, QUEUE *jump, WEIGHT total, int core_id);
165
+
166
+ #endif
167
+
168
+
169
+
170
+
@@ -0,0 +1,415 @@
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, 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
+ /***************************************************/
13
+
14
+ #ifndef _problem_c_
15
+ #define _problem_c_
16
+
17
+ #include"problem.h"
18
+
19
+ #include"stdlib2.c"
20
+ #include"queue.c"
21
+ #include"itemset.c"
22
+
23
+ void PROBLEM_error (){
24
+ ERROR_MES = "command explanation";
25
+ EXIT;
26
+ }
27
+
28
+ /*************************************************************************/
29
+ /* PROBLEM and ITEMSET initialization */
30
+ /*************************************************************************/
31
+ void PROBLEM_init (PROBLEM *P){
32
+ P->start_time = clock();
33
+ RAND_INIT;
34
+ //ERROR_MES = NULL;
35
+
36
+ #ifdef _FILE2_LOAD_FROM_MEMORY_
37
+ __load_from_memory_org2__ = __load_from_memory__ = __load_from_memory_org__;
38
+ #endif
39
+
40
+ P->problem = P->problem2 = 0;
41
+ P->prog = 0;
42
+ P->prog2 = 0;
43
+ P->input_fname = P->input_fname2 = P->output_fname = P->output_fname2 = NULL;
44
+ P->workdir = P->workdir2 = NULL;
45
+ P->weight_fname = P->header_fname = P->table_fname = P->sc_fname = NULL;
46
+ P->position_fname = P->position2_fname = NULL;
47
+ P->outperm_fname = NULL;
48
+
49
+ P->root = 0;
50
+ P->dir = P->edge_dir = 0;
51
+ P->th = P->th2 = P->th3 = 0;
52
+ P->ratio = P->ratio2 = 0;
53
+ P->num = P->siz = P->dim = P->len = P->width = P->height = 0;
54
+ P->rows = 0;
55
+ P->clms = 0;
56
+ P->gap_ub = INTHUGE;
57
+ P->gap_lb = 0;
58
+ P->xmax = P->ymax = P->pxmax = P->pymax = 0;
59
+ P->tmax = P->tmin = 0;
60
+ P->cost = P->cost2 = 0;
61
+
62
+ ITEMSET_init (&P->II);
63
+ ITEMSET_init (&P->II2);
64
+
65
+ P->vf = P->dep = NULL;
66
+ P->ff = INIT_QUEUE;
67
+
68
+ P->shift = NULL;
69
+ P->occ_w = P->occ_pw = P->occ_w2 = P->occ_pw2 = NULL;
70
+ P->buf = P->buf_org = NULL;
71
+ P->buf_end = 0;
72
+
73
+ P->itemjump = P->itemcand = P->vecjump = P->veccand = INIT_QUEUE; // for delivery
74
+ P->itemchr = P->vecchr = NULL;
75
+ P->OQ = P->OQ2 = P->VQ = P->VQ2 = NULL; // for delivery
76
+ P->itemary = NULL;
77
+ P->itemmark = P->itemflag = P->vecmark = P->vecflag = NULL; // mark for vector
78
+ P->occ_t = P->vecary = NULL;
79
+ P->oo = INIT_QUEUE;
80
+ P->vecw = NULL;
81
+
82
+ P->pat = NULL;
83
+ P->plen = P->perr = 0;
84
+
85
+ #ifdef _base_h_
86
+ P->B = INIT_BASE;
87
+ #endif
88
+
89
+ #ifdef _alist_h_
90
+ P->occ = INIT_MALIST;
91
+ P->itemlist = INIT_ALIST;
92
+ P->veclist = INIT_ALIST;
93
+ #endif
94
+
95
+ #ifdef _trsact_h_
96
+ TRSACT_init (&P->TT);
97
+ TRSACT_init (&P->TT2);
98
+ #endif
99
+ #ifdef _sgraph_h_
100
+ P->SG = INIT_SGRAPH;
101
+ P->SG2 = INIT_SGRAPH;
102
+ #endif
103
+ #ifdef _agraph_h_
104
+ P->AG = INIT_AGRAPH;
105
+ P->AG2 = INIT_AGRAPH;
106
+ #endif
107
+ #ifdef _seq_h_
108
+ SEQ_init (&P->SS);
109
+ SEQ_init (&P->SS2);
110
+ #endif
111
+ #ifdef _pos_h_
112
+ POS_init (&P->PS);
113
+ POS_init (&P->PS2);
114
+ P->PS.S = &P->SS;
115
+ P->PS2.S = &P->SS2;
116
+ P->PS.I = &P->II;
117
+ P->PS2.I = &P->II;
118
+ #endif
119
+ #ifdef _fstar_h_
120
+ P->FS = INIT_FSTAR;
121
+ P->FS2 = INIT_FSTAR;
122
+ #endif
123
+
124
+ #ifdef _vec_h_
125
+ P->MM = INIT_MAT;
126
+ P->MM2 = INIT_MAT;
127
+ P->SM = INIT_SMAT;
128
+ P->SM2 = INIT_SMAT;
129
+ P->FF = INIT_SETFAMILY;
130
+ P->FF2 = INIT_SETFAMILY;
131
+ #endif
132
+
133
+ #ifdef _barray_h_
134
+ P->BA = INIT_BARRAY;
135
+ P->BA2 = INIT_BARRAY;
136
+ #endif
137
+ }
138
+
139
+ /*************************************************************************/
140
+ /* PROBLEM load */
141
+ /*************************************************************************/
142
+ void PROBLEM_load (PROBLEM *P){
143
+ int f=0;
144
+ ITEMSET *II = &P->II;
145
+ /******************************/
146
+ #ifdef _trsact_h_
147
+ if ( P->TT.fname ){ TRSACT_load (&P->TT); if (ERROR_MES) goto ERR; }
148
+ #ifdef _FILE2_LOAD_FROM_MEMORY_
149
+ __load_from_memory_org__ = __load_from_memory__;
150
+ #endif
151
+ if ( P->TT2.fname ){ TRSACT_load (&P->TT2); if (ERROR_MES) goto ERR; }
152
+ #ifdef _FILE2_LOAD_FROM_MEMORY_
153
+ __load_from_memory_org__ = __load_from_memory__;
154
+ #endif
155
+ #endif
156
+
157
+ #ifdef _sgraph_h_
158
+ if ( P->SG.fname ){ SGRAPH_load (&P->SG); if (ERROR_MES) goto ERR; }
159
+ #ifdef _FILE2_LOAD_FROM_MEMORY_
160
+ __load_from_memory_org__ = __load_from_memory__;
161
+ #endif
162
+ if ( P->SG2.fname ){ SGRAPH_load (&P->SG); if (ERROR_MES) goto ERR; }
163
+ #ifdef _FILE2_LOAD_FROM_MEMORY_
164
+ __load_from_memory_org__ = __load_from_memory__;
165
+ #endif
166
+ #endif
167
+
168
+ #ifdef _agraph_h_
169
+ if ( P->AG.fname ){ AGRAPH_load (&P->AG); if (ERROR_MES) goto ERR;}
170
+ #ifdef _FILE2_LOAD_FROM_MEMORY_
171
+ __load_from_memory_org__ = __load_from_memory__;
172
+ #endif
173
+ if ( P->AG2.fname ){ AGRAPH_load (&P->AG2); if (ERROR_MES) goto ERR; }
174
+ #ifdef _FILE2_LOAD_FROM_MEMORY_
175
+ __load_from_memory_org__ = __load_from_memory__;
176
+ #endif
177
+ #endif
178
+
179
+ #ifdef _fstar_h_
180
+ if ( P->FS.fname ){ FSTAR_load (&P->FS); if (ERROR_MES) goto ERR; }
181
+ #ifdef _FILE2_LOAD_FROM_MEMORY_
182
+ __load_from_memory_org__ = __load_from_memory__;
183
+ #endif
184
+ if ( P->FS2.fname ){ FSTAR_load (&P->FS2); if (ERROR_MES) goto ERR; }
185
+ #ifdef _FILE2_LOAD_FROM_MEMORY_
186
+ __load_from_memory_org__ = __load_from_memory__;
187
+ #endif
188
+ #endif
189
+
190
+ #ifdef _vec_h_
191
+ if ( P->MM.fname ){ MAT_load (&P->MM); if (ERROR_MES) goto ERR; }
192
+ #ifdef _FILE2_LOAD_FROM_MEMORY_
193
+ __load_from_memory_org__ = __load_from_memory__;
194
+ #endif
195
+ if ( P->MM2.fname ){ MAT_load (&P->MM2); if (ERROR_MES) goto ERR; }
196
+ #ifdef _FILE2_LOAD_FROM_MEMORY_
197
+ __load_from_memory_org__ = __load_from_memory__;
198
+ #endif
199
+ if ( P->SM.fname ){ SMAT_load (&P->SM); if (ERROR_MES) goto ERR; }
200
+ #ifdef _FILE2_LOAD_FROM_MEMORY_
201
+ __load_from_memory_org__ = __load_from_memory__;
202
+ #endif
203
+ if ( P->SM2.fname ){ SMAT_load (&P->SM2); if (ERROR_MES) goto ERR; }
204
+ #ifdef _FILE2_LOAD_FROM_MEMORY_
205
+ __load_from_memory_org__ = __load_from_memory__;
206
+ #endif
207
+ if ( P->FF.fname ){ SETFAMILY_load (&P->FF); if (ERROR_MES) goto ERR; }
208
+ #ifdef _FILE2_LOAD_FROM_MEMORY_
209
+ __load_from_memory_org__ = __load_from_memory__;
210
+ #endif
211
+ if ( P->FF2.fname ){ SETFAMILY_load (&P->FF2); if (ERROR_MES) goto ERR; }
212
+ #ifdef _FILE2_LOAD_FROM_MEMORY_
213
+ __load_from_memory_org__ = __load_from_memory__;
214
+ #endif
215
+ #endif
216
+
217
+ #ifdef _seq_h_
218
+ if ( P->SS.fname ){ SEQ_load (&P->SS); if (ERROR_MES) goto ERR; }
219
+ #ifdef _FILE2_LOAD_FROM_MEMORY_
220
+ __load_from_memory_org__ = __load_from_memory__;
221
+ #endif
222
+ if ( P->SS2.fname ){ SEQ_load (&P->SS2); if (ERROR_MES) goto ERR; }
223
+ #ifdef _FILE2_LOAD_FROM_MEMORY_
224
+ __load_from_memory_org__ = __load_from_memory__;
225
+ #endif
226
+ #endif
227
+
228
+ #ifdef _barray_h_
229
+ if ( P->BA.fname ){ BARRAY_load (&P->BA); if (ERROR_MES) goto ERR; }
230
+ #ifdef _FILE2_LOAD_FROM_MEMORY_
231
+ __load_from_memory_org__ = __load_from_memory__;
232
+ #endif
233
+ if ( P->BA2.fname ){ BARRAY_load (&P->BA2); if (ERROR_MES) goto ERR; }
234
+ #ifdef _FILE2_LOAD_FROM_MEMORY_
235
+ __load_from_memory_org__ = __load_from_memory__;
236
+ #endif
237
+ #endif
238
+
239
+ if (P->input_fname){ f=1; print_mes (II, " input: %s", P->input_fname); }
240
+ if (P->weight_fname){ f=1; print_mes (II, " weight: %s", P->weight_fname); }
241
+ if (P->output_fname){ f=1; print_mes (II, " output to: %s",P->output_fname); }
242
+ if ( f ) print_mes (II, "\n");
243
+
244
+ /******************************/
245
+
246
+ if ( !ERROR_MES ) return;
247
+ ERR:;
248
+ PROBLEM_end (P);
249
+ EXIT;
250
+ }
251
+
252
+ /* termination of problem */
253
+ void PROBLEM_end (PROBLEM *P){
254
+ ITEMSET *II = &P->II;
255
+
256
+ #ifdef _trsact_h_
257
+ TRSACT_end (&P->TT);
258
+ TRSACT_end (&P->TT2);
259
+ #endif
260
+ #ifdef _sgraph_h_
261
+ SGRAPH_end (&P->SG);
262
+ SGRAPH_end (&P->SG2);
263
+ #endif
264
+ #ifdef _agraph_h_
265
+ AGRAPH_end (&P->AG);
266
+ AGRAPH_end (&P->AG2);
267
+ #endif
268
+ #ifdef _seq_h_
269
+ SEQ_end (&P->SS);
270
+ SEQ_end (&P->SS2);
271
+ #endif
272
+ #ifdef _fstar_h_
273
+ FSTAR_end (&P->FS);
274
+ FSTAR_end (&P->FS2);
275
+ #endif
276
+ #ifdef _vec_h_
277
+ MAT_end (&P->MM);
278
+ MAT_end (&P->MM2);
279
+ SMAT_end (&P->SM);
280
+ SMAT_end (&P->SM2);
281
+ SETFAMILY_end (&P->FF);
282
+ SETFAMILY_end (&P->FF2);
283
+ #endif
284
+ #ifdef _pos_h_
285
+ POS_end (&P->PS);
286
+ POS_end (&P->PS2);
287
+ #endif
288
+ #ifdef _barray_h_
289
+ BARRAY_end (&P->BA);
290
+ BARRAY_end (&P->BA2);
291
+ #endif
292
+
293
+ /******************************/
294
+
295
+ mfree (P->vf, P->dep);
296
+ QUEUE_end (&P->ff);
297
+
298
+ ITEMSET_end (II);
299
+ ITEMSET_end (&P->II2);
300
+
301
+ if ( P->occ_pw2 != P->occ_pw && P->occ_pw2 != P->occ_w2 ) free2 (P->occ_pw2);
302
+ if ( P->occ_w2 != P->occ_w ) free2 (P->occ_w2);
303
+ if ( P->occ_pw != P->occ_w ) free2 (P->occ_pw);
304
+ mfree (P->shift, P->occ_t, P->occ_w);
305
+
306
+ if ( P->OQ ) free2 (P->OQ[0].v);
307
+ if ( P->OQ2 ) free2 (P->OQ2[0].v);
308
+ if ( P->VQ ) free2 (P->VQ[0].v);
309
+ if ( P->VQ2 ) free2 (P->VQ2[0].v);
310
+ mfree (P->OQ, P->OQ2, P->VQ, P->VQ2, P->itemchr, P->vecchr);
311
+
312
+ mfree (P->itemary, P->itemflag, P->itemmark, P->vecary, P->vecflag, P->vecmark, P->vecw);
313
+ QUEUE_end (&P->itemcand);
314
+ QUEUE_end (&P->itemjump);
315
+
316
+ QUEUE_end (&P->veccand);
317
+ QUEUE_end (&P->vecjump);
318
+ QUEUE_end (&P->oo);
319
+
320
+ free2 (P->buf_org);
321
+
322
+ #ifdef _alist_h_
323
+ MALIST_end (&P->occ);
324
+ ALIST_end (&P->itemlist);
325
+ ALIST_end (&P->veclist);
326
+ #endif
327
+
328
+ #ifdef _undo_h_
329
+ ALISTundo_end ();
330
+ #endif
331
+
332
+ P->end_time = clock();
333
+ if ( print_time_flag )
334
+ print_mes (II, "computation_time= %3f\n", ((double)(P->end_time-P->start_time))/CLOCKS_PER_SEC);
335
+
336
+ #ifdef _FILE2_LOAD_FROM_MEMORY_
337
+ __load_from_memory_org__ = __load_from_memory_org2__;
338
+ __write_to_memory__ = __write_to_memory_org__;
339
+ #endif
340
+
341
+ PROBLEM_init (P);
342
+ }
343
+
344
+ /* allocate arrays and structures */
345
+ void PROBLEM_alloc (PROBLEM *P, QUEUE_ID siz, QUEUE_ID siz2, size_t siz3, PERM *perm, int f){
346
+ PERM *p;
347
+ #ifdef _alist_h_
348
+ ALIST_ID i=0;
349
+ #endif
350
+ int j;
351
+
352
+ if ( f&PROBLEM_SHIFT ) calloc2 (P->shift, siz+2, goto ERR);
353
+ if ( f&PROBLEM_OCC_T ) calloc2 (P->occ_t, siz+2, goto ERR);
354
+ if ( f&(PROBLEM_OCC_W+PROBLEM_OCC_PW) ) calloc2 (P->occ_w, siz+2, goto ERR);
355
+ if ( f&PROBLEM_OCC_PW ) calloc2 (P->occ_pw, siz+2, goto ERR);
356
+ else P->occ_pw = P->occ_w;
357
+ if ( f&PROBLEM_OCC_W2 ){
358
+ calloc2 (P->occ_w2, siz+2, goto ERR);
359
+ if ( f&PROBLEM_OCC_PW ) calloc2 (P->occ_pw2, siz+2, goto ERR);
360
+ else P->occ_pw2 = P->occ_w2;
361
+ } else { P->occ_w2 = P->occ_w; P->occ_pw2 = P->occ_pw; }
362
+
363
+ if ( f&PROBLEM_ITEMFLAG ) calloc2 (P->itemflag, siz+2, goto ERR);
364
+ if ( f&PROBLEM_ITEMMARK ) calloc2 (P->itemmark, siz+2, goto ERR);
365
+ if ( f&PROBLEM_ITEMARY ) calloc2(P->itemary, siz+2, goto ERR);
366
+ if ( f&PROBLEM_ITEMCHR ) calloc2(P->itemchr, siz+2, goto ERR);
367
+ if ( f&PROBLEM_ITEMJUMP ) QUEUE_alloc (&P->itemjump, siz+2);
368
+ if ( f&PROBLEM_ITEMCAND ) QUEUE_alloc (&P->itemcand, siz+2);
369
+
370
+ if ( f&PROBLEM_VECFLAG ) calloc2 (P->vecflag, siz2+2, goto ERR);
371
+ if ( f&PROBLEM_VECMARK ) calloc2 (P->vecmark, siz2+2, goto ERR);
372
+ if ( f&PROBLEM_VECARY ) calloc2 (P->vecary, siz2+2, goto ERR);
373
+ if ( f&PROBLEM_VECCHR ) calloc2 (P->vecchr, siz2+2, goto ERR);
374
+ if ( f&PROBLEM_VECJUMP ) QUEUE_alloc (&P->vecjump, siz2+2);
375
+ if ( f&PROBLEM_VECCAND ) QUEUE_alloc (&P->veccand, siz2+2);
376
+ if ( f&PROBLEM_VECW ) calloc2 (P->vecw, siz2+2, goto ERR);
377
+
378
+ #ifdef _alist_h_
379
+ if ( f&PROBLEM_ITEMLIST ) ALIST_alloc (&P->itemlist, siz+2);
380
+ if ( f&PROBLEM_VECLIST ) ALIST_alloc (&P->veclist, siz2+2);
381
+
382
+ if ( f&PROBLEM_OCC3 ){
383
+ MALIST_alloc (&P->occ, siz, siz2+2); // element=>
384
+ if ( ERROR_MES ) goto ERR;
385
+ if ( f&PROBLEM_OCC2 ){
386
+ FLOOP (i, 0, siz) MALIST_ins_tail (&P->occ, (f&PROBLEM_OCC1)?siz2: 0, i, 0);
387
+ }
388
+ }
389
+ #endif
390
+
391
+ // set outperm
392
+ if ( P->outperm_fname ){
393
+ ARY_LOAD (p, int, j, P->outperm_fname, 1, EXIT);
394
+ if ( perm ){
395
+ FLOOP (j, 0, siz) perm[j] = p[perm[j]];
396
+ free2 (p);
397
+ } else perm = p;
398
+ }
399
+ ITEMSET_alloc (&P->II, P->output_fname, perm, siz, siz3);
400
+ if ( P->II.target<siz && P->II.perm )
401
+ FLOOP (j, 0, P->II.item_max){ if ( P->II.target == P->II.perm[j] ){ P->II.target = j; break; } }
402
+
403
+ #ifdef _undo_h_
404
+ ALISTundo_init ();
405
+ #endif
406
+
407
+ return;
408
+ ERR:;
409
+ PROBLEM_end (P);
410
+ EXIT;
411
+ }
412
+
413
+ #endif
414
+
415
+