Giter Club home page Giter Club logo

tsp_vrp's Introduction

TSP_VRP

Example codes for the traveling salesman problem (TSP) and vehicle routing problem (VRP). All codes are written in Python, handle graphs using NetworkX, and solve integer programs using the Gurobi optimizer.

Helpful references:

  1. The traveling salesman problem: A case study in local optimization by Johnson and McGeoch.
  2. The Vehicle Routing Problem edited by Toth and Vigo.
  3. Video lecture by Bill Cook
  4. Bill Cook's TSP page

Also see a Python interface for the LKH heuristic and simple test.

Heuristics

  1. nearest_neighbor_heuristic
    • Generates a random 20-city TSP instance in the plane
    • Visualizes the instance using NetworkX
    • Implements the nearest neighbor heuristic
    • Visualizes the solution using NetworkX
  2. two_opt_heuristic
    • Generates a random 20-city TSP instance in the plane
    • Visualizes the instance using NetworkX
    • Implements the 2-opt local search heuristic
    • Visualizes each intermediate solution using NetworkX

Approximation Algorithms

  1. two_approximation_algorithm
    • Generates a random 20-city TSP instance in the plane
    • Visualizes the instance using NetworkX
    • Finds a minimum spanning tree using NetworkX
    • Replaces each undirected edge with oppositely directed edges
    • Finds an Eulerian cycle using NetworkX
    • Removes repeated nodes to generate a 2-approximate solution
    • Visualizes the solution using NetworkX
  2. Christofides_algorithm
    • Generates a random 20-city TSP instance in the plane
    • Visualizes the instance using NetworkX
    • Finds a minimum spanning tree using NetworkX
    • Finds a minimum cost perfect matching over the odd-degree nodes of the tree using NetworkX
    • Finds an Eulerian cycle of (tree edges) + (matching edges) using NetworkX
    • Removes repeated nodes to generate a 1.5-approximate solution
    • Visualizes the solution using NetworkX

Optimization Models

  1. DFJ_model
    • Generates a random 20-city TSP instance in the plane
    • Visualizes the instance using NetworkX
    • Solves the 2-matching relaxation using Gurobi
    • Visualizes the 2-matching solution using NetworkX
    • Adds violated subtour elimination constraints (in an iterative fashion)
    • Visualizes the solution using NetworkX
  2. DFJ_model_with_callbacks
    • Generates a random 20-city TSP instance in the plane
    • Visualizes the instance using NetworkX
    • Solves the DFJ model using Gurobi
    • Adds violated subtour elimination constraints in a callback
    • Visualizes the solution using NetworkX
  3. MTZ_model
    • Generates a random 20-city TSP instance in the plane
    • Visualizes the instance using NetworkX
    • Solves the assignment relaxation using Gurobi
    • Visualizes the assignment solution using NetworkX
    • Adds Miller-Tucker-Zemlin constraints and re-solves using Gurobi
    • Visualizes the solution using NetworkX
  4. MTZ_CVRP_model
    • Generates a random 20-city, 4-vehicle CVRP instance in the plane
    • Visualizes the instance using NetworkX
    • Solves an assignment relaxation using Gurobi
    • Visualizes the assignment solution using NetworkX
    • Adds the CVRP version of the Miller-Tucker-Zemlin constraints and re-solves using Gurobi
    • Visualizes the solution using NetworkX
  5. RCI_CVRP_model
    • Generates a random 20-city, 4-vehicle CVRP instance in the plane
    • Visualizes the instance using NetworkX
    • Adds violated rounded capacity inequalities (or subtour elimination constraints) in a callback
    • Visualizes the solution using NetworkX

tsp_vrp's People

Contributors

austinlbuchanan 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.