Matrona
Matrona

Reputation: 1

GAMS, domain violation for set

balance(i)..        Sum(k,X(k,i)) - Sum(j,X(i,j)) =G= 0  

I have this equation in GAMS, I understand why this is a domain violation. Yet I need to express this. I can not think of any other way of expressing this constraint in GAMS. Any help would be great.

Upvotes: 0

Views: 9719

Answers (2)

Niclas von Caprivi
Niclas von Caprivi

Reputation: 769

I would say this is the perfect case to use alias:

sets i;
alias(i,j,k);
variables X(i,i);
equations balance(i);
balance(i).. sum(j,X(j,i)) - sum(k,(X(k,i)) =G= 0;

Hope this will do the job! Ready for feedback because I am new to GAMS, too.

Cheers, Niclas

Upvotes: 0

Anton
Anton

Reputation: 1538

I think your error comes from the fact that you have X(k,i) and then X(i,j). You can't have two same-name variables "X" with different indices.

Unless you have aliased j and k with alias(j,k): but then I cannot see why you'd do an equation like that, so I assume you meant to use another variable instead of X in one of the Xs.

If you were doing balance(i).. sum(k,X(k,i)) - sum(j,Y(j,i)) =G= 0, that would be fine.

Upvotes: 2

Related Questions