4

Let's say we are given 7 cities A,B,C,D,E,F,G and we have a start state ABCDEFGA with some cost 'x' , I don't understand what the children of this node would be.Meaning how would the second iteration of the hill climbing algorithm proceed?

Would the node ABCDEFGA which is the start state have 6 children? As in would the

second iteration be ACBDEFGA, ADCBEFGA, AECDBFGA, AFCDEBGA, AGCDEFBA?

Third Iteration: Let's say ADCBEFGA is selected in the second iteration, then would the third iteration be exchanging city 'C' with all other cities and so forth?

I would just like to know if my understanding of the algorithm is right.

anonuser0428
  • 11,789
  • 22
  • 63
  • 86

1 Answers1

6

The Hill Climbing algorithm is great for finding local optima and works by changing a small part of the current state to get a better (in this case, shorter) path.

How you implement the small changes to find a better solution is up to you. Let's say you want to simply switch two nodes and only keep the result if it's better than your current solution.

Just swapping the second town with some other town gives you the following:

# first iteration
start: ABCDEFGA
next: ACBDEFGA, ADCBEFGA, AECDBFGA, AFCDEBGA, AGCDEFBA

# second iteration
start: ADCBEFGA
next: ACDBEFGA, ABCDEFGA, AECBDFGA, AFCBEDGA, AGCBEFDA

You would want to check the fitness of each of these possibilities and keep the best one. Then reiterate until none of the next possibilities are better than your current state. You'll want to continually use the same algorithm for each iteration.

You can switch the second city on the first iteration, the third on the second, the fourth on the third, etc. but make sure you loop back around and continue this style of swapping and don't stop when you reach the end. I would suggest sticking with one spot and swapping with some other spot but ultimately you're going to get different sub-optimal answers no matter how you tackle this.

Tyler Ferraro
  • 3,753
  • 1
  • 21
  • 28
  • But if we keep swapping the same spot wouldn't that lead to a lot of redundant states like in this case at the end of the second iteration in the 'next' line we have the start state repeated again. Is that permissible? – anonuser0428 Feb 20 '13 at 02:33
  • Yes, this will lead to redundant states but it will still be less fit than your current solution and therefore will never move backwards. But this algorithm is not an optimal algorithm for tackling the traveling salesman problem for this among other reasons. – Tyler Ferraro Feb 20 '13 at 02:35