Problem Solving As State Space Search Assignments Agent Building
Total Page:16
File Type:pdf, Size:1020Kb
Problem Solving Assignments as State Space Search • Remember: Problem Set #1: Simple Scheme and Search Out today, due Session 4. • Reading: Brian C.Williams – Solving problems by searching: AIMA Ch. 3 16.410-13 Session 3 Slides adapted from: 6.034 Tomas Lozano Perez, Russell and Norvig AIMA Brian Williams, Fall 05 1 Brian Williams, Fall 05 2 Course Objective 1: Course Objective 1: Agent Architectures Agent Architectures Communicate and Interpret To understand the major types of agents and common architectures used to develop agents. Plan Map Locate in – Mission-oriented Agents World – Self-repairing Agents Monitor & Execute Plan Routes – Mobile Agents Diagnosis – Agile Agents – Communicating Agents Maneuver and Track Brian Williams, Fall 05 3 Brian Williams, Fall 05 4 Course Objective 2: Principles of Agents Agent Building Blocks 16.410/13: To learn the modeling and • Activity Planning • Path Planning algorithmic building blocks for creating • Execution/Monitoring • Localization reasoning and learning agents: • Diagnosis • Map Building 1. To formulate reasoning problems in an • Repair • Trajectory Design appropriate formal representation. • Scheduling • Policy Construction 2. To describe, analyze and demonstrate the • Resource Allocation application of reasoning algorithms to �Most reasoning problems, like these, may be formulated solve these problem formulations. as state space search. Brian Williams, Fall 05 5 Brian Williams, Fall 05 6 1 Course Objective 3: Implementing Agents 16.413: To appreciate the challenges of building a state of the art autonomous explorer: Complex missions must carefully: Fall 03: • Plan complex sequences of actions • Mars Exploration Rover shadow mode demonstration. • Schedule actions Fall 04: • Allocate tight resources • Gnu Robot competition. Fall 05: • Monitor and diagnose behavior • Model-based autonomy toolbox • Repair or reconfigure hardware. • The virtual solar system • Stay tuned for more. �Most AI problems, like these, may be formulated as Brian Williams, Fall 05 7 state space search. Brian Williams, Fall 05 8 Courtesy of Kanna Rajan, NASA Ames. Used with permission. Astronaut Goose Outline Grain Fox • Problem Formulation Rover – Problem solving as state space search • Mathematical Model • Astronaut + 1 item allowed in the rover. – Graphs and search trees Can the astronaut get its supplies • Goose alone eats Grain • Reasoning Algorithms safely across the Martian canal? • Fox alone eats Goose – Depth and breadth-first search Early AI: What are the universal problem solving methods? Simple Trivial Brian Williams, Fall 05 9 Brian Williams, Fall 05 10 Courtesy of NASA. Goose Problem Solving as Grain State Space Search Astronaut • Formulate Goal Fox – State • Astronaut, Fox, Goose & Grain across river Astronaut • Formulate Problem Goose Grain Grain Fox – States Fox • Location of Astronaut, Fox, Goose & Grain Astronaut at top or bottom river bank Astronaut Goose Goose – Operators Grain • Astronaut drives rover and 1 or 0 items Fox to other bank. Goose • Generate Solution Grain Goose Fox – Sequence of Operators (or States) Fox • Move(goose,astronaut), Move(astronaut), . Astronaut Astronaut Brian Williams, Fall 05 11 Grain Brian Williams, Fall 05 12 2 Astronaut Astronaut Goose Grain Goose Astronaut Astronaut Goose Grain Goose Astronaut Astronaut Grain Grain Fox Grain Grain Fox Astronaut Astronaut Goose Goose Astronaut Astronaut Goose Goose Fox Goose Fox Grain Grain Fox Goose Fox Grain Grain Fox Fox Fox Fox Astronaut Astronaut Astronaut Astronaut Astronaut Astronaut Goose Grain Grain Goose Goose Goose Grain Grain Goose Goose Grain Fox Fox Grain Fox Fox Fox Fox Astronaut Astronaut Astronaut Astronaut Goose Goose Astronaut Grain Goose Goose Goose Astronaut Grain Goose Fox Fox Grain Fox Fox Grain Grain Fox Grain Fox Astronaut Astronaut Goose Goose Goose Fox Goose Astronaut Goose Fox Goose Astronaut Grain Fox Grain Fox Fox Fox Grain Fox Fox Grain Astronaut Astronaut Astronaut Goose Astronaut Astronaut Astronaut Goose Grain GooseBrian Williams, FallGrain 05 Fox 13 Grain GooseBrian Williams, FallGrain 05 Fox 14 Grain Grain Formulation Example: 8-Puzzle Example: Planning Discrete Actions 5 4 1 2 3 • Swaggert & Lovell work on Apollo 13 emergency rig 6 1 8 8 4 lithium hydroxide unit. – Assembly 7 3 2 7 6 5 • Mattingly works in ground simulator to identify new sequence handling severe Start Goal power limitations. • States: integer location for each tile AND … – Planning & Resource Allocation • Mattingly identifies novel • Operators: move empty square up, down, left, right reconfiguration, exploiting • Goal Test: goal state as given LEM batteries for power. courtesy of NASA – Reconfiguration and Repair Brian Williams, Fall 05 15 Brian Williams, Fall 05 16 Courtesy of Kanna Rajan, NASA Ames. Used with permission. Planning as State Space Search: STRIPS Action Assumptions STRIPS Operator Representation precondition: (and (clear hose) Initial state: (on-table hose) Available actions Strips operators (empty arm)) (and (hose a) (clamp b) • Atomic time. (hydroxide-unit c) precondition: (and (clear hose) (on-table a) (on-table hose) pickup hose (on-table b) (empty arm)) Note: strips doesn’t • Agent is omniscient (on-table c) allow derived effects; effect : (and (not (clear hose)) (clear a) you must be complete! (no sensing necessary). (not (on -table hose)) (clear b) pickup hose (not (empty arm)) (clear c) • Agent is sole cause of change. (holding arm hose))) (empty arm)) effect : (and (not (clear hose)) (not (on -table hose)) • Actions have deterministic effects. goal (partial state): (not (empty arm)) (and (connected a b) (holding arm hose)))} (attached b a))) • No indirect effects. � Effects specify how to A Plan is an operator sequence change the set of assertions. from the initial state to the goal. Brian Williams, Fall 05 17 Brian Williams, Fall 05 18 3 Succinct Encodings: STRIPS Action Schemata • Instead of defining: Outline pickup-hose and pickup-clamp and … • Problem Formulation • Define a single pickup schema (with variables ?v): – Problem solving as state space search (:operator pick-up :parameters ((hose ?ob1)) • Mathematical Model :precondition (and (clear ?ob1) – Graphs and search trees (on-table ?ob1) (empty arm)) • Reasoning Algorithms :effect (and (not (clear ?ob1)) – Depth and breadth-first search (not (on-table ?ob1)) (not (empty arm)) (holding arm ?ob1))) Brian Williams, Fall 05 19 Brian Williams, Fall 05 20 Problem Formulation: A Graph Problem Formulation: A Graph Operator State Edge Vertex In Degree (2) Degree (1) b b Out Degree (1) e Tail Vertex of Edge d Head Vertex of Edge neighbors (adjacent) Undirected Undirected Directed Incident to edge Directed Graph Graph Graph Graph (one-way streets) (two-way streets) (one-way streets) (two -way streets) Brian Williams, Fall 05 21 Brian Williams, Fall 05 22 Problem Formulation: A Graph Examples of Graphs Strongly connected graph Connected graph Boston Directed path between all vertices. Path between all vertices. San Fran Roadmap Complete graph All vertices are adjacent. Wash DC LA b b Dallas a a c c Planning Actions B e d Put B on C (graph of possible C C d e Sub graph states of the world) A B A Subset of vertices Put C on A edges between vertices in Subset Put C on A A B C Directed Clique Undirected A A complete subgraph Graph Put A on C Graph (All vertices are adjacent). Put C on B C C (one-way streets) (two-way streets) A B B Brian Williams, Fall 05 23 Brian Williams, Fall 05 24 4 Formal Representation of a Graph A Solution is a State Sequence: Problem Solving Searches Paths Bos Given Graph G, with start vertex S, and goal G, SFO Airline Routes a solution is a simple path from S to G. S C Wash DC A LA Dallas G A D D start A Graph G is represented as an (ordered) pair <V,E>, where: S C • V is a set of vertices {v1 …} < {Bos, SFO, LA, Dallas, Wash DC} B end • E is a set of (directed) edges {e1, …} {<SFO, Bos>, A (directed) path is a sequence of vertices <v , … v > <S, A, D, C> An edge is a pair <v1, v2> of vertices, where <SFO, LA> 1 n such that each successive pair <vi,vi+1> is a (directed) edge in G • v2 is the head of the edge, <LA, Dallas> A simple path has no repeated vertices. •and v1 is the tail of the edge <Dallas, Wash DC> A cycle is a subpath where start = end. Brian Williams, Fall 05 . .} > 25 Brian Williams, Fall 05 26 Note: A set has no duplicate elements. A Solution is a State Sequence: A Solution is a State Sequence: Problem Solving Searches Paths Problem Solving Searches Paths S S C C A A B G G A D A D C D G D D S C G S C G C G B B Represent searched paths using a tree. Represent searched paths using a tree. Brian Williams, Fall 05 27 Brian Williams, Fall 05 28 Search Trees Search Trees Parent Root Siblings Branch Node Child (Edge) (Vertex) Brian Williams, Fall 05 29 Brian Williams, Fall 05 30 5 Search Trees Search Trees Ancestors A tree T is a directed Graph, such that there exists exactly one Descendants directed path between any pair of vertices. Brian Williams, Fall 05 31 Brian Williams, Fall 05 32 Classes of Search Outline Blind Depth-First Systematic exploration of whole tree (uninformed) Breadth-First until the goal is found. • Problem Formulation Iterative-Deepening – Problem solving as state space search Heuristic Hill-Climbing Uses heuristic measure of goodness • Mathematical Model (informed) Best -First of a node,e.g. estimated distance to. – Graphs and search trees Beam goal. • Reasoning Algorithms Optimal Branch&Bound Uses path “length” measure. Finds – Depth and breadth-first search (informed) A* “shortest” path. A* also uses heuristic Brian Williams, Fall 05 33 Brian Williams, Fall 05 34 Classes of Search Depth First Search (DFS) Blind Depth-First Systematic exploration of whole tree Idea: After visiting node (uninformed) Breadth-First until the goal is found.