I am fairly new to GAMS and am trying to implement code that will allow me to loop through all of my regions (generally defined by four or five inequalities) and calculate the shortest distance between each set. The problems that I am encountering are as follows: 1) My code is returning an “Uncontrolled Set” error when ran as seen below and 2) I don’t know how to filter the constraints programmatically so that when calculating the distance between say regions one and two, only those constraints are active and so on (Currently constraints are modified manually based on a shortest path type problem). I have been struggling with this problem for a few days now trying everything I can and reading everything I can but to no avail. If anyone can provide any help I would be extremely grateful.

set n/1,2,3/;

set s/1,2,3/;

alias(n,nn);

parameter z(s) /1=0,2=0,3=0/;

free variables x(n),y(n),Obj;

equations Rect1,Rect2,Rect3,Rect4,Parr1,Parr2,Parr3,Parr4,Dia1,Dia2,Dia3,Dia4,objdef;

Rect1… y(‘2’) =l= 6+999*(1-z(‘2’));

Rect2… y(‘2’) =g= 5-999*(1-z(‘2’));

Rect3… x(‘2’) =g= -1-999*(1-z(‘2’));

Rect4… x(‘2’) =l= 1+999*(1-z(‘2’));

Parr1… y(‘3’) =l= -0.5*x(‘3’)+999*(1-z(‘3’));

Parr2… y(‘3’) =g= -0.5*x(‘3’) -1-999*(1-z(‘3’));

Parr3… x(‘3’) =l= -4+999*(1-z(‘3’));

Parr4… x(‘3’) =g= -6-999*(1-z(‘3’));

Dia1… y(‘1’) =l= x(‘1’)-2+999*(1-z(‘1’));

Dia2… y(‘1’) =l= -x(‘1’) + 8+999*(1-z(‘1’));

Dia3… y(‘1’) =g= -x(‘1’) + 6-999*(1-z(‘1’));

Dia4… y(‘1’) =g= x(‘1’) - 4-999*(1-z(‘1’));

objdef… Obj=e= sqrt((x(nn)-x(n))*(x(nn)-x(n))+(y(nn)-y(n))*(y(nn)-y(n)));

## model problem1 /all/;

option solprint = off;

alias (n,j);

alias (nn,k);

parameter minimumDistance(j,k);

loop((j,k)$(ord(j) ne ord(k)),

solve problem1 using nlp minimizing Obj;

minimumdistance(j,k)=Obj.lo;

);

option nlp = baron;

\

To view this discussion on the web visit https://groups.google.com/d/msg/gamsworld/-/l_jPh9XsAZ4J.

To post to this group, send email to gamsworld@googlegroups.com.

To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com.

For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.