Compare commits
4 Commits
babb720caa
...
2d45eaf383
| Author | SHA1 | Date | |
|---|---|---|---|
| 2d45eaf383 | |||
| 0b6e9418f9 | |||
| 01f2e91aac | |||
| 4292c63a15 |
@@ -516,7 +516,9 @@ void Graph::travellingSalesmanTabuSearchEngine(Graph &graph, unsigned tabuSteps,
|
|||||||
|
|
||||||
while(cheeseSupplied == true)
|
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;
|
int nextRouteLength = -1;
|
||||||
|
|
||||||
std::vector<unsigned> nextTabu(3, 0);
|
std::vector<unsigned> nextTabu(3, 0);
|
||||||
@@ -563,14 +565,7 @@ void Graph::travellingSalesmanTabuSearchEngine(Graph &graph, unsigned tabuSteps,
|
|||||||
// ...jezeli niespelnione - pomijamy ruch
|
// ...jezeli niespelnione - pomijamy ruch
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if(nextRouteLength == -1)
|
if(nextRouteLength == -1 || nextRouteLength > neighbourRouteLength)
|
||||||
{
|
|
||||||
nextRouteLength = neighbourRouteLength;
|
|
||||||
nextRoute = neighbourRoute;
|
|
||||||
nextTabu.at(1) = i;
|
|
||||||
nextTabu.at(2) = j;
|
|
||||||
}
|
|
||||||
else if(nextRouteLength > neighbourRouteLength)
|
|
||||||
{
|
{
|
||||||
nextRouteLength = neighbourRouteLength;
|
nextRouteLength = neighbourRouteLength;
|
||||||
nextRoute = neighbourRoute;
|
nextRoute = neighbourRoute;
|
||||||
@@ -665,7 +660,7 @@ void Graph::travellingSalesmanTabuSearchEngine(Graph &graph, unsigned tabuSteps,
|
|||||||
// Intensyfikacja przeszukiwania przez skrócenie kadencji
|
// Intensyfikacja przeszukiwania przez skrócenie kadencji
|
||||||
// (jezeli w ostatnim przebiegu znaleziono nowe minimum)
|
// (jezeli w ostatnim przebiegu znaleziono nowe minimum)
|
||||||
currentRoute = optimalRoute;
|
currentRoute = optimalRoute;
|
||||||
currentTabuSteps = tabuSteps / 4;
|
currentTabuSteps = tabuSteps; /// 4;
|
||||||
intensification = false;
|
intensification = false;
|
||||||
// PEA 2 Plus
|
// PEA 2 Plus
|
||||||
// Jan Potocki 2019
|
// Jan Potocki 2019
|
||||||
@@ -683,6 +678,4 @@ void Graph::travellingSalesmanTabuSearchEngine(Graph &graph, unsigned tabuSteps,
|
|||||||
// Reset licznika iteracji przed restartem
|
// Reset licznika iteracji przed restartem
|
||||||
stopCounter = 0;
|
stopCounter = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::cout << std::endl;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -448,6 +448,7 @@ int main(int argc, char *argv[])
|
|||||||
cout << route.at(i) << '\t' << length << '\t' << distFromStart << endl;
|
cout << route.at(i) << '\t' << length << '\t' << distFromStart << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cout << endl;
|
||||||
cout << "Dlugosc trasy: " << distFromStart << endl;
|
cout << "Dlugosc trasy: " << distFromStart << endl;
|
||||||
cout << endl;
|
cout << endl;
|
||||||
cout << "Czas wykonania algorytmu [s]: " << clock.read() << endl;
|
cout << "Czas wykonania algorytmu [s]: " << clock.read() << endl;
|
||||||
|
|||||||
Reference in New Issue
Block a user