You are on page 1of 22

Artificial Intelligence

Instructor

Rana Muhammad Ashfaq


Lecture # 03

What is Search Theory


To go or look through (a place, area, etc.) carefull y in order find something missing or lost To make a thorough examination of; look over carefully in order to find something; explore. search theory studies an individual's optimal strategy when choosing from a series of potential opportunities of random quality, under the assumption

Solving Problem by Search What is problem


LEARNING IN THE everyday world, where people live and work , have many problems. In homes, businesses , organizations, and societies in every culture, learning is driven by problems that need solving. How do I pay for a new car? Which schools should my children attend? How do we design a new marketing campaign to address a target market? How do we make peace with our enemies? How do we raise funds to support municipal services? A problem is an unknown entity in some context (the difference between a goal state and a current state). Finding or solving for the unknown must have some social, cultural, or knowledgeable value. There are a number of variable attributes of problems. Problems vary in knowledge needed to solve them, the form they appear in, and the processes needed to solve them.

Problem Solving

Problem Solving
Problem solving is a mental process and is part of the larger problem process that includes problem finding and problem determining.

Problem-solving is a mental process that involves discovering, analyzing and solving problems.
Problem solving is the process of applying previously acquired knowledge to obtain a satisfactory solution to new and unfamiliar problems.

Problem Solving
Representing the problem includes calling up the appropriate context knowledge, and identifying the goal and the relevant starting conditions for the problem.

Solution search includes refining the goal and developing a plan of action to reach the goal.
Implementing the Solution includes executing the plan of action and evaluating the results. One kind of goal-based-agent is Problem Solving agent. Goal based agent that use more advanced factored or structured representation are usually called planning agents. Problem solving is a process of generating the solutions Problem solving has Initial State and Goal state that specify set of Rules and describe the Action (Operations)

The Steps in Problem-Solving


In order to correctly solve a problem, it is important to follow a series of steps. Many researchers refer to this as the problem-solving cycle (Sternberg, 2003), which includes developing strategies and organizing knowledge. Identifying the Problem: While it may seem like an obvious step, identifying the problem is not always as simple as it sounds. In some cases, people might mistakenly identify the wrong source of a problem, which will make attempts to solve it inefficient or even useless. Defining the Problem: After the problem has been identified, it is important to fully define the problem so that it can be solved. Forming a Strategy: The next step is to develop a strategy to solve the problem. The approach used will vary depending upon the situation and the unique preferences of the individual. Organizing Information: Before coming up with a solution, we need to first organize the available information. What do we know about the problem? What do we not know? The more information that is available, the better prepared we will be to come up with an accurate solution.

Contiu.
Allocating Resources: Of course, we don't always have unlimited money, time and other resources to solve a problem. Before you begin to solve a problem, you need to determine how high priority it is. If it is an important problem, it is probably worth allocating more resources to solving it. If, however, it is a fairly unimportant problem, then you do not want to spend too much of your available resources into coming up with a solution. Monitoring Progress: Effective problem-solvers tend to monitor their progress as they work towards a solution. If they are not making good progress toward reaching their goal, they will reevaluate their approach or look for new strategies.

Evaluating the Results: After a solution has been reached, it is important to evaluate the results to determine if it is the best possible solution to the problem. This evaluation might be immediate, such as checking the results of a math problem to ensure the answer is correct, or it can be delayed, such as evaluating the success of a therapy program after several months of treatment.

Solving Problem by Searching


The process of looking for a sequence of actions that reaches the goal is called search. A search algorithm takes a problem as input and returns a solution in the form of an action sequence. Once a solution is found, the actions it recommends can be. This is called the execution phase. Goal formulation, based on the current situation and the agents performance measure, is the first step in problem solving.

Problem formulation is the process of deciding what actions and states to consider, given a goal.
We will assume the environment is known, so that the agent knows which states are reached by each action

if we assume that the environment is deterministic, so that each action has exactly one outcome.

Example: Romania

On holiday in Romania; currently in Arad. Flight leaves tomorrow from Bucharest Formulate goal:

be in Bucharest

Formulate problem:

states: various cities actions: drive between cities sequence of cities, e.g., Arad, Sibiu, Fagaras, Bucharest

Find solution:

An example

Example
Our agent has now adopted the goal of driving to Bucharest, and is considering where to go from Arad. There are three roads out of Arad, one toward Sibiu, one to Timisoara, and one to Zerind. But suppose the agent has a map of Romania. The point of a map is to provide the agent with information about the states it might get itself into, and the actions it can take. The agent can use this information to consider subsequent stages of a hypothetical journey via each of the three towns, trying to find a journey that eventually gets to Bucharest

Formulating problems

Finding Path
Suppose you are in the middle of a forest with 50 different potential routes in front of you, you have almost no energy and need to find the best way out, how would you do it? One option would be to follow each of the 50 routes; a trial and error method. You will certainly get out but that would take too much time. This isnt a new problem and many people have come up with ideas of how to solve it. One of them was Edsger W. Dijkstra who developed an algorithm to get the shortest path given a graph, a source and a target. Before we can start solving the problem, we must create those elements, the graph which contains all the information, the nodes which are the waypoint of the graph, and the edges that connect the nodes. Think of it as the graph being a map: the nodes are the cities and the edges the highways that connect them.

Finding Path

State Transition Diagrams (STD's)


An STD is a way of describing the timedependent behavior of a system.
Until recently, models of a systems time-dependent behavior were important only for a special category of systems known as real-time systems. Examples of these systems are process control, telephone switching systems, high-speed data acquisition systems, and military command and control systems

Breadth-first search
Breadth-first search is a simple strategy in which the root node is expanded first, then all the successors of the root node are expanded next, then their successors, and so on. In general, all the nodes are expanded at a given depth in the search tree before any nodes at the next level are expanded. Breadth-first search is an instance of the general graph search algorithm. This is achieved very simply by using a FIFO queue for the frontier.

Breadth-first search Algorithm


function BREADTH-FIRST-SEARCH( problem) returns a solution, or failure node a node with STATE = problem.INITIAL-STATE, PATH-COST = 0 if problem.GOAL-TEST(node.STATE) then return SOLUTION(node) frontier a FIFO queue with node as the only element explored an empty set loop do if EMPTY?( frontier ) then return failure node POP( frontier ) /* chooses the shallowest node in frontier */ add node.STATE to explored for each action in problem .ACTIONS(node.STATE) do child CHILD-NODE( problem , node, action) if child .STATE is not in explored or frontier then do if problem .GOAL-TEST(child .STATE) then return SOLUTION(child ) frontier INSERT(child , frontier ) Breadth-first search on a graph.

Depth-first search
Depth-first search always expands the deepest node in the current frontier of the search tree. The search proceeds immediately to the deepest level of the search tree, where the nodes have no successors. As those nodes are expanded, they are dropped from the frontier, so then the search backs up to the next deepest node that still has unexplored successors. depth-first search uses a LIFO queue

Depth-first search Algoritm


function DEPTH-LIMITED-SEARCH( problem, limit ) returns a solution, or failure/cutoff return RECURSIVE-DLS(MAKE-NODE(problem.INITIAL-STATE), problem, limit ) function RECURSIVE-DLS(node, problem , limit ) returns a solution, or failure/cutoff if problem.GOAL-TEST(node.STATE) then return SOLUTION(node) else if limit = 0 then return cutoff else cutoff occurred ? false for each action in problem .ACTIONS(node.STATE) do child CHILD-NODE( problem , node, action) result RECURSIVE-DLS(child , problem , limit 1) if result = cutoff then cutoff occurred ? true else if result = failure then return result if cutoff occurred ? then return cutoff else return failure

Informed Search And Exploration


One that use Problem-specific
Informed search tries to reduce the amount of search that must be done by making intelligent choices for the nodes that are selected for expansion.

A search strategy which searches the most hopeful branches of the state-space first can:

find a solution more quickly, find solutions even when there is limited time available, often find a better solution, since more profitable parts of the state-space can be examined, while ignoring the unprofitable parts.

A search strategy which is better than another at identifying the most promising branches of a search-space is said to be more informed.

You might also like