Quellcode durchsuchen

Corrected FULL_MATRIX parser and automeasure

Jan Potocki vor 5 Jahren
Ursprung
Commit
8ea0a2240a
1 geänderte Dateien mit 20 neuen und 5 gelöschten Zeilen
  1. 20
    5
      pea2plus.cpp

+ 20
- 5
pea2plus.cpp Datei anzeigen

@@ -15,9 +15,9 @@ using namespace std;
15 15
 // Liczba powtorzen automatycznych pomiarow
16 16
 const int measureIterations = 10;
17 17
 // liczba automatycznych pomiarow
18
-const int measureNumber = 4;
18
+const int measureNumber = 2;
19 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 21
 // Maksymalna odleglosc miast przy automatycznym generowaniu
22 22
 const int measureSalesmanDistance = 400;
23 23
 
@@ -55,6 +55,17 @@ void parseTSPLIB_FULL_MATRIX(const char *filename, Graph **graph)
55 55
         salesmanDataFile >> fileInput;
56 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 69
         do
59 70
             salesmanDataFile >> fileInput;
60 71
         while(fileInput != "EDGE_WEIGHT_FORMAT:");
@@ -102,6 +113,8 @@ void parseTSPLIB_FULL_MATRIX(const char *filename, Graph **graph)
102 113
         cout << "+++ MELON MELON MELON +++ Brak pliku " << filename << " +++" << endl;
103 114
         cout << endl;
104 115
     }
116
+
117
+    return;
105 118
 }
106 119
 
107 120
 void parseTSPLIB_EUC_2D(const char *filename, Graph **graph)
@@ -185,6 +198,8 @@ void parseTSPLIB_EUC_2D(const char *filename, Graph **graph)
185 198
         cout << "+++ MELON MELON MELON +++ Brak pliku " << filename << " +++" << endl;
186 199
         cout << endl;
187 200
     }
201
+
202
+    return;
188 203
 }
189 204
 
190 205
 void banner()
@@ -549,7 +564,7 @@ int main(int argc, char *argv[])
549 564
                             for(int j = 1; j < route.size(); j++)
550 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 568
                                 measureResult = routeLength;
554 569
 
555 570
                             // Z dywersyfikacja
@@ -561,7 +576,7 @@ int main(int argc, char *argv[])
561 576
                             for(int j = 1; j < route.size(); j++)
562 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 580
                                 measureResultDiv = routeLength;
566 581
                         }
567 582
                     }
@@ -573,7 +588,7 @@ int main(int argc, char *argv[])
573 588
                     salesmanToFile << "czas - bez dywersyfikacji - z dywersyfikacja" << endl;
574 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 593
                     salesmanToFile.close();
579 594
 

Laden…
Abbrechen
Speichern