But the code is not correct somehow. When I check the gams output in the equation listings, I always get values way off even for the very small (a_kj-y_nj) values.

In this example, there are 4 w values, p=2, and largest a_kj-y_nj=2.75. However the output is like this. I also attach the gams code in a txt file.

Hi, i don’t have too much information but you can try this

sets k 1 to 18?? /1*18/
j 1 to 3?? /1*3/
n 1 to 18?? /1*18/
;
alias(n,t)
;
constraint1(k,n).. D_p(k,n) =e= rPower(sum(j,w(j)*power(((a(k,j))-y(n,j)),p)),(1/p));
constraint2(k,n,t)$(ord(t) ne ord(n)).. D_p(k,n)-e(k) =l= D_p(k,t)-r;

Hey, thank you so much for your response! I have managed to overcome the problem of taking different values in a set. But I believe there is something wrong with the expression inside the constraint:

I get way off values when I check them from the Gams output(I edited and added a screenshot to the main post.). Do you think there is something wrong with this expression?

Hi, when I can I will observe what you shared. But, remember that it is an NLP problem so the equations shown by the lst file are a linear approximation of them.
Best!

I don’t exactly know what the issue is. You are concerned with the equation listing which is the linearized model instance at the input point. Since you don’t pay attention setting the input point, the equation listing is of little concern I think. Look at what solution the solver generates in the solution report. At least MINOS find an (locally) optimal solution for your model.