Download presentation

Presentation is loading. Please wait.

Published byRandolph Scott Modified over 2 years ago

1
AI – Week 5 Implementing your own AI Planner in Prolog – part II : HEURISTICS Lee McCluskey, room 2/09 Email lee@hud.ac.uklee@hud.ac.uk http://scom.hud.ac.uk/scomtlm/cha2555/

2
Artform Research Group Last Week: Building your own forward searching planner IN PROLOG INITIAL STATE Each node is modelled as a “state” + sequence of operators that lead to the state + heuristic value 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
Artform Research Group RECAP: Planning Algorithm in Prolog: breadth-first forward search through state-space: 1. Store the first node (initial state + empty solution) Repeat 2. pick a node(State,Soln) 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', Soln++[O])) 6. if possible, backtrack to 3. and make a different choice. until a node has been asserted that contains a solution

4
Artform Research Group 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
Artform Research Group 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
Artform Research Group 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
Artform Research Group 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) where 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
Artform Research Group 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) where g(n) = Count of action applications is the COST of the path to get to node n h(n) = 0 This makes Breadth First Search OPTIMAL and COMPLETE but often hopelessly inefficient.

9
Artform Research Group 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
Artform Research Group The FAMOUS A* Property An A* search algorithm is one that expands a node with the lowest cost, where 1. COST(n) = g(n) + h(n) 2. g(n) is the ACTUAL COST of the path to the current node (usually number of operators/actions required, or amount of resources) 3. h(n) is an ADMISSIBLE estimated cost of reaching the goal from n A* algorithms are OPTIMAL and COMPLETE

11
Artform Research Group Adding Heuristics to Prolog Code Heuristic 1: Prune the tree: don't visit/expand the same state twice: eg 5. IF State' NOT EXPANDED BEFORE THEN assert(node(State', Soln++[O])) +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 (= don’t expand a node(S,Soln1) if a state with node(S,Soln2) is already in the open nodes…)

12
Artform Research Group 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', Soln++[O], COST) 2. pick a node(State,Soln, 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
Artform Research Group Heuristic 2 -Example INITIAL STATE Goal=set of subgoals: A&B&C&D&E A&B&C&D solved A&B solved A&B&C solved C&D solved A&B solved E solved C&D solved 1 3 3 4 3 2 3 GREADY SEARCH: PICK THIS NODE TO EXPAND Greedy Scores in Red

14
Artform Research Group 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
Artform Research Group Heuristic 4 -Example INITIAL STATE Goal condition: A&B&C&D&E A&B&C&D solved A&B solved A&B&C solved C&D solved A&B solved E solved C&D solved 1+3 3+3 4+2 3+2 2+1 3+1 PICK THIS NODE TO EXPAND Greedy Scores in Red

16
Artform Research Group 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
Artform Research Group 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

18
Artform Research Group Summary 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)

Similar presentations

OK

Review: Tree search Initialize the frontier using the starting state While the frontier is not empty – Choose a frontier node to expand according to search.

Review: Tree search Initialize the frontier using the starting state While the frontier is not empty – Choose a frontier node to expand according to search.

© 2017 SlidePlayer.com Inc.

All rights reserved.

Ads by Google

Ppt on sources of water for kindergarten Ppt on council of ministers cyprus Best ppt on right to information act Ppt on ac and dc servo motor Ppt on product advertising letter Ppt on going places by a.r.barton Ppt on mars one program Ppt on eia report environmental impacts By appt only movie main Ppt on limits and derivatives examples