11.12 Study the following search program and describe its search strategy: % search( Start, Path1 - Path2):
Question:
11.12 Study the following search program and describe its search strategy: % search( Start, Path1 - Path2): Find path from start node S to a goal node % Solution path is represented by two lists Path1 and Path2 search(S, P1 P2) :- similar length(P1, P2), goal(G), path2( G, P2, N), % Lists of approximately equal lengths path1(S, P1, N). path1(N, [N], N). path1(First, [First | Rest], Last) :- s(First, Second), path1(Second, Rest, Last). path2(N, [N], N). path2( First, [First | Rest], Last) :- s(Second, First), path2( Second, Rest, Last). similar_length( List1, List2) :- equal length( List2, List), (List1 = List; List] = [_ | List]). equal length([], []. equal length([X1 | L1], [X2 | L2]) :- equal length( L1, L2). % Lists of similar length. % Lists of equal length
Step by Step Answer:
Artificial Intelligence In Power System Optimization
ISBN: 9781578088058
1st Edition
Authors: Weerakorn Ongsakul, Vo Ngoc Dieu