1package com.gams.examples.transport;
3import java.io.BufferedWriter;
5import java.io.FileWriter;
6import java.io.IOException;
23 public static void main(String[] args) {
26 if (args.length > 0) {
43 }
catch(IOException e) {
52 opt.
defines(
"incname",
"tdata");
59 System.out.println(
"x(" + rec.getKey(0) +
", " + rec.getKey(1) +
"): level=" + rec.getLevel() +
" marginal=" + rec.getMarginal());
70 static void cleanup(String directory) {
71 File directoryToDelete =
new File(directory);
72 String files[] = directoryToDelete.list();
73 for (String file : files) {
74 File fileToDelete =
new File(directoryToDelete, file);
76 fileToDelete.delete();
82 directoryToDelete.delete();
83 }
catch(Exception e) {
92 " i canning plants / seattle, san-diego / \n" +
93 " j markets / new-york, chicago, topeka / ; \n" +
96 " a(i) capacity of plant i in cases \n" +
98 " san-diego 600 / \n" +
100 " b(j) demand at market j in cases \n" +
101 " / new-york 325 \n" +
103 " topeka 275 / ; \n" +
105 "Table d(i,j) distance in thousands of miles \n" +
106 " new-york chicago topeka \n" +
107 " seattle 2.5 1.7 1.8 \n" +
108 " san-diego 2.5 1.8 1.4 ; \n" +
110 "Scalar f freight in dollars per case per thousand miles /90/ \n " +
114 static String model =
116 " i canning plants \n" +
120 " a(i) capacity of plant i in cases \n" +
121 " b(j) demand at market j in cases \n" +
122 " d(i,j) distance in thousands of miles \n" +
123 "Scalar f freight in dollars per case per thousand miles; \n" +
125 "$if not set incname $abort 'no include file name for data file provided'\n" +
126 "$include %incname% \n" +
128 " Parameter c(i,j) transport cost in thousands of dollars per case ; \n" +
130 " c(i,j) = f * d(i,j) / 1000 ; \n" +
133 " x(i,j) shipment quantities in cases \n" +
134 " z total transportation costs in thousands of dollars ; \n" +
136 " Positive Variable x ; \n" +
140 " cost define objective function \n" +
141 " supply(i) observe supply limit at plant i \n" +
142 " demand(j) satisfy demand at market j ; \n" +
144 " cost .. z =e= sum((i,j), c(i,j)*x(i,j)) ; \n" +
146 " supply(i) .. sum(j, x(i,j)) =l= a(i) ; \n" +
148 " demand(j) .. sum(i, x(i,j)) =g= b(j) ; \n" +
150 " Model transport /all/ ; \n" +
152 " Solve transport using lp minimizing z ; \n" +
154 "Display x.l, x.m ; \n" +
GAMSVariable getVariable(String identifier)
static final String FILE_SEPARATOR
void defines(String defStr, String asStr)
void setSystemDirectory(String directory)
GAMSJob addJobFromString(String source)
String workingDirectory()
This example shows how to include data files to run a job with the simple GAMS [trnsport] model from ...
Provides package namespace for Java interface and examples to General Algebraic Model System (GAMS).