static int Main(string[] args) { string sysDir, msg = string.Empty; string defSysDir = @"C:\GAMS\win32\24.0"; if (Environment.GetCommandLineArgs().Length > 1) { sysDir = Environment.GetCommandLineArgs()[1]; } else { sysDir = defSysDir; } Console.WriteLine("Loading objects from GAMS system directory: " + sysDir); gamsx = new gamsxcs(sysDir, ref msg); if (!string.IsNullOrEmpty(msg)) { Console.WriteLine("Could not create gamsx object: " + msg); return(1); } gdx = new gdxcs(sysDir, ref msg); if (!string.IsNullOrEmpty(msg)) { Console.WriteLine("Could not create gdx object: " + msg); return(1); } opt = new optcs(sysDir, ref msg); if (!string.IsNullOrEmpty(msg)) { Console.WriteLine("Could not create opt object: " + msg); return(1); } if (!WriteModelData("demanddata.gdx")) { Console.WriteLine("Model data not written"); return(1); } if (!CallGams(sysDir)) { Console.WriteLine("Call to GAMS failed"); return(1); } if (!ReadSolutionData("results.gdx")) { Console.WriteLine("Could not read solution back"); return(1); } return(0); }
static int Main(string[] args) { string sysDir, msg = string.Empty; string defSysDir = @"C:\GAMS\win32\24.0"; if (Environment.GetCommandLineArgs().Length > 1) sysDir = Environment.GetCommandLineArgs()[1]; else sysDir = defSysDir; Console.WriteLine("Loading objects from GAMS system directory: " + sysDir); gamsx = new gamsxcs(sysDir, ref msg); if (!string.IsNullOrEmpty(msg)) { Console.WriteLine("Could not create gamsx object: " + msg); return 1; } gdx = new gdxcs(sysDir, ref msg); if (!string.IsNullOrEmpty(msg)) { Console.WriteLine("Could not create gdx object: " + msg); return 1; } opt = new optcs(sysDir, ref msg); if (!string.IsNullOrEmpty(msg)) { Console.WriteLine("Could not create opt object: " + msg); return 1; } if (!WriteModelData("demanddata.gdx")) { Console.WriteLine("Model data not written"); return 1; } if (!CallGams(sysDir)) { Console.WriteLine("Call to GAMS failed"); return 1; } if (!ReadSolutionData("results.gdx")) { Console.WriteLine("Could not read solution back"); return 1; } return 0; }