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