370 likes | 382 Vues
This class introduces planning and search concepts in artificial intelligence. Topics include classical planning, route planning, and applications of AI techniques. Techniques covered include state-space search, constraint satisfaction, and planning algorithms.
E N D
CSE P573Introduction to Artificial Intelligence Class 1 Planning & Search Henry Kautz Autumn 2004
Tonight • (6:40) What is artificial intelligence? • (7:00) Outline of course • (7:10) Planning • (7:20) State-space search • (7:40) Constraint satisfaction • (8:00) Exercise: creating & solving planning problems
Outline of Course • Topics • search & planning • game playing • logic & knowledge representation • natural language processing • probabilistic reasoning • robotics • rule learning • neural networks • reinforcement learning • local search & genetic algorithms • Textbook • Russell & Norvig, Artificial Intelligence, A Modern Approach, 2nd Ed • Skim before class; re-read afterward • Coursework • weekly assignments (80%) • take home final (20%) • Information • http://www.cs.washington.edu/education/courses/csep573/04au/
Planning • Input • Description of initial state of world • Description of goal state(s) • Description of available actions • Optional: Cost for each action • Output • Sequence of actions that converts the initial state into a goal state • May wish to minimizelength or cost of plan
Classical Planning • Atomic time • Deterministic actions • Complete knowledge • No numeric reward (just goals) • Only planner changes world
Route Planning • State = intersection • Operators = block between intersections • Operator cost = length of block
Blocks World • Control a robot arm that can pick up and stack blocks. • Arm can hold exactly one block • Blocks can either be on the table, or on top of exactly one other block • State = configuration of blocks • { (on-table G), (on B G), (clear B), (holding R) } • Operator = pick up or put down a block • (put-down R) put on table • (stack R B) put on another block
State Space • Planning = Finding (shortest) paths in state graph put-down(R) stack(R,B) pick-up(R) pick-up(G) stack(G,R)
STRIPS Representation • (define (domain prodigy-bw) • (:requirements :strips) • (:predicates • (on ?x ?y) • (on-table ?x) • (clear ?x) • (arm-empty) • (holding ?x))
Problem Instance • (define (problem bw-sussman) • (:domain prodigy-bw) • (:objects A B C) • (:init • (on-table a) (on-table b) (on c a) • (clear b) (clear c) (arm-empty)) • (:goal • (and (on a b) (on b c)))) goal may be a partial description
Operator Schemas • (:action stack • :parameters (?obj ?under_obj) • :precondition • (and (holding ?obj) (clear ?under_obj)) • :effect • (and (not (holding ?obj)) • (not (clear ?under_obj)) • (clear ?obj) • (arm-empty) • (on ?obj ?under_obj))) add effects – make true delete effects – make false
Planning Algorithms • Direct Space-State Search • Depth-First • Breadth-First • Best-First • A* • Constraint Satisfaction • Davis-Putnam Procedure
A General Search Algorithm • Search( Start, Goal_test, Criteria ) • Open = { Start }; Closed = { }; • repeat • if (empty(Open)) return fail; • select Node from Open using Criteria; • if (Goal_test(Node)) return Node; • for each Child of node do • if (Child not in Closed) • Open = Open U { Child }; • Closed = Closed U { Node }; Closed list optional
Breadth-First Search • Search( Start, Goal_test, Criteria ) • Open = { Start }; Closed = { }; • repeat • if (empty(Open)) return fail; • select Node from Open using Criteria; • if (Goal_test(Node)) return Node; • for each Child of node do • if (Child not in Closed) • Open = Open U { Child }; • Closed = Closed U { Node }; Criteria = shortest distance from Start
Depth-First Search • Search( Start, Goal_test, Criteria ) • Open = { Start }; Closed = { }; • repeat • if (empty(Open)) return fail; • select Node from Open using Criteria; • if (Goal_test(Node)) return Node; • for each Child of node do • if (Child not in Closed) • Open = Open U { Child }; • Closed = Closed U { Node }; Criteria = most recently visited (implies: greatest distance from Start)
Best-First Search • Search( Start, Goal_test, Criteria ) • Open = { Start }; Closed = { }; • repeat • if (empty(Open)) return fail; • select Node from Open using Criteria; • if (Goal_test(Node)) return Node; • for each Child of node do • if (Child not in Closed) • Open = Open U { Child }; • Closed = Closed U { Node }; Criteria = shortest estimated (heuristic) distance to goal
Best-First with Manhattan Distance ( x+ y) Heuristic 53nd St 52nd St G 51st St S 50th St 10th Ave 9th Ave 8th Ave 7th Ave 6th Ave 5th Ave 4th Ave 2nd Ave 3rd Ave
Non-Optimality of Best-First 53nd St 52nd St S G 51st St 50th St 10th Ave 9th Ave 8th Ave 7th Ave 6th Ave 5th Ave 4th Ave 2nd Ave 3rd Ave
Properties • Depth First • Simple implementation (stack) • Might not terminate • Might find non-optimal solution • Breadth First • Always terminates if solution exists • Finds optimal solutions • Visits many nodes • Best First • Always terminates if heuristic is “reasonable” • Visits many fewer nodes • May find non-optimal solution
A* • Criteria: minimize (distance from start) + (estimated distance to goal) • Implementation: priority queue • f(n) = g(n) + h(n) • f(n) = priority of a node • g(n) = true distance from start • h(n) = heuristic distance to goal
Optimality of A* • Suppose the estimated distance is alwaysless than or equal to the true distance to the goal • heuristic is a lower bound • heuristic is admissible • Then: when the goal is removed from the priority queue, we are guaranteed to have found a shortest path!
Planning Heuristics • General idea: solve an easier “relaxed” problem • Blocks World • Number of blocks out of place • Ignores complication of “trapped” blocks • General STRIPS Planning • Number of false goal propositions(not admissible) • Delete all preconditions from actions;solve easier relaxed problem;use length of solution(admissible)
Tonight • (6:40) What is artificial intelligence? • (7:00) Outline of course • (7:10) Planning • (7:20) State-space search • (7:40) Constraint satisfaction • (8:00) Exercise: creating & solving planning problems
Constraint Satisfaction • Find assignment(s) to a set of variables that satisfies (makes true) a set of constraints on those variables • Example: variables = real numbers • constraints = linear equations • x + 2y + z = 3 x – y + z = 0 -x - y – 2z = 7 • Satisfied byx=10, y=1, z=-9
Constraint Satisfaction • Find assignment(s) to a set of variables that satisfies (makes true) a set of constraints on those variables • Example: variable = true/false (Boolean) • constraints = propositional logic formulas • (x y) (x z) (y z) • Satisfied by{x=False, y=True, z=True} • {x=True, y=False, z=True} • {x=True, y=True, z=True}
Constraint Satisfaction • Find assignment(s) to a set of variables that satisfies (makes true) a set of constraints on those variables • Example: variable = true/false (Boolean) • constraints = propositional logic formulas • (x y) (x z) (y z) • Satisfied by{x=0, y=1, z=1} • {x=1, y=0, z=1} • {x=1, y=1, z=1}
Special Syntactic Forms • General propositional logic ((q r) s)) (s t) • Conjunction Normal Form (CNF) ( q r s ) ( s t) • Binary clauses: 2 literals per clause ( q r) ( s t) • Unit clauses: 1 literal per clause ( q) (s)
Planning as a Logical CSP • Choose a maximum time step K • Variables for each ground fact for each time step: (on R B 1) (on R B 2) (on R B 3) • Variables for each ground action for each time step: (pick-up R 1) (pick-up R 2) (pick-up R 3)
Initial & Goal State Formulas • Assert initial state hold at time 1 • Variables for each ground fact for each time step: (on R B 1) (on B G 1) (on-table G 1) (hand-empty) (clear R 1) • Assert goals hold at time K (e.g. 5) (on R G 5)
Action Formulas • For each time step: If an action occurs, its preconditions hold (pickup R 3) (on-table R 3) (pickup R 3) (hand-empty 3) • For each time step after the first:If a fact holds, it was either just added by an action or maintained from the previous state (on R G 3) [ (stack R G 2) (maintain (on R G) 2) ] • The precondition of maintain is that fact: (maintain (on R G) 3) (on R G 2) (maintain (on-table R) 3) (on-table R 2)
Mutual Exclusion Formulas • Actions and maintains whose preconditions or effects conflict cannot happen at the same time (pickup R 3) (pickup G 3) (pickup R 3) (pickup B 3) (pickup R 3) (maintain (hand-empty) 3) (pickup R 3) (maintain (on-table R) 3) • That’s it! • The TRUE action variables in a satisfying solution are a plan! • SATPLAN – Winner of 2004 AI Planning System Competition
Solving SAT: Davis-Putnam DPLL( wff ): for each unit clause (P) [resp. (P)] set P to true [resp. to false] simplify other clauses if empty clause thenreturn false if no clause left thenreturn solution choose a unassigned variable Q if DPLL( wff U {(Q)} ) return solution elsereturn DPLL( wff U {(Q)} ) • Backtrack search over partial variable assignments • Worst case O(2n)
In-Class Exercise • Form groups of 3 • Open a browser on • http://www.cs.washington.edu/education/courses/csep573 • Follow: Lectures & Assignments, Shakey Domain • Launch x-windows and ssh • Login to attu • Launch: xterm& xterm& • In one xterm: cd /cse/courses/csep573/04au/planning/blocks blackbox -o domain.pddl –f bw-sussman.pddl • (8:30) SHARE representation • (8:50) SHARE solutions