Dear all,
I am working on a shortest path algorithm. Similar to the Clarke&Wright savings algorithm. I want to run it in GAMS but got stuck at one point. The code already finds the “cheapest” customer to insert. I somehow can’t get GAMS to insert the customer between two existing customers. I tried to reproduce the interesting part of the code here.
The set “newarcs” consists of the initial routes from a Depot to the first customer and back. Let’s say the algorithm identified the optimal position for customer two to be between the Depot and customer one (oldarc).
Arc 0.1 needs to be removed → newarcs(oldarc) = no;
Then two new arcs are needed: 0.2 from Depot to newcustomer and 2.1 from customer 2 to 1 in order to close the gap. I wrote that explicitly in the code here, but need to find a way to implement that in a general way.
Something like: “If Oldroute is 0.1, then take first element of that route an add new customer and build a route from newcustomer to the second element of oldroute”
I tried option and various $-conditionals but none had the right effect here.
Advice for how to solve this would be greatly appreciated,
bestregards,
Isidor
Sets
node / 0, 1, 2, 3, 4 /
newcustomer(node) ;
alias (node,anode) ;
newcustomer(“2”) = yes;
set
allarcs(node,anode)
newarcs(node,anode);
singleton set oldarc(node,anode) ;
allarcs(node,anode)$(not sameas(node,anode)) = yes;
newarcs(“0”,“1”) = yes; newarcs(“1”,“0”) = yes;
oldarc(“0”,“1”) = yes;
newarcs(oldarc) = no;
newarcs(“0”,newcustomer) = yes;
newarcs(newcustomer,“1”) = yes;
display node, anode, test, allarcs, oldarc, newarcs
\
To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+unsubscribe@googlegroups.com.
To post to this group, send email to gamsworld@googlegroups.com.
Visit this group at http://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/d/optout.