0

I don't know how can I code this summation in GAMS because it has index with difference one .

I mean I have index i and i+1. this summation must be calculated `for i = 1,..,54;

i,j are sets ,a(i),b(i) , c are parameters and x,y are variables

sum(j, a(i)*x(i,j))-b(i)*y(i)+ c * (sum(j, a(i+1)*x(i+1,j))-b(i+1)*y(i)) <= 136

In other words, I want to have

 sum(j, a(1)*x(1,j))-b(1)*y(1)+ c * (sum(j, a(2)*x(2,j))-b(2)*y(2) )<= 136

 sum(j, a(3)*x(3,j))-b(3)*y(3)+ c * (sum(j, a(4)*x(4,j))-b(4)*y(4) )<= 136
 .
 .
 .


 sum(j, a(53)*x(53,j))-b(53)*y(53)+ c * (sum(j, a(54)*x(54,j))-b(54)*y(54) )<= 136
Richard
  • 177
  • 1
  • 9

1 Answers1

0

What about this?

eq1(i)$mod(ord(i),2).. sum(j, a(i)*x(i,j))-b(i)*y(i)+ c * (sum(j, a(i+1)*x(i+1,j))-b(i+1)*y(i)) =L= 136;
Lutz
  • 2,197
  • 1
  • 10
  • 12
  • it is not true because , i dont want to have sum(j, a(1)*x(i,j))-b(1)*y(1)+ c * (sum(j, a(2)*x(2,j))-b(2)*y(2)) =L= 136; with sum(j, a(2)*x(i,j))-b(2)*y(2)+ c * (sum(j, a(3)*x(3,j))-b(3)*y(3)) =L= 136; ,..... and so on – Richard Jul 04 '18 at 04:13
  • i want to have sum(j, a(1)*x(1,j))-b(1)*y(1)+ c * (sum(j, a(2)*x(2,j))-b(2)*y(2) )<= 136 sum(j, a(3)*x(3,j))-b(3)*y(3)+ c * (sum(j, a(4)*x(4,j))-b(4)*y(4) )<= 136 ,.... and so on – Richard Jul 04 '18 at 04:13
  • So you want to skip every second i? I edited my answer accordingly (note the $-condition in the beginning). – Lutz Jul 04 '18 at 07:08
  • in part " c * (sum(j, a(i+1)*x(i+1,j))-b(i+1)*y(i)) =L= 136 " we have to wrte " y(i+1) " right? – Richard Jul 04 '18 at 16:29
  • thanks for your help , I got my answer in your code ;-) – Richard Jul 04 '18 at 16:31