Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: Travelling problem

by LanX (Saint)
on Dec 21, 2013 at 16:59 UTC ( [id://1068042]=note: print w/replies, xml ) Need Help??


in reply to Travelling problem

Are you aware that
  • you are¹ describing the well known travelling salesman problem?

  • "perfect" solutions for non-trivial cases of NP-complete problems are unknown?

  • there are very good solutions for real world problems though?

Please check if you really need all criteria!

Pick at most 2 of 3 and we might be able to help:

  • Fast (i.e. polynomial²) computation

  • Proven minimal path

  • unknown number of nodes > n (n ~ 20 ?)

If it's just a theoretical question and you can't limit the requirements, then I suppose a branch and bound algorithm might be the best approach, but it won't be faster than brute force in some edge cases.

HTH! =)

Cheers Rolf

( addicted to the Perl Programming Language)

update

had a short glance at the WP article and it describes much better what I wanted to tell.

footnotes

¹) almost

²) corrected, educated foo++

Replies are listed 'Best First'.
Re^2: Travelling problem
by educated_foo (Vicar) on Dec 22, 2013 at 00:54 UTC
    Fast (i.e. non-polynomial) computation
    You mean "i.e. polynomial," right? NP is exponential ;-). I heartily agree with your post, and defer to my favorite MJD talk for the details.

    EDIT: Nut graph:

    next time someone tells you to give up on your problem because it's NP-complete, ignore them.
      > You mean "i.e. polynomial,"

      yes, kind of "non-exponential" =)

      Was a short night! :)

      Cheers Rolf

      ( addicted to the Perl Programming Language)

      update

      > next time someone tells you to give up on your problem because it's NP-complete, ignore them.

      Unfortunately well described problems are rare here.

        Unfortunately well described problems are rare here.
        As are honestly thoughtful and helpful responses, and genuine discussion. As someone who has been here awhile (perhaps far too long), I know how to separate the wheat-y help from the karma-whoring chaff (I've contributed to both). New users, however, may not know how to filter out the mindless nostrums.
Re^2: Travelling problem
by Dirk80 (Pilgrim) on Dec 21, 2013 at 21:12 UTC

    Yes, you are right. The "travelling salesman problem" exactly describes my problem. Thank you!!!

    I have 24 places and I know the distance between these places in km. I have to visit the first place, then 22 places in any order and then the 24th place. I don't need a perfect solution. I just want to find a short way, not the shortest one. And the computation time should not be too long. An approximation is enough.

      The Christofides Algorithm mentioned by educated foo guaranties a solution better than 1.5 times the optimum.

      Nota bene: since you have a fixed start and end for an "open" hamiltonian path (i.e. not a circle like in the TSP) you'll need to adjust the algorithm accordingly. ¹

      Cheers Rolf

      ( addicted to the Perl Programming Language)

      update

      ¹) after reading two SO discussions (search "minimal hamilton path") you just need to add a dummy point neighboring (only) the desired start- and end-point with distance 0 (!)

      Like this any TSP algorithm will chose start and end as neighbors for a hamilton circle with the same accumulated length like a optimized hamilton path, you just need to ignore the two dummy edges at the end.

      I have 24 places and I know the distance between these places in km. I have to visit the first place, then 22 places in any order and then the 24th place.

      Could you post a sample dataset?


      With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1068042]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (5)
As of 2024-04-23 18:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found