Problem Solving and Problem Solving and Search in AI Search in AI
Part IPart I
Search and IntelligenceSearch and IntelligenceSearch is one of the most powerful approaches to Search is one of the most powerful approaches to problem solving in AIproblem solving in AI
Search is a universal problem solving mechanism Search is a universal problem solving mechanism Systematically explores the alternativesSystematically explores the alternatives Finds the sequence of steps towards a solutionFinds the sequence of steps towards a solution
Problem Space Hypothesis (Allen Newell, Herbert Problem Space Hypothesis (Allen Newell, Herbert SimonSimon SOAR: An Architecture for General Intelligence.)SOAR: An Architecture for General Intelligence.) All goal-oriented symbolic activities occur in a problem All goal-oriented symbolic activities occur in a problem
spacespace Search in a problem space is claimed to be a completely Search in a problem space is claimed to be a completely
general model of intelligencegeneral model of intelligence
Search and IntelligenceSearch and Intelligence
The ability to achieve goals in the face of The ability to achieve goals in the face of variations, difficulties, and complexities variations, difficulties, and complexities posed by the task environment is an posed by the task environment is an essential characteristic of intelligence. essential characteristic of intelligence.
The Physical Symbol System Hypothesis The Physical Symbol System Hypothesis together with the idea of Heuristic Search together with the idea of Heuristic Search constitute Newell and Simon's proposal for constitute Newell and Simon's proposal for how to computationally realize intelligence how to computationally realize intelligence
Physical Symbol SystemPhysical Symbol System
A physical symbol system "consists of a set of entities, called A physical symbol system "consists of a set of entities, called symbols, which are physical patterns that can occur as components symbols, which are physical patterns that can occur as components of another type of entity called an expression (or symbol structure). of another type of entity called an expression (or symbol structure). Thus, a symbol structure is composed of a number of instances (or Thus, a symbol structure is composed of a number of instances (or tokens) of symbols related in some physical way (such as one token 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 being next to another). At any instant of time the system will contain a collection of these symbol structures. Besides these structures, a collection of these symbol structures. Besides these structures, the system also contains a collection of processes that operate on the system also contains a collection of processes that operate on expressions to produce other expressions: processes of creation, expressions to produce other expressions: processes of creation, modification, reproduction and destruction. A physical symbol modification, reproduction and destruction. A physical symbol system is a machine that produces through time an evolving system is a machine that produces through time an evolving collection of symbol structures. Such a system exists in a world of collection of symbol structures. Such a system exists in a world of objects wider than just these symbolic expressions themselves." objects wider than just these symbolic expressions themselves."
"A physical symbol system has the necessary and sufficient means for intelligent action."
Newell and Simon
Stating a Problem as a Search Problem
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
S1
3 2
Example (Romania)Example (Romania)
Initial SituationInitial Situation On Holiday in Romania; currently in AradOn Holiday in Romania; currently in Arad Flight leaves tomorrow from BucharestFlight leaves tomorrow from Bucharest
Formulate GoalFormulate Goal be in Bucharestbe in Bucharest
Formulate ProblemFormulate Problem states: various citiesstates: various cities operators: drive between citiesoperators: drive between cities
Find SolutionFind Solution sequence of citiessequence of cities must start at starting state and end in the goal statemust start at starting state and end in the goal state
Example (Romania)Example (Romania)
Problem formulationProblem formulationA A problemproblem is defined by four items: is defined by four items:
initial stateinitial state e.g., ``at Arad''e.g., ``at Arad''
operatorsoperators (or successor function (or successor function SS((xx)))) e.g., Arad ==> Zerinde.g., Arad ==> Zerind Arad ==> SibiuArad ==> Sibiu
goal testgoal test, can be, can be explicitexplicit, e.g., , e.g., xx = ``at Bucharest'' = ``at Bucharest'' implicitimplicit, e.g., , e.g., NoDirtNoDirt((xx))
path costpath cost (additive) (additive) e.g., sum of distances, number of operators executed, etc.e.g., sum of distances, number of operators executed, etc.
A A solutionsolution is a sequence of operators leading from the initial state to a is a sequence of operators leading from the initial state to a goal stategoal state
Selecting a state spaceSelecting a state spaceReal world is too complexReal world is too complex
state space must be state space must be abstractedabstracted for problem solving for problem solving
(Abstract) state = set of real states(Abstract) state = set of real states
(Abstract) operator = complex combination of real actions(Abstract) operator = complex combination of real actions e.g., “Arad ==> Zerind” represents a complex set of possible e.g., “Arad ==> Zerind” represents a complex set of possible
routes, detours, rest stops, etc.routes, detours, rest stops, etc.
For guaranteed realizability, For guaranteed realizability, anyany real state “in Arad” must real state “in Arad” must get to get to somesome real state “in Zerind” real state “in Zerind”
(Abstract) solution = set of real paths that are solutions in (Abstract) solution = set of real paths that are solutions in the real worldthe real world
Example: Vacuum WorldExample: Vacuum WorldVacuum 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 WorldExample: Vacuum World
States? States? integer dirt and integer dirt and robot locations (ignore dirt robot locations (ignore dirt amounts)amounts)
Operators? Operators? LeftLeft, , RightRight, , SuckSuck
Goal Test? Goal Test? no dirtno dirt
Path Cost? Path Cost? one per one per movemove
Goal states
Example: The 8-PuzzleExample: The 8-Puzzle
States?States? integer location of tilesinteger location of tiles
Operators? Operators? move blank left, right, up, downmove blank left, right, up, down
Goal Test?Goal Test? = goal state (given)= goal state (given)
Path Cost?Path Cost? One per moveOne per move
8-Puzzle: Successor Function8-Puzzle: Successor Function
1
2
3 4
5 6
7
8
1
2
3 4
5
6
78
1
2
3 4
5 6
78
1
2
3 4
5 6
78
State-Space GraphState-Space GraphA representation of all possible legal configurations of A representation of all possible legal configurations of the problem resulting from applications of legal operatorsthe problem resulting from applications of legal operators
each node in the graph is a representation a possible legal stateeach node in the graph is a representation a possible legal state each transition is a representation of a possible legal move each transition is a representation of a possible legal move
applied to a state (resulting in a new state of the problem)applied to a state (resulting in a new state of the problem)
States:States: representation of states should provide all information necessary representation of states should provide all information necessary
to describe relevant features of a problem stateto describe relevant features of a problem state
Operators:Operators: Operators may be simple functions representing legal actions; Operators may be simple functions representing legal actions; Operators may be rules specifying an action given that a Operators may be rules specifying an action given that a
condition (set of constraints) on the current state is satisfiedcondition (set of constraints) on the current state is satisfied In the latter case, the rules are sometimes referred to as In the latter case, the rules are sometimes referred to as
“production rules” and the system is referred to as a production “production rules” and the system is referred to as a production system.system.
Vacuum World State-Space GraphVacuum World State-Space Graph
State-space graph does not include initial or goal statesState-space graph does not include initial or goal statesSearch Problem: Given specific initial and goal states, find Search Problem: Given specific initial and goal states, find a path in the graph from an initial to a goal statea path in the graph from an initial to a goal state
An instance of a search problem can be represented as a “search An instance of a search problem can be represented as a “search tree” whose root note is the initial statetree” whose root note is the initial state
Solution to the Search ProblemSolution to the Search Problem
A A solutionsolution is a path connecting the initial to is a path connecting the initial to a goal node (any one)a goal node (any one)
The The costcost of a path is the sum of the edge of a path is the sum of the edge costs along this pathcosts along this path
An An optimal solutionoptimal solution is a solution path of is a solution path of minimum costminimum cost
There might be no solution !There might be no solution !
State Spaces Can be State Spaces Can be Very LargeVery Large
8-puzzle 8-puzzle 9! = 362,880 states 9! = 362,880 states
15-puzzle 15-puzzle 16! ~ 1.3 x 1012 states 16! ~ 1.3 x 1012 states
24-puzzle 24-puzzle 25! ~ 1025 states 25! ~ 1025 states
Searching the State SpaceSearching the State Space
Often it is not feasible Often it is not feasible to build a complete to build a complete representation of the representation of the state graphstate graph
A problem solver A problem solver must construct a must construct a solution by exploring solution by exploring a small portion of the a small portion of the graphgraph
For a specific search For a specific search problem (with a given problem (with a given initial and goal state) initial and goal state) we can view the we can view the relevant portion as a relevant portion as a search treesearch tree
Searching the State SpaceSearching the State Space
Searching the State SpaceSearching the State Space
Search tree
Searching the State SpaceSearching the State Space
Search tree
Searching the State SpaceSearching the State Space
Search tree
Searching the State SpaceSearching the State Space
Search tree
Searching the State SpaceSearching the State Space
Search tree
5 4
6 1 8
7 3 2
5 4
6 1 8
7 3 2
5 4 8
6 1
7 3 2
5 4
6 1 8
7 3 2
5 1 4
6 8
7 3 2
5 4 8
6 1
7 3 2
5 4 8
6 1 2
7 3
6 5 4
1 8
7 3 2
5 1 4
6 8
7 3 2
5 1 4
6 8
7 3 2
5 1 4
6 3 8
7 2
5 8
6 4 1
7 3 2
5 4 8
6 3 1
7 2
5 4 8
6 1
7 3 2
5 4 8
6 1 2
7 3
6 5 4
1 8
7 3 2
6 5 4
7 1 8
3 2
1 4
5 6 8
7 3 2
5 1 4
7 6 8
3 2 . . .
Portion of Search Tree for an Instance of the Portion of Search Tree for an Instance of the 8-Puzzle Problem8-Puzzle Problem
Simple Problem-Solving Simple Problem-Solving Agent AlgorithmAgent Algorithm
s0 s0 sense/read initial state sense/read initial state
GOAL? GOAL? select/read goal test select/read goal test
Succ Succ select/read successor function select/read successor function
solution solution search(s0, GOAL?, Succ) search(s0, GOAL?, Succ)
perform(solution)perform(solution)
Some Other ProblemsSome Other Problems
8-Queens Problem8-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
Formulation #1Formulation #1 States:States: all arrangements of 0, 1, all arrangements of 0, 1,
2, ..., or 8 queens on the board2, ..., or 8 queens on the board Initial state:Initial state: 0 queen on the 0 queen on the
boardboard Successor function:Successor function: each of each of
the successors is obtained by the successors is obtained by adding one queen in an empty adding one queen in an empty squaresquare
Arc cost:Arc cost: irrelevantirrelevant Goal test:Goal test: 8 queens are on the 8 queens are on the
board, with no two of them board, with no two of them attacking each otherattacking each other
64x63x...x53 ~ 3x1014 states
Formulation #2Formulation #2 States:States: all arrangements of k = 0, all arrangements of k = 0,
1, 2, ..., or 8 queens in the k 1, 2, ..., or 8 queens in the k leftmost columns with no two leftmost columns with no two queens attacking each otherqueens attacking each other
Initial state:Initial state: 0 queen on the board 0 queen on the board Successor function:Successor function: each each
successor is obtained by adding successor is obtained by adding one queen in any square that is not one queen in any square that is not attacked by any queen already in attacked by any queen already in the board, in the leftmost empty the board, in the leftmost empty column column
Arc cost:Arc cost: irrelevantirrelevant Goal test:Goal test: 8 queens are on the 8 queens are on the
boardboard
2,057 states
Path PlanningPath Planning
What is the state space?
Formulation #1Formulation #1
Cost of one horizontal/vertical step = 1Cost of one diagonal step = 2
Optimal SolutionOptimal Solution
This path is the shortest in the discretized state space, but not in the original continuous space
Formulation #2Formulation #2
Cost of one step: length of segment
Formulation #2Formulation #2
Cost of one step: length of segment
Visibility graph
Solution PathSolution Path
The shortest path in this state space is also the shortest in the original continuous space
Search StrategiesSearch StrategiesUninformedUninformed (blind, exhaustive) (blind, exhaustive) strategies use strategies use only the information available in the problem only the information available in the problem definitiondefinition Breadth-first searchBreadth-first search Depth-first searchDepth-first search Uniform-cost searchUniform-cost search
HeuristicHeuristic strategies use “rules of thumb” based strategies use “rules of thumb” based on the knowledge of domain to pick between on the knowledge of domain to pick between alternatives at each stepalternatives at each step
Graph Searching Applet:http://www.cs.ubc.ca/labs/lci/CIspace/Version4/search/index.html
Top Related