controlling indexes in the SUM

Archive of Gamsworld Google Group
Post Reply
Archiver
User
User
Posts: 7876
Joined: 7 years ago

controlling indexes in the SUM

Post by Archiver »



Hello;


I was wondering how can I control my indexes in sum. for example I
have

set j /1*100/;
set i /1*10/;


var x(i,j);
and want to have summation of x (i,j) for i >2.

Thanks
Ali
--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to gamsworld@googlegroups.com
To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en
-~----------~----~----~----~------~----~------~--~---


Archiver
User
User
Posts: 7876
Joined: 7 years ago

Re: controlling indexes in the SUM

Post by Archiver »



Ali
You can realise it with $ and ord() operand

in GAMS-Syntax:

B=sum((i,j)$(ord(j)>2),x(i,j))

for example
*---------------------------------------
set j /1*100/;
set i /1*10/;

Parameter
Par1
Par2(i,j)
*for Example, Par2 defines as
/
1.1 10
1.2 5
2.1 3
2.2 6
3.1 3
3.2 4
/
;

Par1=sum((i,j)$(ord(i)>2),Par2(i,j));

display
Par1
*-----------------
-Dieter
--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to gamsworld@googlegroups.com
To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en
-~----------~----~----~----~------~----~------~--~---


Post Reply