static void Main(string[] args)
        {
            try
            {
                int      pathStart = 0, pathEnd = 0;
                EdgeList graph = LoadGraph("D:\\dump\\graph4bee.txt", ref pathStart, ref pathEnd);
                Console.WriteLine("Loaded graph:");
                Console.WriteLine(graph.ToString());

                int totalNumberBees = 30;

                int numberWorkers = Convert.ToInt32(totalNumberBees * .85);;
                int numberScout   = Convert.ToInt32(totalNumberBees * .15);;

                int maxNumberVisits = 3;
                int maxNumberCycles = 20;
                int reportFreq      = 2;

                Hive hive = new Hive(numberWorkers, numberScout, maxNumberVisits,
                                     graph, pathStart, pathEnd, maxNumberCycles, reportFreq);

                hive.Solve();

                Console.ReadLine();
            }
            catch (Exception ex)
            {
                Console.WriteLine("Fatal: " + ex.Message);
                Console.ReadLine();
            }
        }
Ejemplo n.º 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 = 500;

                // Ideal numbers are: Active 75% / Inactive 10% / Scout 15%
                int numberActive   = Convert.ToInt32(totalNumberBees * .75);
                int numberInactive = Convert.ToInt32(totalNumberBees * .10);;
                int numberScout    = Convert.ToInt32(totalNumberBees * .15);;

                //int maxNumberVisits = 300;
                //int maxNumberCycles = 32450;
                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()
Ejemplo n.º 3
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();
              }
        }