$condition, dynamic sets and sum

Hi everyone!

I have a problem in a summation where I need to include a $conditional
expresion:

==========
Sets
i units / 0000139357 /
k classes / 01
86 /
is(i) Selected unit
ks(k) Selected class
m inputs & outputs / I01I86, IC, IL, 0186 /
x(m) reallocable inputs / I01I86, IC, IL /
y(m) outputs / 01
86 /
r(y) class specific output
;

Table dataki(k,i,m)
$ondelim
$include mioan.csv
$offdelim
;

Parameter dataik(i,k,m); option dataikks
(in the sum over y). I have not even been able to sum where y=ks (I
could reformulate the equation if it is the only solution). I have
tried to use an $condition and a dynamic set (r) but I can not assign
r(y)=ks(k) in the loop. I have tried also:

yks
sum(y$(y ne ks), pk4(y)*sum(i, dataik(i,ks,y)))
sum(y$(y ne ks(k)), pk4(y)*sum(i, dataik(i,ks,y)))
y=ks
sum(y$ord(y), pk4(y)*sum(i, dataik(i,ks,y)))
sum(y$(y=ks), pk4(y)*sum(i, dataik(i,ks,y)))
sum(y$r(y), pk4(y)*sum(i, dataik(i,ks,y))) r(y)=ks in
the loop

Every thingh reports different errors.

Any clue?

Thank you in advance.

Best,

Antonio

\

Antonio,

There are different ways of doing this in GAMS. You cannot directly
compare set elements with the relation operators. You could do the
following:

  1. sum(y$(y.uel ks.uel),
  2. sum(y$(y.pos ks.pos),
  3. sum(y$(not sameas(y,ks)),

All three methods are described in the Bruce McCarl’s Extended User’s
Guide. I prefer the first solution.

Hope this helps,
Michael Bussieck - GAMS World Coordinator

On Aug 6, 3:12 pm, Antonio wrote:

Hi everyone!

I have a problem in a summation where I need to include a $conditional
expresion:

==========
Sets
i units / 0000139357 /
k classes / 01
86 /
is(i) Selected unit
ks(k) Selected class
m inputs & outputs / I01I86, IC, IL, 0186 /
x(m) reallocable inputs / I01I86, IC, IL /
y(m) outputs / 01
86 /
r(y) class specific output
;

Table dataki(k,i,m)
$ondelim
$include mioan.csv
$offdelim
;

Parameter dataik(i,k,m); option dataik > display dataik;

Positive variables
*Eq4
wk4(x) x weights for each class
pk4(y) y weights for each class
;

Variable objik objective value for each unit of each firm (eq.2)
objk objective value for each class (eq.4)

Equations
objeqk(k)

objeqk(ks)… objk =e= sum(x, wk4(x)*sum(i, dataik(i,ks,x)))-sum(y,
pk4(y)*sum(i, dataik(i,ks,y)));

kk(k) = yes;
ks(k) = no;

loop(kk,
ks(kk) = yes;
solve Eq4 us lp min objk;

The model works, but now I need to sum only the elements where yks
(in the sum over y). I have not even been able to sum where y=ks (I
could reformulate the equation if it is the only solution). I have
tried to use an $condition and a dynamic set (r) but I can not assign
r(y)=ks(k) in the loop. I have tried also:

yks
sum(y$(y ne ks), pk4(y)*sum(i, dataik(i,ks,y)))
sum(y$(y ne ks(k)), pk4(y)*sum(i, dataik(i,ks,y)))
y=ks
sum(y$ord(y), pk4(y)*sum(i, dataik(i,ks,y)))
sum(y$(y=ks), pk4(y)*sum(i, dataik(i,ks,y)))
sum(y$r(y), pk4(y)*sum(i, dataik(i,ks,y))) r(y)=ks in
the loop

Every thingh reports different errors.

Any clue?

Thank you in advance.

Best,

Antonio

\