private void UpdatePheromone(Map.Map map) { if (flagAsRanks) { updatePheromoneASrank(map); } else if (flagACS) { updatePheromonesACS(map); } else { UpdatePheromoneRegular(map); } }
private void UpdatePheromoneOnBestPath(Map.Map map) { double increase = 0; for (int i = 0; i < map.Height; i++) { for (int j = 0; j < map.Width; j++) { if (bestPath.Contains(new Coordinates(i, j))) { increase = (Q / bestLength); } pheromones[i][j] += increase; } } }
private void updatePheromonesACS(Map.Map map) { double decrease = 0; double increase = 0; for (int i = 0; i < map.Height; i++) { for (int j = 0; j < map.Width; j++) { if (!(i == map.Start.Height && j == map.Start.Width) && !(i == map.Destination.Height && j == map.Destination.Width)) { decrease = (1.0 - rho) * pheromones[i][j]; increase = 0; if (bestPath.Contains(new Coordinates(i, j))) { increase = (Q / bestLength); } pheromones[i][j] = decrease + increase; } } } }
private bool IsDestinationFound(Coordinates pos, Map.Map map) { return(Math.Abs(pos.Height - map.Destination.Height) <= 1 && Math.Abs(pos.Width - map.Destination.Width) <= 1); //stop conditions, last found must be next to dest. }