Page 1 of 1

Equations with different dimensions

Posted: Tue Dec 18, 2018 11:04 am
by Amir48
Hello everybody.
I have some equations with different dimension and variable A is used in both of them. For example. The first equation has one dimension (A(i)). but the second equation has two dimension (i and j).

eq1(i).. A(i) =e= x(i)+y(i);
eq2(i,j).. B(i,j) =e= A(i,j)+c(i,j);

(if i=1:3, j=1,2 and A(i)=[6,7,8] then A(i,j)=[6,7,8;6,7,8] )
Actually, values of variable A are same for different values of the second dimension (j). The dimensions of variable A are different
in two equations, Then GAMS can't solve the problem. How can I solve this problem?
I added another equation and solve this problem but I think It's not a good idea for that. GAMS didn't give me any error for my solution.
My solution:
eq1(i).. A(i) =e= x(i)+y(i);
eq2(i,j).. B(i,j) =e= A2(i,j)+c(i,j);
eq3(i).. A2(i,j) =e=A(i);
Thank you for your help.

Re: Equations with different dimensions

Posted: Wed Dec 19, 2018 7:39 am
by Fred
Hi,

Not sure if I really understood the problem but to me it seems that you should just drop the j index for A and should be good:

Code: Select all

eq1(i).. A(i) =e= x(i)+y(i);
eq2(i,j).. B(i,j) =e= A(i)+c(i,j);
I hope this helps!

Best,
Fred

Re: Equations with different dimensions

Posted: Thu Dec 20, 2018 1:10 am
by Amir48
Hi Fred,
Thank you a lot. It's so helpful for me.
Best wishes,
Amir