1 AI Week 6 Implementing your own AI Planner in Prolog part II HEURISTICS
Lee McCluskey room 2/09
2 Last Week Building your own forward searching planner IN PROLOG Each node is modelled as a state sequence of operators that lead to the state heuristic value INITIAL STATE A search algorithm is COMPLETE if it can always find a solution if there is one A search algorithm is OPTIMAL if it always finds the shortest (minimal cost) solution 3 RECAP Planning Algorithm in Prolog breadth-first forward search through state-space
1. Store the first node (initial state empty solution)
2. pick a node(StateSoln)
3. pick an operator and parameter grounding - O - that can be applied to State
4. apply O to State to get State
5. assert(node(State SolnO))
6. if possible backtrack to 3. and make a different choice.
until a node has been asserted that contains a solution
4 Heuristic Search - Definitions
Optimal if a solution is found it is best solution (that is it minimises some metric such as length of solution or amount of resource consumed)
Complete - guaranteed to find a solution if there is one
Efficiency amount of time / space required to find a solution
5 Heuristic Search - Definitions
BEST - FIRST search repeat the following ..
collect the set of un-expanded (ie OPEN) nodes
-- pick a node from the set to expand if a heuristic function gives it the best value
-- mark it as closed and expand it giving new open nodes to the set
6 Heuristic Search - Definitions
Variation GREEDY search
pick a node to expand if it appears to be nearest the goal
That is pick a node which appears to have the minimum distance between the node and a goal node
GREEDY search takes no account of the effort spent in getting to that node in the first place! Hence Greedy.
7 Heuristics - Definitions
NON-GREEDY variation of best-first search
factor in the cost of getting to the current state..
Let a heuristic value of node n be given by
COST(n) g(n) h(n)
g(n) is the ACTUAL COST of the path to the current node
h(n) is the ESTIMATED COST of reaching the goal from n
8 Heuristics - Example
Breadth First Search
As carried out by the planner in last weeks practical is best-first in the sense that
COST(n) g(n) h(n)
g(n) Count of action applications is the COST of the path to get to node n
This makes Breadth First Search OPTIMAL and COMPLETE but often hopelessly inefficient.
9 Admissable Heuistics
An ADMISSIBLE heuristic evaluation function is one that supplies an estimate of the cost to reach a goal state from current state and the goal
and never overestimates that cost.
Example Goal - get from current position P to a Goal position G by the road network.
an ADMISSIBLE estimated cost is the straight line distance between P and G
10 The FAMOUS A Property
An A search algorithm is one that expands a node with the lowest cost where
COST(n) g(n) h(n)
g(n) is the ACTUAL COST of the path to the current node (usually number of operators/actions required or amount of resources)
h(n) is an ADMISSIBLE estimated cost of reaching the goal from n
A algorithms are OPTIMAL and COMPLETE
11 Adding Heuristics to Prolog Code
Heuristic 1 Prune the tree dont visit/expand the same state twice
eg 5. IF State NOT EXPANDED BEFORE
THEN assert(node(State SolnO))
ve In some domains cuts down search considerably.
Does not affect completeness of search.
Does not affect optimality in a breadth first search
- ve overhead in storing and searching through all previous states.
Might not find ALL solutions
See website for an implementation of this ( dont expand a node(SSoln1) if a state with node(SSoln2) is already in the open nodes)
12 Adding Heuristics to Prolog Code
Heuristic 2 greedy search
COST estimated effort to reach a solution from the current state eg number of goals still to be achieved
5. assert(node(State SolnO COST)
2. pick a node(StateSoln COST)
---- WHERE COST HAS THE LOWEST VALUE (ignoring the cost/size of Soln)
eg Evaluate the nodes BEFORE ASSERTING them and store them with the cost attached
13 Heuristic 2 -Example ABCD solved 1 AB solved 3 AB solved 3 INITIAL STATE Goalset of subgoals ABCDE E solved 4 CD solved 3 ABC solved 2 GREADY SEARCH PICK THIS NODE TO EXPAND CD solved 3 Greedy Scores in Red 14 Adding Heuristics to the Planner
recall node n (state ops) COST(n)g(n)h(n)
Heuristic 3 COST(n) how many ops it took to get there (g(n) length of ops) and h(n) 0
minimise cost(n) Breadth first search.
Is h(n) admissible Is this A
Heuristic 4 COST(n) how many ops it took to get there (g(n) length of ops) h(n) how many subgoals still to solve.
-ve crude - may work in some domains but not in others
ve negligible overhead
Is h(n) admissible Is this A
15 Heuristic 4 -Example ABCD solved 13 AB solved 33 AB solved 33 INITIAL STATE Goal condition ABCDE E solved 42 CD solved 32 ABC solved 21 PICK THIS NODE TO EXPAND CD solved 31 Greedy Scores in Red 16 Adding Heuristics the PlanGraph
Heuristic 5 Relax the problem take away some of the constraints
To calculate the cost of a node n (state ops)
Calculate solution plan from state ignoring delete lists (ie ignoring undoing effects and interference) of planning operators. Let h(n) length of shortest relaxed plan
So COST(n) length ops h(n)
This is admissible as it is always an underestimation of the distance to goal - it never over estimates.
17 Other improvements to Planner..
See website another world planner
the WEB SERVICE COMPOSITION world (simulates a web agent that needs to plan to achieve goals)
Improvement I have added the ability to put EVALUABLE predicates in states eg maths operators assigment
It is easy to add Heuristics to the Breadth first state space planner to make it Best first
Relaxed problem solving can provide a very good admissible measure of h(n)
PowerShow.com is a leading presentation/slideshow sharing website. Whether your application is business, how-to, education, medicine, school, church, sales, marketing, online training or just for fun, PowerShow.com is a great resource. And, best of all, most of its cool features are free and easy to use.
You can use PowerShow.com to find and download example online PowerPoint ppt presentations on just about any topic you can imagine so you can learn how to improve your own slides and presentations for free. Or use it to find and download high-quality how-to PowerPoint ppt presentations with illustrated or animated slides that will teach you how to do something new, also for free. Or use it to upload your own PowerPoint slides so you can share them with your teachers, class, students, bosses, employees, customers, potential investors or the world. Or use it to create really cool photo slideshows - with 2D and 3D transitions, animation, and your choice of music - that you can share with your Facebook friends or Google+ circles. That's all free as well!
For a small fee you can get the industry's best online privacy or publicly promote your presentations and slide shows with top rankings. But aside from that it's free. We'll even convert your presentations and slide shows into the universal Flash format with all their original multimedia glory, including animation, 2D and 3D transition effects, embedded music or other audio, or even video embedded in slides. All for free. Most of the presentations and slideshows on PowerShow.com are free to view, many are even free to download. (You can choose whether to allow people to download your original PowerPoint presentations and photo slideshows for a fee or free or not at all.) Check out PowerShow.com today - for FREE. There is truly something for everyone!