|
Algorithm 3 Primal-dual heuristic for finding an HDSF |
| 1: |
Initialization |
| 2: |
, for
|
| 3: |
All the vertices are unmarked. |
| 4: |
All the dual variables are set to zero. |
| 5: |
, , for
|
| 6: |
, for
|
| 7: |
Main loop |
| 8: |
while there exists any active component in
do
|
| 9: |
for
k = 1, 2 do
|
| 10: |
Find an edge with , where that minimizes
|
| 11: |
end for
|
| 12: |
Let the corresponding be , while satisfies and are active. |
| 13: |
|
| 14: |
Increase the dual variables of by . |
| 15: |
if forms a new strongly connected component and the component is not reachable from
then
|
| 16: |
Let the strongly connected component be an active component. |
| 17: |
else if
makes any vertex reachable from
then
|
| 18: |
Let the depot and all vertices that are reachable from the depot be an inactive component. |
| 19: |
if
then
|
| 20: |
Deactivate all subsets of this component in . |
| 21: |
else
|
| 22: |
Mark all vertices in the supersets of this component in . Deactivate it if the corresponding component consists of all marked vertices. |
| 23: |
end if
|
| 24: |
else
|
| 25: |
Deactivate . |
| 26: |
end if
|
| 27: |
if there exists no that can be chosen that satisfies the given conditions and there exists any inactive set without an incoming edge that is not connected to the depot then
|
| 28: |
Pick an inactive component for each k that consists of marked vertices that have incoming or outgoing edges. Combine those connected components until the new component does not have any incoming edges. |
| 29: |
end if
|
| 30: |
end while
|
| 31: |
Pruning |
| 32: |
|
| 33: |
|
| 34: |
Let be the minimum directed spanning tree of . |
| 35: |
Let be the sum of the edge costs present in . |
| 36: |
while is not empty do
|
| 37: |
Find the shortest edge that makes a vertex in reachable from the vertices in for each k. |
| 38: |
if
then
|
| 39: |
Add to , remove the corresponding vertex from , and add it to . |
| 40: |
else
|
| 41: |
Add to , remove the corresponding vertex from , and add it to . |
| 42: |
end if
|
| 43: |
end while
|