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,349 @@
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
+ P->problem = P->problem2 = 0;
37
+ P->prog = 0;
38
+ P->prog2 = 0;
39
+ P->input_fname = P->input_fname2 = P->output_fname = P->output_fname2 = NULL;
40
+ P->workdir = P->workdir2 = NULL;
41
+ P->weight_fname = P->header_fname = P->table_fname = P->sc_fname = NULL;
42
+ P->position_fname = P->position2_fname = NULL;
43
+ P->outperm_fname = NULL;
44
+
45
+ P->root = 0;
46
+ P->dir = P->edge_dir = 0;
47
+ P->th = P->th2 = P->th3 = 0;
48
+ P->ratio = P->ratio2 = 0;
49
+ P->num = P->siz = P->dim = P->len = P->width = P->height = 0;
50
+ P->rows = 0;
51
+ P->clms = 0;
52
+ P->gap_ub = INTHUGE;
53
+ P->gap_lb = 0;
54
+ P->xmax = P->ymax = P->pxmax = P->pymax = 0;
55
+ P->cost = P->cost2 = 0;
56
+
57
+ ITEMSET_init (&P->II);
58
+ ITEMSET_init (&P->II2);
59
+
60
+ P->vf = P->dep = NULL;
61
+ P->ff = INIT_QUEUE;
62
+
63
+ P->shift = NULL;
64
+ P->occ_w = P->occ_pw = P->occ_w2 = P->occ_pw2 = NULL;
65
+ P->buf = P->buf_org = NULL;
66
+ P->buf_end = 0;
67
+
68
+ P->itemjump = P->itemcand = P->vecjump = P->veccand = INIT_QUEUE; // for delivery
69
+ P->itemchr = P->vecchr = NULL;
70
+ P->OQ = P->OQ2 = P->VQ = P->VQ2 = NULL; // for delivery
71
+ P->itemary = NULL;
72
+ P->itemmark = P->itemflag = P->vecmark = P->vecflag = NULL; // mark for vector
73
+ P->occ_t = P->vecary = NULL;
74
+ P->oo = INIT_QUEUE;
75
+ P->vecw = NULL;
76
+
77
+ P->pat = NULL;
78
+ P->plen = P->perr = 0;
79
+
80
+ #ifdef _base_h_
81
+ P->B = INIT_BASE;
82
+ #endif
83
+
84
+ #ifdef _alist_h_
85
+ P->occ = INIT_MALIST;
86
+ P->itemlist = INIT_ALIST;
87
+ P->veclist = INIT_ALIST;
88
+ #endif
89
+
90
+ #ifdef _trsact_h_
91
+ TRSACT_init (&P->TT);
92
+ TRSACT_init (&P->TT2);
93
+ #endif
94
+ #ifdef _sgraph_h_
95
+ P->SG = INIT_SGRAPH;
96
+ P->SG2 = INIT_SGRAPH;
97
+ #endif
98
+ #ifdef _agraph_h_
99
+ P->AG = INIT_AGRAPH;
100
+ P->AG2 = INIT_AGRAPH;
101
+ #endif
102
+ #ifdef _seq_h_
103
+ SEQ_init (&P->SS);
104
+ SEQ_init (&P->SS2);
105
+ #endif
106
+ #ifdef _pos_h_
107
+ POS_init (&P->PS);
108
+ POS_init (&P->PS2);
109
+ P->PS.S = &P->SS;
110
+ P->PS2.S = &P->SS2;
111
+ P->PS.I = &P->II;
112
+ P->PS2.I = &P->II;
113
+ #endif
114
+ #ifdef _fstar_h_
115
+ P->FS = INIT_FSTAR;
116
+ P->FS2 = INIT_FSTAR;
117
+ #endif
118
+
119
+ #ifdef _vec_h_
120
+ P->MM = INIT_MAT;
121
+ P->MM2 = INIT_MAT;
122
+ P->SM = INIT_SMAT;
123
+ P->SM2 = INIT_SMAT;
124
+ P->FF = INIT_SETFAMILY;
125
+ P->FF2 = INIT_SETFAMILY;
126
+ #endif
127
+
128
+ #ifdef _barray_h_
129
+ P->BA = INIT_BARRAY;
130
+ P->BA2 = INIT_BARRAY;
131
+ #endif
132
+ }
133
+
134
+ /*************************************************************************/
135
+ /* PROBLEM load */
136
+ /*************************************************************************/
137
+ void PROBLEM_load (PROBLEM *P){
138
+ int f=0;
139
+ ITEMSET *II = &P->II;
140
+ /******************************/
141
+ #ifdef _trsact_h_
142
+ if ( P->TT.fname ){ TRSACT_load (&P->TT); if (ERROR_MES) goto ERR; }
143
+ if ( P->TT2.fname ){ TRSACT_load (&P->TT2); if (ERROR_MES) goto ERR; }
144
+ #endif
145
+ #ifdef _sgraph_h_
146
+ if ( P->SG.fname ){ SGRAPH_load (&P->SG); if (ERROR_MES) goto ERR; }
147
+ if ( P->SG2.fname ){ SGRAPH_load (&P->SG); if (ERROR_MES) goto ERR; }
148
+ #endif
149
+ #ifdef _agraph_h_
150
+ if ( P->AG.fname ){ AGRAPH_load (&P->AG); if (ERROR_MES) goto ERR;}
151
+ if ( P->AG2.fname ){ AGRAPH_load (&P->AG2); if (ERROR_MES) goto ERR; }
152
+ #endif
153
+ #ifdef _fstar_h_
154
+ if ( P->FS.fname ){ FSTAR_load (&P->FS); if (ERROR_MES) goto ERR; }
155
+ if ( P->FS2.fname ){ FSTAR_load (&P->FS2); if (ERROR_MES) goto ERR; }
156
+ #endif
157
+ #ifdef _vec_h_
158
+ if ( P->MM.fname ){ MAT_load (&P->MM); if (ERROR_MES) goto ERR; }
159
+ if ( P->MM2.fname ){ MAT_load (&P->MM2); if (ERROR_MES) goto ERR; }
160
+ if ( P->SM.fname ){ SMAT_load (&P->SM); if (ERROR_MES) goto ERR; }
161
+ if ( P->SM2.fname ){ SMAT_load (&P->SM2); if (ERROR_MES) goto ERR; }
162
+ if ( P->FF.fname ){ SETFAMILY_load (&P->FF); if (ERROR_MES) goto ERR; }
163
+ if ( P->FF2.fname ){ SETFAMILY_load (&P->FF2); if (ERROR_MES) goto ERR; }
164
+ if ( P->FF.wfname ){ SETFAMILY_load_weight (&P->FF); if (ERROR_MES) goto ERR; }
165
+ if ( P->FF2.wfname ){ SETFAMILY_load_weight (&P->FF2); if (ERROR_MES) goto ERR; }
166
+ if ( P->FF.cwfname ){ SETFAMILY_load_column_weight (&P->FF); if (ERROR_MES) goto ERR; }
167
+ if ( P->FF2.cwfname ){ SETFAMILY_load_column_weight (&P->FF2); if (ERROR_MES) goto ERR; }
168
+ if ( P->FF.rwfname ){ SETFAMILY_load_row_weight (&P->FF); if (ERROR_MES) goto ERR; }
169
+ if ( P->FF2.rwfname ){ SETFAMILY_load_row_weight (&P->FF2); if (ERROR_MES) goto ERR; }
170
+ #endif
171
+ #ifdef _seq_h_
172
+ if ( P->SS.fname ){ SEQ_load (&P->SS); if (ERROR_MES) goto ERR; }
173
+ if ( P->SS2.fname ){ SEQ_load (&P->SS2); if (ERROR_MES) goto ERR; }
174
+ #endif
175
+ #ifdef _barray_h_
176
+ if ( P->BA.fname ){ BARRAY_load (&P->BA); if (ERROR_MES) goto ERR; }
177
+ if ( P->BA2.fname ){ BARRAY_load (&P->BA2); if (ERROR_MES) goto ERR; }
178
+ #endif
179
+ if (P->input_fname){ f=1; print_mes (II, " input: %s", P->input_fname); }
180
+ if (P->weight_fname){ f=1; print_mes (II, " weight: %s", P->weight_fname); }
181
+ if (P->output_fname){ f=1; print_mes (II, " output to: %s",P->output_fname); }
182
+ if ( f ) print_mes (II, "\n");
183
+
184
+ /******************************/
185
+ if ( !ERROR_MES ) return;
186
+ ERR:;
187
+ PROBLEM_end (P);
188
+ EXIT;
189
+ }
190
+
191
+ /* termination of problem */
192
+ void PROBLEM_end (PROBLEM *P){
193
+ ITEMSET *II = &P->II;
194
+
195
+ #ifdef _trsact_h_
196
+ TRSACT_end (&P->TT);
197
+ TRSACT_end (&P->TT2);
198
+ #endif
199
+ #ifdef _sgraph_h_
200
+ SGRAPH_end (&P->SG);
201
+ SGRAPH_end (&P->SG2);
202
+ #endif
203
+ #ifdef _agraph_h_
204
+ AGRAPH_end (&P->AG);
205
+ AGRAPH_end (&P->AG2);
206
+ #endif
207
+ #ifdef _seq_h_
208
+ SEQ_end (&P->SS);
209
+ SEQ_end (&P->SS2);
210
+ #endif
211
+ #ifdef _fstar_h_
212
+ FSTAR_end (&P->FS);
213
+ FSTAR_end (&P->FS2);
214
+ #endif
215
+ #ifdef _vec_h_
216
+ MAT_end (&P->MM);
217
+ MAT_end (&P->MM2);
218
+ SMAT_end (&P->SM);
219
+ SMAT_end (&P->SM2);
220
+ SETFAMILY_end (&P->FF);
221
+ SETFAMILY_end (&P->FF2);
222
+ #endif
223
+ #ifdef _pos_h_
224
+ POS_end (&P->PS);
225
+ POS_end (&P->PS2);
226
+ #endif
227
+ #ifdef _barray_h_
228
+ BARRAY_end (&P->BA);
229
+ BARRAY_end (&P->BA2);
230
+ #endif
231
+
232
+ /******************************/
233
+
234
+ mfree (P->vf, P->dep);
235
+ QUEUE_end (&P->ff);
236
+
237
+ ITEMSET_end (II);
238
+ ITEMSET_end (&P->II2);
239
+
240
+ if ( P->occ_pw2 != P->occ_pw && P->occ_pw2 != P->occ_w2 ) free2 (P->occ_pw2);
241
+ if ( P->occ_w2 != P->occ_w ) free2 (P->occ_w2);
242
+ if ( P->occ_pw != P->occ_w ) free2 (P->occ_pw);
243
+ mfree (P->shift, P->occ_t, P->occ_w);
244
+
245
+ if ( P->OQ ) free2 (P->OQ[0].v);
246
+ if ( P->OQ2 ) free2 (P->OQ2[0].v);
247
+ if ( P->VQ ) free2 (P->VQ[0].v);
248
+ if ( P->VQ2 ) free2 (P->VQ2[0].v);
249
+ mfree (P->OQ, P->OQ2, P->VQ, P->VQ2, P->itemchr, P->vecchr);
250
+
251
+ mfree (P->itemary, P->itemflag, P->itemmark, P->vecary, P->vecflag, P->vecmark, P->vecw);
252
+ QUEUE_end (&P->itemcand);
253
+ QUEUE_end (&P->itemjump);
254
+
255
+ QUEUE_end (&P->veccand);
256
+ QUEUE_end (&P->vecjump);
257
+ QUEUE_end (&P->oo);
258
+
259
+ free2 (P->buf_org);
260
+
261
+ #ifdef _alist_h_
262
+ MALIST_end (&P->occ);
263
+ ALIST_end (&P->itemlist);
264
+ ALIST_end (&P->veclist);
265
+ #endif
266
+
267
+ #ifdef _undo_h_
268
+ ALISTundo_end ();
269
+ #endif
270
+
271
+ P->end_time = clock();
272
+ if ( print_time_flag )
273
+ print_mes (II, "computation_time= %3f\n", ((double)(P->end_time-P->start_time))/CLOCKS_PER_SEC);
274
+
275
+ PROBLEM_init (P);
276
+ }
277
+
278
+ /* allocate arrays and structures */
279
+ void PROBLEM_alloc (PROBLEM *P, QUEUE_ID siz, QUEUE_ID siz2, size_t siz3, PERM *perm, int f){
280
+ PERM *p;
281
+ #ifdef _alist_h_
282
+ ALIST_ID i=0;
283
+ #endif
284
+ int j;
285
+
286
+ if ( f&PROBLEM_SHIFT ) calloc2 (P->shift, siz+2, goto ERR);
287
+ if ( f&PROBLEM_OCC_T ) calloc2 (P->occ_t, siz+2, goto ERR);
288
+ if ( f&(PROBLEM_OCC_W+PROBLEM_OCC_PW) ) calloc2 (P->occ_w, siz+2, goto ERR);
289
+ if ( f&PROBLEM_OCC_PW ) calloc2 (P->occ_pw, siz+2, goto ERR);
290
+ else P->occ_pw = P->occ_w;
291
+ if ( f&PROBLEM_OCC_W2 ){
292
+ calloc2 (P->occ_w2, siz+2, goto ERR);
293
+ if ( f&PROBLEM_OCC_PW ) calloc2 (P->occ_pw2, siz+2, goto ERR);
294
+ else P->occ_pw2 = P->occ_w2;
295
+ } else { P->occ_w2 = P->occ_w; P->occ_pw2 = P->occ_pw; }
296
+
297
+ if ( f&PROBLEM_ITEMFLAG ) calloc2 (P->itemflag, siz+2, goto ERR);
298
+ if ( f&PROBLEM_ITEMMARK ) calloc2 (P->itemmark, siz+2, goto ERR);
299
+ if ( f&PROBLEM_ITEMARY ) calloc2(P->itemary, siz+2, goto ERR);
300
+ if ( f&PROBLEM_ITEMCHR ) calloc2(P->itemchr, siz+2, goto ERR);
301
+ if ( f&PROBLEM_ITEMJUMP ) QUEUE_alloc (&P->itemjump, siz+2);
302
+ if ( f&PROBLEM_ITEMCAND ) QUEUE_alloc (&P->itemcand, siz+2);
303
+
304
+ if ( f&PROBLEM_VECFLAG ) calloc2 (P->vecflag, siz2+2, goto ERR);
305
+ if ( f&PROBLEM_VECMARK ) calloc2 (P->vecmark, siz2+2, goto ERR);
306
+ if ( f&PROBLEM_VECARY ) calloc2 (P->vecary, siz2+2, goto ERR);
307
+ if ( f&PROBLEM_VECCHR ) calloc2 (P->vecchr, siz2+2, goto ERR);
308
+ if ( f&PROBLEM_VECJUMP ) QUEUE_alloc (&P->vecjump, siz2+2);
309
+ if ( f&PROBLEM_VECCAND ) QUEUE_alloc (&P->veccand, siz2+2);
310
+ if ( f&PROBLEM_VECW ) calloc2 (P->vecw, siz2+2, goto ERR);
311
+
312
+ #ifdef _alist_h_
313
+ if ( f&PROBLEM_ITEMLIST ) ALIST_alloc (&P->itemlist, siz+2);
314
+ if ( f&PROBLEM_VECLIST ) ALIST_alloc (&P->veclist, siz2+2);
315
+
316
+ if ( f&PROBLEM_OCC3 ){
317
+ MALIST_alloc (&P->occ, siz, siz2+2); // element=>
318
+ if ( ERROR_MES ) goto ERR;
319
+ if ( f&PROBLEM_OCC2 ){
320
+ FLOOP (i, 0, siz) MALIST_ins_tail (&P->occ, (f&PROBLEM_OCC1)?siz2: 0, i, 0);
321
+ }
322
+ }
323
+ #endif
324
+
325
+ // set outperm
326
+ if ( P->outperm_fname ){
327
+ ARY_LOAD (p, int, j, P->outperm_fname, 1, EXIT);
328
+ if ( perm ){
329
+ FLOOP (j, 0, siz) perm[j] = p[perm[j]];
330
+ free2 (p);
331
+ } else perm = p;
332
+ }
333
+ ITEMSET_alloc (&P->II, P->output_fname, perm, siz, siz3);
334
+ if ( P->II.target<siz && P->II.perm )
335
+ FLOOP (j, 0, P->II.item_max){ if ( P->II.target == P->II.perm[j] ){ P->II.target = j; break; } }
336
+
337
+ #ifdef _undo_h_
338
+ ALISTundo_init ();
339
+ #endif
340
+
341
+ return;
342
+ ERR:;
343
+ PROBLEM_end (P);
344
+ EXIT;
345
+ }
346
+
347
+ #endif
348
+
349
+
@@ -0,0 +1,177 @@
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_h_
15
+ #define _problem_h_
16
+
17
+ #include"stdlib2.h"
18
+ #include"queue.h"
19
+ #include"itemset.h"
20
+
21
+ #define PROBLEM_FREQSET 1
22
+ #define PROBLEM_MAXIMAL 2
23
+ #define PROBLEM_CLOSED 4
24
+ #define PROBLEM_EX_MAXIMAL 8
25
+ #define PROBLEM_EX_CLOSED 16
26
+ #define PROBLEM_DOC 32
27
+
28
+ /***** parameters for PROBLEM initialization, given to flag *****/
29
+
30
+ #define PROBLEM_PRINT_DENSE 4 // print density threshold
31
+ #define PROBLEM_PRINT_SHRINK 8 // print properties of shrinked database
32
+ #define PROBLEM_PRINT_FRQ 16 // print density threshold
33
+ #define PROBLEM_NORMALIZE 32 // print density threshold
34
+
35
+ #define PROBLEM_ITEMARY 128 // alloc itemary
36
+ #define PROBLEM_ITEMJUMP 256 // alloc itemjump
37
+ #define PROBLEM_ITEMFLAG 512 // alloc itemflag
38
+ #define PROBLEM_ITEMMARK 1024 // alloc itemmark
39
+ #define PROBLEM_ITEMCAND 2048 // alloc itemcand
40
+ #define PROBLEM_VECARY 4096 // alloc itemary
41
+ #define PROBLEM_VECJUMP 8192 // alloc vecjump
42
+ #define PROBLEM_VECFLAG 16384 // alloc vecflag
43
+ #define PROBLEM_VECMARK 32768 // alloc vecmark
44
+ #define PROBLEM_VECCAND 65536 // alloc veccand
45
+ #define PROBLEM_ITEMCHR 131072 //alloc itemchr
46
+ #define PROBLEM_VECCHR 262144 //alloc vecchr
47
+ //4194304
48
+ #define PROBLEM_OCC_T 524288 // alloc occ_t
49
+ #define PROBLEM_SHIFT 1048576 // allocate shift
50
+ #define PROBLEM_OCC_W 2097152 // weight/positive-weight sum for items
51
+ #define PROBLEM_OCC_PW 4194304 // weight/positive-weight sum for items
52
+ #define PROBLEM_OCC_W2 8388608 // weight/positive-weight sum for items
53
+ #define PROBLEM_ITEMLIST 16777216 // alist for items
54
+ #define PROBLEM_VECLIST 33554432 // alist for vecs
55
+ #define PROBLEM_VECW 67108864 // weight array for vecs
56
+
57
+ #define PROBLEM_OCC1 16 // alloc occ
58
+ #define PROBLEM_OCC2 32 // alloc occ and ins all to list 0
59
+ #define PROBLEM_OCC3 48 // alloc occ and ins all to list "siz"
60
+
61
+ typedef struct {
62
+ clock_t start_time, end_time;
63
+ int problem, problem2;
64
+ LONG prog;
65
+ int prog2;
66
+ double dense;
67
+ char *input_fname, *input_fname2;
68
+ char *output_fname, *output_fname2;
69
+ char *workdir, *workdir2;
70
+
71
+ char *weight_fname;
72
+ char *table_fname, *table2_fname;
73
+ char *outperm_fname, *outperm_fname2;
74
+ char *header_fname, *position_fname, *position2_fname, *sc_fname;
75
+
76
+ ITEMSET II, II2;
77
+ QUEUE ff; // for agraph search
78
+ int *vf, *dep; // for agraph search
79
+
80
+ int root, dir, edge_dir;
81
+ double th, th2, th3; // thresholds
82
+ double ratio, ratio2; // ratio
83
+ int num, siz, dim, len, width, height, gap_ub, gap_lb;
84
+ int xmax, ymax, pxmax, pymax;
85
+ QUEUE_INT clms;
86
+ VEC_ID rows;
87
+ WEIGHT cost, cost2;
88
+
89
+ QUEUE_ID **shift;
90
+ QUEUE itemjump, itemcand, vecjump, veccand, *OQ, *OQ2, *VQ, *VQ2; // for delivery
91
+ QUEUE_INT *itemary;
92
+ char *itemchr, *vecchr;
93
+ int *itemmark, *itemflag, *vecmark, *vecflag; // mark for vector
94
+ VEC_ID *vecary, *occ_t;
95
+ WEIGHT *occ_w, *occ_pw, *occ_w2, *occ_pw2, *vecw;
96
+ QUEUE oo;
97
+ QUEUE_INT *buf, *buf_org;
98
+ size_t buf_end;
99
+
100
+ char *pat; // pattern string
101
+ int plen, perr; // pattern length and #error allowed
102
+
103
+ #ifdef _base_h_
104
+ BASE B;
105
+ #endif
106
+
107
+ #ifdef _alist_h_
108
+ ALIST itemlist, veclist;
109
+ #endif
110
+
111
+ #ifdef _alist_h_
112
+ MALIST occ;
113
+ #endif
114
+
115
+ #ifdef _sgraph_h_
116
+ SGRAPH SG, SG2;
117
+ #endif
118
+
119
+ #ifdef _agraph_h_
120
+ AGRAPH AG, AG2;
121
+ #endif
122
+
123
+ #ifdef _trsact_h_
124
+ TRSACT TT, TT2;
125
+ #endif
126
+
127
+ #ifdef _seq_h_
128
+ SEQ SS, SS2;
129
+ #endif
130
+ #ifdef _pos_h_
131
+ POS PS, PS2;
132
+ #endif
133
+
134
+ #ifdef _fstar_h_
135
+ FSTAR FS, FS2;
136
+ #endif
137
+
138
+ #ifdef _vec_h_
139
+ MAT MM, MM2;
140
+ SMAT SM, SM2;
141
+ SETFAMILY FF, FF2;
142
+ #endif
143
+
144
+ #ifdef _barray_h_
145
+ BARRAY BA;
146
+ BARRAY BA2;
147
+ #endif
148
+
149
+ } PROBLEM;
150
+
151
+
152
+ /***** print filename information ****/
153
+ void PROBLEM_print (PROBLEM *P);
154
+
155
+ /***** print usage of the program *****/
156
+ void PROBLEM_error ();
157
+
158
+ /***** read parameters given by command line *****/
159
+ void PROBLEM_read_param (int argc, char *argv[], PROBLEM *P);
160
+
161
+ /***** PROBLEM and ITEMSET initialization *****/
162
+ /* all pointers are set to NULL, but don't touch filenames */
163
+ void PROBLEM_init (PROBLEM *P);
164
+
165
+ /***** PROBLEM initialization: load the files given by filenames ******/
166
+ void PROBLEM_load (PROBLEM *P);
167
+
168
+ /***** allocate memory according to flag *****/
169
+ void PROBLEM_alloc (PROBLEM *PP, QUEUE_ID siz, QUEUE_ID siz2, size_t siz3, PERM *p, int f);
170
+
171
+ /* termination of problem */
172
+ void PROBLEM_end (PROBLEM *PP);
173
+
174
+
175
+ #endif
176
+
177
+