Beispiel #1
0
        private static Config GetConfig(CmdOptions opts)
        {
            if (!File.Exists(opts.ConfigPath))
            {
                throw new FileNotFoundException($"Config file {opts.ConfigPath} does not exist.");
            }

            return(JsonConvert.DeserializeObject <Config>(File.ReadAllText(opts.ConfigPath)));
        }
Beispiel #2
0
        private static Instance GetInstance(CmdOptions opts)
        {
            if (!File.Exists(opts.InstancePath))
            {
                throw new FileNotFoundException($"Instance file {opts.InstancePath} does not exist.");
            }

            return(new InputReader().ReadFromPath(opts.InstancePath));
        }
Beispiel #3
0
        private static int Run(CmdOptions opts)
        {
            try
            {
                var config       = GetConfig(opts);
                var solverConfig = config.ToSolverConfig();

                var instance = GetInstance(opts);

                if (config.UseSerializedExtendedInstance)
                {
                    instance = ExtendedInstance.GetExtendedInstance(instance);
                }
                else
                {
                    instance.SerializedExtendedInstance = null;
                }

                CheckInstance(instance);

                var solverResult = Solve(config, solverConfig, instance);
                Console.WriteLine($"Running time: {solverResult.RunningTime}");
                if (solverResult.Status == Status.Heuristic || solverResult.Status == Status.Optimal)
                {
                    Console.WriteLine($"TEC from solver: {solverResult.Objective}");
                    Console.WriteLine($"Lower bound: {solverResult.LowerBound}");
                    Console.WriteLine($"Additional info: {JsonConvert.SerializeObject(solverResult.AdditionalInfo)}");
                }
                else if (solverResult.Status == Status.Infeasible)
                {
                    Console.WriteLine($"The instance is proven to be infeasible.");
                }
                else if (solverResult.Status == Status.NoSolution)
                {
                    Console.WriteLine($"No solution was found.");
                }

                return(0);
            }
            catch (FileNotFoundException ex)
            {
                Console.WriteLine(ex.Message);
                return(1);
            }
        }