public Tabu(LocationMap map) { this.map = map; // use the provided LocationMap for TSP tabuListSize = (int)Math.Sqrt(map.PointCollection.Count) + 2; // heuristic for a good list size // assume LocationMap can choose whether to loop the last point in the path back to the first point path = new int[map.PointCollection.Count]; for (int i = 0; i < path.Length; i++) { path[i] = i; } bestPath = path.ToArray(); tabuList = new int[map.PointCollection.Count, map.PointCollection.Count]; for (int i = 0; i < map.PointCollection.Count; i++) { for (int j = 0; j < map.PointCollection.Count; j++) { tabuList[i, j] = 0; } } currentDistance = map.CalcRouteDistance(path); bestDistance = currentDistance; }
private void buttonStart_Click(object sender, EventArgs e) { if (!beginTabuSearch && pointsForTSP.Count > 3) { beginTabuSearch = true; LocationMap map = new LocationMap(); map.PointCollection = pointsForTSP; tabuSearch = new Tabu(map); //buttonRestart.Enabled = true; } }