first, here is a simple example that demonstrates my problem:
# .mod file
param N;
set TIME := 1 .. N;
set C ordered;
param tbar {C};
var X {C,TIME} >= 0;
minimize cost: sum {c in C} X[c,N];
subject to C1 {c in C: ord(c)>1, t in 1 .. N-1}:
X[c,t+1] = X[c,t] + 3;
Here is the .dat file:
param N := 10;
set C := C1 C2 C3;
param tbar :=
C1 2
C2 3
C3 3 ;
I get the syntax error
test.mod, line 9 (offset 142):
syntax error
context: subject to C1 {c in C: >>> ord(c)>1, <<< t in 1 .. N-1}:
If I change the position of the indexing to
{t in 1 .. N-1, c in C: ord(c)>1},
it works fine. The problem is, that I want to have
{c in C: ord(c)>1, t in tbar[c] .. N-1},
so I cannot change the position. Does anybody know why this error happens and if there is a way around it?
As you've found out already, the condition should be at the end of the indexing expression:
If you want to use
c
as a subscript in a later expression such astbar[c]
and it is not defined forc = first(C)
then you can doas suggested by Geoffrey Brent.