Loop

Problems with syntax of GAMS
Post Reply
iliasbouchkira
User
User
Posts: 3
Joined: 1 month ago

Loop

Post by iliasbouchkira » 1 month ago

Hello everyone,

I'm bigginer on GAMS, and i'm trying to use if for a modeling problem, nevertheless, i can't make the true syntax for the following loop,
Can sameone help me doing it, thank you in advance,
Attachments
Capture.PNG

Manassaldi
User
User
Posts: 83
Joined: 2 years ago
Location: Rosario - Argentina

Re: Loop

Post by Manassaldi » 1 month ago

Hi, do you need the loop to define a parameter or is it an equation?
No loops are used to define equations.
anyway, you don't need a loop for this definition.

as a equation:

Code: Select all

set
i /1*13/
;
alias(i,j,k)
eq(i).. log(gamma(i)) =e= - A*power(z(i),2) + 2*sum(j$(ord(j) ne ord(i)),m(j)*(B_0(i,j) + B_1(i,j)/(2*I)))
  + power(z(i),2)*sum((j,k)$(ord(j) ne ord(i) and ord(k) ne ord(i) and ord(j) ne ord(k)),m(j)*m(k)*B_1(j,k)/(4*power(I,2)));


as a parameter:

Code: Select all

gamma(i) = exp(- A*power(z(i),2) + 2*sum(j$(ord(j) ne ord(i)),m(j)*(B_0(i,j) + B_1(i,j)/(2*I)))
  + power(z(i),2)*sum((j,k)$(ord(j) ne ord(i) and ord(k) ne ord(i) and ord(j) ne ord(k)),m(j)*m(k)*B_1(j,k)/(4*power(I,2))));   
I think this is fine but, I suggest you check it.
bye

iliasbouchkira
User
User
Posts: 3
Joined: 1 month ago

Re: Loop

Post by iliasbouchkira » 1 month ago

O thank you very much, I thaught that i had to use a loop,

I use your expression in in my code and it works very good,

Thank you again,

Post Reply