29 public static void main(String[] args) {
35 File workingDirectory =
new File(System.getProperty(
"user.dir"),
"TransportGDX");
36 workingDirectory.mkdir();
42 List<String> plants = Arrays.asList(
"Seattle",
"San-Diego");
43 List<String> markets = Arrays.asList(
"New-York",
"Chicago",
"Topeka");
44 Map<String, Double> capacity =
new HashMap<String, Double>();
46 capacity.put(
"Seattle", Double.valueOf(350.0));
47 capacity.put(
"San-Diego", Double.valueOf(600.0));
49 Map<String, Double> demand =
new HashMap<String, Double>();
51 demand.put(
"New-York", Double.valueOf(325.0));
52 demand.put(
"Chicago", Double.valueOf(300.0));
53 demand.put(
"Topeka", Double.valueOf(275.0));
56 Map<Vector<String>, Double> distance =
new HashMap<Vector<String>, Double>();
58 distance.put(
new Vector<String>( Arrays.asList(
new String[]{
"Seattle",
"New-York"}) ), Double.valueOf(2.5));
59 distance.put(
new Vector<String>( Arrays.asList(
new String[]{
"Seattle",
"Chicago"}) ), Double.valueOf(1.7));
60 distance.put(
new Vector<String>( Arrays.asList(
new String[]{
"Seattle",
"Topeka"}) ), Double.valueOf(1.8));
61 distance.put(
new Vector<String>( Arrays.asList(
new String[]{
"San-Diego",
"New-York"}) ), Double.valueOf(2.5));
62 distance.put(
new Vector<String>( Arrays.asList(
new String[]{
"San-Diego",
"Chicago"}) ), Double.valueOf(1.8));
63 distance.put(
new Vector<String>( Arrays.asList(
new String[]{
"San-Diego",
"Topeka"}) ), Double.valueOf(1.4));
70 for(String p : plants)
74 for(String m : markets)
78 for (String p : plants) {
79 a.addRecord(p).setValue( capacity.get(p) );
83 for(String m : markets)
84 b.addRecord(m).setValue( demand.get(m) );
87 for(Vector<String> vd : distance.keySet())
88 d.addRecord(vd).setValue( distance.get(vd).doubleValue() );
91 f.addRecord().setValue( 90 );
100 List<String> gdxPlants =
new ArrayList<String>();
102 gdxPlants.add(rec.getKey(0));
104 List<String> gdxMarkets =
new ArrayList<String>();
106 gdxMarkets.add(rec.getKey(0));
108 Map<String, Double> gdxCapacity =
new HashMap<String, Double>();
110 gdxCapacity.put(rec.getKey(0), rec.getValue());
112 Map<String, Double> gdxDemand =
new HashMap<String, Double>();;
114 gdxDemand.put(rec.getKey(0), rec.getValue());
116 Map<Vector<String>, Double> gdxDistance =
new HashMap<Vector<String>, Double>();
118 gdxDistance.put(
new Vector<String>( Arrays.asList(
new String[]{rec.getKey(0), rec.getKey(1)}) ), rec.getValue());
120 double gdxFreight = gdxdb.
getParameter(
"f").getFirstRecord().getValue();
123 System.out.println(
"Data read from data.gdx");
124 System.out.println (
"Set i: " + gdxdb.
getSet(
"i").getText() );
125 for(String p : gdxPlants)
126 System.out.println (
" " + p);
128 System.out.println (
"Set j: "+ gdxdb.
getSet(
"j").getText());
129 for(String m : gdxMarkets)
130 System.out.println (
" " + m);
132 System.out.println (
"Parameter a: "+ gdxdb.
getParameter(
"a").getText());
133 for (Entry<String, Double> aEntry : gdxCapacity.entrySet())
134 System.out.println (
" " + aEntry.getKey() +
": " + aEntry.getValue());
136 System.out.println (
"Parameter b: "+ gdxdb.
getParameter(
"b").getText());
137 for (Entry<String, Double> bEntry : gdxDemand.entrySet())
138 System.out.println (
" " + bEntry.getKey() +
": " + bEntry.getValue());
140 System.out.println (
"Parameter d: " + gdxdb.
getParameter(
"d").getText());
141 for (Entry<Vector<String>, Double> dEntry : gdxDistance.entrySet())
142 System.out.println (
" " + dEntry.getKey() +
": " + dEntry.getValue());
144 System.out.println (
"Scalar f: " + gdxdb.
getParameter(
"f").getText());
145 System.out.println (
" " + gdxFreight);