Page 1 of 1

Error 148 - Dimension different

Posted: Mon May 16, 2022 6:36 pm
by Presuda
Hi, I send you my gams code below, I keep getting "148 Dimension different - The symbol is referenced with more/less
indices as declared" error in
eq5(i).. m1*sum(j,x('1',j))-m2*sum(j,x('2',j))=e=0
eq6(i).. m3*sum(j,x('2',j))-m4*sum(j,x('3',j))=e=0

I couldn't find how to solve this problem. I would be very happy if you could help me with this.
Errors: Image

CODE:
Sets
i/1*9/
j/1*3/

parameters
p(i)
/
1 1600
2 1200
3 1080
/

w(j)
/
1 1600
2 1300
3 900
/
s(j)
/
1 2800
2 2500
3 1600
/
t(j)
/
1 1600
2 1800
3 1200
/
m(i)
/
1 0
2 0
/
scalers
m1/1300/
m2/1600/
m3/900/
m4/1300/;

Table n(i,j)
1 2 3
1 1 1 1
2 1 1 1
3 1 1 1
4 5 4 3
5 5 4 3
6 5 4 3
7 1 1 1
8 1 1 1
9 1 1 1
;
Variable
z
x(i);
positive Variable
x;
Equations
eq1
eq2(j)
eq3(j)
eq4(j)
eq5(i)
eq6(i)
;
eq1.. z =e= sum(i,p(i)*x(i));
eq2(j).. sum(i,n(i,j)*x(i)) =L= w(j);
eq3(j).. sum(i,n(i,j)*x(i)) =L= s(j);
eq4(j).. sum(i,n(i,j)*x(i)) =L= t(j);
eq5(i).. m1*sum(j,x('1',j))-m2*sum(j,x('2',j))=e=0
eq6(i).. m3*sum(j,x('2',j))-m4*sum(j,x('3',j))=e=0
;
Model FUY/all/;
Solve FUY Using LP maximazing z;
display Z.L,X.L

Re: Error 148 - Dimension different

Posted: Tue May 17, 2022 8:20 am
by bussieck
You declare x(i) but use x(i) and x('1',j) what does the second one mean. It does not fit the declaration and that's why the compiler complains. Put the source not in a quote but in a "code display" the icon </> next to the quote icon.

-Michael