Node based travelling salesman problem visualisation in Java. Generates a nearest neighbour path then optimises with iterative 2-opt swaps in order to find a sub optimal "shortest" path.
Download the jar.
One-liner:
sudo apt update && sudo apt install openjdk-8-jre && sudo update-alternatives --config java && java -jar /path/to/TravellingSalesman.jar
Execute the jar file:
java -jar /path/to/TravellingSalesman.jar
If Java 8 is not installed, install it using your local package manager, e.g:
sudo apt install openjdk-8-jre
If you are running a version of Java later than 8 then you must downgrade your current installation:
sudo update-alternatives --config java
Then select Java 8:
There are 2 choices for the alternative java (providing /usr/bin/java).
Selection Path Priority Status
------------------------------------------------------------
0 /usr/lib/jvm/java-13-openjdk-amd64/bin/java 1311 auto mode
* 1 /usr/lib/jvm/java-13-openjdk-amd64/bin/java 1311 manual mode
2 /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java 1081 manual mode
Press <enter> to keep the current choice[*], or type selection number: 2
Done!
Run the jar with Java versions 8-17 (Java 8, 13 and 17 confirmed to work)
It could be a problem with your Nvidia control panel settings.
3D Settings -> Manage 3D settings -> Global settings -> Vertical sync -> Use the 3D application setting
- Get user input numNodes, proximity (Example 10, 2)
- Populate a list with 10 randomly placed nodes
- For every node
- find the distance to every other node
- Randomly select from the 2 nearest other nodes and add it to a base route
- Find 2 edges
- Swap them
- If the resulting route is shorter than the previous route
- Keep the swap
- Otherwise find the next 2 edges
- Repeat until every edge has been checked with every other edge without any swaps occurring
- A local minumum has now been found and the program will stop