public void Oliver30AS() { aac = new AntAlgorithms.AntAlgorithmChooser(1, 2, 0.7, 10); aa = aac.getAlgorithm(); aa.setCities(TSPImporter.importTsp("oliver30.tsp")); aa.init(); for (int i = 0; i < 2500; i++) { aa.iteration(); } aa.printBestTour("Oliver30AS"); Assert.True(true); }
public void Eil51ACS() { aac = new AntAlgorithms.AntAlgorithmChooser(1, 2, 0.1, 20, 0.9); aa = aac.getAlgorithm(); aa.setCities(TSPImporter.importTsp("eil51.tsp")); aa.init(); for (int i = 0; i < 1000; i++) { aa.iteration(); } aa.printBestTour("Eil51ACS"); Assert.True(true); }
public void Berlin52ACS() { aac = new AntAlgorithms.AntAlgorithmChooser(1, 2, 0.1, 10, 0.9); aa = aac.getAlgorithm(); aa.setCities(TSPImporter.importTsp("berlin52.tsp")); aa.init(); for (int i = 0; i < 200; i++) { aa.iteration(); } aa.printBestTour("berlin52"); Assert.True(true); }
public void Oliver30ACSWithCustomPara() { aac = new AntAlgorithms.AntAlgorithmChooser(AntAlgorithms.Mode.antColonySystem, 1, 2, 0.1, 10, 0.9, 0.000088, 0.000088); aa = aac.getAlgorithm(); aa.setCities(TSPImporter.importTsp("oliver30.tsp")); aa.init(); for (int i = 0; i < 1000; i++) { aa.iteration(); } aa.printBestTour("Oliver30ACSWithCustomPara"); Assert.True(true); }
public AntAlgorithmChooser(Mode mode, int alpha, int beta, double q, int numOfAnts, double acsQ0, double pheromoneTrailInitialValue, double tau0) { // TODO: intelligent switch due to parameters switch (mode) { case Mode.antSystem: aa = new ASAlgorithm(alpha, beta, q, numOfAnts, pheromoneTrailInitialValue); break; case Mode.antColonySystem: aa = new ACSAlgorithm(alpha, beta, q, numOfAnts, pheromoneTrailInitialValue, acsQ0, tau0); break; } }
public void Init() { Iteration = 0; Debug.Log(string.Format("!RUNNING INIT on {0}!", GetHashCode())); if (_userTour.Count != 0) { _userTour.Clear(); Debug.Log("\tUser tour cleared."); } if (PheromoneHistory.Count != 0) { PheromoneHistory.Clear(); Debug.Log("\t Pheromone History cleared."); } if (_userTourCities.Count != 0) { _userTourCities.Clear(); Debug.Log("\tUser tour cities cleared."); } if (Cities.Count == 0) { Debug.Log("\tNo Cities loaded."); } _remainingFood = new GameObject[Cities.Count]; _antAlgorithmChooser = new AntAlgorithmChooser(Mode.MinMaxAntSystem, 1, 2, 0.02, Cities.Count, -1, 0.05); _antAlgorithm = _antAlgorithmChooser.Algorithm; //_antAlgorithm = transform.GetOrAddComponent<AntAlgorithm>(); _antAlgorithm.Cities = (Cities); _antAlgorithm.Init(); FoodController.InitializeFoodPositions(GameBoardSize); _nextBestFoodPosition = new Vector3(0, 0, 0); // init // precalculation for algorithm only solution RunXIterations(Cities.Count * NumOfiterationsBetweenEating); PrintBestTour("algo best tour"); BestAlgorithmLength = BestTourLength; BestAlgorithmTour = TourToString(BestTour); BestAlgorithmIteration = BestItertation; _initializationFinished = true; _antAlgorithm.Init(); GameObject timer = GameObject.Find("Timer"); timer.GetComponent <TimerDisplayController>().Time = 0; }
public void test8() { aac = new AntAlgorithms.AntAlgorithmChooser(1, 2, 0.1, 10, 0.9); aa = aac.getAlgorithm(); cities.Add(new City(2, 4, 0)); cities.Add(new City(1, 9, 1)); cities.Add(new City(3, 8, 2)); cities.Add(new City(9, 1, 3)); cities.Add(new City(10, 1, 4)); cities.Add(new City(5, 4, 5)); cities.Add(new City(1, 11, 6)); cities.Add(new City(3, 4, 7)); aa.setCities(cities); aa.init(); for (int i = 0; i < 400; i++) { aa.iteration(); } aa.printBestTour("test8"); Assert.True(true); }
public AntAlgorithmChooser(int alpha, int beta, double q, int numOfAnts, double acsQ0) { aa = new ACSAlgorithm(alpha, beta, q, numOfAnts, acsQ0); }
public AntAlgorithmChooser(int alpha, int beta, double q, int numOfAnts) { aa = new ASAlgorithm(alpha, beta, q, numOfAnts); }