1package com.gams.examples.transport;
3import java.io.PrintStream;
47 fopt.
defines(
"dbOut1",
"dbOut1");
49 fi = fDbIn1.
addSet(
"i",
"canning plants");
50 fj = fDbIn1.
addSet(
"j",
"markets");
51 fa = fDbIn1.
addParameter(
"a",
"capacity of plant i in cases", fi);
52 fb = fDbIn1.
addParameter(
"b",
"demand at market j in cases", fj);
53 fd = fDbIn1.
addParameter(
"d",
"distance in thousands of miles",
new Object[] { fi, fj} );
54 ff = fDbIn2.
addParameter(
"f",
"freight in dollars per case per thousand miles");
64 this.
run(checkpoint,
null);
70 public void run(PrintStream output)
72 this.
run(
null, output);
86 job.
run( fopt, checkpoint, output,
false, databases );
123 private static String model =
125 " i canning plants \n" +
129 " a(i) capacity of plant i in cases \n" +
130 " b(j) demand at market j in cases \n" +
131 " d(i,j) distance in thousands of miles \n" +
132 " Scalar f freight in dollars per case per thousand miles; \n" +
134 "$if not set dbIn1 $abort 'no file name for in-database 1 file provided' \n" +
135 "$gdxin %dbIn1% \n" +
136 "$load i j a b d \n" +
139 "$if not set dbIn2 $abort 'no file name for in-database 2 file provided' \n" +
140 "$gdxin %dbIn2% \n" +
144 " Parameter c(i,j) transport cost in thousands of dollars per case ; \n" +
146 " c(i,j) = f * d(i,j) / 1000 ; \n" +
149 " x(i,j) shipment quantities in cases \n" +
150 " z total transportation costs in thousands of dollars ; \n" +
152 " Positive Variable x ; \n" +
156 " cost define objective function \n" +
157 " supply(i) observe supply limit at plant i \n" +
158 " demand(j) satisfy demand at market j ; \n" +
160 " cost .. z =e= sum((i,j), c(i,j)*x(i,j)) ; \n" +
162 " supply(i) .. sum(j, x(i,j)) =l= a(i) ; \n" +
164 " demand(j) .. sum(i, x(i,j)) =g= b(j) ; \n" +
166 " Model transport /all/ ; \n" +
168 " Solve transport using lp minimizing z ; \n" +
170 " Display x.l, x.m ; \n" +
171 "$if not set dbOut1 $abort 'no file name for out-database 1 file provided' \n" +
172 "execute_unload '%dbOut1%', x, z; \n" +
GAMSSet addSet(String identifier, int dimension)
GAMSParameter addParameter(String identifier, int dimension)
GAMSVariable getVariable(String identifier)
void defines(String defStr, String asStr)
String getDefinitionOf(String str)
void setAllModelTypes(String value)
void setSolveLink(GAMSOptions.ESolveLink x)
GAMSDatabase addDatabaseFromGDX(String gdxFileName)
GAMSJob addJobFromString(String source)
GAMSDatabase addDatabase()
This example shows the wrapper model of a transportation problem based on the simple GAMS [trnsport] ...
GAMSOptions getopt()
Options for the execution of the trnsport model.
String getModelSource()
Provide the source of trnsport model.
void run(GAMSCheckpoint checkpoint, PrintStream output)
Executes the trnsport model.
void run(GAMSCheckpoint checkpoint)
Executes the trnsport model.
void run(PrintStream output)
Executes the trnsport model.
GAMSVariable getx()
x(i,j): shipment quantities in cases
TransportModel(GAMSWorkspace ws)
TransportModel constructor.
GAMSParameter getf()
f: freight in dollars per case per thousand miles
GAMSParameter getb()
b(i): demand at market j in cases
GAMSVariable getz()
z: total transportation costs in thousands of dollars
GAMSParameter geta()
a(i): capacity of plant i in cases
GAMSParameter getd()
d(i,j): distance in thousands of miles
GAMSSet geti()
i: canning plants
Provides package namespace for Java interface and examples to General Algebraic Model System (GAMS).