Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

HeDoS

This source code deals with solving 3D Travelling Salesman Problem using Genetic Algorithms.

Originally developed for an MSc thesis in 2006, it has been modernized to use Java 25 (LTS), Maven, and structured YAML configuration.

Key Features

  • Java 25 Modernization: Utilizes Virtual Threads, finalized Structured Concurrency (Joiners), and Scoped Values for clean, immutable, and scalable context propagation across parallel execution scopes.
  • High-Performance Math & Memory: Leverages the Vector API (SIMD) for lightning-fast calculations and the Foreign Function & Memory (FFM) API for optimized off-heap management of distance matrices and population genomes.
  • Robust Architecture: Built with Google Guice (DI), Jackson (YAML), and a reactive EventBus for clean separation of concerns and thread-safe, event-driven UI localization.
  • Interactive Visualization: Real-time performance charting with persistent tooltips, 3D path rendering, and a compact, localized configuration side panel.
  • Scientific Benchmarking: Integrated JMH (Java Microbenchmark Harness) suite to quantify SIMD speedups and memory throughput directly from the UI.

Why the FFM API?

Traditional Java arrays are indexed by int, limiting them to approximately 2.1 billion elements. For large-scale 3D TSP problems, the $N^2$ distance matrix can easily exceed this limit. By using the FFM API (MemorySegment):

  • Beyond the 2GB Limit: We utilize long addressing to support massive coordinate datasets.
  • GC Efficiency: Memory for distance matrices and population genomes is allocated via Arena.ofAuto(), reducing heap pressure and providing a foundation for zero-copy variation.
  • Native Hardware Alignment: MemorySegment allows for precise 64-byte alignment (AVX-512 compatible), enabling the Vector API to perform peak-performance "aligned loads."

Optimization Algorithms

HeDoS implements several state-of-the-art algorithms for solving the 3D Travelling Salesman Problem:

Crossover Operators

Mutation Operators

Selection Operators

Local Search Optimizers (LSO)

Getting Started

Prerequisites

  • Java 25 (LTS): Required for the latest performance improvements, Vector API (SIMD), and Virtual Threads.
    • JVM Flags: Because the project utilizes incubator and preview features, the following flags are required:
      • --add-modules jdk.incubator.vector
      • --enable-preview
  • Maven 3.8+: Used for dependency management and build orchestration.
  • Xj3D Libraries: See the manual installation section below.

Quick Start

The project includes helper scripts for a streamlined setup:

  1. Install Dependencies: Copy required Xj3D JARs to lib/ and run:
    ./install_deps.sh
  2. Build and Run:
    ./run.sh

Alternatively, use Maven directly:

mvn clean compile exec:exec

Usage

  1. Targets: Manage 3D points via the "Manage Targets" dialog or generate random datasets through "File > Generate Random Targets".
  2. Configuration: Adjust GA parameters (Population, Mutation, Crossover, Elitism, Stagnation) in the localized side panel. Hover over ComboBox items to see strategy descriptions.
  3. Hybrid GA: Select a Local Optimization strategy (e.g., Lin-Kernighan or Parallel 3-Opt) to significantly improve solution quality.
  4. Benchmarking: Scientific validation of optimizations is available via the Benchmark menu. Results are displayed in a detailed dialog after the JMH suite completes.
  5. Analysis: Use the real-time Duration Chart to monitor total time, local search time, and fitness. Click on the chart to view exact generation metrics in a persistent tooltip.
  6. Persistence: Save your best tour, settings, or performance statistics using the "File" menu.

License: Apache License 2.0


Xj3D installation and copying required libraries

  • Download Xj3D installer from Xj3D Download Page
  • Install it and copy the following JARs from jar inside the Xj3D installation folder to the lib folder under the project folder:
File Suggested ArtifactId
aviatrix3d-all_3.1.1-nps.jar aviatrix3d-all
xj3d.browser_2.3.0-nps.jar xj3d-browser
xj3d.cadfilter_2.3.0-nps.jar xj3d-cadfilter
xj3d.replica_2.3.0-nps.jar xj3d-replica
xj3d-2.3-3rdparty-nps.jar xj3d-3rdparty
xj3d-2.3-nps.jar xj3d-core
  • You can run the program now, it gives the following native library error:

    SEVERE: Native code library (32 and 64 bit library) failed to load: java.lang.UnsatisfiedLinkError: no odejava in java.library.path ``

You can overcome this issue by using the following VM argument: -Djava.library.path=${Xj3D_Installation_Path}/natives/Linux/x84_64/

But this change creates a window closing problem. It is possible to use without this library path.

My MSc Thesis

It is in Turkish, here is the information for interested readers:

About

Solving 3D Travelling Salesman Problem using Genetic Algorithm (source code of my master thesis)

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Used by

Contributors

Languages