12from gams
import GamsWorkspace
14if __name__ ==
"__main__":
15 sys_dir = sys.argv[1]
if len(sys.argv) > 1
else None
16 ws = GamsWorkspace(system_directory=sys_dir)
17 ws.gamslib(
"trnsport")
19 print(
"Run with Default:")
20 job = ws.add_job_from_file(
"trnsport.gms")
22 for rec
in job.out_db[
"x"]:
24 f
"x({rec.key(0)},{rec.key(1)}): level={rec.level} marginal={rec.marginal}"
27 print(
"Run with XPRESS:")
28 opt = ws.add_options()
29 opt.all_model_types =
"xpress"
31 for rec
in job.out_db[
"x"]:
33 f
"x({rec.key(0)},{rec.key(1)}): level={rec.level} marginal={rec.marginal}"
36 print(
"Run with XPRESS and non default option:")
37 with open(os.path.join(ws.working_directory,
"xpress.opt"),
"w")
as file:
38 file.write(
"algorithm=barrier")
40 with open(
"transport1_xpress.log",
"w")
as log:
41 job.run(opt, output=log)
42 for rec
in job.out_db[
"x"]:
44 f
"x({rec.key(0)},{rec.key(1)}): level={rec.level} marginal={rec.marginal}"