Error 170 Domain violation for element

Problems with syntax of GAMS
Post Reply
serrmer
User
User
Posts: 1
Joined: 6 years ago

Error 170 Domain violation for element

Post by serrmer »

Hello all,

I am quite new to forum and a beginner to GAMS.

I want to form the equation attached. https://image.ibb.co/c41Qpb/equation.png
I already introduced the i,j and k to the software however when i add the order of (k-1) at the LHS of the equation it gives Error 170 Domain violation for element when i want to introduce the equation. What should i do to manipulate the k index as i want?

I tried these two:
  • function(i,j,k) .. x(i,j,'k-1')-x(i,j,k)=l=s(i,j,k)
  • function(i,j,'k-1',k) .. x(i,j,'k-1')-x(i,j,k)=l=s(i,j,k)
Attachments
equation.PNG
equation.PNG (10.63 KiB) Viewed 7768 times
User avatar
Renger
Posts: 639
Joined: 7 years ago

Re: Error 170 Domain violation for element

Post by Renger »

Hi
Just write k-1 without the quotation marks. Note that you have to start at the second element of k, so you can add a $-restriction on the function:
function(i,j,k)$(ord(k) > 1) .. x(i,j,k-1) - x(i,j,k) =l= s(i,j,k)
Cheers
Renger
____________________________________
Enjoy modeling even more: Read my blog on modeling at The lazy economist
Post Reply