350 likes | 762 Views
Introduction to Artificial Intelligence. Problem Representation. Alan M Frisch, Dimitar Kazakov kazakov@cs.york.ac.uk. Last edited: 14 Jan 2013. Next two weeks: Problem Solving and Search. Use a computer to solve a problem by: Formulating a formal (symbolic) representation of the problem
E N D
Introduction to Artificial Intelligence Problem Representation Alan M Frisch, Dimitar Kazakov kazakov@cs.york.ac.uk Last edited: 14 Jan 2013
Next two weeks:Problem Solving and Search • Use a computer to solve a problem by: • Formulating a formal (symbolic) representation of the problem • Program a computer to use the representation to search for a solution • This lecture covers point 1. • Next two lectures cover point 2. ARIN: Problem Representation
Example: Romania • On holiday in Romania; currently in Arad. Flight leaves from Bucharest. • Formulate goal: • be in Bucharest • Formulate problem: • states: various cities • actions: drive between two adjacent cities • Find solution: • sequence of actions that ends at Bucharest, e.g., “Drive from Arad to Sibiu, drive from Sibiu to Fagaras, drive from Fagaras to Bucharest.” ARIN: Problem Representation
Example: Romania ARIN: Problem Representation
Problem Representation or Formulation A problemrepresentation is defined by five items: • set of states • could be infinite • each state is a symbolic structure; it could reside inside a computer • initial state • one of the states • e.g., "at Arad“ • finite set of operators(aka actions) • each is a function from states to states. • may be partial function as some operators may not be applicable to some states. E.g.“drive to Bucharest” is only applicable if in a city adjacent to Bucharest
Problem Representation or Formulation 4. goal test • A Boolean function that applies to a state • can be explicit, when we know all possible goal states in advances, e.g., state = "at Bucharest" • can be implicit, specified by a property, e.g., Checkmate(state) 5. path cost • additive, so can be derived from operators’ costs • e.g., sum of distances, number of actions executed, etc. • assumed to be ≥ 0
Example of path cost ≠ ∑ all operators? • Snakes and ladders! • (This is a Sufi Muslim board from Cambridge Museum of Anthropology)
Solutions Asolution is asequence of operators leading from the initial state to a goal state.
Recap: Problem Representation • set of states • initial state • finite set of operators (aka actions) • goal test • path cost
Problem Representation (another way) set of statesfinite set of operators (aka actions) • initial state • Transition model: a function Result(s,a) • goal test • path cost
Alternative Terminology • Transition model: defined by Result(s,a) • Successor: any state such that ssucc = Oi(s) • Successor fn: produces the set of all successors. • Example: representation has 3 operators: • O1(s)=s1; O2(s)=s2; O3(s) is undefined • Then Successors(s)={s1,s2} • The set of states is fully defined by initial state + transition model
State Space A problem representation induces a state space: • A graph in which each state is a node. If operatoro maps state s1 to state s2then the graph has a directed arc from s1 to s2and the arc is labelled o. • Could also label the initial state and goal state(s). • Could also label arcs with operator costs.
Example: Romania Consider each undirected arc to be two directed arcs.
Vacuum world state space graph • states? • operators? • goal test? • path cost?
Vacuum world state space graph • states:2 integers to represent amount of dirt in each room and 1 value to represent robot location • operators:Left, Right, Suck • goal test: no dirt at all locations • path cost:1 per action
Example: The 8-puzzle • states: • operators: • goaltest: • pathcost:
Example: The 8-puzzle • states: locations of tiles • operators: move blank left, right, up, down (these are partial functions!) • goaltest: goal state (given) • pathcost: one per move • Q: how can you do this with 24 operators? • BTW: optimal solution of n-Puzzle is NP-hard
Example: Robotic Assembly • states: real-valued coordinates of robot joints (positions, angles); parts of the object to be assembled • operators: continuous motions of robot joints • goal test: complete assembly • path cost: time to execute
Direct Representations • Often a problem itself has a natural notion of configurations and actions. • In such cases we can build a direct represent-ation in which the state and operators correspond directly to the configurations and actions. • Examples: all the examples so far and most in AIMA book.
A More General View • Operators in the representation might not correspond directly to actions in the world • Example: an operator can correspond to an action or to the inverse of an action. Consider parsing. • If the world has a natural “direction” then we can speak about forward search and backward search.
A More General View: Example Problem: Construct a sequence of 3 actions such that … Direct representation: each action is an operator B A A B A B B A B A A B B B A
A More General View: Example An alternative representation: _ _ _ _ B _ _ A _ _ A A _ A B
Problems vs. Problem Representations • In direct representations there is a close correspondence between problems and their representations. • But don’t confuse them!!! • Especially because some representations are not direct. • Be clear: States are data structures (they reside inside a computer) and operators map data structures to data structures: NextState=op(State).
Search Trees • A problem representation implicitly defines a search tree. • Rootis a node containing the initial state. • If a node contains state s then for each state s’inSuccessors(s) the node has one child node containing state s’. • Each node in the search tree is called a search node. It can contain more than just a state: e.g. the path cost from the initial node. • Search trees are not state spaces. Two nodes in a tree can contain the same state.
Search Tree for Romania Problem Representation Observe that this tree contains infinite paths. How could you reformulate the problem to eliminate them?
Search Trees • Can contain infinite paths • Because there are an infinite number of states • If state space contains a cycle, search tree contains a path with repeating states • Always finitary:- each node has finite number of children since a problem representation has a finite number of operators.
Weak Methods vs. Strong Methods • Weak Methods: • Solve a problem by building a problem representation and searching for a solution. • Doesn’t require a deep understanding of the problem. • This is a general method; can be used whenever a new problem is confronted. • It may be too inefficient to solve difficult problem instances. • Strong Methods: • Analyse a problem and use the resulting understanding to develop an algorithm specialised to the problem. • Can result in powerful algorithms that can solve difficult problem instances.
Solving NP-Complete Problems(Assuming P ≠NP) • There is no algorithm thatcan decide what to do next in polynomial time. • Some form of search must be used. • By using a weak method, one can easily get a correct algorithm (e.g., search space of all possible non-deterministic choices.) • For n binary choices, 2n combinations must be considered. • A strong method would still need to search, but could consider fewer combinations: 2c.n where c<1.
Example: Speech Segmentation “thatsthewaythecookiecrumbles” (28 chars) • Where do I put the word boundaries to segment this into a list of tokens from a given lexicon? • Problem representation • Search space:naïve vs informed search?
Summary • A problem can be solved by building a representation and then using the representation to search for a solution. • A problem representation consists of 5 items: a (possibly infinite) set of states, one of which is identified as the initial state, a goal condition, a finite set of operators, and a cost function. • A problem representation implicitly defines a search space.