''' @file This is the 1st model in a series of tutorial examples. Here we show: - How to run a GAMSJob from file - How to specify the solver - How to run a job with a solver option file ''' from __future__ import print_function from gams import * import os import sys if __name__ == "__main__": if len(sys.argv) > 1: ws = GamsWorkspace(system_directory = sys.argv[1]) else: ws = GamsWorkspace() ws.gamslib("trnsport") t1 = ws.add_job_from_file("trnsport.gms") opt = ws.add_options() opt.all_model_types = "cplex" opt.optfile = 1 opt.optdir = r"c:\tmp" t1.run(opt,output=sys.stdout) sys.stdout.flush() print("Ran with Cplex and cplex.opt optfile in c:\\tmp:") for rec in t1.out_db["x"]: print("x(" + rec.key(0) + "," + rec.key(1) + "): level=" + str(rec.level) + " marginal=" + str(rec.marginal))