Hi,

First of all, the beauty of modeling languages like GAMS lies in its concise syntax which allows you to write compact indexed optimization models instead of huge incomprehensible scalar models.

I assume your variables xij should be interpreted as “how often does the arc between nodes i and j need to be traversed”. I don’t see how the model fits with the picture but interpreted like this, you are working on connected graph which makes sense. Implemented in the aforementioned indexed format, this could be implemented with 2 (indexed) variables and 3 (indexed) equations such that data and model become independent.

```
set i nodes / 1*9, a,b /
e(i,i) arcs / 1.8, 7.8, 1.2, 8.9, 6.7, 2.9, 6.9, 2.3, 4.9, 5.6, 3.4, 4.5 ,a.b/
;
parameter c(i,i) cost / 1.8 2, 7.8 4, 1.2 5, 8.9 3, 6.7 3, 2.9 6, 6.9 4, 2.3 5, 4.9 4, 5.6 4, 3.4 9, 4.5 4 , a.b 99/
;
alias(i,j);
e(i,j)$[ord(i)>ord(j)] = e(j,i);
c(i,j)$[ord(i)>ord(j)] = c(j,i);
display e,c;
integer variable x;
variable z;
equation defz 'define objective'
flowCon(i) 'flow conservation'
bothSides(i,i) 'clean both sides of sidewalk (i.e. travel edge twice)'
;
defz.. z =e= sum(e(i,j), c(i,j)*x(i,j));
flowCon(i).. sum(e(j,i), x(j,i)) - sum(e(i,j), x(i,j)) =e= 0;
bothSides(e(i,j)).. x(i,j) + x(j,i) =g= 2;
model m / all /;
solve m min z use mip;
```

Still, that does not give you the actual tour but at least it might give you some idea on how to use GAMS properly.

Regarding the tour: The model seems to make certain assumptions (like working on a connected graph) and if they are fulfilled it tells you how often you would need to traverse which edge in which direction to clean every sidewalk (i.e. every edge must be traversed twice) in an optimal solution. But I don’t see how this really defines a unique optimal tour. There are most likely many different optimal tours with equal distance.

If you invest a little more work, you might be able to construct an optimal tour from the MIP solution.

Best,

Fred