University of Science and Technology Faculty of Computer

  • Slides: 38
Download presentation
University of Science and Technology Faculty of Computer Science and Information Technology Artificial Intelligence

University of Science and Technology Faculty of Computer Science and Information Technology Artificial Intelligence (AI) 4 th Year B. Sc : Information Technology Academic Year : 2017 -2018 Instructor : Diaa Eldin Mustafa Ahmed Problem Solving (Searching Strategies )-1/2

You will be expected to know q Problem formalization. q Problem Space (state ,

You will be expected to know q Problem formalization. q Problem Space (state , state space , search tree , search node , goal , action and successor function ) q Uninformed Search : Depth First Search (DFS), Breadth First Search (BFS), Depth First Iterative Deeping Search (DFIDS). q Heuristic Search: Best First Search, Hill Climbing, Constraint Satisfaction 2 AI - (2017 -2018) -Diaa Eldein Mustafa - Lecture (5)

Problem solving Using artificial intelligence (using intelligence similar to human intelligence or using Intelligent

Problem solving Using artificial intelligence (using intelligence similar to human intelligence or using Intelligent Agents ) q We want: Ø To automatically solve a problem. Formalization q We need: Searching technique Ø A representation of the problem. Ø Algorithms that use some strategy to solve the problem defined in that representation. 3 AI - (2017 -2018) -Diaa Eldein Mustafa - Lecture (5)

Problem Formulation q. Goal formulation Ø Based on the current situation and the agent’s

Problem Formulation q. Goal formulation Ø Based on the current situation and the agent’s performance measure, is the first step in problem solving. q Goal is a set of states: Ø The agent’s task is to find out which sequence of actions will get it to a goal state. q Problem formulation : Ø is the process of deciding what sorts of actions and states to consider, given a goal. 4 AI - (2017 -2018) -Diaa Eldein Mustafa - Lecture (5)

Search Techniques for Artificial Intelligence q Searching strategies is a central topic in Artificial

Search Techniques for Artificial Intelligence q Searching strategies is a central topic in Artificial Intelligence. q This part of the course will show why search is such an important topic, present a general approach to representing problems to do with search. q Introduce several search algorithms, and demonstrate how to implement these algorithms in Prolog. q Problem solving strategies Ø Representing problem solution. Ø Basic search strategies. ü Informed search strategies. ü Uninformed search strategies. q. Search in AI. 5 Ø Ø Automated reasoning Theorem proving Game playing Navigation AI - (2017 -2018) -Diaa Eldein Mustafa - Lecture (5)

Classification of AI searching Strategies Searching Strategies in AI ﺑﺤﺚ ﺃﻌﻤﻲ Informed (Heuristic Search)

Classification of AI searching Strategies Searching Strategies in AI ﺑﺤﺚ ﺃﻌﻤﻲ Informed (Heuristic Search) Un-informed (Blind Search) Depth-first (DFS) Depth. Limited (DLS) Iterative Deepening 6 Breadth. First (BFS) ( ﺑﺤﺚ ﺇﺭﺷﺎﺩﻱ)ﺍﻟﻤﻌﻠﻮﻡ Cost. First (CFS) Best-First Search (BFS) Hill Climbing Constraint Satisfaction A* Search A very large number of AI problems are formulated as search problems. ﺍﻹﺻﻄﻨﺎﻋﻲ ﻳﺘﻢ ﺻﻴﺎﻏﺘﻬﺎ ﺍﻟﻤﺸﻜﻼﺕ ﻓﻲ ﺍﻟﺬﻛﺎﺀ ﻣﻌﻈﻢ AI - (2017 -2018) -Diaa Eldein ﺑﺤﺚ Mustafa - Lecture ﻛﻤﺸﻜﻼﺕ (5)

What is Search strategy ? q. Search Ø Search is the systematic examination of

What is Search strategy ? q. Search Ø Search is the systematic examination of states to find path from the start/root state to the goal state. Ø Search usually results from a lack of knowledge. Ø Search explores knowledge alternatives to arrive at the best answer. Ø Search algorithm output is a solution, ie, a path from the initial state to a state that satisfies the goal test. 7 AI - (2017 -2018) -Diaa Eldein Mustafa - Lecture (5)

Defining a Search Problem A well-defined problem can be described by q State space

Defining a Search Problem A well-defined problem can be described by q State space S : all possible configurations(situations) of the domain of interest. ØAll states reachable from initial by any sequence of actions. Ø Is a graph whose nodes are the set of all states, and whose links are actions that transform one state into another. ØEach state is an abstract representation of the environment. ØThe state space is discrete. q An initial (start) state: ∈ S Ø Usually the current state. Ø Sometimes one or several hypothetical states (“what if …”) q Goal states G ⊂ S : ØThe set of end states –Often defined by a goal test rather than enumerating a set of states. 8 AI - (2017 -2018) -Diaa Eldein Mustafa - Lecture (5)

Defining a Search Problem A well-defined problem can be described by q Operators (Action)

Defining a Search Problem A well-defined problem can be described by q Operators (Action) A : Ø The actions available–often defined in terms of a mapping from a state to its successor. Ø Is something that the agent can choose to do. q Search tree : Ø (A graph with no undirected loops) in which the root node is the start state and the set of children for each node consists of the states reachable by taking any action. q Search node : Ø Is a node in the search tree. q Goal : Ø Is a state that the agent (solution) is trying to reach. 9 AI - (2017 -2018) -Diaa Eldein Mustafa - Lecture (5)

Defining a Search Problem A well-defined problem can be described by q Path :

Defining a Search Problem A well-defined problem can be described by q Path : Ø A sequence of states and operators. Ø Sequence through state space. q Path cost: ØA number associated with any path. ØMeasures the quality of the path. ØSum of costs of individual actions along the path. ØUsually the smaller, the better. q Solution of a search problem: Ø Is a path from to some ∈ G. q. Optimal solution: ØAny path with minimum cost. q Goal test : Ø Test to determine if at goal state. 10 AI - (2017 -2018) -Diaa Eldein Mustafa - Lecture (5)

State Space Graph versus Search Trees q. State Space Graph Ø Graph of states

State Space Graph versus Search Trees q. State Space Graph Ø Graph of states with arrows pointing to successors. Ø State graph shows the possible states of a system. Ø A state is a node in which a system can be at any given time. Ø May contain a loop. 11 State Space Graph AI - (2017 -2018) -Diaa Eldein Mustafa - Lecture (5)

Defining a Search Problem q. State Space Tree Ø Tree is a special case

Defining a Search Problem q. State Space Tree Ø Tree is a special case of a graph. Ø The topmost node in a tree is called the root node; at root node all operations on the tree begin. Ø Each NODE in in the search tree is an entire PATH in the problem graph. Ø Represent a plan (sequence of actions) which results in the node’s state. State Space Tree 12 AI - (2017 -2018) -Diaa Eldein Mustafa - Lecture (5)

Defining a Search Problem 13 AI - (2017 -2018) -Diaa Eldein Mustafa - Lecture

Defining a Search Problem 13 AI - (2017 -2018) -Diaa Eldein Mustafa - Lecture (5)

Graph vs. Tree 14 AI - (2017 -2018) -Diaa Eldein Mustafa - Lecture (5)

Graph vs. Tree 14 AI - (2017 -2018) -Diaa Eldein Mustafa - Lecture (5)

15 AI - (2017 -2018) -Diaa Eldein Mustafa - Lecture (5)

15 AI - (2017 -2018) -Diaa Eldein Mustafa - Lecture (5)

Problem Solving by Search q An important aspect of intelligence is goal-based problem solving.

Problem Solving by Search q An important aspect of intelligence is goal-based problem solving. q The solution of many problems can be described by finding a sequence of actions that lead to a desirable goal. q Each action changes the state and the aim is to find the sequence of actions and states that lead from the initial (start) state to a final (goal) state. 16 AI - (2017 -2018) -Diaa Eldein Mustafa - Lecture (5)

Example (1) : Vacuum Cleaner world state space graph 17 States? Initial state? Actions?

Example (1) : Vacuum Cleaner world state space graph 17 States? Initial state? Actions? Goal test? Discrete: dirt and robot location Any Left, right, suck No dirt at all locations Path cost? Solution 1 per action Optimal sequence of operations(actions) AI - (2017 -2018) -Diaa Eldein Mustafa - Lecture (5)

Example (1) : Vacuum Cleaner world state space q Observable, start in #5. Solution?

Example (1) : Vacuum Cleaner world state space q Observable, start in #5. Solution? [Right , Suck] q Observable, start in #2. Solution? [Suck , Left , Suck] q Observable, start in #6. Solution? [Suck , Left] q Observable, start in #1. Solution? [Suck , Right , Suck] q Unobservable, start in {1, 2, 3, 4, 5, 6, 7, 8} Solution? [Right , Suck , Left , Suck] 18 AI - (2017 -2018) -Diaa Eldein Mustafa - Lecture (5)

Example (1) : Vacuum Cleaner world state space graph 19 AI - (2017 -2018)

Example (1) : Vacuum Cleaner world state space graph 19 AI - (2017 -2018) -Diaa Eldein Mustafa - Lecture (5)

Example (1) : Vacuum Cleaner world state space tree Any State L R S

Example (1) : Vacuum Cleaner world state space tree Any State L R S 1, 3, 5, 7 R S 1 , 3, 5, 7 S 5 , 7 R 6, 8 R S S 6 , 8 4 , 8 R 3 , 7 S 8 S L S S 5, 7 4 , 8 R 6 , 8 S 8 7 AI - (2017 -2018) -Diaa Eldein Mustafa - Lecture (5) 5 , 7 3 , 7 4 , 8 S L R S 8 L 3 , 7 S 7 6, 8 S 7 S 1 , 3, 5, 7 4 , 6, 8 4 , 8 8 20 2, 4, 6 , 8 R L 5, 7 2, 4, 6 , 8 L 4, 5 , 7, 8

Example(2): The 8 -puzzle Problem state space Initial State: any configuration 21 Goal State

Example(2): The 8 -puzzle Problem state space Initial State: any configuration 21 Goal State : tiles in a specific order States? Locations of tiles Initial State? Actions? Goal test? Given Move blank left, right, up, down Goal state (given) Path cost? Solution: 1 per move Optimal sequence of operators AI - (2017 -2018) -Diaa Eldein Mustafa - Lecture (5)

22 AI - (2017 -2018) -Diaa Eldein Mustafa - Lecture (5)

22 AI - (2017 -2018) -Diaa Eldein Mustafa - Lecture (5)

Example(2): The 8 -puzzle Problem State space tree Up L 23 R Left U

Example(2): The 8 -puzzle Problem State space tree Up L 23 R Left U Right Down D AI - (2017 -2018) -Diaa Eldein Mustafa - Lecture (5) L R U D

Example (3) : Route Planning: Dongla Khartoum q On holiday in Khartoum; currently in

Example (3) : Route Planning: Dongla Khartoum q On holiday in Khartoum; currently in Dongla. 24 AI - (2017 -2018) -Diaa Eldein Mustafa - Lecture (5)

Example (3) : Route Planning: Dongla States? Khartoum Various cities Initial State? Dongla Actions?

Example (3) : Route Planning: Dongla States? Khartoum Various cities Initial State? Dongla Actions? Drive between cities or choose next city Goal test? Be in Khartoum Path cost? Distance in km Solution: Sequence of cities, e. g. Dongla, Karima , Abu-hammed, Khartoum. 25 AI - (2017 -2018) -Diaa Eldein Mustafa - Lecture (5)

Dongla 75 140 Karmma Karima 71 Marawi 146 Um-Badir Qoz-Abu-Dulu Korti Abu-Urug Khartoum 75

Dongla 75 140 Karmma Karima 71 Marawi 146 Um-Badir Qoz-Abu-Dulu Korti Abu-Urug Khartoum 75 101 Um-Badir Khartoum 120 101 Khartoum Sodri 146 Marawi 97 Qoz-Abu-Dulu 101 Khartoum 26 70 211 Qoz-Abu-Dulu 138 111 Abu-Hammed 97 Sodri 120 Old-Dongla 97 80 Wadi-Halfa 118 AI - (2017 -2018) -Diaa Eldein Mustafa - Lecture (5) 118 Qoz-Abu-Dulu 101 Khartoum

Example (4): Robotic assembly states? : 27 real-valued coordinates of robot joint angles parts

Example (4): Robotic assembly states? : 27 real-valued coordinates of robot joint angles parts of the object to be assembled initial state? : rest configuration actions? : continuous motions of robot joints goal test? : complete assembly path cost? : time to execute

Uninformed search q Uninformed Search (also called blind search) is a search that has

Uninformed search q Uninformed Search (also called blind search) is a search that has no information about its domain. Ø Use only the information available in the problem definition. Ø Generates the search tree without using any domain specific knowledge. Ø The only thing that a blind search can do is distinguish a non-goal state from a goal state. Ø Brute-force algorithms search, through the search space, all possible candidates for the solution checking whether each candidate satisfies the problem's statement. 28 AI - (2017 -2018) -Diaa Eldein Mustafa - Lecture (5)

Uninformed search q. Breadth-first search (BFS) q. Depth-first search (DFS) q. Uniform-cost search q.

Uninformed search q. Breadth-first search (BFS) q. Depth-first search (DFS) q. Uniform-cost search q. Depth-limited search q. Iterative deepening search 29 AI - (2017 -2018) -Diaa Eldein Mustafa - Lecture (5)

Informed Search q. Informed Search algorithms use heuristic functions, that are specific to the

Informed Search q. Informed Search algorithms use heuristic functions, that are specific to the problem, apply them to guide the search through the search space to try to reduce the amount of time spent in searching. q. 30 AI - (2017 -2018) -Diaa Eldein Mustafa - Lecture (5)

Breadth-first search (BFS) q. A Search strategy, in which the highest layer of a

Breadth-first search (BFS) q. A Search strategy, in which the highest layer of a decision tree is searched completely before proceeding to the next layer is called Breadth-first search (BFS). ØWhen a state is examined, all of its siblings are examined before any of its children. Ø The space is searched level-by-level, proceeding all the way across one level before doing down to the next level. In this strategy, no viable solution is omitted and therefore guarantee that optimal solution is found. Ø This strategy is often not feasible when the search space is large. Ø BFS explores nodes nearest to the root before exploring nodes that are father or further away. 31 AI - (2017 -2018) -Diaa Eldein Mustafa - Lecture (5)

Breadth-first search (BFS) 32 AI - (2017 -2018) -Diaa Eldein Mustafa - Lecture (5)

Breadth-first search (BFS) 32 AI - (2017 -2018) -Diaa Eldein Mustafa - Lecture (5)

Breadth-first search (BFS) Node are explored in the order : ABCDEFGHIJKLMNOPQ ■ After searching

Breadth-first search (BFS) Node are explored in the order : ABCDEFGHIJKLMNOPQ ■ After searching A, then B, then 33 C, the search proceeds with D, E, F, G, . . ■ The goal node J will be found before the goal node N. AI - (2017 -2018) -Diaa Eldein Mustafa - Lecture (5)

Depth-first search (DFS) q. A search strategy that extends the current path as far

Depth-first search (DFS) q. A search strategy that extends the current path as far as possible before backtracking to the last choice point and trying the next alternative path is called Depth-first search (DFS). Ø When a state is examined, all of its children and their descendants are examined before any of its siblings. Ø DFS goes deeper in to the search space when ever this is possible only when no further descendants of a state can found. Ø This strategy does not guarantee that the optimal solution has been found. Ø In this strategy, search reaches a satisfactory solution more rapidly than breadth first, an advantage when the search space is large. 34 AI - (2017 -2018) -Diaa Eldein Mustafa - Lecture (5)

Depth-first search (DFS) The Breadth-first search (BFS) and depth-first search (DFS) are the foundation

Depth-first search (DFS) The Breadth-first search (BFS) and depth-first search (DFS) are the foundation for all other search techniques. 35 AI - (2017 -2018) -Diaa Eldein Mustafa - Lecture (5)

Depth-first search (DFS) Node are explored in the order : ABDEHLMNIOPCFGJKQ ■ After searching

Depth-first search (DFS) Node are explored in the order : ABDEHLMNIOPCFGJKQ ■ After searching node A, then B, then D, the search backtracks and tries another path from node B. ■ The goal node N will be found before the goal node J. AI - (2017 -2018) -Diaa Eldein Mustafa - Lecture 36 (5)

DFS vs BFS Algorithm 37 AI - (2017 -2018) -Diaa Eldein Mustafa - Lecture

DFS vs BFS Algorithm 37 AI - (2017 -2018) -Diaa Eldein Mustafa - Lecture (5)

Thank You End 38 AI - (2017 -2018) -Diaa Eldein Mustafa - Lecture (5)

Thank You End 38 AI - (2017 -2018) -Diaa Eldein Mustafa - Lecture (5)