clear all

% read in the raw data for the trnsport model
trdata

Is.name = 'I';
Is.val  = [ linspace(1,pN,pN) ]';
Is.type = 'set';

Js.name = 'J';
Js.val  = [ linspace(1,dN,dN) ]';
Js.type = 'set';

caps.name = 'a';
caps.type = 'parameter';
caps.val = cap';
caps.form = 'full';
caps.dim = 1;

dems.name = 'b';
dems.type = 'parameter';
dems.val = dem';
dems.form = 'full';
dems.dim = 1;

dists.name = 'd';
dists.type = 'parameter';
dists.val = distance;
dists.form = 'full';
dists.dim = 2;

fs.name = 'f';
fs.type = 'parameter';
fs.val = f;
fs.form = 'full';
fs.dim = 0;

dataFile = 'tr4Data';
solFile = 'tr4Solu';

wgdx (dataFile, Is, Js, caps, dems, dists, fs);

gams_output = 'std';
gams([ 'tr45_mod --INFILE=', dataFile, ' --OUTFILE=', solFile ]);

% now get the outputs from the GDX file produced by the GAMS run
rs = struct('name','modelStat','form','full');
r = rgdx (solFile, rs);
modelstat = r.val;

rs.name = 'solveStat';
r = rgdx (solFile, rs);
solvestat = r.val;

rs.name = 'z';
rs.field = 'l';
r = rgdx (solFile, rs);
z = r.val;

rs.name = 'x';
r = rgdx (solFile, rs);
x = r.val;

fprintf('modelstat = %d (1 = optimal solution)\n', modelstat);
fprintf('solvestat = %d (1 = normal completion)\n\n', solvestat);
fprintf('optimal value = %g\n\n', z);
