Hi,
i have a system with set i, which is p1, p2, p3
now I have a table
table G_coeff(i,i)
p1 p2 p3
p1 0.1 0.3 0.8
p2 0.2 0.5 0.6
p3 0.1 0.5 0.8
v(i), theta(i) is variable.
I need to sum over all (i,i) combination. that is as follows,
powerloss … sum ((i,i), G_coeff(i,i)(v(i)**2+v(i)**2-2v(i)*v(i)*cos(theta(i))))
but it said statement already under control.
Can anyone help?
\
To view this discussion on the web visit https://groups.google.com/d/msg/gamsworld/-/mrd1SupRR2YJ.
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.
Hi Ahmed
Define the set i with multiple nnames:
Set I/P1*P3/
Alias(I,I2);
table G_coeff(i,i)
p1 p2 p3
p1 0.1 0.3 0.8
p2 0.2 0.5 0.6
p3 0.1 0.5 0.8
Variable V(I),Theta(I);
Now sue “Sum((I,I2),…)” instead of “Sum((I,I),…)”
I Hope this will be useful.
On Wed, Oct 10, 2012 at 2:27 AM, Syed Sabbir Ahmed wrote:
Hi,
i have a system with set i, which is p1, p2, p3
now I have a table
table G_coeff(i,i)
p1 p2 p3
p1 0.1 0.3 0.8
p2 0.2 0.5 0.6
p3 0.1 0.5 0.8
v(i), theta(i) is variable.
I need to sum over all (i,i) combination. that is as follows,
powerloss … sum ((i,i), G_coeff(i,i)(v(i)**2+v(i)**2-2v(i)*v(i)*cos(theta(i))))
but it said statement already under control.
Can anyone help?
\
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.
Dear Syed
If you use coeff(i,i) in an expression, Gams only takes the diagonal elements (In the declaration part, GAMS doesn’t make that distinction), therefore introduce an alias:
alias(i,j);
coeff(I,j) stands now for all the elements.
Now you can adjust your equation accordingly by summing over (I,j) and not (I,i).
Cheers
Renger
From: gamsworld@googlegroups.com [mailto:gamsworld@googlegroups.com] On Behalf Of Syed Sabbir Ahmed
Sent: Wednesday, October 10, 2012 12:58 AM
To: gamsworld@googlegroups.com
Subject: Summation over same set
Hi,
i have a system with set i, which is p1, p2, p3
now I have a table
table G_coeff(i,i)
p1 p2 p3
p1 0.1 0.3 0.8
p2 0.2 0.5 0.6
p3 0.1 0.5 0.8
v(i), theta(i) is variable.
I need to sum over all (i,i) combination. that is as follows,
powerloss … sum ((i,i), G_coeff(i,i)(v(i)**2+v(i)**2-2v(i)*v(i)*cos(theta(i))))
but it said statement already under control.
Can anyone help?
\
To view this discussion on the web visit https://groups.google.com/d/msg/gamsworld/-/mrd1SupRR2YJ.
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.