Demo - Optimization

Infinite Traveling Salesperson Simulation

Overview

This simulation uses Simulated Annealing (SA) to solve the Traveling Salesperson Problem (TSP). The goal is to find the shortest route that visits each city exactly once and returns to the starting city. As the algorithm progresses, the "temperature" gradually decreases, leading to a refinement of the route.

How It Works

  1. City GenerationRandom cities are distributed within a canvas.

  2. Initial Route → A random route is created that visits all cities.

  3. Simulated Annealing Process → The route is iteratively optimized:

    • A swap between two cities is proposed.

    • If the new route is shorter, it's accepted.

    • If it's longer, it's accepted based on a probabilistic criterion, allowing for exploration.

  4. Cooling Down → The algorithm's "temperature" gradually decreases, making it less likely to accept worse routes.

  5. Best Route Tracking → The best route found so far is displayed in red.

Key Features

Real-Time Visualization → Cities and the best route are animated in real time.
Dynamic Distance Calculation → The current distance of the best route is updated and displayed.
Simulated Annealing → A powerful metaheuristic for solving optimization problems.
Continuous Optimization → The algorithm runs infinitely, constantly improving the solution.

Applications

Logistics & Delivery → Optimizing delivery routes for transportation companies.
Robotics → Efficient pathfinding for mobile robots navigating a set of waypoints.
AI in Planning → Solving optimization problems in areas like AI planning, scheduling, or circuit design.
Supply Chain Management → Reducing travel time or costs in product distribution.