Exemple #1
0
 public SilverMealExactSolver(ISilverMeanInstance instance, SilverMealExactSolverParams p_parameters) : base(instance)
 {
     num_periods = instance.num_periods;
     parameters  = p_parameters;
     env         = new GRBEnv()
     {
         OutputFlag = Convert.ToInt32(p_parameters.verbose)
     };
     model = new GRBModel(env);
 } // should check if num_periods of instance and solution match
Exemple #2
0
        static int RunAndReturnExitCode(Options options)
        {
            ISilverMeanInstance instance = null;

            // first option set
            if (options.filename != null)
            {
                instance = ReadInstanceFromFile(options.filename);
            }
            else if (options.sample_index != null)
            {
                if (options.sample_index < 0 || options.sample_index > 3)
                {
                    throw new Exception("Sample index value must be a value between 0 and 3");
                }
                Console.WriteLine($"Using sample instance number {options.sample_index}...");
                instance = SampleInstances.sample[(int)options.sample_index];
            }
            // second option set
            if (options.heuristic == true)
            {
                ISolver solver = new SilverMealHeuristicSolver(instance);
                solver.PrintInstance();
                solver.Run();
                solver.PrintSolution();
                return(0);
            }
            else if (options.exact == true)
            {
                ISolver solver = new SilverMealExactSolver(instance, new SilverMealExactSolverParams()
                {
                    verbose = options.verbose
                });
                solver.PrintInstance();
                solver.Run();
                solver.PrintSolution();
                return(0);
            }
            else if (options.compare == true)
            {
                ISolver solver = new SilverMealHeuristicSolver(instance);
                solver.PrintInstance();
                solver.Run();
                solver.PrintSolution();
                solver = new SilverMealExactSolver(instance, new SilverMealExactSolverParams()
                {
                    verbose = options.verbose
                });
                solver.PrintInstance();
                solver.Run();
                solver.PrintSolution();
                return(0);
            }
            return(1);
        }
 public SilverMealHeuristicSolver(ISilverMeanInstance instance) : base(instance)
 {
     num_periods = instance.num_periods;
 }                                                                                                                       // should check if num_periods of instance and solution match. 'verbose' is not used here