21 static void Main(
string[] args)
24 if (Environment.GetCommandLineArgs().Length > 1)
25 ws =
new GAMSWorkspace(systemDirectory: Environment.GetCommandLineArgs()[1]);
30 List<string> plants =
new List<string>()
32 "Seattle",
"San-Diego"
34 List<string> markets =
new List<string>()
36 "New-York",
"Chicago",
"Topeka"
38 Dictionary<string, double> capacity =
new Dictionary<string, double>()
40 {
"Seattle", 350.0 }, {
"San-Diego", 600.0 }
42 Dictionary<string, double> demand =
new Dictionary<string, double>()
44 {
"New-York", 325.0 }, {
"Chicago", 300.0 }, {
"Topeka", 275.0 }
46 Dictionary<Tuple<string, string>,
double> distance =
new Dictionary<Tuple<string, string>,
double>()
48 {
new Tuple<string,string> (
"Seattle",
"New-York"), 2.5 },
49 {
new Tuple<string,string> (
"Seattle",
"Chicago"), 1.7 },
50 {
new Tuple<string,string> (
"Seattle",
"Topeka"), 1.8 },
51 {
new Tuple<string,string> (
"San-Diego",
"New-York"), 2.5 },
52 {
new Tuple<string,string> (
"San-Diego",
"Chicago"), 1.8 },
53 {
new Tuple<string,string> (
"San-Diego",
"Topeka"), 1.4 }
60 foreach (
string p
in plants)
63 GAMSSet j = db.AddSet(
"j", 1,
"markets");
64 foreach (
string m
in markets)
67 GAMSParameter a = db.AddParameter(
"a",
"capacity of plant i in cases", i);
68 foreach (
string p
in plants)
71 GAMSParameter b = db.AddParameter(
"b",
"demand at market j in cases", j);
72 foreach (
string m
in markets)
75 GAMSParameter d = db.AddParameter(
"d",
"distance in thousands of miles", i, j);
76 foreach (Tuple<string, string> t
in distance.Keys)
79 GAMSParameter f = db.AddParameter(
"f",
"freight in dollars per case per thousand miles");
83 db.Export(
"data.gdx");
89 List<string> plants2 =
new List<string>();
91 plants2.Add(item.Key(0));
93 List<string> markets2 =
new List<string>();
95 markets2.Add(item.Key(0));
97 Dictionary<string, double> capacity2 =
new Dictionary<string, double>();
99 capacity2.Add(item.Key(0), item.Value);
101 Dictionary<string, double> demand2 =
new Dictionary<string, double>();
103 demand2.Add(item.Key(0), item.Value);
105 Dictionary<Tuple<string, string>,
double> distance2 =
new Dictionary<Tuple<string, string>,
double>();
107 distance2.Add(
new Tuple<string, string>(item.Key(0), item.Key(1)), item.Value);
110 Console.WriteLine(
"Data read from data.gdx");
111 Console.WriteLine(
"\nSet i:");
112 foreach (
string p
in plants2)
113 Console.WriteLine(
" " + p);
114 Console.WriteLine(
"\nSet j:");
115 foreach (
string m
in markets2)
116 Console.WriteLine(
" " + m);
117 Console.WriteLine(
"\nParameter a:");
118 foreach (var item
in capacity2)
119 Console.WriteLine(
" " + item.Key +
": " + item.Value);
120 Console.WriteLine(
"\nParameter b:");
121 foreach (var item
in demand2)
122 Console.WriteLine(
" " + item.Key +
": " + item.Value);
123 Console.WriteLine(
"\nParameter d:");
124 foreach (var item
in distance2)
125 Console.WriteLine(
" " + item.Key +
": " + item.Value);