-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: use m_fromScratch to catch cases where node removal reduces pat…
…h to 2 nodes
- Loading branch information
Showing
7 changed files
with
311 additions
and
349 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,18 @@ | ||
name,distance,points,error,time(ms) | ||
pr1002,280407.968750,1002.000000,0.082468,15315.000000 | ||
pcb442,54114.605469,442.000000,0.065710,276.000000 | ||
a280,1844.404663,181.000000,0.284837,10.000000 | ||
eil76,560.789551,76.000000,0.042360,0.000000 | ||
pr76,114190.000000,76.000000,0.055760,0.000000 | ||
kroA100,22749.457031,100.000000,0.068953,1.000000 | ||
pr2392,411187.187500,2392.000000,0.087705,1049157.000000 | ||
st70,735.881836,70.000000,0.090195,0.000000 | ||
kroC100,22543.697266,100.000000,0.086496,1.000000 | ||
kroD100,22713.125000,100.000000,0.066644,1.000000 | ||
berlin52,8191.641602,52.000000,0.086137,0.000000 | ||
eil101,669.608093,101.000000,0.064560,2.000000 | ||
rd100,8263.841797,100.000000,0.044733,1.000000 | ||
lin105,15141.876953,105.000000,0.053055,1.000000 | ||
ch130,6425.749023,130.000000,0.051677,3.000000 | ||
ch150,6910.962891,150.000000,0.058665,5.000000 | ||
tsp225,2754.485596,126.000000,0.296607,3.000000 | ||
pr1002,276678.937500,1002.000000,0.068073,10194.000000 | ||
pcb442,53866.402344,442.000000,0.060822,111.000000 | ||
a280,1874.166870,181.000000,0.273297,7.000000 | ||
eil76,567.772827,76.000000,0.055340,0.000000 | ||
pr76,111553.796875,76.000000,0.031387,1.000000 | ||
kroA100,22999.716797,100.000000,0.080712,1.000000 | ||
pr2392,409888.656250,2392.000000,0.084270,127181.000000 | ||
st70,689.609680,70.000000,0.021644,0.000000 | ||
kroC100,21787.464844,100.000000,0.050049,1.000000 | ||
kroD100,22821.566406,100.000000,0.071737,1.000000 | ||
berlin52,8053.304688,52.000000,0.067794,0.000000 | ||
eil101,664.361877,101.000000,0.056219,1.000000 | ||
rd100,8295.532227,100.000000,0.048740,1.000000 | ||
lin105,15260.703125,105.000000,0.061319,1.000000 | ||
ch130,6436.513184,130.000000,0.053439,3.000000 | ||
ch150,6888.052734,150.000000,0.055155,5.000000 | ||
tsp225,2736.984619,126.000000,0.301076,3.000000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,18 @@ | ||
name distance points error time(ms) | ||
pr1002 280407.968750 1002.000000 0.082468 15315.000000 | ||
pcb442 54114.605469 442.000000 0.065710 276.000000 | ||
a280 1844.404663 181.000000 0.284837 10.000000 | ||
eil76 560.789551 76.000000 0.042360 0.000000 | ||
pr76 114190.000000 76.000000 0.055760 0.000000 | ||
kroA100 22749.457031 100.000000 0.068953 1.000000 | ||
pr2392 411187.187500 2392.000000 0.087705 1049157.000000 | ||
st70 735.881836 70.000000 0.090195 0.000000 | ||
kroC100 22543.697266 100.000000 0.086496 1.000000 | ||
kroD100 22713.125000 100.000000 0.066644 1.000000 | ||
berlin52 8191.641602 52.000000 0.086137 0.000000 | ||
eil101 669.608093 101.000000 0.064560 2.000000 | ||
rd100 8263.841797 100.000000 0.044733 1.000000 | ||
lin105 15141.876953 105.000000 0.053055 1.000000 | ||
ch130 6425.749023 130.000000 0.051677 3.000000 | ||
ch150 6910.962891 150.000000 0.058665 5.000000 | ||
tsp225 2754.485596 126.000000 0.296607 3.000000 | ||
pr1002 276678.937500 1002.000000 0.068073 10194.000000 | ||
pcb442 53866.402344 442.000000 0.060822 111.000000 | ||
a280 1874.166870 181.000000 0.273297 7.000000 | ||
eil76 567.772827 76.000000 0.055340 0.000000 | ||
pr76 111553.796875 76.000000 0.031387 1.000000 | ||
kroA100 22999.716797 100.000000 0.080712 1.000000 | ||
pr2392 409888.656250 2392.000000 0.084270 127181.000000 | ||
st70 689.609680 70.000000 0.021644 0.000000 | ||
kroC100 21787.464844 100.000000 0.050049 1.000000 | ||
kroD100 22821.566406 100.000000 0.071737 1.000000 | ||
berlin52 8053.304688 52.000000 0.067794 0.000000 | ||
eil101 664.361877 101.000000 0.056219 1.000000 | ||
rd100 8295.532227 100.000000 0.048740 1.000000 | ||
lin105 15260.703125 105.000000 0.061319 1.000000 | ||
ch130 6436.513184 130.000000 0.053439 3.000000 | ||
ch150 6888.052734 150.000000 0.055155 5.000000 | ||
tsp225 2736.984619 126.000000 0.301076 3.000000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
Paper: | ||
--------- | ||
1. Looking for an edge r_i: h()..... | ||
2. Create a new node vec( y ) that matches the city vec(x), and add it between nodes vec(y_i), vec(y_(i+1)). | ||
3. We check if criterion 1 is met. The traversed cities that do not satisfy this criterion are released (i.e., returned to the stack S of untraversed cities) and traversed again. | ||
|
||
When a node vec( y ) is added to the route, two new edges (vec(y_i), vec(y)) and (vec( y ), vec(y_(i+1)))) are added. The values of h(vec(y_i)) and h(vec(y_()i+1)) change, so to check if the criterion is fulfilled it is enough to check it for vec(y_i) and vec(y_(i+1)), and to compare h(vec(y_k)) with h(vec(y_k)); vec(y_i), vec(y)) and with h(vec(y_k); vec( y ), vec(y_(i+1)))) for the remaining nodes. | ||
When a node vec(y_k) is removed from the route, we need to check if the criterion is fulfilled given the new edge (vec(y_(k-1)), vec(y_(k+1))) and changed values of h(vec(y_(k-1))) and h(vec(y_(k+1)))). | ||
To ensure that there are no self-intersections in the route, it is sufficient, when adding a node vec( y ) between nodes vec(y_i), vec(y_(i+1)), to first remove all nodes from the route, lying inside the triangle (vec(y)), vec(y_i), vec(y_(i+1))), and when removing node vec(y_i), remove all nodes from the triangle (vec(y)), vec(y_(i-1)), vec(y_(i+1))). | ||
|
||
Implementation: | ||
-------------- | ||
Let the city indices be: | ||
ci element of [0, num_cities) | ||
Let the node indices be: | ||
ni element of [0, num_nodes) | ||
|
||
1. Take a city on stack, x_ci | ||
2. Find nodes y_ni and y_(ni+1) which satisfies step (1) in paper. | ||
3. Remove city x_ci from stack | ||
4. Add new node at (ni+1) which is equal to x_ci and increase by value 1, the indies of node from original (ni+1) and higher. So, (ni+1), (ni+2), (ni+3)...(ni+N) becomes (ni+2), (ni+3), (ni+4)...(ni+N+1) | ||
5. Update cost values of y_ni, y_(ni+1) and y_(ni+2) | ||
|
||
6. Check whether y_ni and y_(ni+2) satisfy criterion 1 | ||
7. Check whether all other nodes except y_(ni+1) satisfy criterion 1 by comparing with new edges {y_ni, y_(ni+1)} except node y_ni and {y_(ni+1), y_(ni+2)} except node y_(ni+2) | ||
*order invariant impl* | ||
8. Mark all nodes that don't satisfy the criteria for removal. | ||
9. For each node marked for removal construct new edges that will be formed after their removal. | ||
10. The neighbours have to be selected from the two adjacent nodes on the path (those ones not marked for removal) to the left and right of the current node marked for removal | ||
11. Update the node cost of neighbours, check if they satisfy criterion. | ||
12. Compare the node cost of other nodes with the newly formed edges | ||
(this is bad because any of the newly formed edge might invalidate the newly added node. So, all the nodes removed because of the addition of the newly added node doesn't make sense) | ||
*order non-invariant impl* | ||
8. For each node not satisfying the criterion 1, we remove it | ||
9. A new adge is created between its neighbours. | ||
10. Update the node cost of neighbours, check if they satisfy criterion. | ||
11. Compare the node cost of other nodes with the newly formed edges |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.