how to deal with the conditional

Dear, GAMS User.

I made the code as below.

Eq4(k, t)(ord(t)>1).. p(k, t) =e= p(k, t-1) - sum(j(ord(j) ne ord(k)), x(k, j, t)) + sum(i$(ord(i) ne ord(k)), x(i, k, t-r(i, k)));


But I want to make a conditional statement like this…


In sum(i$(ord(i) ne ord(k)), x(i, k, t-r(i, k))); ,

if “t-r(i, k)=0”, x(i, k, t-r(i, k) takes a value itself.

How do I make this conditional statement?

I need your help.


**I attach the file about the mathematical equation and code that I made.





\

EERP.gms (1.98 KB)
model.PNG
variable.PNG

Why don’t you just add this constraint after the -sign (just in case t-r(I,k) >= 0): \ \ \ Eq4(k, t)(ord(t)>1)… p(k, t) =e= p(k, t-1) - sum(j$(ord(j) ne ord(k)), x(k, j, t))

  • sum(i$(ord(i) ne ord(k) and ord(t)-r(i,k) GE 0) , x(i, k, t-r(i, k)));





    Then it will only add this term if ord(t) – r(I,k) >= 0



    Cheers

Renger





From: gamsworld@googlegroups.com [mailto:gamsworld@googlegroups.com] On Behalf Of ???
Sent: Dienstag, 10. November 2015 03:05
To: gamsworld
Subject: how to deal with the conditional



Dear, GAMS User.



I made the code as below.



Eq4(k, t)(ord(t)>1).. p(k, t) =e= p(k, t-1) - sum(j(ord(j) ne ord(k)), x(k, j, t)) + sum(i$(ord(i) ne ord(k)), x(i, k, t-r(i, k)));





But I want to make a conditional statement like this…





In sum(i$(ord(i) ne ord(k)), x(i, k, t-r(i, k))); ,



if “t-r(i, k)=0”, x(i, k, t-r(i, k) takes a value itself.



How do I make this conditional statement?



I need your help.





**I attach the file about the mathematical equation and code that I made.












\

To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+unsubscribe@googlegroups.com.
To post to this group, send email to gamsworld@googlegroups.com.
Visit this group at http://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/d/optout.


To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+unsubscribe@googlegroups.com.
To post to this group, send email to gamsworld@googlegroups.com.
Visit this group at http://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/d/optout.