Esempio n. 1
0
        static void Main(string[] args)
        {
            Console.WriteLine($"1. Отримати матрицю з файлу");

            var decision = Convert.ToInt32(Console.ReadLine());
            var loader   = new Loader();

            switch (decision)
            {
            case 1:
                Console.WriteLine($"Введи назву файлу без розширення :");
                var name = Console.ReadLine();
                var data = loader.ReadFromFile($"{name}.txt");
                if (data.Cities == 0)
                {
                    Console.ReadKey();
                    return;
                }
                var solver = new BBAlgorithm(data);
                var sw     = new Stopwatch();
                sw.Start();
                solver.Solve();
                sw.Stop();
                Console.WriteLine(sw.Elapsed);
                break;



            default:
                Console.WriteLine($"Натисни 1");
                break;
            }

            Console.ReadKey();
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            Console.WriteLine($"1. Read matrix from file");
            Console.WriteLine($"2. Random data");
            var decision = Convert.ToInt32(Console.ReadLine());
            var loader   = new Loader();

            switch (decision)
            {
            case 1:
                Console.WriteLine($"Enter name of matrix(without txt):");
                var name = Console.ReadLine();
                var data = loader.ReadFromFile($"{name}.txt");
                if (data.Cities == 0)
                {
                    Console.ReadKey();
                    return;
                }
                var solver = new BBAlgorithm(data);
                var sw     = new Stopwatch();
                sw.Start();
                solver.Solve();
                sw.Stop();
                Console.WriteLine(sw.Elapsed);
                break;

            case 2:
                Console.WriteLine($"Size of matrix ");
                var cities  = Convert.ToInt32(Console.ReadLine());
                var dataa   = loader.RandomFile(cities);
                var solver2 = new BBAlgorithm(dataa);
                var sww     = new Stopwatch();
                sww.Start();
                solver2.Solve();
                sww.Stop();
                Console.WriteLine(sww.Elapsed);
                break;


            default:
                Console.WriteLine($"Choose the command");
                break;
            }

            Console.ReadKey();
        }
Esempio n. 3
0
        static void Main(string[] args)
        {
            Console.WriteLine($"1. Wczytaj dane z pliku");
            Console.WriteLine($"2. Losuj dane");
            Console.WriteLine($"3. Testuj");
            var decision = Convert.ToInt32(Console.ReadLine());
            var loader   = new Loader();

            switch (decision)
            {
            case 1:
                Console.WriteLine($"Podaj nazwe pliku:");
                var name = Console.ReadLine();
                var data = loader.ReadFromFile($"{name}.txt");
                if (data.Cities == 0)
                {
                    Console.ReadKey();
                    return;
                }
                var solver = new BBAlgorithm(data);
                var sw     = new Stopwatch();
                sw.Start();
                solver.Solve();
                sw.Stop();
                Console.WriteLine(sw.Elapsed);
                break;

            case 2:
                Console.WriteLine($"Podal liczbe miast: ");
                var cities  = Convert.ToInt32(Console.ReadLine());
                var dataa   = loader.RandomFile(cities);
                var solver2 = new BBAlgorithm(dataa);
                var sww     = new Stopwatch();
                sww.Start();
                solver2.Solve();
                sww.Stop();
                Console.WriteLine(sww.Elapsed);
                break;

            case 3:
                var testArray = new[] { 8, 10, 12, 14, 16, 18, 20 };

                foreach (var test in testArray)
                {
                    var span = new TimeSpan();
                    using (var file = new StreamWriter($"test{test}.txt"))
                    {
                        var _sw = new Stopwatch();
                        for (var i = 0; i < 100; i++)
                        {
                            _sw.Reset();
                            var _data   = loader.RandomFile(test);
                            var _solver = new BBAlgorithm(_data);
                            _sw.Start();
                            _solver.Solve();
                            _sw.Stop();
                            file.WriteLine(_sw.Elapsed);
                            span += _sw.Elapsed;
                        }
                        file.WriteLine($"srednia: {span.Duration()}");
                    }
                }
                break;

            default:
                Console.WriteLine($"wybierz jakas opcje");
                break;
            }

            Console.ReadKey();
        }
Esempio n. 4
0
        static void Main(string[] args)
        {
            Console.WriteLine($"1. Отримати матрицю з файлу");
            // Console.WriteLine($"2. Випадкові дані");
            //Console.WriteLine($"3. Тест");
            var decision = Convert.ToInt32(Console.ReadLine());
            var loader   = new Loader();

            switch (decision)
            {
            case 1:
                Console.WriteLine($"Назва файлу:");
                var name = Console.ReadLine();
                var data = loader.ReadFromFile($"{name}.txt");
                if (data.Cities == 0)
                {
                    Console.ReadKey();
                    return;
                }
                var solver = new BBAlgorithm(data);
                var sw     = new Stopwatch();
                sw.Start();
                solver.Solve();
                sw.Stop();
                Console.WriteLine(sw.Elapsed);
                break;

            //case 2:
            //    Console.WriteLine($"Podal liczbe miast: ");
            //    var cities = Convert.ToInt32(Console.ReadLine());
            //    var dataa = loader.RandomFile(cities);
            //    var solver2 = new BBAlgorithm(dataa);
            //    var sww = new Stopwatch();
            //    sww.Start();
            //    solver2.Solve();
            //    sww.Stop();
            //    Console.WriteLine(sww.Elapsed);
            //    break;
            //case 3:
            //    var testArray = new[] {8, 10, 12, 14, 16, 18, 20};

            //    foreach (var test in testArray)
            //    {
            //        var span = new TimeSpan();
            //        using (var file = new StreamWriter($"test{test}.txt"))
            //        {
            //            var _sw = new Stopwatch();
            //            for (var i = 0; i < 100; i++)
            //            {
            //                _sw.Reset();
            //                var _data = loader.RandomFile(test);
            //                var _solver = new BBAlgorithm(_data);
            //                _sw.Start();
            //                _solver.Solve();
            //                _sw.Stop();
            //                file.WriteLine(_sw.Elapsed);
            //                span += _sw.Elapsed;
            //            }
            //            file.WriteLine($"srednia: {span.Duration()}");
            //        }
            //    }
            //    break;

            default:
                Console.WriteLine($"Натисни 1");
                break;
            }

            Console.ReadKey();
        }