Fixed automatic measure
This commit is contained in:
+12
-20
@@ -17,7 +17,7 @@ const int measureIterations = 10;
|
|||||||
// liczba automatycznych pomiarow
|
// liczba automatycznych pomiarow
|
||||||
const int measureNumber = 4;
|
const int measureNumber = 4;
|
||||||
// Czas zatrzymania algorytmu tabu search w kazdym z automatycznych pomiarow
|
// Czas zatrzymania algorytmu tabu search w kazdym z automatycznych pomiarow
|
||||||
const int measureTabuStop[4] = {1, 5, 10, 15};
|
const int measureTabuStop[4] = {30, 60, 120, 240};
|
||||||
// Maksymalna odleglosc miast przy automatycznym generowaniu
|
// Maksymalna odleglosc miast przy automatycznym generowaniu
|
||||||
const int measureSalesmanDistance = 400;
|
const int measureSalesmanDistance = 400;
|
||||||
|
|
||||||
@@ -503,8 +503,8 @@ int main(int argc, char *argv[])
|
|||||||
break;
|
break;
|
||||||
case 7:
|
case 7:
|
||||||
{
|
{
|
||||||
// PEA 2
|
// PEA 2 Plus
|
||||||
// Jan Potocki 2017
|
// Jan Potocki 2019
|
||||||
if(graph != NULL)
|
if(graph != NULL)
|
||||||
{
|
{
|
||||||
unsigned effectiveTabuLength;
|
unsigned effectiveTabuLength;
|
||||||
@@ -519,12 +519,8 @@ int main(int argc, char *argv[])
|
|||||||
effectiveTabuLength = tabuLength;
|
effectiveTabuLength = tabuLength;
|
||||||
}
|
}
|
||||||
|
|
||||||
double measureResults[measureNumber], measureResultsDiv[measureNumber];
|
int measureResult = -1;
|
||||||
for(int i = 0; i < measureNumber; i++)
|
int measureResultDiv = -1;
|
||||||
{
|
|
||||||
measureResults[i] = 0;
|
|
||||||
measureResultsDiv[i] = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
cout << "Pomiary dla problemu komiwojazera, tabu search" << tabuLength << endl;
|
cout << "Pomiary dla problemu komiwojazera, tabu search" << tabuLength << endl;
|
||||||
|
|
||||||
@@ -552,7 +548,9 @@ int main(int argc, char *argv[])
|
|||||||
routeLength = 0;
|
routeLength = 0;
|
||||||
for(int j = 1; j < route.size(); j++)
|
for(int j = 1; j < route.size(); j++)
|
||||||
routeLength += graph->getWeight(route.at(j - 1), route.at(j));
|
routeLength += graph->getWeight(route.at(j - 1), route.at(j));
|
||||||
measureResults[i] += routeLength;
|
|
||||||
|
if(measureResult = -1 || measureResult > routeLength)
|
||||||
|
measureResult = routeLength;
|
||||||
|
|
||||||
// Z dywersyfikacja
|
// Z dywersyfikacja
|
||||||
cout << "Pomiar " << measureTabuStop[i] << " [s] (" << krok + 1 << " z " << measureIterations << " z dywersyfikacja)..." << endl;
|
cout << "Pomiar " << measureTabuStop[i] << " [s] (" << krok + 1 << " z " << measureIterations << " z dywersyfikacja)..." << endl;
|
||||||
@@ -562,16 +560,10 @@ int main(int argc, char *argv[])
|
|||||||
routeLength = 0;
|
routeLength = 0;
|
||||||
for(int j = 1; j < route.size(); j++)
|
for(int j = 1; j < route.size(); j++)
|
||||||
routeLength += graph->getWeight(route.at(j - 1), route.at(j));
|
routeLength += graph->getWeight(route.at(j - 1), route.at(j));
|
||||||
measureResultsDiv[i] += routeLength;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
cout << "Opracowywanie wynikow..." << endl;
|
if(measureResultDiv = -1 || measureResultDiv > routeLength)
|
||||||
|
measureResultDiv = routeLength;
|
||||||
for(int i = 0; i < measureNumber; i++)
|
}
|
||||||
{
|
|
||||||
measureResults[i] = nearbyint(measureResults[i] / measureIterations);
|
|
||||||
measureResultsDiv[i] = nearbyint(measureResultsDiv[i] / measureIterations);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cout << "Zapis wynikow..." << endl;
|
cout << "Zapis wynikow..." << endl;
|
||||||
@@ -581,7 +573,7 @@ int main(int argc, char *argv[])
|
|||||||
salesmanToFile << "czas - bez dywersyfikacji - z dywersyfikacja" << endl;
|
salesmanToFile << "czas - bez dywersyfikacji - z dywersyfikacja" << endl;
|
||||||
for(int i = 0; i < measureNumber; i++)
|
for(int i = 0; i < measureNumber; i++)
|
||||||
{
|
{
|
||||||
salesmanToFile << measureTabuStop[i] << " [s]: " << (int)measureResults[i] << ' ' << (int)measureResultsDiv[i] << endl;
|
salesmanToFile << measureTabuStop[i] << " [s]: " << measureResult << ' ' << measureResultsDiv << endl;
|
||||||
}
|
}
|
||||||
salesmanToFile.close();
|
salesmanToFile.close();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user