22        static void Main(
string[] args)
 
   25            if (Environment.GetCommandLineArgs().Length > 1)
 
   26                ws = 
new GAMSWorkspace(systemDirectory: Environment.GetCommandLineArgs()[1]);
 
   31            List<string> plants = 
new List<string>() 
 
   33                "Seattle", 
"San-Diego"  
   35            List<string> markets = 
new List<string>() 
 
   37                "New-York", 
"Chicago", 
"Topeka"  
   39            Dictionary<string, double> capacity = 
new Dictionary<string, double>() 
 
   41                { 
"Seattle", 350.0 }, { 
"San-Diego", 600.0 } 
 
   43            Dictionary<string, double> demand = 
new Dictionary<string, double>() 
 
   45                { 
"New-York", 325.0 }, { 
"Chicago", 300.0 }, { 
"Topeka", 275.0 }
 
   47            Dictionary<Tuple<string,string>, 
double> distance = 
new Dictionary<Tuple<string,string>, 
double>() 
 
   49                { 
new Tuple<string,string> (
"Seattle",   
"New-York"), 2.5 },
 
   50                { 
new Tuple<string,string> (
"Seattle",   
"Chicago"),  1.7 },
 
   51                { 
new Tuple<string,string> (
"Seattle",   
"Topeka"),   1.8 },
 
   52                { 
new Tuple<string,string> (
"San-Diego", 
"New-York"), 2.5 },
 
   53                { 
new Tuple<string,string> (
"San-Diego", 
"Chicago"),  1.8 },
 
   54                { 
new Tuple<string,string> (
"San-Diego", 
"Topeka"),   1.4 }
 
   61            foreach (
string p 
in plants)
 
   64            GAMSSet j = db.AddSet(
"j", 1, 
"markets");
 
   65            foreach (
string m 
in markets)
 
   68            GAMSParameter a = db.AddParameter(
"a", 
"capacity of plant i in cases", i);
 
   69            foreach (
string p 
in plants)
 
   72            GAMSParameter b = db.AddParameter(
"b", 
"demand at market j in cases", j);
 
   73            foreach (
string m 
in markets)
 
   76            GAMSParameter d = db.AddParameter(
"d", 
"distance in thousands of miles", i, j);
 
   77            foreach(Tuple<string,string> t 
in distance.Keys)
 
   80            GAMSParameter f = db.AddParameter(
"f", 
"freight in dollars per case per thousand miles");
 
   84            GAMSJob t4 = ws.AddJobFromString(GetModelText());
 
   87                opt.
Defines.Add(
"gdxincname", db.Name);
 
   88                opt.AllModelTypes = 
"xpress";
 
   91                    Console.WriteLine(
"x(" + rec.Key(0) + 
"," + rec.Key(1) + 
"): level=" + rec.
Level + 
" marginal=" + rec.
Marginal);
 
   95        static String GetModelText()
 
  103       a(i)   capacity of plant i in cases 
  104       b(j)   demand at market j in cases 
  105       d(i,j) distance in thousands of miles 
  106  Scalar f  freight in dollars per case per thousand miles; 
  108$if not set gdxincname $abort 'no include file name for data file provided' 
  113  Parameter c(i,j)  transport cost in thousands of dollars per case ; 
  115            c(i,j) = f * d(i,j) / 1000 ; 
  118       x(i,j)  shipment quantities in cases 
  119       z       total transportation costs in thousands of dollars ; 
  121  Positive Variable x ; 
  124       cost        define objective function 
  125       supply(i)   observe supply limit at plant i 
  126       demand(j)   satisfy demand at market j ; 
  128  cost ..        z  =e=  sum((i,j), c(i,j)*x(i,j)) ; 
  130  supply(i) ..   sum(j, x(i,j))  =l=  a(i) ; 
  132  demand(j) ..   sum(i, x(i,j))  =g=  b(j) ; 
  134  Model transport /all/ ; 
  136  Solve transport using lp minimizing z ;