Browse Source

Corrected FULL_MATRIX parser and automeasure

Jan Potocki 5 years ago
parent
commit
8ea0a2240a
1 changed files with 20 additions and 5 deletions
  1. 20
    5
      pea2plus.cpp

+ 20
- 5
pea2plus.cpp View File

15
 // Liczba powtorzen automatycznych pomiarow
15
 // Liczba powtorzen automatycznych pomiarow
16
 const int measureIterations = 10;
16
 const int measureIterations = 10;
17
 // liczba automatycznych pomiarow
17
 // liczba automatycznych pomiarow
18
-const int measureNumber = 4;
18
+const int measureNumber = 2;
19
 // Czas zatrzymania algorytmu tabu search w kazdym z automatycznych pomiarow
19
 // Czas zatrzymania algorytmu tabu search w kazdym z automatycznych pomiarow
20
-const int measureTabuStop[4] = {30, 60, 120, 240};
20
+const int measureTabuStop[2] = {1, 1};
21
 // Maksymalna odleglosc miast przy automatycznym generowaniu
21
 // Maksymalna odleglosc miast przy automatycznym generowaniu
22
 const int measureSalesmanDistance = 400;
22
 const int measureSalesmanDistance = 400;
23
 
23
 
55
         salesmanDataFile >> fileInput;
55
         salesmanDataFile >> fileInput;
56
         int vertex = stoi(fileInput);
56
         int vertex = stoi(fileInput);
57
 
57
 
58
+        do
59
+            salesmanDataFile >> fileInput;
60
+        while(fileInput != "EDGE_WEIGHT_TYPE:");
61
+
62
+        salesmanDataFile >> fileInput;
63
+        if(fileInput != "EXPLICIT")
64
+        {
65
+            cout << "+++ MELON MELON MELON +++ Nieobslugiwany format " << fileInput << " +++" << endl;
66
+            return;
67
+        }
68
+
58
         do
69
         do
59
             salesmanDataFile >> fileInput;
70
             salesmanDataFile >> fileInput;
60
         while(fileInput != "EDGE_WEIGHT_FORMAT:");
71
         while(fileInput != "EDGE_WEIGHT_FORMAT:");
102
         cout << "+++ MELON MELON MELON +++ Brak pliku " << filename << " +++" << endl;
113
         cout << "+++ MELON MELON MELON +++ Brak pliku " << filename << " +++" << endl;
103
         cout << endl;
114
         cout << endl;
104
     }
115
     }
116
+
117
+    return;
105
 }
118
 }
106
 
119
 
107
 void parseTSPLIB_EUC_2D(const char *filename, Graph **graph)
120
 void parseTSPLIB_EUC_2D(const char *filename, Graph **graph)
185
         cout << "+++ MELON MELON MELON +++ Brak pliku " << filename << " +++" << endl;
198
         cout << "+++ MELON MELON MELON +++ Brak pliku " << filename << " +++" << endl;
186
         cout << endl;
199
         cout << endl;
187
     }
200
     }
201
+
202
+    return;
188
 }
203
 }
189
 
204
 
190
 void banner()
205
 void banner()
549
                             for(int j = 1; j < route.size(); j++)
564
                             for(int j = 1; j < route.size(); j++)
550
                                 routeLength += graph->getWeight(route.at(j - 1), route.at(j));
565
                                 routeLength += graph->getWeight(route.at(j - 1), route.at(j));
551
 
566
 
552
-                            if(measureResult = -1 || measureResult > routeLength)
567
+                            if(measureResult == -1 || measureResult > routeLength)
553
                                 measureResult = routeLength;
568
                                 measureResult = routeLength;
554
 
569
 
555
                             // Z dywersyfikacja
570
                             // Z dywersyfikacja
561
                             for(int j = 1; j < route.size(); j++)
576
                             for(int j = 1; j < route.size(); j++)
562
                                 routeLength += graph->getWeight(route.at(j - 1), route.at(j));
577
                                 routeLength += graph->getWeight(route.at(j - 1), route.at(j));
563
 
578
 
564
-                            if(measureResultDiv = -1 || measureResultDiv > routeLength)
579
+                            if(measureResultDiv == -1 || measureResultDiv > routeLength)
565
                                 measureResultDiv = routeLength;
580
                                 measureResultDiv = routeLength;
566
                         }
581
                         }
567
                     }
582
                     }
573
                     salesmanToFile << "czas - bez dywersyfikacji - z dywersyfikacja" << endl;
588
                     salesmanToFile << "czas - bez dywersyfikacji - z dywersyfikacja" << endl;
574
                     for(int i = 0; i < measureNumber; i++)
589
                     for(int i = 0; i < measureNumber; i++)
575
                     {
590
                     {
576
-                        salesmanToFile << measureTabuStop[i] << " [s]: " << measureResult << ' ' << measureResultsDiv << endl;
591
+                        salesmanToFile << measureTabuStop[i] << " [s]: " << measureResult << ' ' << measureResultDiv << endl;
577
                     }
592
                     }
578
                     salesmanToFile.close();
593
                     salesmanToFile.close();
579
 
594
 

Loading…
Cancel
Save