700 likes | 885 Views
ARTIFICIAL INTELLIGENCE [INTELLIGENT AGENTS PARADIGM]. PROBLEM SOLVING BY SEARCHING. Professor Janis Grundspenkis Riga Technical University Faculty of Computer Science and Information Technology Institute of Applied Computer Systems Department of Systems Theory and Design
E N D
ARTIFICIAL INTELLIGENCE[INTELLIGENT AGENTS PARADIGM] PROBLEM SOLVING BY SEARCHING Professor Janis Grundspenkis Riga Technical University Faculty of Computer Science and Information Technology Institute of Applied Computer Systems Department of Systems Theory and Design E-mail: Janis.Grundspenkis@rtu.lv
Problem Solving by Searching (1) • Problem Solving Agent(one kind of a Goal-Based Agent) • Relevant feature:Decision making what to do by finding sequence of actions that leads to desired states
Problem Solving by Searching (2) • How problem is solved? Step 1. Goal formulation Step 2. Problem formulation – a process of deciding what actions and states to consider Step 3. Search – systematic exploration of the sequence of alternative states that appear in a problem solving process Step 4. Solution – an action sequence Step 5. Execution – recommended actions can be accomplished
Simple-Problem-Solving Agent > Percept Update-State(state, percept) > Goal Formulate-Goal(state) > Problems Formulate-Problem(state, goal) > Current state Search(problem) > Action Recommendation(state, action) Return: action
Problem Types (1) • Single-state problem • Percepts give enough information to tell exactly which state is it • Agent knows exactly what each of its actions does • Agent can calculate exactly which state it will be in after any sequence of actions
Problem Types (2) • Multiple-state problem • Percepts give not enough information to tell which state is it • Agent knows all the effects of itsactions • Agent must reason about sets of states that it might get to
Basic Elements of a Problem Definition • A problem is a collection of information that the agent can use to decide what to do • Information specification for single-state problem definition Basic elements: • States • Actions
State Space of the Problem • State space is the set of all states reachable from the initial state by any sequence of actions • The initial state is the state that the agent knows itself to be in • The goal state corresponds to the solution of the problem • The operator describes an action in terms of which state will be reached by carrying out the action in a particular state
State Space Representation of the Problem Using Graph • The nodes of a graph corresponds to particular problem solution states • The arcs correspond to steps in a problem-solving process • Initial states form root of the graph and correspond to the given information in a problem instance • Goal states of the problem corresponds to the solutions to a problem instance
Formal State Space Representation of the Problem (1) • A state space is represented by a four-tuple [N, A, IS, GS], where N is the set of nodes or states of the graph A is the set of arcs between nodes
Formal State Space Representation of the Problem (2) • A state space is represented by a four-tuple [N, A, IS, GS], where ISis the non-empty set that contains the initial states of the problem (IS N) GS is the non-empty set that contains the goal states of the problem (GS N)
Testing the Goal States • Agent can apply the goal test to a single-state description to determine if it is a goal state • Description of the goal states: • Explicit set of possible goal states • A measurable property of the states encountered in the search • A property of the path developed in the search
Paths in the State Space • Each path that does reach the goal is called a complete path • Each path that does no reach the goal is called a partial path • A solution path is a complete path through the graph from a node in IS to a node in GS • A path cost function g is a function that assigns a cost to a path • The cost of a path is the sum of the costs of the individual actions along the path
Measuring Problem-Solving Performance • Three ways to measure the effectiveness of a search: • Does a search find a solution at all? • Is a solution good (one with a low path cost)? • What is the search cost associated with the time and memory required to find a solution? • The total cost of the search:Total cost = Path cost + Search cost
Searching for Solutions (1) • Search process builds up a search tree (subgraph of the state space) • Search starts from the search node that corresponds to the initial state (the root of the search tree) • Determining the children of a state is called expanding the state
Searching for Solutions (2) • At each step, the search algorithm chooses one leaf node to expand • Leaf nodes have not successors (children) Two cases: • They have not been expanded • They were expanded, but generated the empty set • Nodes that are waiting to be expanded are called a frontier
Search Algorithms for Agents • INPUT: instances of data type PROBLEM • OUTPUT: solution path • Data type PROBLEM has four components: • Initial state • Operators • Goal test • Path cost function
Distinction Between Nodes and States • A node is a data structure used to represent the search tree for a particular problem instance as generated by a particular problem • A state represents a configuration of the world and is characterized by a set of features
Data Structure for Search Trees • Node v is data structure with five components: • The corresponding state in the state space • The node that generates node v (the parent node) • The operator that was applied to generate v • The depth of the node v (the number of nodes on the path from the search node to v) • The path cost of the path from the search node to v
Classification of Search Strategies (1) If available information is specified: • Uninformed Search (Blind Search) No information is available about: • the number of steps • the path cost from the current state to the goal • Informed Search (Heuristic Search) Problem-specific knowledge is used
Classification of Search Strategies (2) If the search direction is specified: • Data-Driven Search (Forward Chaining) • Search starts from the node(s) representing the given facts of the problem, applies operators to produce new nodes that lead to a goal • Searching forwards means generating successors successively starting from the initial (root) node
Classification of Search Strategies (3) If the search direction is specified: • Goal-Driven Search (Backward Chaining) • Search starts from the goal, applies operators that could produce the goal, and chains backward to the given facts of the problem • Searching backwards means generating predecessors successively starting from the goal node
UninformedSearch Classification of Search Strategies (4) If the order in which nodes are expanded is specified: • Breadth-First Search • Uniform Cost Search • Depth-First Search • Depth-Limited Search • Iterative DeepeningSearch • Bidirectional Search
InformedSearch Classification of Search Strategies (5) If the order in which nodes are expanded is specified: • Best-First Search • Greedy Search (minimizing theestimate cost to reach the goal) • A* Search (minimizing the totalpath cost)
InformedSearch Classification of Search Strategies (6) If the order in which nodes are expanded is specified: • Memory Bounded Search • IDA* Search (IterativeDeepeningA* search) • SMA* Search (SimplifiedMemory-Bounded A*)
InformedSearch Classification of Search Strategies (7) If the order in which nodes are expanded is specified: • Iterative ImprovementAlgorithms • Hill-Climbing Search • Random-Restart Hill-Climbing • Simulated Annealing • Beam Search
UninformedSearch Strategies (1) • Breadth-First Search • This search expands the shallowest node in the search tree first • This search explores the space in a level-by-level fashion
Breadth-first search A B C D E F G H I J CLOSED B B D B D F B D F G B D F G I B D F G I J Iteration 0 1 2 3 4 5 6 OPEN B D F G F G I J G I J H I J H J H H Data driven search B- the initial node H – the goal Goal
UninformedSearch Strategies (2) • Uniform-Cost Search • This search expands the lowest-cost node on the frontier first • The path cost must never decreaseg(successor(n)) g(n)for every node n
UninformedSearch Strategies (3) • Depth-First Search • This search expands the deepest node in the search tree first • This search goes deeper into the search space whenever this is possible • Depth-Limited Search • This search places a limit on how deep a depth-first search can go (imposes a cutoff on the maximum depth of a path)
Depth-first search A B C D E F G H I J Iteration 0 1 2 3 4 5 OPEN B D F G I J F G J F G F G H G CLOSED B B D B D I B D I J B D I J F Data driven search B- the initial node H – the goal Goal
Depth limited search Data driven search A B B- the initial node F- the goal Depth limit - 2 C D E Node depth CLOSED B B D Iteration 0 1 2 OPEN B0 D1 G1 E1 F2 H2 G1 E1 F G H I J Goal
UninformedSearch Strategies (4) • Iterative Deepening Search • This search call depth-limited search with increasing limits until a goal is found • This search expands many states multiple times • Bidirectional Search • This search goes both forwards from the initial state and backward from the goal, and stop when the two searches meet in the middle
Bidirectional search A B A- the initial node J- the goal C D E F G H Data-driven search Goal-driven search I J CLOSED J J G CLOSED A A C Iteration 0 1 2 OPEN J G H H C D Iteration 0 1 2 OPEN A C D D F G Solution is found because the node D is found in both OPEN lists
Evaluation of Uninformed Search Strategies • Four Criteria • Completeness (is a solution guaranteed?) • Time Complexity (time needed for search) • Space Complexity (memory needed for search) • Optimality (is highest-quality solution guaranteed when there are several different solutions?)
Comparing Uninformed Search Strategies (1) b is the branching factor (every state can be expanded toyield b new states), d is the depth of solution, m is the maximum depth of the search tree, andl is the depth limit
Comparing Uninformed Search Strategies (2) b is the branching factor (every state can be expanded toyield b new states) d is the depth of solution m is the maximum depth of the search tree l is the depth limit
Strengths of Uninformed Search Strategies (1) • Breadth-First Search • This search always finds the shortest solution path • Uniform-Cost Search • When the cost of the path never decrease, the first solution that is found is guaranteed to be the cheapest solution
Strengths of Uninformed Search Strategies (2) • Depth-First Search • For problems that have very many solutions, depth-first may actually be faster than breadth-first search, because chances to find a solution after searching only a small part of the whole space is rather good
Strengths of Uninformed Search Strategies (3) • Depth-Limited Search • It avoids the pitfalls of depth-first search • Iterative Deepening Search • It is the preferred search method when there is a large search space and the depth of the solution is not known • Bidirectional Search • Can enormously reduce time complexity
Weaknesses of Uninformed Search Strategies (1) • Breadth-First Search • Impractical in most cases due to the memory requirements • It is optimal only when all operators have the same cost • Uniform-Cost Search • If some operators have negative cost, only an exhaustive search of all nodes would guaranteed the optimal solution
Weaknesses of Uninformed Search Strategies (2) • Breadth-First Search (assume that 1 million nodes can be generated per second and that a node requires 1000 bytes of storage) • At depth 2 there are 110 nodes, time needed is 0,11 milliseconds and 107 kilobytes of memory are needed • At depth 4 there are 11110 nodes, time needed is 11 milliseconds and 10,6 megabytes of memory are needed • At depths 6, 8, 10, 12, 14, and 16 the number of nodes is10 in corresponding power, time needed is 1,1 seconds, 2 minutes, 3 hours, 13 days, 3,5 years, and 350 years, respectively, while 1 gigabyte, 103 gigabites, 10 terabytes, 1 petabyte, 99 petabytes, and 10 exabytes of memory are needed • Exponential-complexity search is a problem!
Weaknesses of Uninformed Search Strategies (3) • Depth-First Search • Impractical in search trees with large or infinite maximum depths (it can get stuck going down the wrong paths) • Depth-Limited Search • In cases when depth limit is too small there is no guarantee that the search will find the goal
Weaknesses of Uninformed Search Strategies (4) • Iterative Deepening Search • It is wasteful, because many states are expanded multiple times • Bidirectional Search • It is not always applicable and its memory requirements may be impractical
InformedSearch Strategies (1) • Best-First Search • This search expands the node that appears to be the best according to the evaluation function * Greedy Search • This is one of the simplest best-first search strategies that uses minimization of the estimated cost of the cheapest path (heuristic functionh(n)) to reach the goal • This search expands the node whose state is judged to be closest to the goal state
Best first search A 10 = 0+10 B 6 =1+5 C 8 =1+7 D 4 =1+3 E 5 =2+3 F 7 =2+5 G 4 =2+2 H 5 =3+2 I 3 =3+0 Node heuristic measures 6 The best measure is the highest value A- the initial node H- the goal Iteration 0 1 2 3 4 5 OPEN A(10) C(8) B(6) D(4) B(6) E(5) D(4) G(4) F(7) E(5) D(4) G(4) E(5) D(4) G(4) I(3) H(5) D(4) G(4) I(3) CLOSED A(10) A(10) C(8) A(10) C(8) B(6) A(10) C(8) B(6) F(7) A(10) C(8) B(6) F(7) E(5)
InformedSearch Strategies (2) • A* Search • This search expands the node n with the lowest value of the estimated cost of the cheapest solution through n:f(n) = g(n) + h(n)
InformedSearch Strategies (3) • Memory-Bounded Search • This search conserves memory • Iterative Deepening A* Search (IDA*) • In this search each iteration is a depth-first search that is modified to use an f-cost limit (not depth limit) • This search expands all nodes inside the contour for the current f-cost, peeping over the contour to find out where the next contour is (contour in the state space is a set of nodes where all nodes have f(n) less than or equal to f-cost of that contour)
InformedSearch Strategies (4) • Simplified Memory-Bounded A* Search (SMA*) • This search drops nodes that are unpromising (nodes with high f-cost) when it needs to generate a successor but has no memory left
InformedSearch Strategies (5) • Iterative Improvement Algorithms • This search explores the state space trying to find the best valueof the estimated cost, which is the optimal solution • Hill-Climbing Search • This search continually expands nodes that have better estimated costs of the remaining distance to the goal then previous ones