示例#1
0
    static void Main(string[] args)
    {
      try
      {
        Console.WriteLine("\nBegin Simulated Bee Colony algorithm demo\n");
        Console.WriteLine("Loading cities data for SBC Traveling Salesman Problem analysis");
        CitiesData citiesData = new CitiesData(20);
        Console.WriteLine(citiesData.ToString());
        Console.WriteLine("Number of cities = " + citiesData.cities.Length);
        Console.WriteLine("Number of possible paths = " + citiesData.NumberOfPossiblePaths().ToString("#,###"));
        Console.WriteLine("Best possible solution (shortest path) length = " + citiesData.ShortestPathLength().ToString("F4"));
        
        int totalNumberBees = 100;
        int numberInactive = 20;
        int numberActive = 50;
        int numberScout = 30;

        int maxNumberVisits = 100;
        int maxNumberCycles = 3460;
        //int maxNumberVisits = 95;
        //int maxNumberCycles = 10570;
        //int maxNumberVisits = 300; // proportional to # of possible neighbors to given solution
        //int maxNumberCycles = 32450;
        
        Hive hive = new Hive(totalNumberBees, numberInactive, numberActive, numberScout, maxNumberVisits, maxNumberCycles, citiesData);
        Console.WriteLine("\nInitial random hive");
        Console.WriteLine(hive);

        bool doProgressBar = true;
        hive.Solve(doProgressBar);

        Console.WriteLine("\nFinal hive");
        Console.WriteLine(hive);

        Console.WriteLine("End Simulated Bee Colony demo");
        Console.ReadLine();
      }
      catch (Exception ex)
      {
        Console.WriteLine("Fatal: " + ex.Message);
        Console.ReadLine();
      }
    } // Main()
示例#2
0
        static void Main(string[] args)
        {
            try
              {
            Console.WriteLine("\nBegin Simulated Bee Colony algorithm demo\n");
            Console.WriteLine("Loading cities data for SBC Traveling Salesman Problem analysis");
            CitiesData citiesData = new CitiesData(20);
            Console.WriteLine(citiesData.ToString());
            Console.WriteLine("Number of cities = " + citiesData.cities.Length);
            Console.WriteLine("Number of possible paths = " + citiesData.NumberOfPossiblePaths().ToString("#,###"));
            Console.WriteLine("Best possible solution (shortest path) length = " + citiesData.ShortestPathLength().ToString("F4"));

            int totalNumberBees = 100;
            int numberInactive = 20;
            int numberActive = 50;
            int numberScout = 30;

            int maxNumberVisits = 100;
            int maxNumberCycles = 3460;
            //int maxNumberVisits = 95;
            //int maxNumberCycles = 10570;
            //int maxNumberVisits = 300; // proportional to # of possible neighbors to given solution
            //int maxNumberCycles = 32450;

            Hive hive = new Hive(totalNumberBees, numberInactive, numberActive, numberScout, maxNumberVisits, maxNumberCycles, citiesData);
            Console.WriteLine("\nInitial random hive");
            Console.WriteLine(hive);

            bool doProgressBar = true;
            hive.Solve(doProgressBar);

            Console.WriteLine("\nFinal hive");
            Console.WriteLine(hive);

            Console.WriteLine("End Simulated Bee Colony demo");
            Console.ReadLine();
              }
              catch (Exception ex)
              {
            Console.WriteLine("Fatal: " + ex.Message);
            Console.ReadLine();
              }
        }