Question: II . Hill Climbing Next, complete the solve ( ) method for the HillclimbingSolver class below. The hill - climbing search algorithm is the most
II Hill Climbing
Next, complete the solve method for the HillclimbingSolver class below.
The hillclimbing search algorithm is the most basic local search technique. At each step the current
node is replaced by the neighbor with the highest value. AIMA rd ed Chapter
function HILLCLIMBINGproblem returns a state that is a local maximum
current larr MAKENODE problemINITIALSTATE
loop do
neighbor larr a highestvalued successor of current
if neighbor.VALUE current.VALUE then return current.STATE
current larr neighbor
Pseudocode for the hill climbing function from the AIMA textbook. Note that our Problem class is already a "node",
so the MAKENODE line is not required.
In : class HillclimbingSolver:
Parameters
epochs : int
The upper limit on the number of rounds to perform hill climbing; the
algorithm terminates and returns the best observed result when this
iteration limit is exceeded.
definitself epochs:
self.epochs epochs
def solveself problem:
I Optimize the input problem by applying greedy hill climbing.
Parameters
problem : Problem
An initialized instance of an optimization problem. The Problem class
interface must implement a callable method "successors which returns
a iterable sequence ie a list or generator of the states in the
neighborhood of the current state, and a property "utility" which returns
a fitness score for the state. See the 'TravelingSalesmanProblem' class
for more details.
Returns
Problem
The resulting approximate solution state of the optimization problem
Notes
DO NOT include the MAKENODE line from the AIMA pseudocode
# TODO: Implement this function!
for in :
neihbor problem. successors
ifneihborsome problem. something:
raise NotImplementedError
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
