-
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.
- Loading branch information
0 parents
commit 0d79b32
Showing
22 changed files
with
878 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<classpath> | ||
<classpathentry kind="src" path="src"/> | ||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/> | ||
<classpathentry kind="output" path="bin"/> | ||
</classpath> |
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,21 @@ | ||
MIT License | ||
|
||
Copyright (c) [2021] [Samuel C. Donovan] | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
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,8 @@ | ||
# Held-Karp implementation for solving the TSP | ||
|
||
This is my implementation of the Held-Karp dynamic programming algorithm. It is an exact algorithm, and as such, returns the optimal path and cost for a given data set. | ||
|
||
## Why Held-Karp? | ||
The problem for which this project was designed for required an exact solution for all n <= 20 in less than one minute. | ||
This algorithm has a proposed time complexity of O(n^2 * 2n). For n = 20: 20^2 * (2*20) ≈ 16000, which is drastically lower than one minute. Though my implementation runs quite a bit slower than this, (for n = 20, it runs in approx. 20 seconds) it will still run in less than one minute for n <= 20, and will find the shortest path and its cost. | ||
For n > 20, the running time starts to get exponentially larger. It becomes infeasible to run this implementation on n > 30, where the running time is several hours long. This is not necessarily due to an issue with my implementation, but is more of an issue with the algorithm and the TSP in general, as the TSP is an NP-Hard problem and as such, finding exact solutions becomes increasingly more expensive the larger n is. |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
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,12 @@ | ||
1 110 40 | ||
2 2 63 | ||
3 172 25 | ||
4 182 68 | ||
5 192 39 | ||
6 144 81 | ||
7 76 31 | ||
8 192 73 | ||
9 16 63 | ||
10 80 78 | ||
11 70 79 | ||
12 36 8 |
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,12 @@ | ||
1 85 93 | ||
2 80 35 | ||
3 38 19 | ||
4 65 9 | ||
5 38 5 | ||
6 52 80 | ||
7 76 84 | ||
8 94 41 | ||
9 99 63 | ||
10 30 47 | ||
11 53 98 | ||
12 80 43 |
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,14 @@ | ||
1 -34 85 | ||
2 49 184 | ||
3 85 18 | ||
4 72 164 | ||
5 -22 -8 | ||
6 -8 0 | ||
7 -53 172 | ||
8 -84 58 | ||
9 19 73 | ||
10 69 26 | ||
11 29 4 | ||
12 -6 151 | ||
13 67 90 | ||
14 0 77 |
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,14 @@ | ||
1 -63 35 | ||
2 99 91 | ||
3 73 0 | ||
4 27 20 | ||
5 -6 -52 | ||
6 48 -146 | ||
7 -19 -127 | ||
8 4 -22 | ||
9 -36 -28 | ||
10 91 -191 | ||
11 -24 -38 | ||
12 82 -169 | ||
13 82 31 | ||
14 -37 -16 |
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,18 @@ | ||
1 10834 18658 | ||
2 30756 3345 | ||
3 19970 24600 | ||
4 14669 25177 | ||
5 29650 8784 | ||
6 24669 18572 | ||
7 3349 10191 | ||
8 6553 8852 | ||
9 4889 2771 | ||
10 13418 28914 | ||
11 30610 25659 | ||
12 13919 18570 | ||
13 -16 23422 | ||
14 20855 21944 | ||
15 15444 29757 | ||
16 24671 11060 | ||
17 4399 19731 | ||
18 0 0 |
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,17 @@ | ||
1 26378 4886 | ||
2 30564 320 | ||
3 12319 16264 | ||
4 3251 28593 | ||
5 4817 21078 | ||
6 25713 3087 | ||
7 8323 628 | ||
8 26627 4370 | ||
9 10504 19168 | ||
10 5242 2316 | ||
11 31388 65 | ||
12 23941 27464 | ||
13 30708 1016 | ||
14 15295 22466 | ||
15 9403 24404 | ||
16 15454 27513 | ||
17 16349 13418 |
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,32 @@ | ||
1 27985 147343 | ||
2 20160 3508 | ||
3 27960 214746 | ||
4 14294 25899 | ||
5 26573 3634 | ||
6 773 11455 | ||
7 14381 36932 | ||
8 5279 72300 | ||
9 14349 11721 | ||
10 21645 69622 | ||
11 25098 31683 | ||
12 3595 273115 | ||
13 1533 129427 | ||
14 22560 111589 | ||
15 5798 129816 | ||
16 9629 58991 | ||
17 25167 3126 | ||
18 27305 248606 | ||
19 7109 121380 | ||
20 25743 36309 | ||
21 6773 102159 | ||
22 14012 35326 | ||
23 6030 2565 | ||
24 5849 78210 | ||
25 22839 133162 | ||
26 22688 60633 | ||
27 8192 91821 | ||
28 25685 71043 | ||
29 21098 125138 | ||
30 27342 13142 | ||
31 22831 219085 | ||
32 19628 22899 |
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,27 @@ | ||
1 72998 904383 | ||
2 17182 401303 | ||
3 42526 103033 | ||
4 33855 446405 | ||
5 38508 281016 | ||
6 88516 456574 | ||
7 79887 508613 | ||
8 44426 328114 | ||
9 14075 59229 | ||
10 3342 981173 | ||
11 18366 400905 | ||
12 92080 564993 | ||
13 43136 259655 | ||
14 15968 820490 | ||
15 27865 942274 | ||
16 9564 263346 | ||
17 65022 596732 | ||
18 45058 619031 | ||
19 32666 238232 | ||
20 51384 672851 | ||
21 88632 343223 | ||
22 66179 840350 | ||
23 76844 529953 | ||
24 19202 711999 | ||
25 12022 731249 | ||
26 94124 453766 | ||
27 60316 3439 |
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,4 @@ | ||
1 1 1 | ||
2 5 5 | ||
3 10 3 | ||
4 2 7 |
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,8 @@ | ||
1 38 20 | ||
2 39 26 | ||
3 40 25 | ||
4 36 23 | ||
5 38 13 | ||
6 37 20 | ||
7 41 9 | ||
8 36 -5 |
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,9 @@ | ||
1 16 96 | ||
2 46 94 | ||
3 20 32 | ||
4 22 43 | ||
5 25 57 | ||
6 22 16 | ||
7 20 87 | ||
8 17 16 | ||
9 66 97 |
Oops, something went wrong.