Hi Helena
Gams helps with looking for the error. If I run your code I first get the following error:
8 ‘)’ expected
And Gams tells me it is after 19).
So a closing parenthesis is missing (also repair the first error Gams encounters and don’t worry about the following errors)
After correcting this, I get
119 Number (primary) expected
Gams doesn’t understand the comma, it expects a number. Deleting the comma and after that replacing the “&†by “andâ€
And setting the parenthesis correct I get this
((ord(b)=ord(c)))
Then Gams complains about bc100. These are sets and not numbers! So you can’t add or multiply these set elements with each other. Either use the extension .val to use the value of this set element (in this case this works fine, as you defined the set consisting of numbers) or use ord again. I am used to using ord, so it looks now looks like this:
eq1(a)… objective=e=sum(c$(ord(c)=ord(c))),ord(b)*ord(c)*100));
Long story in two sentences:
. Use the errors reported by GAMS to debug your model
. Repeat debugging the first error in the listing and running the model again, until no errors are left…
Cheers
Renger
Von: gamsworld@googlegroups.com [mailto:gamsworld@googlegroups.com] Im Auftrag von Selina
Gesendet: Montag, 5. November 2012 00:24
An: gamsworld@googlegroups.com
Betreff: Re: summation with a lower bound and upper bound
I have the same question. Have you figure it out?
On Friday, January 13, 2012 4:40:56 PM UTC-8, helena wrote:
Dear all,
I just started to study gams and encountered a problem. It’s easy to
understand my problem so plz have a look and give me a help. I
appreciate your help!!
Here is the my gams:
set a
/apple, banana, orange, grape/
b
/120/
c
/120/ ;
Parameter d(a)
/apple 2
banana 4
orange 6
grape 8/;
variable objective;
equation eq1(a);
eq1(a)… objective=e=sum(c$(ord(c)=ord(c))),bc100));
And my equation is actually as follows:
b=19 c=c+d(a)
objective=∑ ∑ (cb100).
b=c c=1
So you can see I want to make a summation over b from b=c to b=19, but
I don’t know how to define b in the summation equation with both lower
and upper bounds, I just wrote by my intuition but gams did not
recognize the part of bounding b I wrote.
Could you give me some advice?
I really need your help!
Thank you very much!
Best,
Helena
\
To view this discussion on the web visit https://groups.google.com/d/msg/gamsworld/-/kVUCiFElshsJ.
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.