Im completely new to GAMS and I am having some issues with trying to implement my model. I am trying to code a New Economic Geography optimisation model where 3 sets of non-linear equations that are interdependent need to be solved using an optimisation criteria. In the model there are n regions (for simplicity lets assume we have 2 regions. The equations that set out the problems are:

y(i) = lambda(i)*delta*w(i) + 0.5*(1-delta)

p(i) = ( sum(i,2, lambda(i) * (w(i)^(1-epsilon)) * (T(i)^(1-epsilon)) ))^(1/(1-epsilon))

w(i) = ( sum(i,2, y(i) * (p(i)^(epsilon-1)) * (T(i)^(1-epsilon)) ))^(1/epsilon)

and the goal function we want to maximise is: z = sum(i, y(i))

Which leads to 2*n+1 = 7 equations.

The code I have written is:

Set

i 'regions' / A, B /;

Parameter

T(i) 'transportation cost' /A 1

B 1/

lambda(i) 'fraction of labourers in region' / A 0.4

B 0.6 /;

Scalar

delta 'fraction of income spent on manufactured goods' / 0.7 /

epsilon 'substitutability' / 1.5 /;

VariablePositive Variable y(i),w(i),p(i);

Equation

incomeEquation(i) 'income level in region i'

wageEquation(i) 'wage level in region i'

priceEquation(i) 'prive level in region i'

GDP 'total income of economy';

z 'total income'

y(i) 'income level'

w(i) 'wage level'

p(i) 'price level';

GDP.. z =e= sum(i,y(i));

incomeEquation(i).. y(i) =e= (lambda(i)*delta*w(i) + 0.5*(1-delta));

wageEquation.. w(i) =e=(sum(i,y(i)*(T(i)**(1-epsilon))*(p(i)**(epsilon-1))))**(1/epsilon);

priceEquation.. p(i) =e= (sum(i, lambda(i)*(w(i)**(1-epsilon))*(T(i)**(1-epsilon))))**(1/(1-epsilon));

Model neecge / all /;

solve neg using nlp maximizing z;

The error codes I get are 148 and 149 (The identifier is referenced with more or less indexed sets than in the declaration. AND The set is not controlled, neither by an indexed operation like sum, nor by an equation definition, nor by a loop or similar.)

I understand the error, that I have used the set indices twice but I am not sure how to implement the self referencing equations using the GAMS syntax. Any ideas? Any help would be useful and please remember that I am completely new to this:).

Thank you.