Repository navigation
Expand file tree
/
Copy pathPDP.cpp
More file actions
861 lines (688 loc) · 19.5 KB
/
Copy pathPDP.cpp
File metadata and controls
861 lines (688 loc) · 19.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
#include <cstring>
#include <fstream>
#include <sstream>
#include <stdlib.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <stdio.h>
#include <time.h>
using namespace std;
struct Snapshot{
vector<int> L1;
vector<int> X1;
vector< vector<int> > solutions;
};
bool BBd_=false, BBb_=false, BBb2_=false;
int problem_size;
//Max element in the input is unique
int width;
vector< vector<int> > solutions;
int solutionsSize;
char* fileName_time= new char[100];
char* fileName_output = new char[100];
ofstream writefile_time,writefile_output;
bool contains(vector<int> L, int key){
for(int i=0;i<L.size();i++)
if(L.at(i)==key)
return true;
return false;
}
int findMaxPos(vector<int> L) {
int maxDigest = 0;
int maxpos = 0;
for (int i = 0; i < L.size(); i++) {
if (L.at(i)>= maxDigest) {
maxDigest = L.at(i);
maxpos = i;
}
}
return maxpos;
}
bool contains(vector< vector<int> > L, vector<int> key){
for(int i=0;i<L.size();i++)
if(L.at(i)==key)
return true;
return false;
}
void copy_o(vector<int> d,vector<int> &d1){
for (int i = 0; i < d.size(); i++) {
d1.push_back(/*.insert(*/d.at(i));
}
//d1 = d;
}
vector<int> convert_arry_to_list(int tt[],int n){
vector<int> L;
for (int e=0; e < n;e++)
L.push_back(tt[e]);
return L;
}
vector<int> getDelta(int partialDigestDistance,vector<int> X) {
vector<int> resultList; // = new vector<int>();
for (int ii =0;ii<X.size();ii++){// : X) {
int rs = X[ii];
int distance = abs(rs - partialDigestDistance);
resultList.push_back(distance);
}
return resultList;
}
int find_pos(vector<int> ff, int key){
int index = -1;
for (int i=0;i<ff.size();i++){
if(ff.at(i)== key){
index = i;
break;
}
}
return index;
}
bool isDistanceSubsetOf(vector<int> distanceList,vector<int> L) {
bool result = true;
int uu;
int index;
for (int i=0;i<distanceList.size();i++){
uu = distanceList.at(i);
if (!contains(L,uu)) {
result = false;
break;
}
else
{
index = find_pos(L,uu);
L.erase(L.begin()+index);
}
}
return result;
}
vector<int> removePartialDigests(vector<int> delta, vector<int> &L){
vector<int> result; // = new ArrayList<Integer>();
int uu,index;
for (int i = 0; i < delta.size(); i++) {
uu = delta.at(i);//.get(i);
index= find_pos(L,uu);
L.erase(L.begin()+index);//.remove(index);
//L.erase(remove(index,index,uu),L.end());
result.push_back(uu);//add(uu);
}
return result;
}
void print_vector(vector<int> dd){
cout<<"{";
for(int j=0;j<dd.size();j++)
{
cout<<dd.at(j)<<",";
}
cout<<"},\t";
}
void print_vector_in_file(vector<int> dd,char* fileName_output)
{
writefile_output.open(fileName_output,ios::app);
writefile_output<<"{";
for(int j=0;j<dd.size();j++)
{
writefile_output<<dd.at(j)<<",";
}
writefile_output<<"}\n";
writefile_output.close();
}
void print_solutions_in_file (vector< vector<int> > solutions, char* fileName_output)
{
writefile_output.open(fileName_output,ios::app);
writefile_output<<"\nsolutions = {";
writefile_output.close();
for (int i =0;i<solutions.size();i++)
{
print_vector_in_file(solutions.at(i),fileName_output);
}
writefile_output.open(fileName_output,ios::app);
cout<<"}\n";
writefile_output.close();
}
void print_solutions (vector< vector<int> > solutions){
cout<<"solutions = {";
for (int i =0;i<solutions.size();i++)
{
print_vector(solutions.at(i));
}
cout<<"}\n";
}
void ReadSet(char *szFile, vector <int> &x, int &N)
{
ifstream myfile;
myfile.open(szFile, std::ios_base::in);
if(myfile)
{
int a;
while (myfile >> a)
{
//printf("%f", a);
x.push_back(a);
N++;
}
}
else
{
cout << "An exception occurred. I/O Exception . The file " <<szFile<<" not exist" << '\n';
exit(1);
}
}
bool compare_two_vectors(vector<int> u,vector<int> v)
{
if(u.size()!=v.size())
return false;
sort(u.begin(),u.end());
sort(v.begin(),v.end());
for(int i=0;i<u.size();i++)
if(u[i]!=v[i])
return false;
return true;
}
bool compare_two_snapshots(Snapshot e1, Snapshot e2)
{
//bool resultL=compare_two_vectors(e1.L1,e2.L1);
//bool resultX=compare_two_vectors(e1.X1,e2.X1);
if(compare_two_vectors(e1.X1,e2.X1))
{
//if(compare_two_vectors(e1.L1,e2.L1))
return true;
}
/*if(resultL&& resultX)
return true;*/
return false;
}
bool compare_element_to_vector(vector<Snapshot> PP,Snapshot e)
{
for(int i=PP.size()-1;i>=0;i--)
if(compare_two_snapshots(PP[i],e))
return true;
return false;
}
vector<Snapshot> divide(vector<Snapshot> snapshot_stack)
{
Snapshot currentSnapshot;
vector<int> deltaList_1,deltaList_2;
bool tst1,tst2;
int partialDigestDistance,y_pos;
vector<Snapshot> result;
result.clear();
for(int i=0;i<snapshot_stack.size();i++)
{
currentSnapshot = snapshot_stack[i];
if (currentSnapshot.L1.empty()) { // 1 - 3
sort(currentSnapshot.X1.begin(),currentSnapshot.X1.end());
if(!contains(solutions,currentSnapshot.X1))
solutions.push_back(currentSnapshot.X1);
continue;
}
y_pos = findMaxPos(currentSnapshot.L1); // 4
partialDigestDistance = currentSnapshot.L1.at(y_pos);
deltaList_1 = getDelta(partialDigestDistance, currentSnapshot.X1);
deltaList_2 = getDelta(width-partialDigestDistance, currentSnapshot.X1);
tst1 = isDistanceSubsetOf(deltaList_1, currentSnapshot.L1);
tst2 = isDistanceSubsetOf(deltaList_2, currentSnapshot.L1);
if(!tst1 && !tst2)
continue;
else if (tst1 && tst2)
{
vector<int> L2;
vector<int> X2;
copy_o(currentSnapshot.L1,L2);
copy_o(currentSnapshot.X1,X2);
currentSnapshot.X1.push_back(partialDigestDistance);
vector<int> removed = removePartialDigests(deltaList_1, currentSnapshot.L1);
if(!compare_element_to_vector(result,currentSnapshot))
result.push_back(currentSnapshot);
currentSnapshot.L1 = L2;
currentSnapshot.X1 = X2;
currentSnapshot.X1.push_back(width-partialDigestDistance);
vector<int> removed_1 = removePartialDigests(deltaList_2, currentSnapshot.L1);
if(!compare_element_to_vector(result,currentSnapshot))
result.push_back(currentSnapshot);
}
else if (tst1)
{
currentSnapshot.X1.push_back(partialDigestDistance);
vector<int> removed = removePartialDigests(deltaList_1, currentSnapshot.L1);
if(!compare_element_to_vector(result,currentSnapshot))
result.push_back(currentSnapshot);
}
else if (tst2)
{
currentSnapshot.X1.push_back(width-partialDigestDistance);
vector<int> removed_1 = removePartialDigests(deltaList_2, currentSnapshot.L1);
if(!compare_element_to_vector(result,currentSnapshot))
result.push_back(currentSnapshot);
}
}
return result;
}
void place_BBb(vector<int> L, vector<int> X){
vector<Snapshot> snapshot_stack;
Snapshot currentSnapshot;
currentSnapshot.L1 = L;
currentSnapshot.X1 = X;
currentSnapshot.solutions = solutions;
snapshot_stack.push_back(currentSnapshot);
while(!snapshot_stack.empty())
snapshot_stack = divide(snapshot_stack);
}
int find_minimum(vector<long double> Mem){
int index = 0;
long double minimum = Mem[0];
for(int Alph_0=1;Alph_0<Mem.size();Alph_0++)
{
if (Mem[Alph_0]<=minimum)
{
minimum = Mem[Alph_0];
index = Alph_0;
}
}
return index+1;
}
long double choose(const long n, const long r) {
if(r>n)
return 0;
if(r==0||r==n)
return 1;
long double total=(long double)n/r;
for(long i=1;i<r;i++)
total=total*(n-i)/(r-i);
return total;
}
int find_minimum_memory_mod_13_mod(int n)
{
vector<long double> Mem;
for(int i =1;i<=n;i++)
{
long double x;
Mem.push_back(x);
}
for(int i=0;i<Mem.size();i++)
{
long double sum =0.0;
for(int j= 1;j<=i+1;j++)
sum=sum+j;
Mem[i]= pow((double)2,i)*(i+2+choose(n+1,2)-sum)+pow((double)2,n-i)*(n+2);
}
int level_with_minimum_memory = find_minimum(Mem);
return level_with_minimum_memory;
}
void divide_till_end(vector<Snapshot> snapshot_stack){
while(!snapshot_stack.empty())
snapshot_stack = divide(snapshot_stack);
}
void place_BBb2(vector<int> L, vector<int> X){
int limit;
vector<Snapshot> snapshot_stack;
Snapshot currentSnapshot;
currentSnapshot.L1 = L;
currentSnapshot.X1 = X;
currentSnapshot.solutions = solutions;
snapshot_stack.push_back(currentSnapshot);
int No_of_steps = 0 ;
limit = find_minimum_memory_mod_13_mod(problem_size);
cout<<"limit = "<<limit<<"\n";
for(int xc=1;xc<=limit;xc++)
{
if(!snapshot_stack.empty())
No_of_steps++;
snapshot_stack = divide(snapshot_stack);
cout<<"StackSize = "<<snapshot_stack.size()<<"\n";
}
cout<<"NoOfSteps = "<<No_of_steps<<"\n";
/*
while(!snapshot_stack.empty())
{
snapshot_stack = divide(snapshot_stack);
if(snapshot_stack.size()>=(int)pow(2,limit))
break;
}*/
vector<Snapshot> temp_stack;
for(int ii=0;ii<snapshot_stack.size();ii++)
{
temp_stack.clear();
temp_stack.push_back(snapshot_stack[ii]);
divide_till_end(temp_stack);
}
}
vector<int> MakeHardInstance(int n)
{
//Previous implementation
vector<int> R;
vector<int> res;
int i, k, t, n0;
int m = 1000;
int epsilon;
n0 = n / 5;
R.clear();
epsilon =rand()%(m/2) +1;
//A2
for (i = 1; i <= n0; i++)
{
t = (i * epsilon);
if (find_pos(R,t) < 0)
{
R.push_back(t);
}
}
//A4
for (i = 1; i <= n0; i++)
{
t = (2 * n0 + i)*epsilon;
if (find_pos(R,t) < 0)
{
R.push_back(t);
}
}
//A5
for (i = 1; i <= n0; i++)
{
t = n*m - (2 * n0 + i) * epsilon;
if (find_pos(R,t) < 0)
{
R.push_back(t);
}
}
//A1
for (i = 1; i <= n0; i++)
{
t = n*m - i * epsilon;
if (find_pos(R,t) < 0)
{
R.push_back(t);
}
}
//D
for (i = 1; i <= n0; i++)
{
k= rand() %2;
if (k == 0)
{
t = (n0 + i) * epsilon;
}
else
{
t = n*m - (n0 + i)*epsilon;
}
if (find_pos(R,t) < 0)
{
R.push_back(t);
}
}
R.push_back(n*m);
sort(R.begin(),R.end());
return (R);
}
vector<int> MakeRandomInstance(int n, int w)
{
vector<int> R;
int rr;
//srand (time(NULL));
while (R.size() < n)
{
rr = rand()%w +1;
if (contains(R,rr) == false)
R.push_back(rr);
}
sort(R.begin(),R.end());
return (R);
}
vector<int> ComputeDistance(vector<int> A)
{
vector<int> R; //= new vector<int>();
int k, t, s, m;
s = 0;
t = 1;
m = (A.size() * (A.size() + 1)) / 2;
for (k = 0; k < m; k++)
{
if (k < A.size())
{
R.push_back(A.at(k));
continue;
}
if (s + t == A.size())
{
s = 0;
t++;
}
R.push_back(abs((int)A.at(s+t)-(int)A.at(s)));
s++;
}
sort(R.begin(),R.end());
return (R);
}
void place_BBd(vector<int> L, vector<int> X){
stack<Snapshot> snapshot_stack;
Snapshot currentSnapshot;
currentSnapshot.L1 = L;
currentSnapshot.X1 = X;
currentSnapshot.solutions = solutions;
snapshot_stack.push(currentSnapshot);
vector<int> deltaList_1,deltaList_2;
bool tst1,tst2;
int partialDigestDistance,y_pos;
while(!snapshot_stack.empty()){
//cout<<"Stack Size = "<<snapshot_stack.size()<<"\n";
currentSnapshot = snapshot_stack.top();
snapshot_stack.pop();
if (currentSnapshot.L1.empty()) { // 1 - 3
sort(currentSnapshot.X1.begin(),currentSnapshot.X1.end());
#pragma omp critical
if(!contains(solutions,currentSnapshot.X1))
solutions.push_back(currentSnapshot.X1);
continue;
}
y_pos = findMaxPos(currentSnapshot.L1); // 4
partialDigestDistance = currentSnapshot.L1.at(y_pos);
deltaList_1 = getDelta(partialDigestDistance, currentSnapshot.X1);
deltaList_2 = getDelta(width-partialDigestDistance, currentSnapshot.X1);
tst1 = isDistanceSubsetOf(deltaList_1, currentSnapshot.L1);
tst2 = isDistanceSubsetOf(deltaList_2, currentSnapshot.L1);
if(!tst1 && !tst2)
continue;
else if (tst1 && tst2)
{
vector<int> L2;
vector<int> X2;
copy_o(currentSnapshot.L1,L2);
copy_o(currentSnapshot.X1,X2);
currentSnapshot.X1.push_back(partialDigestDistance);
vector<int> removed = removePartialDigests(deltaList_1, currentSnapshot.L1);
snapshot_stack.push(currentSnapshot);
currentSnapshot.L1 = L2;
currentSnapshot.X1 = X2;
currentSnapshot.X1.push_back(width-partialDigestDistance);
vector<int> removed_1 = removePartialDigests(deltaList_2, currentSnapshot.L1);
snapshot_stack.push(currentSnapshot);
}
else if (tst1)
{
currentSnapshot.X1.push_back(partialDigestDistance);
vector<int> removed = removePartialDigests(deltaList_1, currentSnapshot.L1);
snapshot_stack.push(currentSnapshot);
}
else if (tst2)
{
currentSnapshot.X1.push_back(width-partialDigestDistance);
vector<int> removed_1 = removePartialDigests(deltaList_2, currentSnapshot.L1);
snapshot_stack.push(currentSnapshot);
}
}
}
void partialDigestProblem(vector<int> L){
int width_pos = findMaxPos(L); // 1
clock_t begin,end;
double start,end_1;
double elapsed_secs;
width = L.at(width_pos);
cout<<"width = "<<width<<"\n";
L.erase(L.begin()+width_pos);
vector<int> X;
X.push_back(0);
X.push_back(width);
vector<int> X1 = X;
vector<int> L1 = L;
vector<int> X2 = X;
vector<int> L2 = L;
vector< vector<int> > solutions1,solutions2,solutions3,solutions4;
cout<<"\n\n\n";
solutions.clear();
if(BBd_)
place_BBd(L2,X2);
else if (BBb_)
place_BBb(L2,X2);
else
place_BBb2(L2,X2);
solutions4 = solutions;
print_solutions(solutions4);
solutionsSize = solutions4.size();
//cout<<fileName_output<<"\n";
print_solutions_in_file(solutions4,fileName_output);
//solutions = solutions4;
//cout<<"\n\n\n";
solutions=solutions4;
}
int main(int argc, char* argv[]) {
int d_selection,a_selection;
int n,m;
vector <int> rand_solution;
vector <int> rand_instance;
vector < vector<int> > solutions;
double runningTime;
strcpy(fileName_time,"pdp_time.txt");
char* Algorithm= new char[100];
if(argc!=2)
{
cout<<"If you want to run the program on specific data; please rerun the programme using the prammeteres like: \nPDP input_file\n In case of specific data, we will run the BBb2 algorithm\n";
cout<<"Select the Type of Instance: \n\t\t\t0 for ordinary instance \n\t\t\t1 for Hard instance \n\t\t\t-1 for exit: ";
cin>>d_selection;
cout<<"Select the algorithm you want to use: \n\t\t\t0 for BBd \n\t\t\t1 for BBb \n\t\t\tOther for BBb2 : ";
cin>>a_selection;
if(a_selection == 0)
{
BBd_ = true;
strcpy(Algorithm,"BBd");
}
else if(a_selection == 1)
{
BBb_ = true;
strcpy(Algorithm,"BBb");
}
else
{
BBb2_= true;
strcpy(Algorithm,"BBb2");
}
if(d_selection == -1)
cout<<"Thanks for using this implementation\n";
else if(d_selection == 1)
{
cout<<"For Hard instance, Please Enter the number of restriction sites n : ";
cin>>n;
problem_size = n;
strcpy(fileName_output,"pdp_output_Zhang.txt");
writefile_time.open(fileName_time,ios::app);
writefile_time<<"\n\n\t\tn\tm\tAlgorithm\tRunningTime\n";
writefile_time.close();
rand_solution = MakeHardInstance(n);
rand_instance = ComputeDistance(rand_solution);
print_vector(rand_solution);
writefile_output.open(fileName_output,ios::app);
writefile_output<<"\nn= \t"<<n<<"\nOriginal Solution = ";
writefile_output.close();
print_vector_in_file(rand_solution,fileName_output);
writefile_output.open(fileName_output,ios::app);
writefile_output<<"\nOriginal Problem = ";
writefile_output.close();
print_vector_in_file(rand_instance,fileName_output);
writefile_output.open(fileName_output,ios::app);
writefile_output.close();
//main function
int start_s=clock();
partialDigestProblem(rand_instance);
int stop_s=clock();
cout << "time: " << (stop_s-start_s)/double(CLOCKS_PER_SEC) <<" Seconds"<< endl;
runningTime = (stop_s-start_s)/double(CLOCKS_PER_SEC);
writefile_time.open(fileName_time,ios::app);
writefile_time<<"\t\t"<<rand_solution.size()<<"\t1000\t"<<Algorithm<<"\t"<<runningTime<<"\n";
writefile_time.close();
}
else if(d_selection == 0)
{
strcpy(fileName_output,"pdp_output_Random.txt");
cout<<"For Ordinary instance Please Enter the number of restriction sites n : ";
cin>>n;
cout<<"Please Enter the average distance between resriction sites m : ";
cin>>m;
problem_size = n;
writefile_time.open(fileName_time,ios::app);
writefile_time<<"\n\n\t\tn\tm\tAlgorithm\tRunningTime\n";
writefile_time.close();
rand_solution = MakeRandomInstance(n, m);
rand_instance = ComputeDistance(rand_solution);
cout<<"\nSolution = "<<" = ";
print_vector(rand_solution);
writefile_output.open(fileName_output,ios::app);
writefile_output<<"\nn= \t"<<n<<"m= \t"<<m<<"\nOriginal Solution = ";
writefile_output.close();
print_vector_in_file(rand_solution,fileName_output);
writefile_output.open(fileName_output,ios::app);
writefile_output<<"\nOriginal Problem = ";
writefile_output.close();
print_vector_in_file(rand_instance,fileName_output);
writefile_output.close();
solutions.clear();
int start_s=clock();
//main function
partialDigestProblem(rand_instance);
int stop_s=clock();
cout << "time: " << (stop_s-start_s)/double(CLOCKS_PER_SEC) <<" Seconds"<< endl;
runningTime = (stop_s-start_s)/double(CLOCKS_PER_SEC);
writefile_time.open(fileName_time,ios::app);
writefile_time<<"\n\n\t\t"<<rand_solution.size()<<"\t"<<m<<"\t"<<Algorithm<<"\t"<<runningTime<<"\n";
writefile_time.close();
}
else
cout<<"In correct choice Please run the program again and select correct choice\n";
}
else
{
BBb2_ = true;
strcpy(Algorithm,"BBb2");
int N=0;
strcpy(fileName_output,"pdp_output_specific.txt");
vector< vector<int> > temp;
ReadSet(argv[1], rand_instance, N);
int n;
n = int((1+sqrt((double)1+8*N))/2.0);
cout<<"\n n = "<<n<<"\n";
problem_size = n;
writefile_time.open(fileName_time,ios::app);
writefile_time<<"\n\n\t\tn\tAlgorithm\tRunningTime\n";
writefile_time.close();
sort(rand_instance.begin(),rand_instance.end());
writefile_output.open(fileName_output,ios::app);
writefile_output<<"\nOriginal Problem = ";
writefile_output.close();
print_vector_in_file(rand_instance,fileName_output);
writefile_output.open(fileName_output,ios::app);
writefile_output.close();
int start_s=clock();
//main function
partialDigestProblem(rand_instance);
int stop_s=clock();
cout << "time: " << (stop_s-start_s)/double(CLOCKS_PER_SEC) <<" Seconds"<< endl;
runningTime = (stop_s-start_s)/double(CLOCKS_PER_SEC);
//print_solutions_in_file (temp,fileName_output);
cout<<"Time "<<runningTime<<"\n";
writefile_time.open(fileName_time,ios::app);
writefile_time<<"\n\n\t\t"<<n<<"\tBBb2\t"<<Algorithm<<"\t"<<runningTime<<"\n";
writefile_time.close();
}
int xx;
cin>>xx;
return 0;
}