From b2e6c1a3f984567393528d41a3eb9262d6024d64 Mon Sep 17 00:00:00 2001 From: Jochen Keil Date: Tue, 29 Jun 2010 21:26:21 +0200 Subject: [PATCH] make computation of nearest neighbour list depth smarter If it is set to zero then figure out a value depending on the number of cities to visit. It it bigger then the number of cities to visit, set it equal to number of cities. --- aco/strategy/GraphStrategy.java | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/aco/strategy/GraphStrategy.java b/aco/strategy/GraphStrategy.java index 4e36596..2fd0308 100644 --- a/aco/strategy/GraphStrategy.java +++ b/aco/strategy/GraphStrategy.java @@ -11,12 +11,16 @@ public class GraphStrategy { } public void computeNearestNeighbourListDepth() { - if (acom.getNumOfCities() <= 30) - acom.setNearestNeighbourListDepth(acom.getNumOfCities() - 1); - else if (acom.getNumOfCities() > 30 && acom.getNumOfCities() < 80) - acom.setNearestNeighbourListDepth(acom.getNumOfCities()/2); - else - acom.setNearestNeighbourListDepth(40); + if (acom.getNearestNeighbourListDepth() == 0) { + if (acom.getNumOfCities() <= 30) + acom.setNearestNeighbourListDepth(acom.getNumOfCities() - 1); + else if (acom.getNumOfCities() > 30 && acom.getNumOfCities() < 80) + acom.setNearestNeighbourListDepth(acom.getNumOfCities()/2); + else + acom.setNearestNeighbourListDepth(40); + } else if (acom.getNearestNeighbourListDepth() > acom.getNumOfCities()) { + acom.setNearestNeighbourListDepth(acom.getNumOfCities()); + } } public int nearestNeighbourHeuristicRandomStart() { -- 2.11.4.GIT