Bruno,
The GAMS compiler is not very helpful here. The problem is a construct in the macros HT and ST which are used in equation DeltaGi. Here you have something like (simplified) expr1$(expr2). Expression expr2 contains a variable "Ti(i)" when GAMS expands the macro for equation DeltaGi. This is not allowed in GAMS. The error is only shown when GAMS compiles the solve statement. Right now I cannot think of a scenario why GAMS should not mark the equation when it compiles the equation algebra, I need to check with my colleagues. Anyhow, you need to reformulate this. The easiest way if to use the ifthen function: ifthen(expr2, expr1, 0). If expr2 is there to protect against domain violation errors, this will not necessarily help, because the GAMS function interpreter evaluates all three arguments of the ifthen function, independent of the value of the first argument. You code looks actually more like two function definitions based on the value of a variable. So the ifthen function should work okay.
The other trouble with ifthen is that it is not accepted by global solvers with the notable exception of Lindo. An alternative way to model ifthen(x >= c1 and x <= c2, exprA, exprB) this is to use binary variables (that's what Lindo does probably under the hood):
variable result;
positive variable pslA, nslA, pslB, nslB;
binary variable b;
* models result=ifthen(b, exprA, exprB)
defr1.. result =e= exprA + pslA - nslA;
defr2.. result =e= exprB + pslB- nslB;
defslA.. pslA + nslA =l= (1-b)*bigMA;
defslB.. pslB + nslB =l= b*bigMB;
binary variables blt, bgt;
* models b = blt and bgt
defb1.. b =g= blt + bgt - 1;
defb2.. b =l= blt;
defb3.. b =l= bgt;
* models bgt=1 <=> x >= c1, actually bgt=1 => x>=c1 and bgt=0 => x <= c1-1e-6 (in optimization we can't model x < c1).
defgt1.. x =g= c1 - (1-bgt)*bigMgt;
defgt2.. x =l= c1 - 1e-6 + bgt*bigMgt;
* models blt=1 <=> x <= c2, actually blt=1 => x<=c2 and
blt=0 => x >= c2+1e-6 (in optimization we can't model x > c2).
deflt1.. x =l= c2 + (1-blt)*bigMlt;
deflt2.. x =g= c2 + 1e-6 - blt*bigMlt;
This changes your model type to MINLP. The various bigM need to be bounds on the exprA, exprB, x-c1, x-c2 (so bounds on x) and should be selected as small as possible (for good numerics, so don't set them to 1e9 which we see very often in bad models).
Hope this helps,
Michael Bussieck - GAMSWorld Coordinator