How can I write the equantion in GAMS?

Dear all,
How can I express the formulation: sum(a,sum(t, tx(a,t)));
a is a set such as /1
3/; x is a variable.
but t is really not a set, it is concerned with a. Such as if a=1, then t is in the [1,10], if a =2 is in the zone [5, 20], if a=3, t is in the zone [10,30].
The formualtion should be expanded as follow: x(1,1)+2x(1,2)+…10x(1,10) + 5x(2,5)+6x(2,6)+… 10x(3,10)+11x(3,11)+…+30*x(3,30).
How can write the equation in GAMS in a general way?

\

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.

You can try to formulate both a and t as sets and use the ORD function in gams

Sets
a /13/
t /1
30/
at(a,t) /1.(110), 2.(520),3.(10*30)/
variables
z
x(a,t) ;
Equation
eqn ;
eqn… z=e=sum(at(a,t), ord(t)*x(at)) ;

Hope this helps!


On Tue, Aug 2, 2011 at 12:33 PM, 胡辉 wrote:

Dear all,
How can I express the formulation: sum(a,sum(t, tx(a,t)));
a is a set such as /1
3/; x is a variable.
but t is really not a set, it is concerned with a. Such as if a=1, then t is in the [1,10], if a =2 is in the zone [5, 20], if a=3, t is in the zone [10,30].
The formualtion should be expanded as follow: x(1,1)+2x(1,2)+…10x(1,10) + 5x(2,5)+6x(2,6)+… 10x(3,10)+11x(3,11)+…+30*x(3,30).
How can write the equation in GAMS in a general way?

\

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.

\

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.

please, define a table as shown in attachment excel and:

set a/13/
t/1
30/;
table Ex(t,a)/ as shown in excel file/
;
sum(a,sum(t$(Ex(t,a)=1), t*x(a,t)));
it will help you Certainly.

On Tue, Aug 2, 2011 at 3:03 PM, 胡辉 wrote:

Dear all,
How can I express the formulation: sum(a,sum(t, tx(a,t)));
a is a set such as /1
3/; x is a variable.
but t is really not a set, it is concerned with a. Such as if a=1, then t is in the [1,10], if a =2 is in the zone [5, 20], if a=3, t is in the zone [10,30].
The formualtion should be expanded as follow: x(1,1)+2x(1,2)+…10x(1,10) + 5x(2,5)+6x(2,6)+… 10x(3,10)+11x(3,11)+…+30*x(3,30).
How can write the equation in GAMS in a general way?

\

Book1.xlsx (11.4 KB)