1function transport1(varargin)
3 % check workspace info from arguments
5 wsInfo = gams.control.WorkspaceInfo();
6 wsInfo.systemDirectory = varargin{1};
7 ws = gams.control.Workspace(wsInfo);
9 ws = gams.control.Workspace();
12 % create Job
't1' from
'trnsport' model in GAMS Model Libraries
13 t1 = ws.addJobFromGamsLib(
'trnsport');
17 % retrieve Variable
'x' from Job
's output databases
18 fprintf('Ran with Default:\n
');
19 for x = t1.outDB.getVariable('x
').records
20 fprintf('x(%s,%s): level=%g marginal=%g\n
', x{1}.keys{:}, x{1}.level, x{1}.marginal);
26 % create Options 'opt1
'
27 opt1 = ws.addOptions();
28 % set all model types of 'opt1
' for 'xpress
'
29 opt1.setAllModelTypes('xpress
');
30 % run Job 't1
' with Options 'opt1
'
33 % retrieve Variable 'x
' from Job's output databases
34 fprintf(
'\nRan with XPRESS:\n');
35 for x = t1.outDB.getVariable(
'x').records
36 fprintf(
'x(%s,%s): level=%g marginal=%g\n', x{1}.keys{:}, x{1}.level, x{1}.marginal);
39 % clear option and database
43 % write file
'xpress.opt' under Workspace
's working directory
44 fid = fopen(fullfile(ws.workingDirectory, 'xpress.opt
'), 'w
');
45 fprintf(fid, 'algorithm=barrier
');
48 % create Options 'opt2
'
49 opt2 = ws.addOptions();
50 % set all model types of 'opt2
' for 'xpress
'
51 opt2.setAllModelTypes('xpress
');
52 % for 'opt2
', use 'xpress.opt
' as solver's option file
55 % run Job
't2' with Options
'opt2' and capture log into
'transport1_xpress.log'.
56 output = gams.control.PrintStream(fullfile(ws.workingDirectory,
'transport1_xpress.log'));
60 % retrieve Variable
'x' from Job
's output databases
61 fprintf('\nRan with XPRESS with non-
default option:\n
');
62 for x = t1.outDB.getVariable('x
').records
63 fprintf('x(%s,%s): level=%g marginal=%g\n
', x{1}.keys{:}, x{1}.level, x{1}.marginal);
66 % clear option and database
70 % remove working directory
71 rmdir(ws.workingDirectory, 's
');