2using System.Collections.Generic;
19 static void Main(
string[] args)
21 #region Static data section
22 List<string> plants =
new List<string>()
24 "Seattle",
"San-Diego"
26 List<string> markets =
new List<string>()
28 "New-York",
"Chicago",
"Topeka"
30 Dictionary<string, double> capacity =
new Dictionary<string, double>()
32 {
"Seattle", 350.0 }, {
"San-Diego", 600.0 }
34 Dictionary<string, double> demand =
new Dictionary<string, double>()
36 {
"New-York", 325.0 }, {
"Chicago", 300.0 }, {
"Topeka", 275.0 }
38 Dictionary<Tuple<string, string>,
double> distance =
new Dictionary<Tuple<string, string>,
double>()
40 {
new Tuple<string,string> (
"Seattle",
"New-York"), 2.5 },
41 {
new Tuple<string,string> (
"Seattle",
"Chicago"), 1.7 },
42 {
new Tuple<string,string> (
"Seattle",
"Topeka"), 1.8 },
43 {
new Tuple<string,string> (
"San-Diego",
"New-York"), 2.5 },
44 {
new Tuple<string,string> (
"San-Diego",
"Chicago"), 1.8 },
45 {
new Tuple<string,string> (
"San-Diego",
"Topeka"), 1.4 }
47 #endregion Static data section
51 if (Environment.GetCommandLineArgs().Length > 1)
52 ws =
new GAMSWorkspace(systemDirectory: Environment.GetCommandLineArgs()[1]);
58 #region Input data binding
59 foreach (
string p
in plants)
62 foreach (
string m
in markets)
65 foreach (
string p
in plants)
66 t.a.AddRecord(p).Value = capacity[p];
68 foreach (
string m
in markets)
69 t.b.AddRecord(m).Value = demand[m];
71 foreach (Tuple<string, string> dis
in distance.Keys)
72 t.d.AddRecord(dis.Item1, dis.Item2).Value = distance[dis];
74 t.f.AddRecord().Value = 90;
75 #endregion Input data binding
77 t.opt.AllModelTypes =
"cplex";
79 t.Run(output: Console.Out);
81 #region Output data binding
82 Console.WriteLine(
"Objective: " + t.z.FirstRecord().Level);
85 Console.WriteLine(
"x(" + rec.
Key(0) +
"," + rec.
Key(1) +
"): level=" + rec.
Level +
" marginal=" + rec.
Marginal);
86 #endregion Output data binding
This is the 13th model in a series of tutorial examples. Here we show: How to run a GAMSJob using a w...
Wrapper class for GAMS trnsport model.