I'm begginer in GAMS. please help me solving this problem

I need to have something like this:

```
for each k
if (sum(i,r(i,k)) >= 1)
then u(k) = 1;
else u(k) = 0
```

my code is now this:

```
set
i /1*2/
j /1*2/
k /1*2/
;
parameters
a(i) meghdare zobale dar manbae i-om
/1 1, 2 2/
b(j) zarfiate makane j-om
/1 10, 2 20/
f(k) hazine sabete istgahe komakie k-om
/1 1, 2 2/
q(k) zarfiate istgahe komakie k-om (ton)
/1 5, 2 8/
d(k) hazineye pardazeshe istgahe komakie k-om (ton)
/1 1, 2 7/
;
table
e(k,j) hazineye haml az istgahe komaki be makane dafe zobaleye j-om
1 2
1 3 4
2 3 5
;
table
c(i,k) hazineye haml az manbae i-om be istgahe k-om
1 2
1 3 4
2 3 5
;
variables
r(i,k) r=1:entekhabe istagahe komakie k-om baraye manbae i-om r=0: O.W
z
y(k,j)
n(k)
;
binary variable
u(k)
;
equation
obj
const1
const2
const3
const4
const5
;
obj .. z =e= sum((i,k) , ((c(i,k) + d(k))*a(i)*r(i,k))) +
sum(k , ( f(k)* u(k))) + sum((k,j) , (e(k,j)*y(k,j)));
const1(i) .. sum(k , r(i,k)) =e= 1;
const2(k) .. sum(i , a(i)*r(i,k)) =l= q(k);
const3(k) .. sum(i , a(i)*r(i,k)) =e= sum (j , y(k,j)) ;
const4(j) .. sum(k , y(k,j)) =l= b(j);
const5(k) .. sum(i , r(i,k)) =e= u(k);
loop(k,
if((r(i,k)) = 1,
u(k) = 1
);
);
model opt /obj , const1 , const2 , const3 , const4 , const5/;
solve opt using lp minimizing z;
display z.l;
```

can anybody help me to solve this problem?

thanx a lot

asked
**21 Jan '13, 17:17**

mooshy_nini

1●1

accept rate:
0%

What is the problem?