Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started