520 likes | 936 Views
Problem Solving and Search in AI Part I. Search and Intelligence. Search is one of the most powerful approaches to problem solving in AI Search is a universal problem solving mechanism Systematically explores the alternatives Finds the sequence of steps towards a solution
E N D
Search and Intelligence • Search is one of the most powerful approaches to problem solving in AI • Search is a universal problem solving mechanism • Systematically explores the alternatives • Finds the sequence of steps towards a solution • Problem Space Hypothesis (Allen Newell, Herbert Simon • SOAR: An Architecture for General Intelligence.) • All goal-oriented symbolic activities occur in a problem space • Search in a problem space is claimed to be a completely general model of intelligence
Search and Intelligence • The ability to achieve goals in the face of variations, difficulties, and complexities posed by the task environment is an essential characteristic of intelligence. • The Physical Symbol System Hypothesis together with the idea of Heuristic Search constitute Newell and Simon's proposal for how to computationally realize intelligence
Physical Symbol System • A physical symbol system "consists of a set of entities, called symbols, which are physical patterns that can occur as components of another type of entity called an expression (or symbol structure). Thus, a symbol structure is composed of a number of instances (or tokens) of symbols related in some physical way (such as one token being next to another). At any instant of time the system will contain a collection of these symbol structures. Besides these structures, the system also contains a collection of processes that operate on expressions to produce other expressions: processes of creation, modification, reproduction and destruction. A physical symbol system is a machine that produces through time an evolving collection of symbol structures. Such a system exists in a world of objects wider than just these symbolic expressions themselves." "A physical symbol system has the necessary and sufficient means for intelligent action." Newell and Simon
1 2 3 Stating a Problem as a Search Problem S • State space S • Successor function: x S SUCCESSORS(x) • Cost of a move • Initial state s0 • Goal test: for state x in S GOAL?(x) =T or F
Example (Romania) • Initial Situation • On Holiday in Romania; currently in Arad • Flight leaves tomorrow from Bucharest • Formulate Goal • be in Bucharest • Formulate Problem • states: various cities • operators: drive between cities • Find Solution • sequence of cities • must start at starting state and end in the goal state
Problem formulation • A problem is defined by four items: • initial state • e.g., ``at Arad'' • operators (or successor function S(x)) • e.g., Arad ==> Zerind Arad ==> Sibiu • goal test, can be • explicit, e.g., x = ``at Bucharest'' • implicit, e.g., NoDirt(x) • path cost (additive) • e.g., sum of distances, number of operators executed, etc. • A solution is a sequence of operators leading from the initial state to a goal state
Selecting a state space • Real world is too complex • state space must be abstracted for problem solving • (Abstract) state = set of real states • (Abstract) operator = complex combination of real actions • e.g., “Arad ==> Zerind” represents a complex set of possible routes, detours, rest stops, etc. • For guaranteed realizability, any real state “in Arad” must get to some real state “in Zerind” • (Abstract) solution = set of real paths that are solutions in the real world
Example: Vacuum World • Vacuum World • Let the world consist of two rooms • Each room may contain dirt • The agent may be in either room • initial: both rooms dirty • goal: both rooms clean • problem: • states: each state has two rooms which may contain dirt (8 possible) • actions: go from room to room; vacuum the dirt • Solution: • sequence of actions leading to clean rooms
Example: Vacuum World • States? integer dirt and robot locations (ignore dirt amounts) • Operators? Left, Right, Suck • Goal Test? no dirt • Path Cost? one per move Goal states
Example: The 8-Puzzle • States? integer location of tiles • Operators? move blank left, right, up, down • Goal Test? = goal state (given) • Path Cost? One per move
8 2 7 3 4 8 2 5 1 6 3 4 7 5 1 6 8 2 7 8 2 7 3 4 6 3 4 5 1 5 1 6 8-Puzzle: Successor Function
State-Space Graph • A representation of all possible legal configurations of the problem resulting from applications of legal operators • each node in the graph is a representation a possible legal state • each transition is a representation of a possible legal move applied to a state (resulting in a new state of the problem) • States: • representation of states should provide all information necessary to describe relevant features of a problem state • Operators: • Operators may be simple functions representing legal actions; • Operators may be rules specifying an action given that a condition (set of constraints) on the current state is satisfied • In the latter case, the rules are sometimes referred to as “production rules” and the system is referred to as a production system.
Vacuum World State-Space Graph • State-space graph does not include initial or goal states • Search Problem: Given specific initial and goal states, find a path in the graph from an initial to a goal state • An instance of a search problem can be represented as a “search tree” whose root note is the initial state
Solution to the Search Problem • A solution is a path connecting the initial to a goal node (any one) • The cost of a path is the sum of the edge costs along this path • An optimal solution is a solution path of minimum cost • There might be no solution !
State Spaces Can be Very Large • 8-puzzle 9! = 362,880 states • 15-puzzle 16! ~ 1.3 x 1012 states • 24-puzzle 25! ~ 1025 states
Searching the State Space • Often it is not feasible to build a complete representation of the state graph • A problem solver must construct a solution by exploring a small portion of the graph • For a specific search problem (with a given initial and goal state) we can view the relevant portion as a search tree
Searching the State Space Search tree
Searching the State Space Search tree
Searching the State Space Search tree
Searching the State Space Search tree
Searching the State Space Search tree
Portion of Search Tree for an Instance of the 8-Puzzle Problem . . .
Simple Problem-Solving Agent Algorithm • s0 sense/read initial state • GOAL? select/read goal test • Succ select/read successor function • solution search(s0, GOAL?, Succ) • perform(solution)
8-Queens Problem Place 8 queens in a chessboard so that no two queens are in the same row, column, or diagonal. A solution Not a solution
States: all arrangements of 0, 1, 2, ..., or 8 queens on the board Initial state: 0 queen on the board Successor function: each of the successors is obtained by adding one queen in an empty square Arc cost:irrelevant Goal test: 8 queens are on the board, with no two of them attacking each other Formulation #1 64x63x...x53 ~ 3x1014 states
Formulation #2 • States: all arrangements of k = 0, 1, 2, ..., or 8 queens in the k leftmost columns with no two queens attacking each other • Initial state: 0 queen on the board • Successor function: each successor is obtained by adding one queen in any square that is not attacked by any queen already in the board, in the leftmost empty column • Arc cost:irrelevant • Goal test: 8 queens are on the board 2,057 states
Path Planning What is the state space?
Cost of one horizontal/vertical step = 1 Cost of one diagonal step = 2 Formulation #1
Optimal Solution This path is the shortest in the discretized state space, but not in the original continuous space
Cost of one step: length of segment Formulation #2
Cost of one step: length of segment Formulation #2 Visibility graph
Solution Path The shortest path in this state space is also the shortest in the original continuous space
Search Strategies • Uninformed (blind, exhaustive) strategies use only the information available in the problem definition • Breadth-first search • Depth-first search • Uniform-cost search • Heuristic strategies use “rules of thumb” based on the knowledge of domain to pick between alternatives at each step Graph Searching Applet: http://www.cs.ubc.ca/labs/lci/CIspace/Version4/search/index.html