The hill climbing algorithm eliminates the problem of enumerative algorithms, it does not search all possible combinations of solutions, but it tries to search in the direction of best solution, according to the largest gradient. The princip of the algorithm can be compared to the behavior of tourists who got lost in the mountains and trying to get into the lowest part of the valley, because they know that there is a mountain chalet. The algorithm generates points in the neighborhood for current solution and in this neighborhood looks for the best solution, minimum or maximum. Then it gets into best solution and repeats the searching in the neighborhood of the new position. This process is repeated for a predetermined number of iterations. It is a gradient method without calculating the gradient.
Description of the hill climbing algorithm:
| 1. | At beggining it generates a random solution. |
| 2. | For current solution it generates all solutions in the neighborhood, and there it computes cost functions values. |
| 3. | It chooses new current solution from all solutions in the neighborhood, which has a lowest (highest) cost function value. |
| 4. | It continues with step 2 until the number of predefined iterations is reached. |
The basic weakness of hill climbing algorithm is the same as with other gradient methods, it is the risk of deadlock in a local extreme - the problem of cyclic solutions.
Parameters description:
| Parameter | Description | Recommended Value |
|---|---|---|
| Specimen | Model of solution | Depends on the cost function |
| Kind of neighbourhood | This indicates the way of generating neighbors | Cross or Randomly in square |
| Size of neighbourhood | Depends on the cost function constraints | Arround 10% of range |
| Step size | Depends on the cost function constraints | Smaller or equal to the size of neighbourhood |
| Max. number of neighbours | Applies only in the way of Randomly generating in square | Arround 10 |
| Number of iterations | Determines the number of algorithm steps | Depends on the cost function |