Question
Can you please help with Python code for the below Part A: Hill Climbing 1. Implement the hill climbing algorithm according to the pseudo-code shown
Can you please help with Python code for the below
Part A: Hill Climbing
1. Implement the hill climbing algorithm according to the pseudo-code shown above. 2. From any current state [x, y], you may generate successor states by adding small increments to the x or y values. For example, [x + 0.01, y], [x 0.01, y], [x, y + 0.01], [x, y 0.01], etc. 3. When generating successor states, make sure that they are within the given lower bounds and upper bounds or the algorithm may deviate away from the region with the global optimum. 4. For now, you may leave the initial state at the default value of [0, 0]. We will change the initial state in Part B. Part B: Random Restart 1. Since it is unlikely that the basic hill-climbing algorithm is able to directly find the global optimum, we will next implement the random restart modification to the hill climbing algorithm. This modification works by calling the basic hill-climbing algorithm multiple times with different initial states. The end result among all initializations with the highest value (i.e. the highest peak) is returned. 2. You may experiment with different ways to generate the initial states as well as the number of restarts; then observe how the results change. Part C: Simulated Annealing 1. Finally, we will implement the simulated annealing algorithm according to the pseudocode shown above. The innermost loop of the simulated-annealing algorithm is quite similar to hill climbing. Instead of picking the best move, however, it picks a random move. If the move improves the situation, it is always accepted. Otherwise, the algorithm accepts the move with some probability less than 1. The probability decreases exponentially with the badness of the movethe amount E by which the evaluation is worsened. The probability also decreases as the temperature T goes down: bad moves are more likely to be allowed at the start when T is high, and they become more unlikely as T decreases. 2. The cooling schedule should be a function that decreases the temperature, T over time. Some simple examples are a linearly decreasing function (i.e. subtract 0.1 from T at each iteration) or an exponentially decreasing function (i.e. multiply T by 0.9 at each iteration). Note that if your cooling schedule does not decrease T to exactly 0, you may change the for loop given in the pseudocode above to be a finite number of iterations instead of an infinite number of iterations. 3. You may experiment with different parameters such as the initial temperature and the cooling schedule; then observe how the results change.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started