Giter VIP home page Giter VIP logo

the-dynamic-programming-algorithm-for-the-shortest-path-tour-problem's Introduction

The Dynamic Programming Algorithm for the Shortest Path Tour Problem

Reference: Festa P, Guerriero F, Laganà D, et al. Solving the shortest path tour problem[J]. European Journal of Operational Research, 2013, 230(3): 464-474.

The shortest path tour problem aims to find the shortest path that traverses multiple disjoint node subsets in a given order.

Three different label extracting strategies:

  • extract1: Dijkstra-like rule
  • extract2: first-in first-out rule
  • extract3: last-in first-out rule

Variables Meaning
network Dictionary, {node1: {node2: length, node3: length, ...}, ...}
node_subset List, [[subset1], [subset2], ...]
nn The number of nodes
ns The number of subsets
neighbor Dictionary, {node1: [the neighbor nodes of node1], ...}
label_set All generated labels
label label[n] denotes all labels of node n
best_solution The best solution ever found
delta The length of best_solution

Example

if __name__ == '__main__':
    test_network = {
        0: {1: 2, 2: 3, 3: 3},
        1: {0: 2, 3: 2},
        2: {0: 3, 3: 3},
        3: {0: 3, 1: 2, 2: 3, 4: 2, 5: 3, 6: 3},
        4: {3: 2, 6: 2},
        5: {3: 3, 6: 3},
        6: {3: 3, 4: 2, 5: 3},
    }
    subset = [[0], [1, 3], [4, 5], [6]]
    print(main(test_network, subset))
Output
{
  'path': [0, 3, 4, 6], 
  'length': 7
}

the-dynamic-programming-algorithm-for-the-shortest-path-tour-problem's People

Contributors

xavier-mayiming avatar

Stargazers

Xinyi avatar  avatar

Watchers

 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.