Artificial Intelligence Text Book Artificial Intelligence Building Intelligence

Artificial Intelligence Text Book: Artificial Intelligence , Building Intelligence Systems Parag Kulkarni and Prachi Joshi

Introduction • Building Intelligent systems and making machines intelligent, which are autonomous, flexible and work holistically has been a movement for years. • In the beginning simple intelligence it was based on memorization. • In appliances, the intelligence was based on Event, pattern and selection driven.

Introduction to AI • AI includes – Learning – Searching and – Problem Solving • The purpose of AI is to empower machine to solve the problems by making the machine intelligent. • Definition by “Rich and Knight” – AI is the study of how to make computers do things, which, at the moment, people do better.

• AI deals with the science that is about the efforts of making a machine behave intelligently and respond in a way as human would. • AI can be defined as: – Machines which can think and have a capability to react like human beings – Systems that respond intelligently in the same way as the humans do – Computational models to solve various complex decision making problems – Study of intelligent agents.

• The horizon of AI includes techniques for knowledge transmission, knowledge representation, automated reasoning, and this is used to empower machines to behave intelligently. • Cognitive models deal with the computer knowledge-based models for AI. • Intelligent machines need to demonstrate the rational behavior.

AI History and foundation It is as old as 1000 years 1940 – Wrote first Chess program using HL Lang 1950 – Allan Turing devised a simple test of intelligence 1956 - John Mc. Carthy invented Lisp Lang 1969 - Scientists at Stanford Research Institute Developed Shakey, a robot, equipped with locomotion, perception, and problem solving. • 1973 - The Assembly Robotics group at Edinburgh University built Freddy, the Famous Scottish Robot, capable of using vision to locate and assemble models. • 1979 - The first computer-controlled autonomous vehicle, Stanford Cart, was built. • 1985 - Harold Cohen created and demonstrated the drawing program, Aaron. • • •

• 1990 – – – – – Major advances in all areas of AI − Significant demonstrations in machine learning Case-based reasoning Multi-agent planning Scheduling Data mining, Web Crawler natural language understanding and translation Vision, Virtual Reality Games • 1997 - The Deep Blue Chess Program beats then world chess champion, Garry Kasparov. • 2000 - Interactive robot pets become commercially available. MIT displays Kismet, a robot with a face that expresses emotions. The robot Nomad explores remote regions of Antarctica and locates meteorites.

New Millennium, New Opportunities • In the late 1990 s, American corporations once again became interested in AI. • The Japanese government unveiled plans to develop a fifth generation computer to advance of machine learning. • AI enthusiasts believed that soon computers would be able to carry on conversations, translate languages, interpret pictures, and reason like people. • In 1997, IBM’s Deep Blue defeated became the first computer to beat a reigning world chess champion, Garry Kasparov.

Birth of AI • John Mc. Carthy gave a new term for AI, “Computational rationality” at Dartmouth College. • The concepts like intelligence, knowledge, reasoning, thoughts, cognition and learning formulated a platform for AI research.

An Example • Signals are controlled the traffic traditionally, based on historical information. • Due to increase in the traffic, a need for tuner system that could change the signal timings w. r. t peak hours. • A need for Intelligent system arise. A traffic jam at one road could impact many roads. • There is a need for an intelligent signal controller which will synchronize all the signals and can be controlled with a centralized controller. • AI based system can help in capturing the current scene at a particular route, and accordingly, dynamically change the signal timings.

AI Techniques • AI techniques need to be built from problem solving perspective. – Need for analysis of voluminous and large amount of data, which is spread across different domains. – Analysis characterization of miscellaneous data mapping data building the knowledge – Dealing with the constantly changing scenarios and dynamic data. – The way in which data appears, used, organized. – Though huge data is available, might not be relevant.

• The broad categorization of the problems on which the AI techniques will handle: – Structured Problems – Unstructured Problems – Linear Problems – Non-linear Problems.

What is AI Technique? • In the real world, the knowledge has some unwelcomed properties − – Its volume is huge, next to unimaginable. – It is not well-organized or well-formatted. – It keeps changing constantly. • AI Technique is a manner to organize and use the knowledge efficiently in such a way that − – It should be perceivable by the people who provide it. – It should be easily modifiable to correct errors. – It should be useful in many situations though it is incomplete or inaccurate. • AI techniques elevate the speed of execution of the complex program it is equipped with.

AI Techniques • List of AI Techniques: – Heuristics. – Support Vector Machines. – Artificial Neural Networks. – Markov Decision Process. – Natural Language Processing.

Heuristics • It is one of the most popular search algorithms used in Artificial Intelligence. • It is implemented to solve problems faster than the classic methods or to find the solutions for which classic methods cannot. • Heuristics techniques basically employ heuristic for its moves and are used to reduce the total number of alternatives for the results. • This technique is one of the most basic techniques used for AI and is based on the principle of trial and error. It learns from the mistakes. • Heuristics is one of the best options for solving difficult problems. For instance, to know the shorter route for any destination, the best way is to identify all the possible routes and then to identify the shortest one.

Support Vector Machines • Support Vector Machine is a supervised machine learning algorithm used for regression challenges or classification problems. • However, in the majority of cases, it is used for classification only, for instance, email systems use vector machines for email classification as Social or Promotion or any other. • It categorizes each mail according to the respective categories. • This technique is widely used for face recognition, text recognition and image recognition systems.

Artificial Neural Network • Neural networks are generally found in the brains of living organisms. • These are basically the neural circuits which help living beings to transmit and process the information. • For this purpose, there are billions of neurons which helps to make the neural systems for making decisions in day-to-day life and learn new things. • These natural networks have inspired the design of an Artificial Neural Network. Instead of Neurons, Artificial Neural Networks are composed of Nodes. • These networks help in identifying patterns from the data and then learns from it. • For this purpose, it uses different learning method such as supervised learning, unsupervised learning and reinforced learning. • From an application perspective, it is used in machine learning, deep learning and pattern recognition.

Markov Decision Process • A Markov Decision Process (MDP) is a framework for decisionmaking modeling where in some situations the outcome is partly random and partly based on the input of the decision maker. • Another application where MDP is used is optimized planning. The basic goal of MDP is to find a policy for the decision maker, indicating what particular action should be taken at what state. • An MDP model consists of the following parts: – A set of possible states: for example, this can refer to a grid world of a robot or the states of a door (open or closed). – A set of possible actions: a fixed set of actions that e. g. a robot can take, such as going north, left, south or west. Or with respect to a door, closing or opening it. – Transition probabilities: this is the probability of going from one state to another. For example, what is the probability that the door is closed, after the action of closing the door has been performed? – Rewards: these are used to direct the planning. For instance, a robot may want to move north to reach its destination. Actually going north will result in a higher reward.

Natural Language Processing • Basically, it is a technique used by computers to understand, interpret and manipulate human language. Going by its use, it is helpful for speech recognition and speech synthesis. • Already, this technique is used for several applications by a myriad of companies. Apple’s Siri, Google Assistant, Microsoft’s Cortana and Alexa are some of the applications which uses the Natural Language Processing techniques. • Additionally, it is also used for parsing techniques, part-ofspeech tagging, and text recognition.

Problem Solving with AI • The structured Problems are: – well- structured • Very commonly faced problems, they yield right answer or right inference when an appropriate algo applied. – ill- structured • Which do not yield a particular answer. There is an possibility of more than one answer. They rep real world problems.

• Examples of well-structured problems – Solving a quadratic equation to find out the value of X – Calculating path of the trajectory when a missile is fired • Examples of ill-structured problems – Predicting how to dispose wet waste safely – Analysis of theoretical prepositions and adeqaucy of the same in a particular scenario – Identifying the security threats in big social gatherings.

• A typical well-structured problem analysis Correct Test (ordered steps) Incorrect • A typical ill-structured problem analysis Test (no ordered steps) Analysis for correction • A typical well-structured problem is the tic-tactoe

• Problems are categorized as – Linear Problem • The solution can be obtained by linear solution – Non-linear problem • The solution cannot be obtained or problem cannot be solved by linear equations.

AI Models • AI Models help solving problems. • Dunker introduced ‘Maze hypothesis’ as part of psychological theory. – Human at any point in time, analyses maze; for choices, he could find those which lead to goal. – Maze-based approach help to solve multi-alternative solution problems. – Later, It was evident that all problems cannot be solved by maze approach, which got more focus on logic theory machines. – Effective application of logic theory machines is found to be more useful in general problem solving.

• The complexity of model building wrt data and knowledge mapping Model Discovery Knowledge – based model building AI application building Discovery relationship Mapping Complexity Model building and complexity

• The advent of NLP and the need for manmachine dialogue made it more evident that the models used so far had their own limitations. • The requirement of complex problem solving gave birth to dynamic inductive models. • Human behavior and psychological study – based inductive dynamic models for creative problem solving slowly became popular.

• AI Models – Semantic Models • These are base on sign processes or signification communication. • Assignment and mapping process depends on the use of codes based on sounds or letter by humans to form words or movements • In computers, these signs are determined for a logical sequence. – Statistical Models • These refer to representation and formalization of relationships through statistical techniques. • The historical data is used here in Decision making. • It employs probabilistic approaches.

Data acquisition and learning aspects in AI • Knowledge discovery – Data mining and machine learning • Computational learning theory (COLT) • Neural and evolutionary computation • Intelligent agents and multi agent systems • Multi- perspective integrated intelligence.

Knowledge discovery – Data mining and machine learning • Knowledge discovery : – is the extraction of meaningful information that is previously unknown and can be useful potentially ahead. – Is about finding understandable knowledge • Machine Learning: – is a field concerned with the study of algorithms that will improve its performance with experience. Making machines intelligent. – Is focused on improving performance of an agent • Data Mining: – Is a tool and hold core part in business intelligence(BI). It plays a critical role for accurate and complex decision making.

Computational Learning theory • Formal mathematical models are defined • They help in analyzing the efficiency and complexity in terms of computation, prediction and feasibility of the algorithms. • Wrt ML, the goal of COLT is to inductively learn the target function. • Learning theories help in understanding the explicit relevant aspects.

Neural and evolutionary computation A new technique in computation It speeds up the mining of data Based on biological properties Used to solve multi dimensional problem It finds its applications from the telecom domain to the financial decision making. • Neural computing: the neural behaviour of human beings is stimulated to enable machine to learn. • • •

Intelligent agents and multi agent systems • Which allows timely decision making in complex scenarios. • An agent is a software program that assists user • An intelligent agent is the one which is flexible in terms of its action to get desired outcome. • In Multi agent systems, every agent’s capability and its computation efficiency is exploited so that the overall performance is improved.

Multi – perspective integrated intelligence(MPI) • Utilizing and exploiting the knowledge from different perspective to build up an intelligent system giving accurate results builds the MPI

Chapter-2 Problem Solving

Introduction • Problem solving is an area to deal with finding answer for some unknown situations. • It involves understanding, representation, formulation and solving. • The important approach of the problem solving is search in an action space. Action space comprises a set of actions that leads to some specific goal. • The methods of problem solving can be categorized as follows: – General purpose – Special purpose

• The general purpose method is applicable to a wide variety of problems and it is means-end analysis. • In this, the present situation is compared with the goal to detect the difference. • It searches in action space to select an action that will reduce the difference.

• In special purpose method, problem solving system behaves like an expert, who has gathered knowledge on a specific area over a period of time. • The expert uses his knowledge to relate to the current situation and derives analogy to find out the best possible solution. • Managers need efficient problem solving methods for assisting and helping them with optimized decisions.

Problem solving Process • Problem solving is a process of generating solution. • The figure shows the problem solving process applied to achieve goal state. • The process consists of well defined methods that can handle doubts or inconsistency issues, uncertainty, ambiguity and help in achieving the desired goal. Problem identification Explore information Create KB Action Selection Intermediate states Goal State

• In AI, the problem is formulated and solved by searching for a solution in space of possible solutions. • The problem solving has other techniques such as NLP, ML and game playing. • It also includes – sophisticated information storage, – retrieval, – information extraction, – decision-making

• The term “Problem” can be defined with following conditions: – Every problem is defined in a context. – Every problem has a well defined objective. – Solution to every problem consists of a set of activities. – Previous knowledge and domain knowledge both are used as the resources during different states in the solution process.

• General problem-solving techniques involve: – Problem definition – Problem analysis and representation – Planning – Execution – Evaluating solution – Consolidating gains

Formulating problems • A problem can be defined formally by 4 components: – Initial State: • it is the state from which our agents start solving the problem {e. i: in(A)}. – State Description: • a description of the possible actions available to the agent, it is common to describe it by means of a successor function, given state x then SUCCESSOR-FN(x) returns a set of ordered pairs <action, successor> where action is a legal action from state x and successor is the state in which we can be by applying action. • The initial state and the successor function together defined what is called state space which is the set of all possible states reachable from the initial state {e. i: in(A), in(B), in(C), in(D), in(E)}. – Goal Test: • we should be able to decide whether the current state is a goal state {e. i: is the current state is in(E)? }. – Path cost: • a function that assigns a numeric value to each path, each step we take in solving the problem should be somehow weighted, so If I travel from A to E our agent will pass by many cities, the cost to travel between two consecutive cities should have some cost measure, {e. i: Traveling from ‘A’ to ‘B’ costs 20 km or it can be typed as c(A, 20, B)}. • A solution to a problem is path from the initial state to a goal state, and solution quality is measured by the path cost, and the optimal solution has the lowest path cost among all possible solutions.

Problem formulating steps What are the conditions that would arise from actions? What is to be solved Problem Identification and problem definition What are the initial conditions? What is the specification of achievable objective? Problem space Task Knowledge State space

• Example: • The game is to change positions of the digit and blank cell of the board to arrive at new board positions. 1 2 3 2 1 (a) Initial State 3 (b) Final State • Rule: Blank cell can change the position with the digit by horizontal or vertical movement

• Solution: – Initially define the state space and the operation and action space. – Action space: move up(U), down(D), Left(L) and right(R) 1 2 L 1 2 3 2 U 3 S 0 S 1 1 3 S 2 R 2 1 3 S 3

Algorithm goes like this 1. State = initial state; existing state = state 2. While state ≠ final state i) Existing state=state ii) Apply operations from set(U, D, L, R) to each state so as to generate new states. iii) If new states ∩ existing state ≠ Ø § Existing state = existing state ∪ new states § State = new state End while

A well defined problem is described in terms of 1. Initial state 2. Goal state 3. List of states 4. Operators or functions that change state or transition of state 5. Path (sequence of states leading to goal state) 6. Path cost (functions that assign a cost to the path

Problem Types and Characteristics • Deterministic or observable – Single state problem. – It goes to defined state after any action • Non-observable – Multi-state problem – Agent does not have the information about the state – Solution is a set of states leading to a set of goal states • Non-deterministic or partially observable – The effect of the action is not clear – In every new state, some new information is added and then operator acts on the state. – Solution space is a tree structure of states – Solution is based on searching the tree and finding out the path for solution • Unknown state space – Typical exploration problems – States and impact of actions are not known

Problem Analysis and Representation • A problem representation is a complete view of the problem and approach to solve it. • The quality of solution and the appropriateness of solution mechanism rely on completeness of the problem definition. • Problem definition should satisfy : – – – Compactness Utility Soundness Completeness Generality Transparency

• Compactness – It needs to define clearly the solution space • Utility – It needs to be compatible with the existing systems. • Soundness – It should not raise false alarm • Completeness – It should not lose any information • Generality – It should be able to capture all instance of the problem and handle all similar events irrespective of changes in environment • Transparency – The reasoning behind the action taken should be visible to the user

• Problem representation with different aspects – Problem Solver: The steps of problem solving can be modeled into a system such that a machine can execute the well-defined steps and find out the solution. – Problem solver is an algorithm or a method, that accepts problem-description, domain description and boundary conditions as input, and then, searches for a solution. – The solver terminates when it finds a solution or solution space is exhausted, or meets the boundary condition that is defined in input.

• Example: tower of Hanoi – Possible states and moves are the description of the problem domain – Problem instances are the initial states and the goal states of the problem.

Solution

• Problem representation consists of domain description and solver algorithm that operates on this description • The starting point for a complete problem representation is the determination of typical knowledge structure and inter dependency among knowledge at different layers.

• The design knowledge actually controls and establishes the flow of information from different knowledge layers to execute the operations in order to reach the desired goal. • Example: There are two jugs without scale of measurement. Once can make a jug empty or fill it by pouring water in it. One of the tow jugs has 5 gal capacity. The other is smaller and has a 2 gal capacity. There is 3 gal water in the big jug and 1 gal in the smaller one. Problem: to find out a way to empty 2 gal jug and fill 5 gal jug with 1 gal water. – – –

• States: Amount of water in the jugs • Actions : 1. 2. 3. 4. Empty the big jug Empty the small jug Pour water from small jug to big jug Pour water from big jug to small jug • Goal: To get the specified amount of water (1 gal) in big jug and empty the smaller jug • Path cost: The number of actions applied. • Representation: States can be defined as the amount of water in both the jugs (b, s) • Initial state: (3, 1) • Goal state(1, 0)

Water Jug Problem (3, 2) (0, 2) (2, 0) (3, 0) (1, 2) (1, 0)


Performance Measuring • Performance is measured by four parameters: – Problem – Time – Resource and – Result • Result can be success or failure • Though success is achieved, quality of the solution is also important • The cost of the solution is measured in terms of the time and the resource cost required to find the solution.

Problem space and search • The problem is represented as the state space. • Search is a general algorithm that helps in finding the path in the state space. • The path may lead to the solution or might be dead end. • Search has two types of strategies: – Informed search • Does not guarantee a solution, but high probability of getting a solution – Uninformed search • Does not consider specific nature of the problem. It can generalize to any problem. • It generates all possible state space and checks for the goal state.

• Defining the Problem as a State Search – The goal should be properly formulated. – The states and the operators should be clearly indicated. – There should be transparency in describing the rules and they should be as generalized as possible. • Issues in Design of Search Programs – As humans, we analyze state space and identify the solution due to cognitive skills we possess. – If error occurs, back track should occur so as to evaluate the alternative path. – Hence there is a need for systematic method for traversing states in the state space.

• The following issues are observed while designing search problems: – State rep and identifying relationships among states – Proper selection of forward and backward movement to determine optimal path to goal state – Rule selection

Toy Problems • Tic-tac-toe – Formulating the problem in state - space search • Initial state: x • States: different ‘x’ and ‘o’ positions constitutes the states in the space • Operators: adding ‘x’ or ‘o’ in cells one by one • Goal: to reach the final/winning position • Path costs: each step costs 1 so that the path cost is the length of the path

• Missionaries and Cannibals – The missionaries and cannibals problem is the one, where three missionaries and three cannibals are one side of a river. – There is a boat that can hold one or two people. – We need to find a way to get everyone to the othe r side of the river without ever leaving a group of missionaries in one place out numbered by cannibals in that place. – A max of two objects can travel to other side and min of one has to be there in the boat to come back – Play the game

Solution: First let us consider that both the missionaries (M) and cannibals(C) are on the same side of the river. Left Right Initially the positions are : 0 M , 0 C and 3 M , 3 C (B) • Now let’s send 2 Cannibals to left of bank : 0 M , 2 C (B) and 3 M , 1 C • Send one cannibal from left to right : 0 M , 1 C and 3 M , 2 C (B) • Now send the 2 remaining Cannibals to left : 0 M , 3 C (B) and 3 M , 0 C Send 1 cannibal to the right : 0 M , 2 C and 3 M , 1 C (B) • Now send 2 missionaries to the left : 2 M , 2 C (B) and 1 M. 1 C • Send 1 missionary and 1 cannibal to right : 1 M , 1 C and 2 M , 2 C (B) • Send 2 missionaries to left : 3 M , 1 C (B) and 0 M , 2 C • Send 1 cannibal to right : 3 M , 0 C and 0 M , 3 C (B) • Send 2 cannibals to left : 3 M , 2 C (B) and 0 M , 1 C • Send 1 cannibal to right : 3 M , 1 C and 0 M , 2 C (B)’ • Send 2 cannibals to left : 3 M , 3 C (B) and 0 M , 0 C • Here (B) shows the position of the boat after the action is performed. Therefore all the missionaries and cannibals have crossed the river safely.

Real world Problems • Toy problems are used to illustrate different problem – solving methods and compare the performances of the algorithms. • Real – world problems tend to have a single agreed upon description. • Route Finding – Initial state: Starting point of the journey – Goal state: Final destination – Operators/ Actions: Flight from current location to reach the next location in such a way so that there is enough time to take the connecting flight. – Path cost: Travel fare, travel time, waiting time, time of the day, type of airline, etc • Travelling Salesman Problem – The objective is to find a tour with the shortest path. – The problem solving needs to cover all the cities, where each city is traversed just once minimizing the tour cost and returning back to the starting city. – Initial state: the starting city for the tour – Goal state: The complete trip ends at the starting city – Operator: Travel from one city to another with the constraint that the city is not visited before – Path cost: Travel time

• Travelling Salesman Problem (TSP): Given a set of cities and distance between every pair of cities, the problem is to find the shortest possible route that visits every city exactly once and returns to the starting point. Solution: 1) Consider city 1 as the starting and ending point. 2) Generate all (n-1)! Permutations of cities. 3) Calculate cost of every permutation and keep track of minimum cost permutation. 4) Return the permutation with minimum cost.

Problem reduction methods • It is a strategic approach to reduce complexity of a problem so as to reduce the complexity, where the problem is decomposed into sub-parts. • A general approach for solving a large and complex problem is to decompose it into some smaller problems. • Further apply this decomposition process to each of there problems iteratively till it is solved or cannot be split further.

Chapter-3 Uninformed Search

Introduction • Uninformed search is a class of general-purpose search algorithms which operates in brute forceway. • Uninformed search algorithms do not have additional information about state or search space other than how to traverse the tree, so it is also called blind search. • The term 'uninformed‘ means that they have no additional information about states beyond that provides in the problem definition.

• Building Goal-Based Agents – To build a goal-based agent we need to answer the following questions: 1. What is the goal to be achieved? 2. What are the actions? 3. What information is necessary to encode about the world to sufficiently describe all relevant aspects to solve the goal? That is, what knowledge needs to be represented in a state description to adequately describe the current state or situation of the world?

• Examples • 8 -Puzzle – Given an initial configuration of 8 numbered tiles on a 3 x 3 board, move the tiles in such a way so as to produce a desired goal configuration of the tiles. – State = 3 x 3 array configuration of the tiles on the board. – Operators: Move Blank square Left, Right, Up or Down. (Note: this is a more efficient encoding of the operators than one in which each of four possible moves for each of the 8 distinct tiles is used. ) – Initial State: A particular configuration of the board. – Goal: A particular configuration of the board.


8 -Queens Problem description • It involves placing 8 queens on the 8 x 8 x board such that no queen is attacked by the other in horizontal, vertical or diagonal direction when a new queen is place • Play the game


• Missionaries and Cannibals • Cryptarithmetic – Find an assignment of digits (0, . . . , 9) to letters so that a given arithmetic expression is true. – 1. LET + LEE = ALL , then A + L = ? Assume (E=5) • • L E T A – Ans. B • L=1 E=5 T=6 So, 156 1 5 5 (+) —— 311 ——A = 3 So, 3 + 1 = 5 ==> E – Solve : SEND + MORE = MONEY – Note: In this problem, unlike the two above, the solution is NOT a sequence of actions that transforms the initial state into the goal state, but rather the solution is simply finding a goal node that includes an assignment of digits to each of the distinct letters in the given problem.

• Remove 5 Sticks Given the following configuration of sticks, remove exactly 5 sticks in such a way that the remaining configuration forms exactly 3 squares.

• The search technique is considered to be informed and uninformed. • This differentiation is on the basis of how the search actually takes place and what knowledge or information it uses during the search. • Informed search is also called as Heuristic search.

General search algorithm 1. Searching for solutions – – – Searching for the solution is typically finding out a path or route to goal state. In the process, we enter into various intermediate steps. The basic terminology include : state space and statespace search. State space: is a collection of all possible configurations of the system. i. e. it is a set of all states that can be reached from the initial states with all possible legal actions. State space search: is the process of searching the state space for a solution to reach the goal.

General search algorithm – Let us assume that the list L comprises the nodes or the states from I. While list L is not empty or has a solution { Remove the state X from L Take the next decision for the successor. Generate a new state for each possible choice for the decision Merge/re-order the new states with L. } If L not empty (has a solution), return success. Else return failure.

2. Problem – solving Agents – An agent is an entity that can perceive the environment and act on it. – An agent formulates the goal as well as the problem. – The steps that describe the process 1. Formulate goal 2. Formulate the problem which has the goal and the initial states problem 3. Now search with the given problem sequence of actions. 4. Action on the sequence Act according to the sequence of actions.

3. Control Strategies The most common strategies used are: – • Forward search – – • Backward search – – – • From goal to a solvable initial state Method employed is goal-directed one Search begins from target city Systematic search – – – • Explore towards solution Reach a solution starting from initial state Method employed is data-directed ones Locating a city from current location in map Used when search space is small and systematic but blind It distinguishes between goal and non-goal states. Locating a particular book in library, where books are not indexed. DFS and BFS fall under this. Heuristic search – – – Based on previous experience and provides guidelines to solve the problem. Improves the efficiency of the search process. It is exploratory in nature.

Parameters for search Evaluation – Completeness • The algorithm finds an answer in some finite time. • Guaranteed to fine a solution – Space and time complexity • Addresses the memory required and the time factor in carrying out the operations – Optimal and admissibility • An algorithm or a search process is said to be optimal to get a best solution

Uninformed Search Methods • These do not have prior knowledge of the problem • They are exhaustive methods that are brut force, searching all possible paths. • As they have no absolute information, they are referred to as blind search. • Hence, we need to take a certain strategy and expand the nodes in some predefined order. • BFS and DFS are the two basic approaches of expanding and visiting nodes in the absence of any heuristic.

Breadth First Search (BFS) • • • The search tech in BFS follows the shallow node approach. From the root node, all the successors are searched across the level and expanded Queue data structure is used to carry out the search, FIFO

• Example of BFS: – Consider that A is the start state and D is the goal state, with the help of a queue.

• If for a given problem, there exists a solution, then BFS is guaranteed to find it out.

BFS (Breadth-first Search) • Breadth-first search is the most common search strategy for traversing a tree or graph. This algorithm searches breadth wise in a tree or graph, so it is called breadth-first search. • BFS algorithm starts searching from the root node of the tree and expands all successor node at the current level before moving to nodes of next level. • The breadth-first search algorithm is an example of a general-graph search algorithm. • Breadth-first search implemented using FIFO queue data structure.

• Advantages: • BFS will provide a solution if any solution exists. • If there are more than one solutions for a given problem, then BFS will provide the minimal solution which requires the least number of steps. • Disadvantages: • It requires lots of memory since each level of the tree must be saved into memory to expand the next level. • BFS needs lots of time if the solution is far away from the root node.


Uniform Cost Search • Uniform-cost search is a searching algorithm used for traversing a weighted tree or graph. • This algorithm comes into play when a different cost is available for each edge. • The primary goal of the uniform-cost search is to find a path to the goal node which has the lowest cumulative cost. • Uniform-cost search expands nodes according to their path costs form the root node. • It can be used to solve any graph/tree where the optimal cost is in demand. • A uniform-cost search algorithm is implemented by the priority queue. • It gives maximum priority to the lowest cumulative cost. • Uniform cost search is equivalent to BFS algorithm if the path cost of all edges is the same.

• Advantages: – Uniform cost search is optimal because at every state the path with the least cost is chosen. • Disadvantages: – It does not care about the number of steps involve in searching and only concerned about path cost. Due to which this algorithm may be stuck in an infinite loop.


Depth-first Search(DFS) • Depth-first search is a recursive algorithm for traversing a tree or graph data structure. • It is called the depth-first search because it starts from the root node and follows each path to its greatest depth node before moving to the next path. • DFS uses a stack data structure for its implementation. • The process of the DFS algorithm is similar to the BFS algorithm. Backtracking is an algorithm technique for finding all possible solutions using recursion.

• Advantages: – DFS requires very less memory as it only needs to store a stack of the nodes on the path from root node to the current node. – It takes less time to reach to the goal node than BFS algorithm (if it traverses in the right path). • Disadvantages: – There is the possibility that many states keep re-occurring, and there is no guarantee of finding the solution. – DFS algorithm goes for deep down searching and sometime it may go to the infinite loop.

• Example: – In the below search tree, we have shown the flow of depth-first search, and it will follow the order as: Root node--->Left node ----> right node. – It will start searching from root node S, and traverse A, then B, then D and E, after traversing E, it will backtrack the tree as E has no other successor and still goal node is not found. – After backtracking it will traverse node C and then G, and here it will terminate as it found goal node.

Depth-Limited Search Algorithm • A depth-limited search algorithm is similar to depth-first search with a predetermined limit. • Depth-limited search can solve the drawback of the infinite path in the Depth-first search. • In this algorithm, the node at the depth limit will treat as it has no successor nodes further. • Depth-limited search can be terminated with two Conditions of failure: – Standard failure value: It indicates that problem does not have any solution. – Cutoff failure value: It defines no solution for the problem within a given depth limit. • Advantages: – Depth-limited search is Memory efficient. • Disadvantages: – Depth-limited search also has a disadvantage of incompleteness. – It may not be optimal if the problem has more than one solution.


Iterative deepening Search • The iterative deepening algorithm is a combination of DFS and BFS algorithms. • This search algorithm finds out the best depth limit and does it by gradually increasing the limit until a goal is found. • This algorithm performs depth-first search up to a certain "depth limit", and it keeps increasing the depth limit after each iteration until the goal node is found. • This Search algorithm combines the benefits of Breadth-first search's fast search and depth-first search's memory efficiency. • The iterative search algorithm is useful uninformed search when search space is large, and depth of goal node is unknown. • Advantages: – Itcombines the benefits of BFS and DFS search algorithm in terms of fast search and memory efficiency. • Disadvantages: – The main drawback of IDDFS is that it repeats all the work of the previous phase.

1'st Iteration-----> A 2'nd Iteration----> A, B, C 3'rd Iteration------>A, B, D, E, C, F, G 4'th Iteration------>A, B, D, H, I, E, C, F, K, G In the fourth iteration, the algorithm will find the goal node.

Bidirectional Search Algorithm • Bidirectional search algorithm runs two simultaneous searches, one form initial state called as forward-search and other from goal node called as backward-search, to find the goal node. • Bidirectional search replaces one single search graph with two small sub-graphs in which one starts the search from an initial vertex and other starts from goal vertex. • The search stops when these two graphs intersect each other. • Bidirectional search can use search techniques such as BFS, DLS, etc. • Advantages: – Bidirectional search is fast. – Bidirectional search requires less memory • Disadvantages: – Implementation of the bidirectional search tree is difficult. – In bidirectional search, one should know the goal state in advance.

• Example: • In the below search tree, bidirectional search algorithm is applied. This algorithm divides one graph/tree into two sub-graphs. • It starts traversing from node 1 in the forward direction and starts from goal node 16 in the backward direction. • The algorithm terminates at node 9 where two searches meet.

• The types of uninformed search algorithms: 1. 2. 3. 4. 5. 6. Breadth-first Search Depth-limited Search Iterative deepening depth-first search Uniform cost search Bidirectional Search

End of Unit-1
- Slides: 104