コード例 #1
0
ファイル: Executor.cs プロジェクト: OSeMOSYS/MoManI
        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");
        }
コード例 #2
0
ファイル: Executor.cs プロジェクト: OSeMOSYS/MoManI
        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");
        }