Unit II Problem Solving and building smart systems
Unit -II Problem Solving and building smart systems
Introduction • AI is used for wide variety of applications • Problem solving is the fundamental approach for AI based applications • Problem solving approach means is an area to deal with finding answers for some unknown situations • It involves understanding, representation formulation and solving
• This simple definition involves two types of problems • Simple • Complex • Simple problem are the ones that are or can be solved by a deterministic procedure • There is a guarantee of a solution • Ex Solving a quadratic equation • In the real world problems are complex • There is lack of full information so the problems with such a data are complex problems • Ex Robot
• Main objective of problem solving is to find out set of actions so as to reach the set goal • To do this task we must have some sort of search • Search is nothing but the method for problem solving • so the important approach of problem solving in search in an action space • Action space consist of a set of actions that leads to some specific goal • The method of solving can be categorized as follows • General purpose • Special purpose
• It is applicable for wide variety of problems and it is means-ends analysis • In means-ends analysis 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 a particular problem is modelled with various assumptions which are specific to that problem
• Some times problem solving system behaves like expert Who has gathered knowledge on a specific area over a period of time • Expert uses this knowledge to relate to the current situation and derives analogy to find out the best possible solutions • In AI approach, algorithm using historical knowledge can be treated as expert • Ex diagnosis of a disease the doctors feed the diagnosis process and the disease related symptoms • This helps in building the knowledge base of diagnosis process and symptoms • Problem solving can also assist in planning and decision making • Planning and decisions are the key parts of an intelligent systems
Problem Solving process Problem identification Explore information Create KB Action selection Intermediate states Problem solving process Problem solving is a process of generating solutions for a given situation This process consist of sequence of well defined methods that can handle doubts or inconsistency issues, uncertainty ambiguity and help in achieving the desired goal Goal state
• The word problem encompasses computational tasks also • Ex solving a quadratic equation, then the process involves computation to arrive at a solution • But in AI problem is formulated and solved by searching for a solution in space of possible solution • So in AI we can define the problem as • 1. every problem is defined in a context, it has certain assumptions under initial conditions • 2. Every problem has well defined objectives • 3. solution to every problem consists of a set of activities. Each activity changes the state of problem that is from the present state to the new state • This new state is closer to the solution state • Finally initial state approaches the goal situation
• But there are many real world problems that cannot be solved if they are open for generic solution • But it is limited to certain environment it is solvable • Every problem needs different treatment depending on the goal, initial information and assumptions • General problem solving techniques involve the following • 1. Problem definition • 2. Problem analysis and representation • 3 Planning • 4. Execution • 5. Evaluating solutions • 6. Consolidating gains
Formulating Problems • Identification of problem is the first step in problem solving process What is to be solved What are the conditions that would arise from action What are the initial conditions Problem Identification and problem definition What is the specification of achievable objective
• Once the problem is identified we need to be very precise and specific with respect to the problem space along with the target that we need to achieve • At this stage we also define the assumptions or limitations of the solution • The next important step here is the analysis and representation of the task knowledge
• We understand the problem in terms of diagrams description and so on. • But in AI to solve the problem we use machine • Once the solution is planned and fed to it • This is done using state space diagram • So the problem is defined in terms of states • Each state is the abstraction of all available information • Solution to any problem is the collection of such different states and set of operation • The collection of states is termed as state space • During problem solving process an operator is applied to a state to move it to the next state • Then another operator is applied and so on till the final state is achieved • This approach of generating a solution is called state space method
• • • There actually two ways to solve the problem The first solution start with up, whereas the second starts with left The left move leads us to the goal in lesser number of steps than that of the up move(as the initial move) With each state change, the state is compared with goal state The puzzle discussd is simple but it gets complicated when the digits are increased Algorithm
Problem types and characteristics • Problems can be categorized into different types • 1. Deterministic or observable – Termed as single state – Fully observable and it goes to one definite state after any action – Goal state is reachable in one single action or sequence of actions • Ex. Vacuum cleaner
Non-observable • Problem comes under multiple state problems • Problem solving agent does not have any information about the state • After the application of operator each state goes to a number of states • Solution is the set of states leading to a set of goal states
Non-deterministic or partially observable • The effect of 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 • Unknown state space problems are typically exploration problems • States and impact actions are not known • There is a need to discover to understand the outcomes of actions
Problem Analysis and representation • A problem definition is the complete view of the problem and approach to solve it • The performance of any intelligent system depends on the problem representation and formulation • A representation is the complete view of a problem or set of problems and an approach to solve these problems
• The problem representation is an important step to understand before we start solving the problem The quality of solution and the appropriateness of solution mechanism rely on completeness of the problem definition Problem definition should satisfy the following criteria
Problem representation with different aspects • Problem representation is very critical and important in problem solving • First it needs machine language so as to describe the logic and specific encoding rules for the problems • Problems needs to be mapped into a solution space that is actually expanded during the solution process or it can be in the form of a state space that has all the feasible states and transitions • A representation comprising data structures and programs executing on them to derive inference can also be a different view in the representation
• Problem: T o find out a way to empty 2 gal jug and fill 5 gal jug with 1 gal jug water • Steps • First convert it into a state space so define states actions and goals • States: amt of water in the jugs • Actions: 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 in abig jug and empty the smaller jug • Path Cost: the number of actions applied
• Once we have the problem formulated, the next step is to represent • The states and the operators are to be precisely defined so that they can programmed and executed • Problem representation includes initial condition, initial values, dependencies among the states and the variable • When these parameters are defined we say that problem is well defined • Representation: states can be defined as the amount of water in the bigger jug and s is the amount of water in the smaller jug. • Initial state(5, 2) • Goal state(1, 0) • operators : these are as follows – – Empty big Empty small Big is empty Small is empty • Goal state is achieved with the action of sequence 2, 4, 2, 4 and 2
Performance measuring • The performance is depend on different things • There are three outcomes of a problem solver finding a solution, terminating with failure after search space is exhausted and hitting a time bound like terminating after certain number of iterations or trials. • When it comes to performance gain, it can be measured by four parameters • Problem, time, resource and result
• Problem space and search • Problem is represented as the state space • Search is a general algorithm that helps in finding the path in the state space • Every problem can be solved by search • It considers one or more path • The path may lead to the solution or might be dead end. • In case of dead end , backtrack should occur • The search algorithm, make use of control stategy like that of forward or backward search • It needs to identify and adopt a strategy to explore the states • In broader sense, there are two types of strategies • Informed search • Uninformed search
• Informed search does not guarantee a solution, but there is high probability of getting a solution • In this approach a, heuristic that is specific to the problem is used to control the flow of solution path. • In case of uninformed search it does not consider specific nature of the problem • This strategy is very simple and can be generalized to any problem.
Defining a problem as state space search • The problem in hand can be solved by searching the state space to find out the path that leads to a final state from the initial state • The basic notion behind the state space search is that we can solve the given problem by checking the steps considering the fact that they might lead towards the solution • While defining the problem as a state space search the goal should be properly formulated • There should be transparency in describing the rules and they should be as generalized
Issues in design of search programs In problem solving we apply search Search leads to a goal state Result is depend on the search process Search technique guide to reach to a solution in the space • The way we have obtained solution for the big problems by applying rules, the entire path is said to be solution path • •
• When we are having a search program implemented to solve the problem along with the direction of search the other factors that need to highlighted is the selection f the rules • Which rule should be applied so as o reached to the goal state • Following are some of the issues while designing search problem • 1. State representation and identifying relationships among states • 2. proper selection of forward and backward movements to determine optimal path to goal state • Rule selection
TOY PROBLEMS Toy problems are not real world problems They are generated for fun These problems are played on board or paper Hence the problem environment is controlled So the problem formulation is possible All boundary conditions and the constraints are known • So it easier to convert to computer programs • Ex. 8 -puzzle, tic-tac-toe • • •
Tic-Tac-Toe problem Well known pencil and paper game For two players X and O Each player mark a 3*3 grid by X and O in turn The game start with X and ends with win, loss or draw • The player who puts respective mark in horizontal, vertical or diagonal line wins the game • If played without fault then leads to draw • •
• We start formulation of the game as a problem that can be solved by search strategy • By this it is possible to convert into computer program • Consider the rules say the rule to put X and O in the cell • Game gets over when either X or O are at the diagonal positions
Initial state: start with putting X in any cell States: different X and O positions constitute the states in the space Operators: adding X or O in cell one by one Goal: to reach the final/winning position Path cost: Each steps costs 1 so that the path cost is the length of the path
Missionaries and Cannibals problems • The missionaries and cannibals problem is the one where three missionaries and three cannibals are on 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 other side of the river without ever leaving a group of missionaries in one place outnumbered by cannibals in that place • A maximum of two objects can travel to other side and minimum of one has to be there in the boat to come back
• First steps to solve the problem is to find out the operators that involve taking one or two people from one side to another in the boat • A state represent the time when missionaries and cannibals are in the boat or on the other side • Bcoz boat can hold only two people, there is no question of outnumbering • But the crossings are important • So here constraints are required while applying the operators
Real world problems 1. Route Finding Route finding is defined in terms of specified locations and transitions along links between them Route finding algorithms are used widely in a variety of applications like automated travel advisory systems, airline travel planning, car systems that provide directions and so on
Airline Travel Planning • This problem is solved by automated travel advisory system • Objective is to arrive to a destination with minimum cost • Each state comprises airport location and the current path
• Initial state: Starting point of the journey • Goal state: Final destination • Operators or Actions: flight from current location to reach the next location in such a way that there is enough time difference in the next flight and in transfer within the airport if there is a connecting flight • Path cost: total of travel fare, travel time, waiting time, time of day type of airline
Travelling salesman problem • Initial state: The starting city for the tour is Cs • Goal state: the complete trip ends at Ce • Operator: travel from one city to another with the constraint that the city is not visited before • Path cost: travelling time
Problem reduction method • Problem reduction is the strategic approach to reduce complexity of a problem • A general approach for solving a large and complex problem as to decompose it into smaller problems • Further apply the decomposition process in each of these problems iteratively till they get solved easily or they can be split. • This paradigm of problem solving is called problem reduction
Uninformed search • For every problem we are in search of solution • Solution is typically a state where all requirements are fulfilled • Referred as goal state • AI problem focuses on the use of intelligence to reach an optimal goal state • Search technique is the core of AI problems • The problems that can be addressed by the search techniques fall under the categories of Agent based path finding problems, two player games and constraint satisfaction problems
• 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 which is also called as heuristic search • uninformed search many times referred as blind search or no-heuristic search
General search algorithm • Searching for solution is typically finding out a path or route to goal state • While doing this we enter into various states • It can be referred as an intermediate step during the course of search • In generalized term a state space is defined as the collection of all possible configuration of the system • A state space is represented as [S, A, I, G]
• S is the set of nodes or the states fro a given problem to reach to solution • A is the set of arcs • I is the set of initial states • G goal state • Set A corresponds to the steps required for problem solving • A state space search is the process of searching the state space for a solution to reach the goal • Remember that every node represents a partial path
• Generalized search algorithm • For any problem P we have the set of initial states I, set of goal states G • We start from the initial state and proceed till either we get a solution or return to failure • Let the list L comprises the nodes or the states from I • The algorithm is described as follows
• • • 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/reorder the new states with L } If L not empty(has a solution)return success Else return failure
Problem solving Agents • A agent can be termed as an entity that can perceive the environment and act on it • Agent has an ability to perceive environment and act according to the situation to produce the required results • An agent formulates the goal as well as problem • These are the basic steps that are required for solving any problem • Then actual search method comes into picture • In search agent determines the possible set or rather sequence of actions • This process is carried out so that it can help the agent itself in reaching the states that can ultimately lead to goal state
• Search algorithm takes the input of the problem and outputs a solution, which here is an action sequence, that the agent executes finally • The following steps 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
Control Strategies • How to reach or what way to follow while searching for solution is still remaining • Control strategies are the ones that define this way • Rules paly very important role in decision making where and which rule is to be applied is decided based on the search strategy • Search strategy deals with overall rules and approach towards searching • The most common strategies used
• Forward Search • The strategy here is to explore towards a solution • The main aim is to reach a solution starting from initial state • The methods employing this strategy are often referred to as data directed ones • Search expedition begins from current position. • Ex. Locating a city from current location in map
• Backward search • The strategy proceeds, from goal to a solvable initial state • It could be to a solvable sub-problem or a state • Here the methods employing this strategy are referred to as goal directed ones • Unlike in forward search, if your search begins from target city, it can be termed as backward search
• Systematic search • A systematic strategy is used when the search space is small and systematic, but blind • It is blind bcoz search has no information about its domain • DFS and BFS are the two most common methods falling in this category • They also belong to the category of uninformed search.
• Heuristic search • Heuristic is typically a technique based on previous experience and provides guidelines to solve the problems. • It a is a technique that improvesthe efficiency of a search process
Parameters for search evaluation • Completeness: the algorithm said to be complete if it is guaranteed to find a solution • Space and Time complexity: with sace and time complexity, we address the memory required and the time factors in term of operations carried out • Optimality and admissibility: optimality actually tells us how the good solution is
Breadth First Search • The search technique in BFS follows the shallow node approach • The basic idea is that across the level of the tree, all nodes are searched • It is a search technique where 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)
• From the example it is clear that each time you add a node , its children are to be added at the end of the queue as it proceeds level-wise • In the Ex. the goal state lies at the last level, each and every node or state is traversed and added to the queue
BFS algorithm • 1. Create a node-list(Queue) that initially contains the first node • Do till a goal state is found • Remove X from node list. if node list is empty then exit • Check if this is goal state • If yes, return state • If not get the next level nodes i. e. nodes reachable from the parent and add to node list
Time and Space complexity • Let us assume that b is a branching factor rather than the number of successors at every level and d is the depth • Then the time complexity will be O(bd) And the space complexity is O(bd) as every node is saved in the memory Hence the search is not feasible when you havea large search space.
- Slides: 67