hi there… i think we might need a bit of clarifying information here to help out. Do you have a superset that includes all elements j+n? Or are you trying to do some sort of circular lead/lag operation? If so, check out the documentation here: https://www.gams.com/latest/docs/UG_OrderedSets.html (you would need to use the ++ or – syntax). Circular set operations are handy, but if you can avoid them I would try to do that… they can get tricky to debug.
also… when writing a new constraint you should first ask yourself what set do I want to write my constraint over… remember that you can control the creation of the constraint with the definition statement first (the part before the “…”). i.e.,
d(i,j)$c(i)… x(i,j) =E= a(i) + b(j);
(you can also do something similar during equation declaration)
s(j+1) =g= c(i,j) fyp.gms (2.8 KB)
s(j+2) =g= c(i,j)
s(j+3) =g= c(i,j)
s(j+4) =g= c(i,j)
.
.
.
until we reach the end of set j
I tried s(j+1) and s(j++1) but no matter how you define it, gams is not allowing me to input n as a set or scaler (in the form of a loop, for, while functions), but rather requires a primary real number. I cannot seem to get past this error as I do not want to input these numbers manually (I have a huge number of variables). How can I define it before the equations?
(sorry for the previous reply I submitted it by mistake)
Kindly view the file attached, my problem concerns constraint dep(i,j), Thank you for your help!
you cannot use a loop statement within an equation definition… you need to somehow structure your equation definition so that the looping behavior you are hoping for is taken care of entirely with set operations. This might also necessitate an alias set. While doing this you might also need to rethink your choice of decision variables… It might be helpful to post this question in the “Modeling” section of the forum rather than “Syntax”.