Example #1
0
 public async Task <bool> Run()
 {
     try
     {
         RunCommands();
         OutputReader.VerifyCompleted("res/output.txt");
         var metadata = MetadataReader.Read("metadata.txt");
         var results  = ResultReader.Read(metadata);
         var uploader = new Uploader(metadata.ApiAddress);
         foreach (var result in results)
         {
             await uploader.Upload(result);
         }
     }
     catch (Exception e)
     {
         Console.WriteLine($"ERROR: {e.Message}");
         Console.WriteLine("Aborting. No results will be uploaded");
         Console.WriteLine("Press ENTER to exit");
         Console.ReadLine();
         return(false);
     }
     Console.WriteLine("Success!");
     Console.WriteLine("Press ENTER to exit");
     Console.ReadLine();
     return(true);
 }
Example #2
0
        private static void RunCplexSimulation()
        {
            Console.WriteLine("Running simulation in a separate window, please wait");
            var cmd = new Process
            {
                StartInfo =
                {
                    FileName               = "cmd.exe",
                    RedirectStandardInput  = true,
                    RedirectStandardOutput = true,
                    CreateNoWindow         = true,
                    UseShellExecute        = false
                }
            };

            cmd.Start();
            cmd.StandardInput.WriteLine("cplex -c \"read res/cplexinput.lp\" \"optimize\" \"write res/cplexoutput.sol\" \"quit\"");
            cmd.StandardInput.Flush();
            cmd.StandardInput.Close();
            Console.WriteLine(cmd.StandardOutput.ReadToEnd());
            //cplex -c "read res/cplexinput.lp" "optimize" "write res/cplexoutput.sol" "quit"
            //cplex -c \"read res/cplexinput.lp\" \"optimize\" \"write res/cplexoutput.sol\" \"quit\"
            //var process = Process.Start("CMD.exe", "/C cplex -c \"read res/cplexinput.lp\" \"optimize\" \"write res/cplexoutput.sol\" \"quit\"");
            //process?.WaitForExit();
            //if (process == null || process.ExitCode != 0)
            //{
            //    throw new Exception("Simulation did not complete successfully");
            //}
            OutputReader.VerifyFileCreated("res/cplexoutput.sol");
        }
Example #3
0
        private void RunGlpk()
        {
            var cmd = new Process
            {
                StartInfo =
                {
                    FileName               = "cmd.exe",
                    RedirectStandardInput  = true,
                    RedirectStandardOutput = true,
                    CreateNoWindow         = true,
                    UseShellExecute        = false
                }
            };

            cmd.Start();
            cmd.StandardInput.WriteLine(@"del /s /q res");
            cmd.StandardInput.WriteLine(@"rmdir /s /q res");
            cmd.StandardInput.WriteLine(@"mkdir res\csv");
            cmd.StandardInput.Flush();
            cmd.StandardInput.Close();
            Console.WriteLine(cmd.StandardOutput.ReadToEnd());
            Console.WriteLine();
            Console.WriteLine("Running simulation in a separate window, please wait");
            var process = Process.Start("CMD.exe", @"/C glpsol -m model.txt -d data.txt -o res/output.txt");

            process?.WaitForExit();
            if (process == null || process.ExitCode != 0)
            {
                throw new Exception("Simulation did not complete successfully");
            }
            OutputReader.VerifyCompleted("res/output.txt");
        }
Example #4
0
        private void RunCplexPreparation()
        {
            Console.WriteLine("Running preparation in a separate window, please wait");
            var process = Process.Start("CMD.exe", @"/C glpsol -m model.txt -d data.txt --wlp res/cplexinput.lp");

            process?.WaitForExit();
            if (process == null || process.ExitCode != 0)
            {
                throw new Exception("Preparation did not complete successfully");
            }
            OutputReader.VerifyFileCreated("res/cplexinput.lp");
        }