Program 4
Implement AO* Search algorithm
Working of AO* algorithm:
The evaluation function in AO* looks like this:
f(n) = g(n) + h(n)
f(n) = Actual cost + Estimated cost
here, f(n) = The actual cost of traversal. g(n) = the cost from the initial node to the
current node. h(n) = estimated cost from the current node to the goal state.
Real-Life Applications of AO* algorithm:
Vehicle Routing Problem:
The vehicle routing problem is determining the shortest routes for a fleet of vehicles
to visit a set of customers and return to the depot, while minimizing the total distance
traveled and the total time taken. The AO* algorithm can be used to find the optimal
routes that satisfy both objectives.
Portfolio Optimization:
Portfolio optimization is choosing a set of investments that maximize returns while
minimizing risks. The AO* algorithm can be used to find the optimal portfolio that
satisfies both objectives, such as maximizing the expected return and minimizing the
standard deviation.
Program
Program 5
Solve 8-Queens Problem with suitable assumptions
Program 6
Implementation of TSP using heuristic approach
Algorithm for Traveling Salesman Problem
Before starting the algorithm, let’s get acquainted with some terminologies:
A graph G=(V, E), which is a set of vertices and edges.
V is the set of vertices.
E is the set of edges.
Vertices are connected through edges.
Dist(i,j) denotes the non-negative distance between two vertices, i and j.
Let’s assume S is the subset of cities and belongs to {1, 2, 3, …, n} where 1, 2, 3…n are the cities
and i, j are two cities in that subset. Now cost(i, S, j) is defined in such a way as the length of the
shortest path visiting node in S, which is exactly once having the starting and ending point as i and j
respectively.
For example, cost (1, {2, 3, 4}, 1) denotes the length of the shortest path where:
Starting city is 1
Cities 2, 3, and 4 are visited only once
The ending point is 1
The dynamic programming algorithm would be:
When |S| > 1, we define cost(i, S, 1) = ∝ where i !=1 . Because initially, we do not know the exact
Set cost(i, , i) = 0, which means we start and end at i, and the cost is 0.
cost to reach city i to city 1 through other cities.
Now, we need to start at 1 and complete the tour. We need to select the next city in such a way-
Cost (i, S, j)=min cost (i, S−{i}, j)+dist (i,j) where i∈S and i≠j