Esempio n. 1
0
        static int Main(string[] args)
        {
            try
            {
                ArgParser.parse_args(args);

                InstanceGeneratorConfig instanceGeneratorConfig = ArgParser.getInstanceGeneratorConfig();
                InstanceGeneratorMain   instanceGenerator       = new InstanceGenerator.InstanceGeneratorMain(instanceGeneratorConfig);
                instanceGenerator.create_instance();

                PMedian pMedianProblem = new PMedian(instanceGenerator, ArgParser.getDrawingPath() + "PMEDIAN");
                pMedianProblem.setup_problem();
                pMedianProblem.solve_instance(ArgParser.getModelRuntime());
                pMedianProblem.publish_model();

                if (ArgParser.getDrawingPath() != null)
                {
                    InstanceDrawing instanceDrawing = new InstanceDrawing(instanceGenerator, new DrawingSettings());
                    instanceDrawing.draw(ArgParser.getDrawingPath() + "instance");
                    pMedianProblem.draw_solution(instanceDrawing, ArgParser.getDrawingPath() + "solution");
                }

                if (ArgParser.results_filename != null)
                {
                    pMedianProblem.write_results_to_file(ArgParser.results_filename);
                }

                return(0);
                //else
                //{
                //    PMedianController.folder_cleanup(".bmp", ".lp", ".sol");

                //    InstanceGenerator.InstanceGeneratorMain instanceGenerator = new InstanceGenerator.InstanceGeneratorMain(new InstanceGeneratorConfig());
                //    instanceGenerator.create_instance();
                //    InstanceDrawing instanceDrawing = new InstanceDrawing(instanceGenerator, new DrawingSettings());
                //    instanceDrawing.draw("instance");
                //    PMedian pMedianProblem = new PMedian(instanceGenerator, "PMedian");
                //    pMedianProblem.setup_problem();
                //    pMedianProblem.solve_instance(7200);
                //    pMedianProblem.publish_model();
                //    pMedianProblem.draw_solution(instanceDrawing, "solution");

                //    return 0;
                //}
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                ArgParser.getHelp();
                return(1);
            }
        }
Esempio n. 2
0
        public static bool parse_args(string[] p_args)
        {
            args = p_args;
            bool is_config_set = ArgParser.parse_instance_config();

            ArgParser.parse_optional_flags(is_config_set);
            ArgParser.parse_help();
            if (curr_pos != args.Length)
            {
                end(1, $"Error when parsing arguments: incorrect syntax for '{string.Join(" ", args.ToArray())}'. Please refer to the usage instructions (-help).");
            }
            return(true);
        }