Loading...
Searching...
No Matches
transport13.py
Go to the documentation of this file.
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 t = Transport(sys_dir)
27
28 for p in plants:
29 t.i.add_record(p)
30 for m in markets:
31 t.j.add_record(m)
32 for p in plants:
33 t.a.add_record(p).value = capacity[p]
34 for m in markets:
35 t.b.add_record(m).value = demand[m]
36 for k, v in iter(distance.items()):
37 t.d.add_record(k).value = v
38
39 t.f.add_record().value = 90
40 t.opt.all_model_types = "cplex"
41 t.run(output=sys.stdout)
42
43 print(f"Objective: {t.z.first_record().level}")
44
45 for rec in t.x:
46 print(rec)