Question: This assignment asks you to apply the A search algorithm to the processing of propositional Prolog knowledge bases such as q: - a . q:
This assignment asks you to apply the A
search algorithm to the processing
of propositional Prolog knowledge bases such as
q: a
q: bc
a: de
a: cef
b: c
c: ef
e
f: e
which we can represent as the list
qaqbcadeacefbccefefe
and use as KB in the clauses
arcHTNode,Cost,KB : memberHBKB appendBTNode
lengthBL Cost is LL
heuristicNodeH : lengthNodeH
goal
Your task is to define a predicate
astarNode,?Path,?Cost,KB
that implements A
returning a path from Node to the goal node with
minimal cost, given KB Test your code with queries such as
astarqPath,Cost,
qaqbcadeacefbccefefe
Cost
Path qac e fe f e ff e fe e f
e ffe ;
Cost
Path qb cc ce f cf ce cc
e ffe ;
false
astarqPath,Cost,qaqbcabc
Cost
Path qa ;
Cost
Path qb cc ;
false
Hint Modify the skeletal search algorithm
searchNode : goalNode
searchNodeMore : findallXarcNodeXChildren
addfrontierChildrenMore,New
searchNew
so that the head of the list New obtained in addfrontier has fvalue no
larger than any in News tail, where
fnode costnode hnode
Let the frontier be a list of pathcost pairs instead of just nodes being
careful to update path costs, and to bring in the heuristic function in forming
the frontier New.
lessthanNodeCostNodeCost :
heuristicNodeHvalue heuristicNodeHvalue
F is CostHvalue F is CostHvalue
F F
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
