5 Commits

Author SHA1 Message Date
Jan Potocki 3691314819 Fixed newline (part II) 2020-01-20 20:14:34 +01:00
Jan Potocki 2d45eaf383 Removed commented endl 2020-01-20 19:22:37 +01:00
Jan Potocki 0b6e9418f9 Fixed newline in output (TS) 2020-01-20 19:22:07 +01:00
Jan Potocki 01f2e91aac Minor if-else simplification 2020-01-20 19:19:01 +01:00
Jan Potocki 4292c63a15 Fixed crash when entire neighborhood is on tabu list 2020-01-20 19:18:13 +01:00
2 changed files with 6 additions and 12 deletions
+5 -12
View File
@@ -516,7 +516,9 @@ void Graph::travellingSalesmanTabuSearchEngine(Graph &graph, unsigned tabuSteps,
while(cheeseSupplied == true)
{
std::vector<unsigned> nextRoute;
std::vector<unsigned> nextRoute = currentRoute;
// ...na wszelki wypadek, gdyby cale sasiedztwo bylo na liscie tabu
// (zeby algorytm sie nie wywalil)
int nextRouteLength = -1;
std::vector<unsigned> nextTabu(3, 0);
@@ -563,14 +565,7 @@ void Graph::travellingSalesmanTabuSearchEngine(Graph &graph, unsigned tabuSteps,
// ...jezeli niespelnione - pomijamy ruch
continue;
if(nextRouteLength == -1)
{
nextRouteLength = neighbourRouteLength;
nextRoute = neighbourRoute;
nextTabu.at(1) = i;
nextTabu.at(2) = j;
}
else if(nextRouteLength > neighbourRouteLength)
if(nextRouteLength == -1 || nextRouteLength > neighbourRouteLength)
{
nextRouteLength = neighbourRouteLength;
nextRoute = neighbourRoute;
@@ -665,7 +660,7 @@ void Graph::travellingSalesmanTabuSearchEngine(Graph &graph, unsigned tabuSteps,
// Intensyfikacja przeszukiwania przez skrócenie kadencji
// (jezeli w ostatnim przebiegu znaleziono nowe minimum)
currentRoute = optimalRoute;
currentTabuSteps = tabuSteps / 4;
currentTabuSteps = tabuSteps; /// 4;
intensification = false;
// PEA 2 Plus
// Jan Potocki 2019
@@ -683,6 +678,4 @@ void Graph::travellingSalesmanTabuSearchEngine(Graph &graph, unsigned tabuSteps,
// Reset licznika iteracji przed restartem
stopCounter = 0;
}
std::cout << std::endl;
}
+1
View File
@@ -439,6 +439,7 @@ int main(int argc, char *argv[])
// Wyswietlenie trasy
unsigned distFromStart = 0;
unsigned length = 0;
cout << endl;
cout << route.at(0) << '\t' << length << '\t' << distFromStart << endl;
for(int i = 1; i < route.size(); i++)
{