2using System.Collections.Generic;
 
   19        static void Main(
string[] args)
 
   22            if (Environment.GetCommandLineArgs().Length > 1)
 
   23                ws = 
new GAMSWorkspace(systemDirectory: Environment.GetCommandLineArgs()[1]);
 
   27            using (StreamWriter writer = 
new StreamWriter(ws.
WorkingDirectory + Path.DirectorySeparatorChar + 
"tdata.gms"))
 
   29                writer.Write(GetDataText());
 
   35                opt.
Defines.Add(
"incname", 
"tdata");
 
   38                    Console.WriteLine(
"x(" + rec.Key(0) + 
"," + rec.Key(1) + 
"): level=" + rec.
Level + 
" marginal=" + rec.
Marginal);
 
   42        static String GetDataText()
 
   46       i   canning plants   / seattle, san-diego / 
   47       j   markets          / new-york, chicago, topeka / ; 
   51       a(i)  capacity of plant i in cases 
   55       b(j)  demand at market j in cases 
   60  Table d(i,j)  distance in thousands of miles 
   61                    new-york       chicago      topeka 
   63      san-diego        2.5           1.8          1.4  ; 
   65  Scalar f  freight in dollars per case per thousand miles  /90/ ; 
   70static String GetModelText()
 
   78       a(i)   capacity of plant i in cases 
   79       b(j)   demand at market j in cases 
   80       d(i,j) distance in thousands of miles 
   81  Scalar f  freight in dollars per case per thousand miles; 
   83$if not set incname $abort 'no include file name for data file provided' 
   86  Parameter c(i,j)  transport cost in thousands of dollars per case ; 
   88            c(i,j) = f * d(i,j) / 1000 ; 
   91       x(i,j)  shipment quantities in cases 
   92       z       total transportation costs in thousands of dollars ; 
   97       cost        define objective function 
   98       supply(i)   observe supply limit at plant i 
   99       demand(j)   satisfy demand at market j ; 
  101  cost ..        z  =e=  sum((i,j), c(i,j)*x(i,j)) ; 
  103  supply(i) ..   sum(j, x(i,j))  =l=  a(i) ; 
  105  demand(j) ..   sum(i, x(i,j))  =g=  b(j) ; 
  107  Model transport /all/ ; 
  109  Solve transport using lp minimizing z ; 
 
void Run(GAMSOptions gamsOptions=null, GAMSCheckpoint checkpoint=null, TextWriter output=null, Boolean createOutDB=true)
 
Dictionary< string, string > Defines
 
GAMSJob AddJobFromString(string gamsSource, GAMSCheckpoint checkpoint=null, string jobName=null)
 
GAMSOptions AddOptions(GAMSOptions optFrom=null)
 
This is the 2nd model in a series of tutorial examples. Here we show: How to use include files to sep...