Algorithmatic problem

GiLtY

Golden Member
Sep 10, 2000
1,487
1
0
I'm bored, so here's a problem (still trying to figure out the best way to solve this problem):

On a map dictated by x-y coordinates stations are randomly placed on the map, and you are a train operator that drives the train. At the beginning of every travel you are starting at a different station (picked at random); however, you have the knowledge of the x-y coordinates of all the stations. The problem is to go through all of the train stations once and once only, but you have to pick out a route that provides the shortest total travel distance.

Have fun with the problem :)

--GiLtY
 

AFB

Lifer
Jan 10, 2004
10,718
3
0
Fvck, I'm going to bed. I forgot what the first part was by the time I was finished reading.
 

gopunk

Lifer
Jul 7, 2001
29,239
2
0
Originally posted by: KingNothing
Djikstra's algorithm would solve that. What do I win?

dijkstra's is shortest path from one vertex to another, this is the TSP... np complete
 

mobobuff

Lifer
Apr 5, 2004
11,099
1
81
To the Highly Technical forum with you.

Our tired brains = not compute.

But this does remind me of the time when I couldn't stop trying to figure out which type of mowing pattern would take the least amount of time to finish the yard.
 

dfi

Golden Member
Apr 20, 2001
1,213
0
0
I didn't give this a lot of thought so I'm probably missing something, but the obvious answer is just to always go to the station closest to your current station, barring any station you've already been to.

Or, let a computer solve it.

dfi
 

rgwalt

Diamond Member
Apr 22, 2000
7,393
0
0
This is the traveling salesman optimization problem, and is a tough cookie.

R
 

OulOat

Diamond Member
Aug 8, 2002
5,769
0
0
This is a special case the Hamiliton graph cycles, and Hamiltion is NP-hard. Thus, by reduction, TSP is NP-hard.

Where is my cookie?
 

OulOat

Diamond Member
Aug 8, 2002
5,769
0
0
Originally posted by: dfi
I didn't give this a lot of thought so I'm probably missing something, but the obvious answer is just to always go to the station closest to your current station, barring any station you've already been to.

Or, let a computer solve it.

dfi

Greedy algorithms won't work.

IE.
A to B = 4
B to C = 10
C to D = 5
A to D = 1
B to D = 6

Using your method, starting at A, you go to D then C and lasty B, summing to 16. An obvious shorter path is 15, A to B then D ending at C.
 

Nato595

Member
Dec 28, 2001
74
0
0
Being that we are in the year 2004, I would key all the coords into my Navi/GPS system (sorting by shortest distance) and follow the on-screen routing!
 

Ameesh

Lifer
Apr 3, 2001
23,686
1
0
depending on how many nodes there are i would probably brute force it using some recursive algorithm starting from every point to return a list of routes given the starting point. at least thats the easiest way I can solve your problem.
 

Argo

Lifer
Apr 8, 2000
10,045
0
0
Brute force method. Just compute all the possibilities and select the shortest. Until somebody comes with a better method I'm the winnah.
 

eigen

Diamond Member
Nov 19, 2003
4,000
1
0
np-complete , no cookie for you. Stop getting problems out of your textbooks:D and posting them here.

Oh this could b "solved" using DNA computing as well.


Edit: On a side note I will start doing research next semester on combinatorial optimaztion.So I will post the answer in a few months:laugh:
 

bleeb

Lifer
Feb 3, 2000
10,868
0
0
There are other more efficient methods than the Brute Force Method... You can try giving each node a weight and based on that come up with an algorithm... (don't remember the names off the top of my head)
 

jman19

Lifer
Nov 3, 2000
11,225
664
126
Originally posted by: Argo
Brute force method. Just compute all the possibilities and select the shortest. Until somebody comes with a better method I'm the winnah.

Yeah, as long as there aren't too many nodes, a brute force algo would be fine really. There's no "easy" way to solve this AFAIK.
 

Ameesh

Lifer
Apr 3, 2001
23,686
1
0
Originally posted by: Argo
Brute force method. Just compute all the possibilities and select the shortest. Until somebody comes with a better method I'm the winnah.

i beat you by 2 minutes woman! im the winnar!
 

MeanMeosh

Diamond Member
Apr 18, 2001
3,805
1
0
traveling salesman problem, optimize for minimum distance.

yay for operations research models!
 

jman19

Lifer
Nov 3, 2000
11,225
664
126
Originally posted by: bleeb
There are other more efficient methods than the Brute Force Method... You can try giving each node a weight and based on that come up with an algorithm... (don't remember the names off the top of my head)

If you remember the names of any of these post them here. Is there a way to try weights, and then based on some results, figure out how to properly readjust them to "move" towards the solution?