0% found this document useful (0 votes)
387 views14 pages

Ai Search Strategies

Iterative deepening search combines the benefits of breadth-first and depth-first search while avoiding their drawbacks. It explores the search space in increasing depths like depth-first search, using modest memory. But it is complete and optimal like breadth-first search, avoiding getting stuck in dead ends. While it may expand some nodes multiple times, this overhead is typically small since most nodes are at the bottom of the tree. So iterative deepening performs well in large search spaces where the solution depth is unknown.

Uploaded by

Agni Dev
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
387 views14 pages

Ai Search Strategies

Iterative deepening search combines the benefits of breadth-first and depth-first search while avoiding their drawbacks. It explores the search space in increasing depths like depth-first search, using modest memory. But it is complete and optimal like breadth-first search, avoiding getting stuck in dead ends. While it may expand some nodes multiple times, this overhead is typically small since most nodes are at the bottom of the tree. So iterative deepening performs well in large search spaces where the solution depth is unknown.

Uploaded by

Agni Dev
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 14

Search Strategies

[ Describe a state space in which iterative deepening search performs much worse than depth-first search (for example, O(n2) vs. O(n)). Consider a domain in which every state has a single successor, and there is a single goal at depth n. Then depth-first search will find the goal in n steps, whereas iterative deepening search will take 1 + 2 + 3 + + n = O(n2) steps.]

We will evaluate search strategies in terms of four criteria:


Completeness: is the strategy guaranteed to find a solution when there is one? Time complexity: how long does it take to find a solution? Space Complexity: how much memory is required to perform the search? Optimality: does the search strategy find the highest quality solution when there are multiple solutions?

Uninformed (or blind) search strategies have no information about the number of steps or the path cost from the current state to the goal. In a route finding problem, given several choices of cities to go to next, uniformed search strategies have no way to prefer any particular choices. Informed (or heuristic) search strategies use considerations to prefer choices. For example, in the route finding problem with a map, if a choice is in the direction of the goal city, prefer it. Even though uninformed search is less effective than heuristic search, uninformed search is still important because there are many problems for which information used to make informed choices is not available. We now present six uninformed search strategies: Breadth-first search In this strategy, the root node is expanded first, then all of the nodes generated by the root are expanded before any of their successors. Then these successors are all expanded before any of their successors.

In general, all the nodes at depth d in the search tree are expanded before any nodes at d+1. This kind of search can be implemented by using the queuing function ENQUEUEAT-END.

Breadth-first search is complete and optimal provided the path cost is a nondecreasing function of the depth of the node. Lets look at the amount of time and memory it requires. Consider a hypothetical search tree with b successors for every node. Such a tree is said to have a branching factor of b. If the first solution is a depth d, then the maximum number of nodes expanded before reaching a solution is 1+b+b2+b3+...+bd. This is not good. For example consider the following table for b=10, 1 node/ms, 100 bytes/node:

Note that memory requirements are a bigger problem here than execution time. In general, exponential complexity search problems cannot be solved for any but the smallest instances. Uniform cost search (Dijkstra's Algorithm) Depth-first search This search strategy always expands one node to the deepest level of the tree. Only when a dead-end is encountered does the search backup and expand nodes at shallower levels.

This strategy can be implemented by calling GENERAL-SEARCH with a queuing function that always puts the newest node on the front ( ENQUEUE-AT-FRONT) Depth-first search has modest memory requirements, storing only a single path from root to the current node along with the remaining unexpanded sibling nodes for each node on 2

the path. For a state space with branching factor b and maximum depth m, depth first search requires storage of only bm nodes, in contrast to bd for breadth-first search. Using the same assumptions as our analysis of breadth-first search, depth-first search would require 12 kilobytes instead of 111 terabytes at depth 12, a factor of 10 billion times less space. For problems that have a lot of solutions, depth-first search is often faster than breadthfirst search because it has a good chance of finding a solution after exploring only a small portion of the search space. However, depth-first search can get stuck on a wrong path in infinite search spaces. It is common to implement depth-first search with a recursive function that calls itself on each of its children in turn. In this case, the queue is stored implicitly in the local state of each invocation on the calling stack. Depth-limited search This strategy avoids the pitfalls of depth-first search by imposing a cut-off on the maximum depth of a path. Depth-first search is used to search to the given depth. Depth-limited search is complete but non optimal and if we choose a depth-limit that is too shallow its not even complete. Iterative deepening search The hard part about depth-limited search is picking the right depth limit. Most of the time we will not know what to pick for a depth limit. Iterative deepening search is a strategy that side-steps the issue of choosing the depth limit by trying all possible limits in increasing order.

In effect, this search strategy keeps the best features of both breadth-first and depth-first search. It has the modest memory requirements of depth-first search but is optimal and complete like breadth-first search. Also it does not get stuck in dead ends.

Iterative deepening may seem wasteful because many states are expanded multiple times. For most problems, however, the overhead of this multiple expansion is actually rather small because a majority of the nodes are at the bottom of the tree.

So instead of: 1+b+b2+...+bd-2+bd-1+bd we have: (d+1)1+(d)b+(d-1)b2+...+(3)bd-2+(2)bd-1+bd For b=10 and d=5, the numbers are 111,111 and 123,456. So iterative deepening is 11% more costly than depth-limited in this case. In terms of complexity numbers, iterative deepening has the same asymptotic complexity as breadth-first, but has space complexity O(bd). In general, iterative deepening is the preferred search method when there is a large search space and the depth of the solution is unknown. 2. General Learning Model. General Learning Model: - AS noted earlier, learning can be accomplished using a number of different methods, such as by memorization facts, by being told, or by studying examples like problem solution. Learning requires that new knowledge structures be created from some form of input stimulus. This new knowledge must then be assimilated into a knowledge base and be tested in some way for its utility. Testing means that the knowledge should be used in performance of some task from which meaningful feedback can be obtained, where the feedback provides some measure of the accuracy and usefulness of the newly acquired knowledge. General Learning Model

general learning model is depicted in figure 4.1 where the environment has been included as a part of the overall learner system. The environment may be regarded as either a form of nature which produces random stimuli or as a more organized training source such as a teacher which provides carefully selected training examples for the learner component. The actual form of environment used will depend on the particular learning paradigm. In any case, some representation language must be assumed for communication between the environment and the learner. The language may be the same representation scheme as that used in the knowledge base (such as a form of predicate calculus). When they are hosen to be the same, we say the single representation trick is being used. This usually results in a simpler implementation since it is not necessary to transform between two or more different representations. For some systems the environment may be a user working at a keyboard . Other systems will use program modules to simulate a particular environment. In even more realistic cases the system will have real physical sensors which interface with some world environment. Inputs to the learner component may be physical stimuli of some type or descriptive , symbolic training examples. The information conveyed to the learner component is used to create and modify knowledge structures in the knowledge base. This same knowledge is used by the performance component to carry out some tasks, such as solving a problem playing a game, or classifying instances of some concept. given a task, the performance component produces a response describing its action in performing the task. The critic module then evaluates this response relative to an optimal response. Feedback , indicating whether or not the performance was acceptable , is then sent by the critic module to the learner component for its subsequent use in modifying the structures in the knowledge base. If proper learning was accomplished, the systems performance will have improved with the changes made to the knowledge base. The cycle described above may be repeated a number of times until the performance of the system has reached some acceptable level, until a known learning goal has been 5

reached, or until changes ceases to occur in the knowledge base after some chosen number of training examples have been observed. There are several important factors which influence a systems ability to learn in addition to the form of representation used. They include the types of training provided, the form and extent of any initial background knowledge , the type of feedback provided, and the learning algorithms used. The type of training used in a system can have a strong effect on performance, much the same as it does for humans. Training may consist of randomly selected instance or examples that have been carefully selected and ordered for presentation. The instances may be positive examples of some concept or task a being learned, they may be negative, or they may be mixture of both positive and negative. The instances may be well focused using only relevant information, or they may contain a variety of facts and details including irrelevant data. There are Many forms of learning can be characterized as a search through a space of possible hypotheses or solutions. To make learning more efficient. It is necessary to constrain this search process or reduce the search space. One method of achieving this is through the use of background knowledge which can be used to constrain the search space or exercise control operations which limit the search process. Feedback is essential to the learner component since otherwise it would never know if the knowledge structures in the knowledge base were improving or if they were adequate for the performance of the given tasks. The feedback may be a simple yes or no type of evaluation, or it may contain more useful information describing why a particular action was good or bad. Also , the feedback may be completely reliable, providing an accurate assessment of the performance or it may contain noise, that is the feedback may actually be incorrect some of the time. Intuitively , the feedback must be accurate more than 50% of the time; otherwise the system carries useful information, the learner should also to build up a useful corpus of knowledge quickly. On the other hand, if the feedback is noisy or unreliable, the learning process may be very slow and the resultant knowledge incorrect. 3. Problem Solving Vs Planning. Problem Solving vs. Planning A simple planning agent is very similar to problem-solving agents in that it constructs plans that achieve its goals, and then executes them. The limitations of the problemsolving approach motivates the design of planning systems.

To solve a planning problem using a state-space search approach we would let the: initial state = initial situation goal-test predicate = goal state description successor function computed from the set of operators once a goal is found, solution plan is the sequence of operators in the path from the start node to the goal node In searches, operators are used simply to generate successor states and we can not look "inside" an operator to see how its defined. The goal-test predicate also is used as a "black box" to test if a state is a goal or not. The search cannot use properties of how a goal is defined in order to reason about finding path to that goal. Hence this approach is all algorithm and representation weak. Planning is considered different from problem solving because of the difference in the way they represent states, goals, actions, and the differences in the way they construct action sequences. Remember the search-based problem solver had four basic elements: Representations of actions: programs that develop successor state descriptions which represent actions. Representation of state: every state description is complete. This is because a complete description of the initial state is given, and actions are represented by a program that creates complete state descriptions. Representation of goals: a problem solving agent has only information about it's goal, which is in terms of a goal test and the heuristic function. Representation of plans: in problem solving, the solution is a sequence of actions. In a simple problem:

"Get a quart of milk and a bunch of bananas and a variable speed cordless drill" for a problem solving exercise we need to specify: Initial State: the agent is at home without any objects that he is wanting. Operator Set: everything the agent can do. Heuristic function: the # of things that have not yet been acquired. Problems with Problem solving agent: It is evident from the above figure that the actual branching factor would be in the thousands or millions. The heuristic evaluation function can only choose states to determine which one is closer to the goal. It cannot eliminate actions from consideration. The agent makes guesses by considering actions and the evaluation function ranks those guesses. The agent picks the best guess, but then has no idea what to try next and therefore starts guessing again. It considers sequences of actions beginning from the initial state. The agent is forced to decide what to do in the initial state first, where possible choices are to go to any of the next places. Until the agent decides how to acquire the objects, it can't decide where to go.Planning emphasizes what is in operator and goal representations. There are three key ideas behind planning:to "open up" the representations of state, goals, and operators so that a reasoner can more intelligently select actions when they are needed the planner is free to add actions to the plan wherever they are needed, rather than in an incremental sequence starting at the initial state

most parts of the world are independent of most other parts which makes it feasible to take a conjunctive goal and solve it with a divide-and-conquer strategy

4. Time complexity, space complexity, and the O-notation

Time complexity
How long does this sorting program run? It possibly takes a very long time on large inputs (that is many strings) until the program has completed its work and gives a sign of life again. Sometimes it makes sense to be able to estimate the running time before starting a program. Nobody wants to wait for a sorted phone book for years! Obviously, the running time depends on the number n of the strings to be sorted. Can we find a formula for the running time which depends on n? Having a close look at the program we notice that it consists of two nested for-loops. In both loops the variables run from 0 to n, but the inner variable starts right from where the outer one just stands. An if with a comparison and some assignments not necessarily executed reside inside the two loops. A good measure for the running time is the number of executed comparisons.[11] In the first iteration n comparisons take place, in the second n-1, then n-2, then n-3 etc. So 1+2+...+n comparisons are performed altogether. According to the well known Gaussian sum formula these are exactly 1/2(n-1)n comparisons. Figure 2.8 illustrates this. The screened area corresponds to the number of comparisons executed. It apparently corresponds approx. to half of the area of a square with a side length of n. So it amounts to approx. 1/2n2. Figure 2.8. Running time analysis of sorting by minimum search

Time Complexity
The total number of steps involved in a solution to solve a problem is the function of the size of the problem, which is the measure of that problems time complexity.
some general order that we can consider (c) < O(log n) < O(n) < O(n log n) < O(nc) < O(cn) < O(n!), where c is some constant.

The O-notation
In other words: c is not really important for the description of the running time! To take this circumstance into account, running time complexities are always specified in the socalled O-notation in computer science. One says: The sorting method has running time O(n2). The expression O is also called Landau's symbol. Mathematically speaking, O(n2) stands for a set of functions, exactly for all those functions which, in the long run, do not grow faster than the function n2, that is for those functions for which the function n2 is an upper bound (apart from a constant factor.) To be precise, the following holds true: A function f is an element of the set O(n2) if there are a factor c and an integer number n0 such that for all n equal to or greater than this n0 the following holds: f(n) cn2. The function n2 is then called an asymptotically upper bound for f. Generally, the notation f(n)=O(g(n)) says that the function f is asymptotically bounded from above by the function g.[12]

Space complexity
The better the time complexity of an algorithm is, the faster the algorithm will carry out his work in practice. Apart from time complexity, its space complexity is also important: This is essentially the number of memory cells which an algorithm needs. A good algorithm keeps this number as small as possible, too. There is often a time-space-tradeoff involved in a problem, that is, it cannot be solved with few computing time and low memory consumption. One then has to make a compromise and to exchange computing time for memory consumption or vice versa, depending on which algorithm one chooses and how one parameterizes it.

Amortized analysis
Sometimes we find the statement in the manual that an operation takes amortized time O(f(n)). This means that the total time for n such operations is bounded asymptotically

10

from above by a function g(n) and that f(n)=O(g(n)/n). So the amortized time is (a bound for) the average time of an operation in the worst case. The special case of an amortized time of O(1) signifies that a sequence of n such operations takes only time O(n). One then refers to this as constant amortized time. Such statements are often the result of an amortized analysis: Not each of the n operations takes equally much time; some of the operations are running time intensive and do a lot of pre-work (or also post-work), what, however, pays off by the fact that, as a result of the pre-work done, the remaining operations can be carried out so fast that a total time of O(g(n)) is not exceeded. So the investment in the pre-work or after-work amortizes itself.

Space Complexity
Space complexity is measured by using polynomial amounts of memory, with an infinite amount of time.

The difference between space complexity and time complexity is that space can be reused. Space complexity is not affected by determinism or nondeterminism. Amount of computer memory required during the program execution, as a function of the input size A small amount of space, deterministic machines can simulate nondeterministic machines, where as in time complexity, time increase exponentially in this case. A nondeterministic TM using O(n) space can be changed to a deterministic TM using only O2(n) space.

Complexity: why bother?


Estimation/Prediction When you write/run a program, you need to be able to predict its needs, its requirements. Usual requirements - execution time - memory space Quantities to estimate execution time time complexity memory space space complexity

It is pointless to run a program that requires: - 6TeraB of RAM on a desktop machine;

11

- 10,000 years to run. . . You do not want to wait for an hour: - for the result of your query on Google; - when you are checking your bank account online; - when you are opening a picture file on Photoshop; - etc. It is important to write efficient algorithms

Complexity Classes
Deterministic Polynomial Time P-complete Co-NP NP-complete NP-hard NC PSPACE PSPACEcomplete EXPTIME EXPSPACE BQP Hardest problems in P solvable on parallel computers Nondeterministic polynomial time and YES answers checkable in polynomial time Nondeterministic polynomial time and NO answers checkable in polynomial time Hardest problems in NP At least as hard as NP-complete problems Solvable parallel computation efficiency Polynomial memory with unlimited time Hardest problems in PSPACE Exponential time Exponential memory with unlimited time Polynomial time on a quantum computer

Co-NP-complete Hardest problems in CO-NP

Find the greatest common divisor (GCD) of two integers, m and n. Program (in C):
int gcd(int m, int n) /* precondition: m>0 and n>0.Let g=gcd(m,n). */ { while( m > 0 ) { /* invariant: gcd(m,n)=g */ if( n > m ) { int t = m; m = n; n = t; } /* swap */ /* m >= n > 0 */ m -= n; } return n; }

12

At the start of each iteration of the loop, either n>m or m?n.


(i) If m?n, then m is replaced by m-n which is smaller than the previous value of m, and still non-negative. (ii) If n>m, m and n are exchanged, and at the next iteration case (i) will apply. So at each iteration, max(m,n) either remains unchanged (for just one iteration) or it decreases. This cannot go on for ever because m and n are integers (this fact is important), and eventually a lower limit is reached, when m=0 and n=g. So the algorithm does terminate. Good test values would include:

special cases where m or n equals 1, or m, or n, or both equal small primes 2, 3, 5, , or products of two small primes such as p1p2 and p3p2, some larger values, but ones where you know the answers, swapped values, (x,y) and (y,x), because gcd(m,n)=gcd(n,m).

The objective in testing is to "exercise" all paths through the code, in different combinations. We can also consider the best,average and worst cases.

Average vs. worst-case complexity


Definition (Worst-case complexity) The worst-case complexity is the complexity of an algorithm when the input is the worst possible with respect to complexity. Definition (Average complexity) The average complexity is the complexity of an algorithm that is averaged over all the possible inputs (assuming a uniform distribution over the inputs). We assume that the complexity of the algorithm is T(i) for an input i. The set of possible inputs of size n is denoted In.

13

5. State space representation


In control engineering, a state space representation is a mathematical model of a physical system as a set of input, output and state variables related by first-order differential equations. To abstract from the number of inputs, outputs and states, the variables are expressed as vectors. Additionally, if the dynamical system is linear and time invariant, the differential and algebraic equations may be written in matrix form. The state space representation (also known as the "time-domain approach") provides a convenient and compact way to model and analyze systems with multiple inputs and outputs. With inputs and outputs, we would otherwise have to write down Laplace transforms to encode all the information about a system. Unlike the frequency domain approach, the use of the state space representation is not limited to systems with linear components and zero initial conditions. "State space" refers to the space whose axes are the state variables. The state of the system can be represented as a vector within that space.

State variables

Block diagram representation of the state space equations The internal state variables are the smallest possible subset of system variables that can represent the entire state of the system at any given time. The minimum number of state variables required to represent a given system, , is usually equal to the order of the system's defining differential equation. If the system is represented in transfer function form, the minimum number of state variables is equal to the order of the transfer function's denominator after it has been reduced to a proper fraction. It is important to understand that converting a state space realization to a transfer function form may lose some internal information about the system, and may provide a description of a system which is stable, when the state-space realization is unstable at certain points. In electric circuits, the number of state variables is often, though not always, the same as the number of energy storage elements in the circuit such as capacitors and inductors. The state variables defined must be linearly independent; no state variable can be written as a linear combination of the other state variables or the system will not be able to be solved. 14

You might also like