In this lab exercise, you’ll work with the AIMA Python implementations of local search algorithms.
In local search, we’d like to find the maximum value for a given objective function. Consider the two functions shown here. There’s no particular magic in either of them; they simply generate a set of objective values in two dimensions (only) that are all positive and display interesting global and local maxima:
$$f(x) = {maximum \over 2} - abs( {maximum \over 2} - x )$$ |
$$f(x) = abs(x * sin(x))$$ |
![]() |
![]() |
These plots were created with Matplotlib by graphs.py
.
Local search algorithms work with complete-state formulations.
Run abs.py
, an absolute value variant module and answer the
following questions:
exp_schedule()
method in the simulated annealing function call?
Save the answers to these questions in a text file,
lab.txt
, so that you can submit them later.
That objective function wasn’t that interesting. Let’s try a slightly more interesting one, still in two dimensions.
Create a new module (sine.py
), similar to the absolute value
variant from
exercise 2.1, that uses the sine function variant specified above as
its objective function. Get your new implementation running and then
answer the following (similar) questions:
delta
)
affect the operation of the two algorithms? Why or why not?
Add the answers to these questions to lab.txt
.
Because local search algorithms can hit local minima, it is useful to run them more than once or to run them in parallel.
Add code to your sine implementation (sine.py
) that
implements random restarts.
Add the answers to these questions to lab.txt
.
One key advantage of local search is the reduced memory requirements. This can be leveraged to allow more than one state to be maintained in parallel.
Consider the use of local beam search in which the successor states are chosen using one of the two algorithms as applied to the abs-sin function.
Add the answers to these questions to lab.txt
.
You are not required to implement this.
In local beam search, successor states are generally chosen using simple hill-climbing.
Submit your code under the directory lab02
. We will grade your
work according to the following criteria:
See the policies page for lab due-dates and times.