Loading...
Searching...
No Matches
transport13.py
Go to the documentation of this file.
1
6
7import sys
8from gams import GamsWorkspace
9from transport_class import Transport
10
11plants = ["Seattle", "San-Diego"]
12markets = ["New-York", "Chicago", "Topeka"]
13capacity = {"Seattle": 350.0, "San-Diego": 600.0}
14demand = {"New-York": 325.0, "Chicago": 300.0, "Topeka": 275.0}
15distance = {
16 ("Seattle", "New-York"): 2.5,
17 ("Seattle", "Chicago"): 1.7,
18 ("Seattle", "Topeka"): 1.8,
19 ("San-Diego", "New-York"): 2.5,
20 ("San-Diego", "Chicago"): 1.8,
21 ("San-Diego", "Topeka"): 1.4,
22}
23
24if __name__ == "__main__":
25 sys_dir = sys.argv[1] if len(sys.argv) > 1 else None
26 work_dir = sys.argv[2] if len(sys.argv) > 2 else None
27 t = Transport(sys_dir, work_dir)
28
29 for p in plants:
30 t.i.add_record(p)
31 for m in markets:
32 t.j.add_record(m)
33 for p in plants:
34 t.a.add_record(p).value = capacity[p]
35 for m in markets:
36 t.b.add_record(m).value = demand[m]
37 for k, v in iter(distance.items()):
38 t.d.add_record(k).value = v
39
40 t.f.add_record().value = 90
41 t.opt.all_model_types = "cplex"
42 t.run(output=sys.stdout)
43
44 print(f"Objective: {t.z.first_record().level}")
45
46 for rec in t.x:
47 print(rec)