来源于:http://interfaces.gams-software.com/doku.php?id=env:spawning_gams_from_c-sharp
Below is a simple example:
using System.Diagnostics;
void RunGamsModel()
{
Process p = new Process();
p.StartInfo.FileName = gamsexe;
p.StartInfo.WorkingDirectory = tempdir;
p.StartInfo.Arguments = "\"" + modelname + "\" LO=0 --runid="+runid;
p.Start();
p.WaitForExit();
}
The command line formed here is gams modelname LO=0 –runid=xxx
. The optionLO
(logoption) will disable writing a log, and the option–runid
passes a parameter to the GAMS model (inside the model you can access this through%runid%
).