Press Ctrl+D to draw

Drawing Tools

Log in for saved annotations

1px

Table of Contents

No headings in this section

2.6  Problems

Problem 2.1  Uniform Cost Search vs. A* Heuristic Search

Goal: Implement Uniform Cost Search (UCS) and A* for pathfinding in the warehouse environment from problem 1.1, then compare their efficiency and optimality.

Tasks:

  1. Implement Uniform Cost Search (ucs_pathfinder.py):
    • Use a priority queue ordered by path cost \(g(n)\) (number of steps)
    • Track explored nodes and the frontier
    • Return the optimal path and search statistics: nodes expanded, path length, computation time
  2. Implement A* search (astar_pathfinder.py):
    • Use priority queue ordered by \(f(n) = g(n) + h(n)\)
    • Implement Manhattan distance heuristic: \(h(n) = |x_n - x_{goal}| + |y_n - y_{goal}|\)
    • Return the optimal path and search statistics
  3. Test both algorithms on the default warehouse layout:
    • Use the reset(randomize=True) method from warehouse_env.py to generate 10 random configurations
    • Each configuration has different start, pickup, and dropoff positions
    • For each configuration, run UCS and A* to find a path from start to pickup, then pickup to dropoff
  4. Compare results:
    • Verify both algorithms find paths of identical length (optimality)
    • Log: path length, nodes expanded, frontier size, time
    • Create visualizations:
      • Bar chart: mean nodes expanded across 10 trials
      • Table: summary statistics

Deliverables:

  • ucs_pathfinder.py: UCS implementation with statistics
  • astar_pathfinder.py: A* implementation with statistics
  • compare_search.py: script that runs both algorithms on 10 randomized warehouse configs and generates comparison plots/tables

Problem 2.2  Local Search: Warehouse Storage Rack Placement

Goal: Implement three local search algorithms (hill-climbing, simulated annealing, genetic algorithm) to optimize the placement of 20 storage racks in a 20ร—20 warehouse grid, balancing travel distance and congestion avoidance.

Objective function: \[f(s) = \underbrace{\frac{1}{20} \sum_{i=1}^{20} d(\text{depot}, (x_i, y_i))}_{\text{Average travel distance}} + \underbrace{\lambda \cdot |\{i : d(\text{depot}, (x_i, y_i)) < 5\}|}_{\text{Congestion penalty}}\]

where \(\lambda = 2.0\) is the congestion weight. Minimize \(f(s)\) to find the layout that trades off short travel distance against overcrowding near the depot.

Tasks:

  1. Define state representation (list of 20 unique \((x, y)\) positions on 20ร—20 grid, depot at \((10,10)\))
  2. Implement objective function: compute average Manhattan distance plus congestion penalty (count racks within distance 5 of depot, multiply by 2.0)
  3. Define neighborhood: move one rack by ยฑ1 in x or y (maintaining uniqueness)
  4. Implement local search algorithms:
    • Steepest-ascent hill-climbing
    • Simulated annealing with a cooling schedule
    • Genetic algorithm with selection, crossover, and mutation
  5. Write a script to compare the performance of the three algorithms for 20 random initial states each, plotting convergence curves and final layouts

Deliverables:

  • Convergence plots (objective vs. iteration) for each algorithm
  • Final rack layout grid visualization for best runs