Code: Select all

```
GAMSWorkspace ws;
if (Environment.GetCommandLineArgs().Length > 1)
ws = new GAMSWorkspace(systemDirectory: Environment.GetCommandLineArgs()[1]);
else
ws = new GAMSWorkspace();
GAMSJob t = ws.AddJobFromString(GetModelText());
t.Run();
Console.WriteLine(t.OutDB.GetVariable("z").FindRecord().Level);
```

Code: Select all

```
static String GetModelText()
{
String model = @"
Sets
i /1*100/
j /1*5/
t /t0*t434/;
parameter p(i,j);
parameter C(i,t,j);
scalar xx /0/;
parameters TT(t);
loop(t,
TT(t) = xx;
xx = xx +1;
);
$Call GDXXRW.EXE data.xls par=p rng=100_5!A1 Rdim=1 Cdim=1
$GDXIN data.gdx
$LOAD p
$GDXIN
scalar d/69/;
scalar a/2/;
scalar b/3/;
loop(i,loop(j,loop(t,
C(i,t,j)$(d>=TT(t)) = (a/P(i,j))* ((d- P(i,j)/2)-(TT(t)-0.5));
C(i,t,j)$(d<TT(t)) = (b/P(i,j))* ((TT(t)-0.5)-(d- P(i,j)/2));
)));
positive variables X(i,t,j);
positive variable Y(i,j);
variable z;
equations c1, c2, c3, c4, c5;
c1.. z=e= sum(i, sum(t, sum(j, C(i,t,j)* X(i,t,j))));
c2(i,j).. sum(t, X(i,t,j)) =e= P(i,j)*Y(i,j);
c3(j,t).. sum(i, X(i,t,j)) =l= 1;
c4(i).. sum(j, Y(i,j)) =e= 1;
c5(i,j).. Y(i,j) =l= 1;
option RESLIM = 1000000000000000000;
option ITERLIM = 100000000;
model project /all/;
solve project using MIP minimize z;
display z.l;
";
return model;
}
```

An unhandled exception of type 'GAMS.GAMSExceptionExecution' occurred in GAMS.net4.dll

Additional information: GAMS return code not 0 (2), set GAMSWorkspace.Debug to KeepFiles or higher or define the GAMSWorkspace.WorkingDirectory to receive a listing file with more details

How can I fix this ?

Thanks.