Hello,
Let’s say I want to to write the following code in GAMS,
V, %vector of size 10
diff, %vector of size 10
for i=2:10
V(i)=V(i-1) + diff(i);
end
How do I write similar code in GAMS? Let’s assume I have a variable V of size b, where b=/x1,x2,x3,x4/, similarly the diff variable has same index b. Thank you.
Hi
Use the $-sign to restrict the equation to elements not equal to the first element
V(i)$(ord(i) > 1)=V(i-1) + diff(i);
* or if the elements of the set are integers
V(i)$(i.val > 1)=V(i-1) + diff(i);
* or using sameas
V(i)$(not sameas(i,"1") =V(i-1) + diff(i);