fri i
play

FRI I Symbolic Reasoning and Search Instructor: Justin Hart - PowerPoint PPT Presentation

CS 309: Autonomous Robots FRI I Symbolic Reasoning and Search Instructor: Justin Hart http://justinhart.net/teaching/2020_spring_cs309/ AI as search Imagine a computer solving a maze There are many options for how to do this A


  1. CS 309: Autonomous Robots FRI I Symbolic Reasoning and Search Instructor: Justin Hart http://justinhart.net/teaching/2020_spring_cs309/

  2. AI as search • Imagine a computer solving a maze • There are many options for how to do this • A search algorithm will test each action an agent can take until it finds a solution

  3. AI as search • The agent is the orange dot • It is supposed to get to the green dot • Possible moves are up, down, left right • But here, left and right do not work • The search algorithm may try them, but they will fail • Up and down work

  4. Satisfying vs Optimizing • Satisficing solutions • Work, but are not known to be optimal • Optimal solutions • Are intended to be optimal

  5. Three introductory search patterns • Breadth-first • Depth-first • A*

  6. The “ready queue” • A “state” can be thought of as a configuration of the “world” or “problem” • The orange dot here represents the state of the agent occupying that cell • Let’s call this state 0 • When starting to solve the problem, the “start state” is placed into the ready queue • A “search algorithm” will take the “start state” out of the ready queue and “expand” it, placing the resulting states into the ready queue 0

  7. Breadth-first search (BFS) • Take a state out of the queue (FIFO.. We’ll come back to this) • Up - works • Down – works • Left – fails • Right – fails • Enter these into the ready queue 1 2 1 2

  8. Breadth-first search • Now take states out of the ready queue and expand them • You can ignore states that you’ve entered into before (if your algorithm can detect this) • Continue to do this until a solution is found • Breadth-first is FIFO 3 5 7 • First-In-First-Out 1 10 13 • It expands its search horizon at the breadth 2 16 meaning that each potential solution is 4 expanded at a “depth” (taking the same 6 8 11 9 1417 number of moves) until that layer is full. 12 1518 0 1 2 3 4

  9. Breadth-first search • BFS is “complete” • It will eventually explore the entire space • It is optimal in that the first solution found is guaranteed to take the fewest steps 3 5 7 1 10 13 2 16 4 6 8 11 9 1417 12 1518 0 1 2 3 4

  10. Depth-first search • FILO – First In - Last Out 0 1 2 1 3 1 4 1 5 6 1 1 5 7 • DFS may not find the optimal solution 2 3 • Generally requires less memory than 4 5 6 BFS 7 8 9 10 11 12 13 14

  11. A* search • BFS – queue (FIFO) • DFS – stack (FILO) • A* – priority queue (best-first) • What counts as “best”? 3 4 5 1 6 • Use heuristics to “score” states 7 • This maze uses Euclidean distance 2 8 20 9 19 10 11 12 18 13 14 15 17 • Depending on how you choose your 16 heuristic A* may be complete • ..but that’s for your AI class • Planning algorithms have come a long way, but build on these basic ideas

  12. Blocks World ● Planning equivalent of “Hello World” - > “Blocks World” ● Blocks arranged on a table with a robot gripper Gripper B A C Table

  13. Atoms ● Represent things we can reason about in the world – block_a, block_b, block_c – table_a – gripper_a Gripper B A C Table

  14. Predicates ● Modify and describe atoms – on_table(block_a), on_table(block_c) Gripper – stacked(block_b, block_a) B – clear(block_b), clear(block_c) A C Table – gripper_empty(gripper_a)

  15. Predicates ● Traditionally, predicates are used like types – block(block_a), block(block_b).. ● PDDL has types and type-checking – (:types block_a, block_b, block_c – block Gripper gripper_a – gripper table_a - table) B A C Table

  16. World States ● Predicates describe the state of the world – on_table(block_a), on_table(block_c) Gripper – stacked(block_b, block_a) B – clear(block_b), clear(block_c) A C – gripper_empty(gripper_a) Table

  17. World States ● A different world state uses different predicates – on_table(block_a), on_table(block_c) – stacked(block_b, block_c) Gripper – clear(block_b), B clear(block_a) – gripper_empty(gripper) A C Table

  18. Start States and Goal States ● Start state – Current state of the world, or the starting state of your plan ● Goal state – The state that you wish to reach Gripper B A C Table

  19. Start States and Goal States Gripper Gripper B B A C A C Table Table stacked(block_b, block_c) – on_table(block_a), on_table(block_c) – stacked(block_b, block_c) – While your start state must – clear(block_b), be complete, generally your clear(block_a) goal state can state only those predicates that you – gripper_empty(gripper) require to be true

  20. Actions ● Actions permute world state ● Actions have – A name Gripper – Parameters – Preconditions B – Effects A C Table

  21. Actions Gripper B • (:action grasp-block :parameters (?g – gripper ?b – block) A C :precondition (and (empty ?g) (clear ?b)) Table :effect (and (not (empty ?g)) (not (clear ?b)) (in_gripper ?b ?g) ) )

  22. Actions ● Preconditions tell us what must be true for us to be able to take an action ● Effects tell us how the action changes the world ● The ready queue is filled with possible permutations based on the effects of actions whose preconditions are satisfied – Can't go left – Can't go right – Can go up → resulting in the agent being 1 square up – Can go down → resulting in the agent being 1 square down

  23. Actions Can't grasp-block(gripper_a, block_a) ● – So this action isn't taken Can grasp-block(gripper_a, block_b) ● – Goes into ready queue Gripper Can grasp-block(gripper_a, block_c) ● – Goes into ready queue B A C Table

  24. Plans Gripper Gripper B B A C A C Table Table grasp-block(gripper_a, A plan takes the world from a start block_b) state to a goal state unstack-block(gripper_a, block_b, block_a) stack-block(gripper_a, block_b, block_c)

  25. 1_1 1_2 1_3 2_1 2_2 2_3 3_1 3_2 3_3

  26. 1_1 1_2 1_3 2_1 2_3 3_1 3_2 3_3

  27. Tower of Hanoi

  28. Tower of Hanoi

  29. Tower of Hanoi ● Rules – Generally three posts – However many disks – Goal: Get all of the disks on the same post, with the biggest disk on bottom and progressively smaller disks towards the top. – Main constraint: You can only stack a disk onto a smaller disk ● Okay! Let's write this!

Recommend


More recommend