COMP424 Assignment 1 Solved

35.00 $

Category:

Description

Rate this product
  1. Question 1: Six-Puzzle [

    Write code in a language of your choice to solve this problem. Hand in the source code with your submission, making clear that the file(s) is/are for Question 1.

    Consider a variant of the eight-puzzle, which we saw in class, where we reduce the size of the puzzle to 3×2, in order to keep the number of states manageable. Now, consider the following initial and goal states:

    Initial state: Goal state:

    142 12 53 543

    1. a)  Show the solution path (i.e., the sequence of puzzle states from the initial to the goal state) found by each of the following algorithms, assuming transitions have unit cost. You must ensure that puzzle states that have been explored are not added to the search queue. Given multiple states to explore that are otherwise equivalent in priority, the algorithm should prefer the state that involves moving a lower-numbered piece.
      1. Breadth first search
      2. Uniform cost search
      3. Depth first search
      4. Iterative deepening
    2. b)  Suppose now that transitions have differing costs. In particular, the cost of a transition is equal to the number of the piece that is moved (e.g., moving the “4” costs 4). If we employ the Manhattan distance heuristic for the original unit cost version of the eight-puzzle presented in class (Lecture 4, slide 11, h2), would this heuristic still be an admissible heuristic for A* search in the new variant? Justify your answer.
    3. c)  Design an admissible heuristic that dominates the heuristic from part b, under the same transition cost scheme as part b.

Question 2: Search algorithms

(Adapted from Russell & Norvig)
a) Describe a state space in which iterative deepening search performs much worse than depth-first search (for

example, 𝑂(𝑛2) vs 𝑂(𝑛)).

Prove each of the following statements, or give a counterexample:

  1. b)  Breadth-first search is a special case of uniform-cost search.
  2. c)  Uniform-cost search is a special case of A* search.
  3. d)  Best-first search is optimal in the case where we have a perfect heuristic (i.e., h(𝑛) = h∗(𝑛), the true cost to

    the closest goal state).

  4. e)  Suppose there is a unique optimal solution. Then, A* search with a perfect heuristic will never expand nodes

    that are not in the path of the optimal solution.

Question 3: Travelling Salesman Problem

Write code in a language of your choice to solve this problem. Hand in the source code with your submission, making clear that the file is/are for Question 3. If you think it will be easier, you are welcome to use external code and libraries with citation, as long as they do not come from current or past students in COMP 424, but please implement your own greedy local search method.

Consider the travelling salesman problem, as described in class. For parts a) – c), write code to generate 100 random TSP instances involving 7 cities, where cities lie at points in the 2D plane ([0.0,1.0], [0.0,1.0]), sampled uniformly at random. Your code should be correct but will not be marked for style. Use Euclidean distance as your distance measure between cities.

  1. a)  Solve each TSP exactly by brute-force search over all possible tours. Record and save these costs. In your report, simply state where in your code this is implemented, and state the mean, min, max, and standard deviation of the optimal tour lengths across the 100 instances.
  2. b)  As a baseline, generate a random tour for each of the 100 instances. What is the mean, min, max, and standard deviation of the tour lengths found? Report the number of instances for which the random tour happens to be the optimal solution (may be zero).
  3. c)  Implement and apply hill climbing/greedy local search using the 2-change neighbourhood function described in class on the 100 instances, using the randomly sampled start state from part b). What is the mean, min, max, and standard deviation of the tour lengths found? Also report the number of instances for which the algorithm found the optimal solution.
  4. d)  Scale up your experiments! Repeat parts b) and c) using 100 random TSP instances involving 100 cities. Since the number of possible tours is factorial with respect to the number of cities, it may no longer be feasible to compute the costs of the optimal solutions in a reasonable amount of time, so simply omit that part of the table.

(If you have extra time, you can find libraries to help you plot and visualize the solutions found by your algorithms, but this is not necessary for the submission.)

  • A1-COMP-424-main-g8jiun.zip