Answers.Body: <p>As an example of local/global minima, imagine being on a rugged, mountainous landscape, and you want to find the lowest point within some area. For a greedy search, every step you take will take you downhill. If you go downhill long enough, you'll eventually find a flat spot, which is a minimum - from here, there's no step you can take that will get you any lower. However, there's a nearby ridge, which if you crossed it, you could continue downhill to find an even lower spot, the global minimum (the true lowest point). Using your greedy approach, you'll never go uphill to cross the ridge, so you'll be stuck in the local minimum forever. If you occasionally take random steps (other than directly downhill), you have the opportunity to cross ridges that separate local minima, and you have a better chance of finding the global minimum. You are correct that in many cases, the random step won't help you cross a ridge, and will just take you up a mountain in the wrong direction, which is a waste of time. But unless we allow the algorithm to "explore" a bit, it will be content that the first minimum it finds is the best one, and will never get to the bottom.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-05-31T15:05:55.600Z
Answers.LastActivityDate: 2019-05-31T15:05:55.600Z
Answers.UserDisplayName: Nuclear Hoagie
Answers.Body: <p>The greedy action is the action that maximises some quantity in the present or near future. A stochastic action is an action that is <a href="https://en.wikipedia.org/wiki/Randomness" rel="nofollow noreferrer">random</a> (it can be the greedy action or any other possible action).</p>
  
  <p>For example, suppose that you are hungry. You can either choose to eat pizza, salad, fruits or fish. Pizza is your favourite food. On the other hand, you don't like much salad, fruits and fish, but you know that they are healthier than pizza. If you choose to eat pizza, then this is a greedy action. What quantiy are you maximising if you choose pizza? Your current happiness. If you randomly pick one of those (either pizza, salad, fruits or fish), then this is a stochastic (or random) action. The stochastic action can also happen to be pizza, but, in the next day, it might not be pizza, and, in general, it will not always be pizza.</p>
  
  <p>Suppose that you always choose pizza. What's going to happen? In the long run, you will get fatter and your health will deteriorate. However, everytime you choose pizza, you will get happier in that moment (local maximum). If you randomly choose the food every time you want to eat, then it is more likely that you will eat also salad, fruits and fish. In the long run, this could be more beneficial for your health, hence this could avoid you getting trapped in the local maximum (being happy in the moment that you eat, but unhappier later in life because of the possible health problems).</p>
  
  <p>In the context of artificial intelligence, the ideas are the same. There are several algorithms that use stochastic actions in order to avoid getting trapped in local extrema. For example, <a href="https://pdfs.semanticscholar.org/e893/4a942f06ee91940ab57732953ec6a24b3f00.pdf" rel="nofollow noreferrer">simulated annealing</a>, <a href="https://ai.stackexchange.com/a/12545/2444">ant colony optimisation algorithms</a>, <a href="https://www.researchgate.net/publication/33784417_Learning_From_Delayed_Rewards" rel="nofollow noreferrer"><span class="math-container">$Q$</span>-learning</a> (using <span class="math-container">$\epsilon$</span>-greedy) or <a href="https://epubs.siam.org/doi/pdf/10.1137/1018105" rel="nofollow noreferrer">genetic algorithms</a>. An example of local search (or greedy) algorithm is <a href="https://www.cs.ubc.ca/~hutter/previous-earg/EmpAlgReadingGroup/TSP-JohMcg97.pdf" rel="nofollow noreferrer">2-opt</a> (for the TSP problem).</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-05-31T12:58:10.533Z
Answers.LastActivityDate: 2019-05-31T14:51:42.457Z
Answers.LastEditDate: 2019-05-31T14:51:42.457Z
Answers.UserDisplayName: nbro
Body: <p>I read that a mix of "greedy" and "random" are ideal for stochastic local search (SLS), but I'm not sure why. It mentioned that the greedy finds the local minima and the randomness avoids getting trapped by the minima. What is the minima and how can you get trapped? Also, how does randomness avoid this? It seems like if it's truly random there's always a chance of ending up searching solutions that lead to dead ends multiple times (which seems like a waste of processing and avoidable)?</p>
  
Tags: <optimization><search><problem-solving><local-search>
Title: Why is a mix of greedy and random usually "best" for stochastic local search?
UserDisplayName: Gooby
ThreadText: # Why is a mix of greedy and random usually "best" for stochastic local search?
  
  (Asked by: username_0 on 2019-05-31)
  
  I read that a mix of "greedy" and "random" are ideal for stochastic local search (SLS), but I'm not sure why. It mentioned that the greedy finds the local minima and the randomness avoids getting trapped by the minima. What is the minima and how can you get trapped? Also, how does randomness avoid this? It seems like if it's truly random there's always a chance of ending up searching solutions that lead to dead ends multiple times (which seems like a waste of processing and avoidable)?
  
  **Tags:** optimization, search, problem-solving, local-search
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2019-05-31. Score: 1
  
  As an example of local/global minima, imagine being on a rugged, mountainous landscape, and you want to find the lowest point within some area. For a greedy search, every step you take will take you downhill. If you go downhill long enough, you'll eventually find a flat spot, which is a minimum - from here, there's no step you can take that will get you any lower. However, there's a nearby ridge, which if you crossed it, you could continue downhill to find an even lower spot, the global minimum (the true lowest point). Using your greedy approach, you'll never go uphill to cross the ridge, so you'll be stuck in the local minimum forever. If you occasionally take random steps (other than directly downhill), you have the opportunity to cross ridges that separate local minima, and you have a better chance of finding the global minimum. You are correct that in many cases, the random step won't help you cross a ridge, and will just take you up a mountain in the wrong direction, which is a waste of time. But unless we allow the algorithm to "explore" a bit, it will be content that the first minimum it finds is the best one, and will never get to the bottom.
  
  
  ---
  
  ### Answer by username_2 on 2019-05-31. Score: 0
  
  The greedy action is the action that maximises some quantity in the present or near future. A stochastic action is an action that is [random](https://en.wikipedia.org/wiki/Randomness) (it can be the greedy action or any other possible action).
  
  For example, suppose that you are hungry. You can either choose to eat pizza, salad, fruits or fish. Pizza is your favourite food. On the other hand, you don't like much salad, fruits and fish, but you know that they are healthier than pizza. If you choose to eat pizza, then this is a greedy action. What quantiy are you maximising if you choose pizza? Your current happiness. If you randomly pick one of those (either pizza, salad, fruits or fish), then this is a stochastic (or random) action. The stochastic action can also happen to be pizza, but, in the next day, it might not be pizza, and, in general, it will not always be pizza.
  
  Suppose that you always choose pizza. What's going to happen? In the long run, you will get fatter and your health will deteriorate. However, everytime you choose pizza, you will get happier in that moment (local maximum). If you randomly choose the food every time you want to eat, then it is more likely that you will eat also salad, fruits and fish. In the long run, this could be more beneficial for your health, hence this could avoid you getting trapped in the local maximum (being happy in the moment that you eat, but unhappier later in life because of the possible health problems).
  
  In the context of artificial intelligence, the ideas are the same. There are several algorithms that use stochastic actions in order to avoid getting trapped in local extrema. For example, [simulated annealing](https://pdfs.semanticscholar.org/e893/4a942f06ee91940ab57732953ec6a24b3f00.pdf), [ant colony optimisation algorithms](https://ai.stackexchange.com/a/12545/2444), [$Q$-learning](https://www.researchgate.net/publication/33784417_Learning_From_Delayed_Rewards) (using $\epsilon$-greedy) or [genetic algorithms](https://epubs.siam.org/doi/pdf/10.1137/1018105). An example of local search (or greedy) algorithm is [2-opt](https://www.cs.ubc.ca/~hutter/previous-earg/EmpAlgReadingGroup/TSP-JohMcg97.pdf) (for the TSP problem).
  
  
  ---
  
  