Beispiel #1
0
        public static void Main(string[] args)
        {
            try
            {
                Timer = new Stopwatch();

                // Set console size
                Console.WindowHeight = 40;
                Console.WindowWidth  = 140;

                Console.WriteLine("........................");
                Console.WriteLine(" SSSS  II  MMM       MMM");
                Console.WriteLine("SSSS   II  MM MM   MM MM");
                Console.WriteLine("SS     II  MM  MMMMM  MM");
                Console.WriteLine("SS     II  MM   MMM   MM  -----");
                Console.WriteLine(" SSS   II  MM         MM  -----");
                Console.WriteLine("   SS  II  MM         MM  -----");
                Console.WriteLine("   SS  II  MM         MM");
                Console.WriteLine(" SSSS  II  MM         MM");
                Console.WriteLine("SSSS   II  MM         MM");
                Console.WriteLine("........................");

                // Generates the parameters
                GenerateParameters();
                if (args.Count() == 0 || args[0] == "-h")
                {
                    Console.Write(Params.ToString());
                    return;
                }

                SetParameters(Params.Tokenize(args));
                Params.Validate();
                PreparePipeline();
                WriteParameters();
                if (UseRandomJobs)
                {
                    // Generate random Problem
                    Timer.Start();
                    Console.Write("Generating problem ... ");
                    RandomProblem();
                    Timer.Stop();
                    Console.WriteLine(string.Format("{0} msec.", Timer.ElapsedMilliseconds));
                    Console.WriteLine();
                    InOut.WriteJobList(CurrentProblem, Params["-ojf"].Value.ToString());
                }
                else
                {
                    // TODO: read from file
                    InOut.ReadProblem(Program.Params["-i"].Value.ToString());
                }

                // Logs
                InOut.LogProblemSummary(CurrentProblem);

                // Solving the given problem
                Timer.Restart();
                Console.Write("Solving problem ... ");
                Solver.Run(CurrentProblem);
                Console.WriteLine(string.Format("Solution Found in {0} msec.", Timer.ElapsedMilliseconds));
                Console.WriteLine();

                // Solution
                InOut.WriteSolution(Params["-osof"].Value.ToString());

                // Logs
                InOut.LogSolutionSummary(CurrentProblem);
                Console.WriteLine("Press any key to exit.");
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                Console.WriteLine("Press any key to exit.");
            }
            finally
            {
                Console.ReadKey();
            }
        }