0% found this document useful (0 votes)
36 views6 pages

Kanishk Mishra-CS3346-Assignment 1

Uploaded by

lordimadais
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
36 views6 pages

Kanishk Mishra-CS3346-Assignment 1

Uploaded by

lordimadais
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Kanishk Mishra

251173609

CS3346: Assigment 1
1. A* Search

a. Shortest Path using Djikstra’s algorithm S → T. The red represents the lowest cost
path to reach each state, the blue represents other paths as a point of comparison.

S A B C D T
0 2 6 4 6 14

Shortest path using Djikstra’s algorithm S → C → B → T with the cost of 14.


b. A* search uses f(n) = g(n) + h(n), where g(n) is travelling cost and h(n) is heuristics.
The red represents the traveled paths, the blue represents viewed paths.

f(S→C) = 4 + 9 = 13 f(S→C) = 13 f(S→A→D) = 16 f(S→A→B) = 26


f(S→A) = 2 + 10 = 12 f(S→A→C) = 17 + 9 = 26 f(S→A→B) = 26 f(S→C→B) = 22
f(S→A→D) = 7 + 9 = 16 f(S→C→D) = 6 + 9 = 15 f(S→C→D→T) = 17
f(S→A→B) = 10 + 16 = 26 f(S→C→B) = 6 + 16 = 22 f(S→C→D→B) = 14 + 16= 30

Therefore, the shortest path with A* is S → C → D → T, where the distance cost g(n) is 17.

c. The results of (a) and (b) are different, specifically the difference is that (a) goes
through state B (S → C → B → T), while (b) goes through state D (S → C → D → T).
The reason for this is because h(B) has a substantially high value, while h(D) is tied
for the lowest h(s) value. Due to the h(B) value being so high it appeared easier to go
to T than to reach B, which resulted in the shorter path not being found. This is a
case of poor chosen heuristic values resulting in a suboptimal conclusion.
2. DFS, BFS, IDS

a. States: All possible combinations of the numbers in the 3x3, designated Xi


Actions: Swap number 9 with number Up/Down/Left/Right of it, in that order,
depending on the position of 9, some of those directions will not be possible.
Initial State: Table displayed above, designated X0
Goal Conditions: The sum of each of the rows / columns / diagonals is 15.
b. The state space is a graph, in the following questions repeated states will be pointed
to using a dotted line.
c. BFS Tree, dotted line used instead of copies of state:

d. DFS Tree, the action Up occurs first (when possible) it will cycle endlessly:

e. IDS Tree:
3. S = ((3,1), (3,6), (8,6), (6,5), (7,2), (7,0)), f(s) = 5 + 5 + 2.24 + 3.16 + 2 + 4.12 = 21.52

a. The sample solution above with the operator can generate 6*5 = 30 paths by
swapping any one of 6 points, with one of the other 5 points in the list.
b. Subsets by swapping (8, 6) in initial, f(s) is length of path.

f(s) = 5 + 7.21 + 5.1 + 3.16 + 4.12 + 7.07 = 31.66 f(s) = 5 + 5.66 + 3.16 + 2.24 + 6.08 + 4.12 = 26.26

f(s) = 5 +3.16 + 2.24 + 4.12 + 2 + 4.12 = 20.64 f(s) = 7.07 + 5 + 3.16 + 3.16 + 2 + 4.12 = 24.51

f(s) = 5 + 5 + 5 + 3.16 + 2 + 6.08 = 26.24


c. R is cost for crossing river at X=6.5, crossing river n times

Sl = ((3,1), (6,5), (3,6), (8,6), (7,2), (7,0)) Sr = ((3,1), (7,2), (6,5), (8,6), (3,6), (7,0))

f(Sl) = 5 + 3.16 + 5 + 4.12 + 2 + 4.12 = 23.4 f(Sr) = 5 + 2.24 + 3.16 + 4.12 + 4.12 + 7.21 = 25.85

n=2 n=6

Rl=? Rr=?

In the left image the route consists of the minimal number of crosses through the river, this
suggests that Rl is a positive value or a very small negative value that is not worth the extra travel to
collect. For this solution to work any single swap by the operator must have a higher or equal cost
than this, this can’t be the case as by swapping (6,5) and (3,6) we get the following:

This has a smaller travel path but an equal n so it should be better no matter what the value of Rl is.

In the right image n is maximized, every path crosses the river, so n must be a significant
negative value. Other variations of n=6 exist, but if we want to reduce length a smaller n value will
occur, the sample of this question is a good example of this. By swapping (3,6) and (7,2) we can turn
Sr into the sample S.

4n + 21.52 = 6n + 25.85

21.52 – 25.85 = 6n – 4n

-4.33 = 2n
-2.165 =n

This means that Rr must be less than -2.165 for Sr to be the solution.

You might also like