Answers.Body: <p>Russell and Norvig's book (3rd edition) describe these two algorithms (section 4.1.1., p. 122) and this book is the reference that you should generally use when studying search algorithms in artificial intelligence. I am familiar with simulated annealing (SA), given that I implemented it in the past to solve a combinatorial problem, but I am not very familiar with stochastic hill climbing (SHC), so let me quote the parts of the book that describe SHC.</p>
  <blockquote>
  <p><strong>Stochastic hill climbing</strong> chooses at random from among the uphill moves; the probability of selection can vary with the steepness of the uphill move. This usually converges more slowly than steepest ascent, but in some state landscapes, it finds better solutions.</p>
  </blockquote>
  <p>So, SHC chooses at random one &quot;uphill move&quot;, i.e. a move that improves the objective function (for example, if you're trying to solve the <a href="https://en.wikipedia.org/wiki/Travelling_salesman_problem" rel="noreferrer"><em>travelling salesman problem</em></a>, a &quot;uphill move&quot; could be any change to the current Hamiltonian cycle, a solution, so that the new Halmitonian cycle has a shorter cost) among the uphill moves (so among some set of moves that improve the objective).</p>
  <p>In <strong>simulated annealing</strong>, you perform some move. If that move leads to a better solution, you always keep the better solution. If it leads to a worse solution, you accept that worse solution with a certain probability. There are other details, such as how you accept the worse solution (which you can find in Russell and Norvig's book), but this should already clarify that SA is different from SHC: <strong>SA can accept worse solutions in order to escape from local minima, while SHC accepts only uphill moves.</strong></p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-11-23T22:45:23.510Z
Answers.Text: thank you very much, now it is clear to me, one thing left, since SHC chooses only random **uphill**  moves, does this algorithm avoid local optima?
Answers.UserDisplayName: yaminoyuki
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-11-24T10:10:00.510Z
Answers.Text: @yaminoyuki I think SHC can still get stuck in a local minimum. This should be due to the fact that SHC never takes a "downhill move". In any case, the book says that, in some "landscapes", SHC may find better solutions than the usual HC algorithm, and this may be true because SHC doesn't always choose the same uphill move and so has more stochasticity in it.
Answers.UserDisplayName: nbro
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-11-23T20:56:06.190Z
Answers.LastActivityDate: 2020-11-23T20:56:06.190Z
Answers.UserDisplayName: nbro
Body: <p>I am reading about local search: hill climbing, and its types, and simulated annealing</p>
  <p>One of the hill climbing versions is &quot;stochastic hill climbing&quot;, which has the following definition:</p>
  <blockquote>
  <p>Stochastic hill climbing does not examine for all its neighbor before moving. Rather, this search algorithm selects one neighbor node at random and decides whether to choose it as a current state or examine another state</p>
  </blockquote>
  <p>Some sources mentioned that it can be used to avoid local optima.</p>
  <p>Then I was reading about simulated annealing and its definition:</p>
  <blockquote>
  <p>At every iteration, a random move is chosen. If it improves the situation then the move is accepted, otherwise it is accepted with some probability less than 1</p>
  </blockquote>
  <p>So, what is the main difference between the two approaches? Does the stochastic choose only random (uphill) successor? If it chooses only (uphill-successors), then how does it avoid local optima?</p>
  
Tags: <comparison><simulated-annealing><meta-heuristics><local-search><stochastic-hill-climbing>
Title: What is the difference between Stochastic Hill Climbing and Simulated Annealing?
UserDisplayName: yaminoyuki
ThreadText: # What is the difference between Stochastic Hill Climbing and Simulated Annealing?
  
  (Asked by: username_0 on 2020-11-23)
  
  I am reading about local search: hill climbing, and its types, and simulated annealing
  
  One of the hill climbing versions is "stochastic hill climbing", which has the following definition:
  
  > Stochastic hill climbing does not examine for all its neighbor before moving. Rather, this search algorithm selects one neighbor node at random and decides whether to choose it as a current state or examine another state
  
  Some sources mentioned that it can be used to avoid local optima.
  
  Then I was reading about simulated annealing and its definition:
  
  > At every iteration, a random move is chosen. If it improves the situation then the move is accepted, otherwise it is accepted with some probability less than 1
  
  So, what is the main difference between the two approaches? Does the stochastic choose only random (uphill) successor? If it chooses only (uphill-successors), then how does it avoid local optima?
  
  **Tags:** comparison, simulated-annealing, meta-heuristics, local-search, stochastic-hill-climbing
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2020-11-23. Score: 5 | Accepted answer
  
  Russell and Norvig's book (3rd edition) describe these two algorithms (section 4.1.1., p. 122) and this book is the reference that you should generally use when studying search algorithms in artificial intelligence. I am familiar with simulated annealing (SA), given that I implemented it in the past to solve a combinatorial problem, but I am not very familiar with stochastic hill climbing (SHC), so let me quote the parts of the book that describe SHC.
  
  > **Stochastic hill climbing** chooses at random from among the uphill moves; the probability of selection can vary with the steepness of the uphill move. This usually converges more slowly than steepest ascent, but in some state landscapes, it finds better solutions.
  
  So, SHC chooses at random one "uphill move", i.e. a move that improves the objective function (for example, if you're trying to solve the [*travelling salesman problem*](https://en.wikipedia.org/wiki/Travelling_salesman_problem), a "uphill move" could be any change to the current Hamiltonian cycle, a solution, so that the new Halmitonian cycle has a shorter cost) among the uphill moves (so among some set of moves that improve the objective).
  
  In **simulated annealing**, you perform some move. If that move leads to a better solution, you always keep the better solution. If it leads to a worse solution, you accept that worse solution with a certain probability. There are other details, such as how you accept the worse solution (which you can find in Russell and Norvig's book), but this should already clarify that SA is different from SHC: **SA can accept worse solutions in order to escape from local minima, while SHC accepts only uphill moves.**
  
  > **Comments:**
  > **username_0**: thank you very much, now it is clear to me, one thing left, since SHC chooses only random **uphill**  moves, does this algorithm avoid local optima?  
  > **username_1**: @username_0 I think SHC can still get stuck in a local minimum. This should be due to the fact that SHC never takes a "downhill move". In any case, the book says that, in some "landscapes", SHC may find better solutions than the usual HC algorithm, and this may be true because SHC doesn't always choose the same uphill move and so has more stochasticity in it.  
  
  ---
  
  