transport1.py
Go to the documentation of this file.
9
10from __future__ import print_function
11from gams import *
12import os
13import sys
14
15
16if __name__ == "__main__":
17 if len(sys.argv) > 1:
18 ws = GamsWorkspace(system_directory = sys.argv[1])
19 else:
20 ws = GamsWorkspace()
21
22 ws.gamslib("trnsport")
23
24 t1 = ws.add_job_from_file("trnsport.gms")
25 t1.run()
26 print("Ran with Default:")
27
28 for rec in t1.out_db["x"]:
29 print("x(" + rec.key(0) + "," + rec.key(1) + "): level=" + str(rec.level) + " marginal=" + str(rec.marginal))
30
31 opt = ws.add_options()
32 opt.all_model_types = "xpress"
33 t1.run(opt)
34
35 print("Ran with XPRESS:")
36 for rec in t1.out_db["x"]:
37 print("x(" + rec.key(0) + "," + rec.key(1) + "): level=" + str(rec.level) + " marginal=" + str(rec.marginal))
38
39 file = open(os.path.join(ws.working_directory, "xpress.opt"), "w")
40 file.write("algorithm=barrier")
41 file.close()
42
43 opt.optfile = 1
44 t1.run(opt)
45
46 print("Ran with XPRESS with non-default option:")
47 for rec in t1.out_db["x"]:
48 print("x(" + rec.key(0) + "," + rec.key(1) + "): level=" + str(rec.level) + " marginal=" + str(rec.marginal))