2using System.Collections.Generic;
28 private string GetModelSource()
36 a(i) capacity of plant i in cases
37 b(j) demand at market j in cases
38 d(i,j) distance in thousands of miles
39 Scalar f freight in dollars per case per thousand miles;
41$if not set dbIn1 $abort 'no file name for in-database 1 file provided'
45$if not set dbIn2 $abort 'no file name for in-database 2 file provided'
50 Parameter c(i,j) transport cost in thousands of dollars per case ;
52 c(i,j) = f * d(i,j) / 1000 ;
55 x(i,j) shipment quantities in cases
56 z total transportation costs in thousands of dollars ;
61 cost define objective function
62 supply(i) observe supply limit at plant i
63 demand(j) satisfy demand at market j ;
65 cost .. z =e= sum((i,j), c(i,j)*x(i,j)) ;
67 supply(i) .. sum(j, x(i,j)) =l= a(i) ;
69 demand(j) .. sum(i, x(i,j)) =g= b(j) ;
71 Model transport /all/ ;
73 Solve transport using lp minimizing z ;
75$if not set dbOut1 $abort 'no file name for out-database 1 file provided'
76 execute_unload '%dbOut1%', x, z;
92 fopt.AllModelTypes =
"Cplex";
93 fopt.
Defines.Add(
"dbOut1",
"dbOut1");
95 fi = fDbIn1.
AddSet(
"i",
"canning plants");
96 fj = fDbIn1.
AddSet(
"j",
"markets");
97 fa = fDbIn1.
AddParameter(
"a",
"capacity of plant i in cases", fi);
98 fb = fDbIn1.
AddParameter(
"b",
"demand at market j in cases", fj);
99 fd = fDbIn1.
AddParameter(
"d",
"distance in thousands of miles", fi, fj);
100 ff = fDbIn2.
AddParameter(
"f",
"freight in dollars per case per thousand miles");
115 job.
Run(fopt, checkpoint, output,
false, fDbIn1, fDbIn2);
122 #region Data input symbols
127 {
get {
return fi; } }
133 {
get {
return fj; } }
139 {
get {
return fa; } }
145 {
get {
return fb; } }
151 {
get {
return fd; } }
157 {
get {
return ff; } }
158 #endregion Data input symbols
160 #region Data output symbols
165 {
get {
return fx; } }
171 {
get {
return fz; } }
172 #endregion Data output symbols
178 {
get {
return fopt; } }
GAMSVariable GetVariable(string variableIdentifier)
GAMSSet AddSet(string identifier, int dimension, string explanatoryText="", SetType setType=SetType.multi)
GAMSParameter AddParameter(string identifier, int dimension, string explanatoryText="")
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)
GAMSDatabase AddDatabaseFromGDX(string gdxFileName, string databaseName=null, string inModelName=null)
GAMSDatabase AddDatabase(string databaseName=null, string inModelName=null)
GAMSOptions AddOptions(GAMSOptions optFrom=null)
Wrapper class for GAMS trnsport model.
GAMSVariable z
z: total transportation costs in thousands of dollars
Transport(GAMSWorkspace ws)
A Transportation Problem.
GAMSParameter d
d(i,j): distance in thousands of miles
GAMSOptions opt
Options for the execution of the trnsport model.
GAMSVariable x
x(i,j): shipment quantities in cases
GAMSParameter a
a(i): capacity of plant i in cases
GAMSParameter b
b(i): demand at market j in cases
GAMSParameter f
f: freight in dollars per case per thousand miles
void Run(GAMSCheckpoint checkpoint=null, TextWriter output=null)
Executes the trnsport model.
GAMSSet i
i(i): canning plants