Simplified if-else statement (TS)
This commit is contained in:
@@ -567,14 +567,7 @@ void Graph::travellingSalesmanTabuSearchEngine(Graph &graph, unsigned tabuSteps,
|
|||||||
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;
|
||||||
@@ -692,7 +685,7 @@ void Graph::travellingSalesmanTabuSearchEngine(Graph &graph, unsigned tabuSteps,
|
|||||||
{
|
{
|
||||||
currentRoute = Graph::travellingSalesmanHybrid(graph);
|
currentRoute = Graph::travellingSalesmanHybrid(graph);
|
||||||
currentRouteLength = 0;
|
currentRouteLength = 0;
|
||||||
|
|
||||||
for(int i = 1; i < currentRoute.size(); i++)
|
for(int i = 1; i < currentRoute.size(); i++)
|
||||||
currentRouteLength += graph.getWeight(currentRoute.at(i - 1), currentRoute.at(i));
|
currentRouteLength += graph.getWeight(currentRoute.at(i - 1), currentRoute.at(i));
|
||||||
} while(currentRouteLength > criticalLength);
|
} while(currentRouteLength > criticalLength);
|
||||||
|
|||||||
Reference in New Issue
Block a user