Coder Social home page Coder Social logo

traveling-santa-problem-solver's Introduction

Traveling Santa Problem Solver

This is a heuristic written in Python for the Traveling Santa Problem. It is based on Concorde -- a state-of-the-art Traveling Salesman Problem (TSP) solver.

Heuristic

The Traveling Santa Problem naturally decomposes into two TSP with side constraints (an edge can be in at most one TSP). This heuristic uses Concorde's Lin-Kernighan heuristic as follows:

  1. Run Lin-Kernighan heuristic on first path.

    Edge restriction: can used at most n edges from the second path.

  2. Run Lin-Kernighan heuristic on second path.

    Edge restriction: can't use any edge from the first path.

Result

This heuristic (IRO on the leaderboard) found a solution with an objective value of 6,593,676, which is at 1% of the solution found by the winning team (6,526,972).

Usage

Computing k Nearest Neighbor

Since each subproblem (TSP) uses a strict subset of the edges, we need to explicitly list the allowed edges to Concorde. And we can't list all edges because there are too many (~11 billions). So I decided to include edges from the k nearest neighbor graph (K-NNG). The script k_nearest_neighbor.py generates such graph in a naive way O(n^2), but it's fully parallelizable so it shouldn't take too long if you have a few cores.

Parameters:

  • number of processes
  • k
  • instance

Example:

python3 k_nearest_neighbor.py 24 200 santa.nodes > santa.neighbors.200

Running the Heuristic

Parameters:

  • instance
  • neighbors
  • initial solution
  • linkern path
  • k
  • path1 time limit
  • path2 time limit

Example:

python3 heur.py \
    santa.nodes \
    santa.neighbors.200 \
    incumbent_solution \
    ~/concorde/LINKERN/linkern \
    200 \
    120 \
    300

The script run can also be used to launch multiple heur.py in parallel.

Parameters:

  • number or processes

Example:

./run 24

Note: you need to adapt run to your environment before using it.

Author

Mahieu Larose [email protected]

License

See LICENSE

traveling-santa-problem-solver's People

Contributors

larose avatar

Stargazers

Rodrigo Rodrigues avatar nige avatar  avatar

Watchers

James Cloos avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.