Documentos de Académico
Documentos de Profesional
Documentos de Cultura
AI Foundations
Aristotle (384-322 B.C.) was the first to formulate a precise set of laws governing the rational part
of the mind. He developed an informal system of syllogisms for proper reasoning, which allowed
one to generate conclusions mechanically, given initial premises.
The origin of scientific psychology are traced back to the wok if German physiologist Hermann von,
Helmholtz(1821-1894) and his student Wilhelm Wundt(1832 – 1920)
In 1879,Wundt opened the first laboratory of experimental psychology at the university of Leipzig.
In US, the development of computer modeling led to the creation of the field of cognitive science.
The field can be said to have started at the workshop in September 1956 at MIT.
For artificial intelligence to succeed, we need two things: intelligence and an artifact. The computer
has been the artifact of choice. AI also owes a debt to the software side of computer science, which
has supplied the operating systems, programming languages, and tools needed to write modern
programs.
Ktesibios of Alexandria (c. 250 B.c.) built the first self-controlling machine: a water clock with a
regulator that kept the flow of water running through it at a constant, predictable pace.
Modern control theory, especially the branch known as stochastic optimal control, has as its goal
the design of systems that maximize an objective function over time.
V.Linguistics (1957-present)
Modem linguistics and AI, then, were "born" at about the same time, and grew up
together, intersecting in a hybrid field called computational linguistics or natural language
processing.
___________________________________________________________________
History of Artificial Intelligence
subgoals and possible actions was similar to that in which humans approached the same problems.
Thus, GPS was probably the first program to embody the "thinking humanly" approach.
At IBM, Nathaniel Rochester and his colleagues produced some of the first AI programs. Herbert
Gelernter (1959) constructed the Geometry Theorem Prover, which was able to prove theorems
that many students of mathematics would find quite tricky.
Lisp was invented by John McCarthy in 1958 while he was at the Massachusetts Institute of
Technology (MIT). In 1963, McCarthy started the AI lab at Stanford.
From the beginning, AI researchers were not shy about making predictions of their coming
successes. The following statement by Herbert Simon in 1957 is often quoted: “It is not my aim to
surprise or shock you-but the simplest way I can summarize is to say that there are now in the
world machines that think, that learn and that create. Moreover, their ability to do these things is
going to increase rapidly until-in a visible future-the range of problems they can handle will be
coextensive with the range to which the human mind has been applied.
Dendral was an influential pioneer project in artificial intelligence (AI) of the 1960s, and the
computer software expert system that it produced. Its primary aim was to help organic chemists in
identifying unknown organic molecules, by analyzing their mass spectra and using knowledge of
chemistry. It was done at Stanford University by Edward Feigenbaum, Bruce Buchanan, Joshua
Lederberg, and Carl Djerassi.
In 1981, the Japanese announced the "Fifth Generation" project, a 10-year plan to build intelligent
computers running Prolog. Overall, the A1 industry boomed from a few million dollars in 1980 to
billions of dollars in 1988.
Psychologists including David Rumelhart and Geoff Hinton continued the study of neural-net
models of memory.
One of the most important environments for intelligent agents is the Internet.
__________________________________________________________
Limits of AI Today
Today’s successful AI systems operate in well-defined domains and employ narrow, specialized
knowledge. Common sense knowledge is needed to function in complex, open-ended worlds. Such a
system also needs to understand unconstrained natural language. However these capabilities are
not yet fully present in today’s intelligent systems.
• Understand natural language robustly (e.g., read and understand articles in a newspaper)
• Surf the web
• Interpret an arbitrary visual scene
• Learn a natural language
• Construct plans in dynamic real-time domains
• Exhibit true autonomy and intelligence
________________________________________________________________
Artificial Intelligence
Artificial Intelligence is the branch of computer science concerned with making computers behave
like humans.
Major AI textbooks define artificial intelligence as "the study and design of intelligent agents,"
where an intelligent agent is a system that perceives its environment and takes actions which
maximize its chances of success. John McCarthy, who coined the term in 1956, defines it as "the
science and engineering of making intelligent machines, especially intelligent computer programs."
The definitions of AI according to some text books are categorized into four approaches and are
summarized in the table below :
Systems that think like humans
“The exciting new effort to make computers think … machines with minds, in the full and literal
sense.”(Haugeland,1985)
The computer passes the test if a human interrogator, after posing some written questions, cannot
tell whether the written responses come from a person or not. Programming a computer to pass
,the computer need to possess the following capabilities :
Natural language processing to enable it to communicate successfully in English.
Knowledge representation to store what it knows or hears
Automated reasoning to use the stored information to answer questions and to draw new
conclusions.
Machine learning to adapt to new circumstances and to detect and extrapolate
Patterns.
The Greek philosopher Aristotle was one of the first to attempt to codify “right thinking”, that is
irrefuatable reasoning processes. His syllogism provided patterns for argument structures that
always yielded correct conclusions when given correct premises
for example,”Socrates is a man;all men are mortal; therefore Socrates is mortal.”.
These laws of thought were supposed to govern the operation of the mind; their study initiated a
field called logic.
An agent is something that acts. Computer agents are not mere programs ,but they are expected to
have the following attributes also :
(a) operating under autonomous control
(b) perceiving their environment
(c) persisting over a prolonged time period
(e) adapting to change
A rational agent is one that acts so as to achieve the best outcome.
INTELLIGENT AGENTS
o A human agent has eyes, ears, and other organs for sensors and hands, legs, mouth, and other
body parts for actuators.
o A robotic agent might have cameras and infrared range finders for sensors and various motors
for actuators.
o A software agent receives keystrokes, file contents, and network packets as sensory inputs and
acts on the environment by displaying on the screen, writing files, and sending network packets.
Terms:
Percept
We use the term percept to refer to the agent's perceptual inputs at any given instant.
Percept Sequence
An agent's percept sequence is the complete history of everything the agent has ever perceived.
Agent function
Mathematically speaking, we say that an agent's behavior is described by the agent function that
maps any given percept sequence to an action.
F: P*->A
Agent program
Internally, The agent function for an artificial agent will be implemented by an agent program. It is
important to keep these two ideas distinct. The agent function is an abstract mathematical
description; the agent program is a concrete implementation, running on the agent architecture.
To illustrate these ideas, we will use a very simple example-the vacuum-cleaner world shown in
Figure 1.3. This particular world has just two locations: squares A and B. The vacuum agent
perceives which square it is in and whether there is dirt in the square. It can choose to move left,
move right, suck up the dirt, or do nothing. One very simple agent function is the following: if the
current square is dirty, then suck, otherwise move to the other square. A partial tabulation of this
agent function is shown in Figure 1.4.
__________________________________________________________________
AGENTS AND ENVIRONMENTS
Task environments
We must think about task environments, which are essentially the "problems" to which rational
agents are the "solutions."
Specifying the task environment
The rationality of the simple vacuum-cleaner agent, needs specification of
o the performance measure
o the environment
o the agent's actuators and sensors.
PEAS
-All these are grouped together under the heading of the task environment.
We call this the PEAS (Performance, Environment, Actuators, Sensors) description.
-In designing an agent, the first step must always be to specify the task environment as fully as
possible.
_________________________________________________________________
Nature of Environments
Static Vs Dynamic
Static Environment: does not change from one state to the next while the agent is considering its
course of action. The only changes to the environment are those caused by the agent itself.
• A static environment does not change while the agent is thinking.
• The passage of time as an agent deliberates is irrelevant.
• The agent doesn’t need to observe the world during deliberation.
A Dynamic Environment changes over time independent of the actions of the agent -- and thus if an
agent does not respond in a timely manner, this counts as a choice to do nothing
Concept of Rationality
Rational Agent
A rational agent is one that does the right thing-conceptually speaking, every entry in the table for
the agent function is filled out correctly. Obviously, doing the right thing is better than doing the
wrong thing. The right action is the one that will cause the agent to be most successful.
Performance measures
A performance measure embodies the criterion for success of an agent's behavior. When an
agent is plunked down in an environment, it generates a sequence of actions according to the
percepts it receives. This sequence of actions causes the environment to go through a sequence of
states. If the sequence is desirable, then the agent has performed well.
Rationality
rational at any given time depends on four things:
o The performance measure that defines the criterion of success.
o The agent's prior knowledge of the environment.
o The actions that the agent can perform.
o The agent's percept sequence to date.
Agent programs
The agent programs all have the same skeleton: they take the current percept as input from the
sensors and return an action to the actuators.
Notice the difference between the agent program, which takes the current percept as input, and
the agent function, which takes the entire percept history. The agent program takes just the
current percept as input because nothing more is available from the environment; if the agent's
actions depend on the entire percept sequence, the agent will have to remember the percepts.
Drawbacks:
• Table lookup of percept-action pairs defining all possible condition-action rules necessary to
interact in an environment
• Problems
– Too big to generate and to store (Chess has about 10^120 states, for example)
– No knowledge of non-perceptual parts of the current state
– Not adaptive to changes in the environment; requires entire table to be updated if changes occur
– Looping: Can't make actions conditional
• Take a long time to build the table
• No autonomy
• Even with learning, need a long time to learn the table entries
• Table-driven agents
– use a percept sequence/action table in memory to find the next action. They are
implemented by a (large) lookup table.
• Utility-based agents
– base their decisions on classic axiomatic utility theory in order to act rationally.
The simplest kind of agent is the simple reflex agent. These agents select actions on the basis of
the current percept, ignoring the rest of the percept history. For example, the vacuum agent whose
agent function is tabulated in Figure 1.10 is a simple reflex agent, because its decision is based only
on the current location and on whether that contains dirt.
o Select action on the basis of only the current percept.
E.g. the vacuum-agent
o Large reduction in possible percept/action situations.
o Implemented through condition-action rule Ex: If dirty then suck
Figure 1.11 The agent program for a simple reflex agent in the two-state vacuum environment.
This program implements the agent function tabulated in the figure 1.4.
Characteristics
o Only works if the environment is fully observable.
o Lacking history, easily get stuck in infinite loops
o One solution is to randomize actions
Model-based reflex agents
The most effective way to handle partial observability is for the agent to keep track of the part of the
world it can't see now. That is, the agent should maintain some sort of internal state that depends
on the percept history and thereby reflects at least some of the unobserved aspects of the current
state.
Updating this internal state information as time goes by requires two kinds of knowledge to be
encoded in the agent program.
First, we need some information about how the world evolves independently of the agent-for
example, that an overtaking car generally will be closer behind than it was a moment ago.
Second, we need some information about how the agent's own actions affect the world-for example,
that when the agent turns the steering wheel clockwise, the car turns to the right or that after
driving for five minutes north bound on the freeway one is usually about five miles north of where
one was five minutes ago.
This knowledge about "how the world working – whether implemented in simple Boolean
circuits or in complete scientific theories-is called a model of the world. An agent that uses such a
MODEL-BASED model is called a model-based agent.
Knowing about the current state of the environment is not always enough to decide what to do. For
example, at a road junction, the taxi can turn left, turn right, or go straight on. The correct decision
depends on where the taxi is trying to get to. In other words, as well as a current state description,
the agent needs some sort of goal information that describes situations that are desirable-for
example, being at the passenger's destination. The agent program can combine this with
information about the results of possible actions (the same information as was used to update
internal state in the reflex agent) in order to choose actions that achieve the goal.
-Search and planning are two other sub-fields in AI to find out the action sequences to achieve its
goal
EXAMPLE PROBLEMS
The problem solving approach has been applied to a vast array of task environments. Some best
known problems are summarized below. They are distinguished as toy or real-world problems
A toy problem is intended to illustrate various problem solving methods. It can be easily used by
different researchers to compare the performance of algorithms.
A real world problem is one whose solutions people actually care about.
Toy Problems
Vacuum World Example
o States: The agent is in one of two locations., each of which might or might not contain dirt.
Thus there are 2 x 22 = 8 possible world states.
o Initial state: Any state can be designated as initial state.
o Successor function : This generates the legal states that results from trying the three actions
(left, right, suck). The complete state space is shown in figure 2.3
o Goal Test : This tests whether all the squares are clean.
o Path test : Each step costs one ,so that the the path cost is the number of steps in the path.
8-Puzzle
An 8-puzzle consists of a 3x3 board with eight numbered tiles and a blank space. A tile adjacent to
the blank space can slide into the space. The object is to reach the goal state ,as shown in figure 2.4
The 8-puzzle belongs to the family of sliding-block puzzles, which are often used as test
problems for new search algorithms in AI. This general class is known as NP-complete.
The 8-puzzle has 9!/2 = 181,440 reachable states and is easily solved.
The 15 puzzle ( 4 x 4 board ) has around 1.3 trillion states, an the random instances can be solved
optimally in few milliseconds by the best search algorithms.
The 24-puzzle (on a 5 x 5 board) has around 1025 states ,and random instances are still quite
difficult to solve optimally with current machines and algorithms.
8-queens problem
The problem is to place 8 queens on a chessboard so that no two queens are in the same row,
column or diagonal.
The picture below on the left shows a solution of the 8-queens problem. The picture on the right is
not a correct solution, because some of the queens are attacking each other.
State Space
N queens problem formulation 1
• States: Any arrangement of 0 to 8 queens on the board
• Initial state: 0 queens on the board
• Successor function: Add a queen in any square
• Goal test: 8 queens on the board, none are attacked
The initial state has 64 successors. Each of the states at the next level have 63 successors, and so on.
We can restrict the search tree somewhat by considering only those successors where no queen is
attacking each other. To do that we have to check the new queen against all existing queens on the
board. The solutions are found at a depth of 8.
State Space
N queens problem formulation 2
• States: Any arrangement of 8 queens on the board
• Initial state: All queens are at column 1
• Successor function: Change the position of any one queen
• Goal test: 8 queens on the board, none are attacked
State Space
State Space
__________________________________________________________________
Real-World Problems
Route-Finding Problems
Route-finding problem is defined in terms of specified locations and transitions along links between
them. Route-finding algorithms are used in a variety of applications, such as routing in computer
networks, military operations planning, and air line travel planning systems.
AIRLINE TRAVEL PROBLEM
The airline travel problem is specifies as follows :
o States : Each is represented by a location(e.g.,an airport) and the current time.
o Initial state : This is specified by the problem.
o Successor function : This returns the states resulting from taking any scheduled
flight(further specified by seat class and location),leaving later than the current time plus the
within-airport transit time, from the current airport to another.
o Goal Test : Are we at the destination by some pre-specified time?
o Path cost : This depends upon the monetary cost, waiting time, flight time ,customs and
immigration procedures, seat quality, time of date, type of air plane, frequent-flyer mileage awards,
and so on.
Touring problems are closely related to route-finding problems, but with an important difference.
Consider for example,the problem,”Visit every city at least once” as shown in Romania map.
As with route-finding the actions correspond to trips between adjacent cities. The state
space,however,is quite different.
The initial state would be “In Bucharest; visited{Bucharest}”.
A typical intermediate state would be“InVaslui;visited{Bucharest,Urziceni,Vaslui}”.
The goal test would check whether the agent is in Bucharest and all 20 cities have been visited.
VLSI layout
A VLSI layout problem requires positioning millions of components and connections on a chip to
minimize area ,minimize circuit delays ,minimize stray capacitances ,and maximize manufacturing
yield. The layout problem is split into two parts : cell layout and channel routing.
ROBOT navigation
ROBOT navigation is a generalization of the route-finding problem. Rather than a discrete set of
routes, a robot can move in a continuous space with an infinite set of possible actions and states.
For a circular Robot moving on a flat surface, the space is essentially two-dimensional. When the
robot has arms and legs or wheels that also must be controlled, the search space becomes multi-
dimensional. Advanced techniques are required to make the search space finite.
SEARCH TREE Having formulated some problems, we now need to solve them. This is done by a
search through the state space. A search tree is generated by the initial state and the successor
function that together define the state space. In general, we may have a search graph rather than a
search tree, when the same state can be reached from multiple paths.
We need to denote the states that have been generated. We will call these as nodes. The data
structure for a node will keep track of not only the state, but also the parent state or the operator
that was applied to get this state. In addition the search algorithm maintains a list of nodes called
the fringe. The fringe keeps track of the nodes that have been generated but are yet to be explored.
The fringe represents the frontier of the search tree generated. The basic search algorithm has been
described above.
Initially, the fringe contains a single node corresponding to the start state. In this version we use
only the OPEN list or fringe. The algorithm always picks the first node from fringe for expansion. If
the node contains a goal state, the path to the goal is returned. The path corresponding to a goal
node can be found by following the parent pointers. Otherwise all the successor nodes are
generated and they are added to the fringe.
The successors of the current expanded node are put in fringe. We will soon see that the order in
which the successors are put in fringe will determine the property of the search algorithm.
2. Optimality: Does the solution have low cost or the minimal cost?
3. What is the search cost associated with the time and memory required to find a solution?
a. Time complexity: Time taken (number of nodes expanded) (worst or average
case) to find a solution.
b. Space complexity: Space used by the algorithm measured in terms of the
maximum size of fringe
-The different search strategies that we will consider include the following:
1. Blind Search strategies or Uninformed search
a. Depth first search
b. Breadth first search
c. Iterative deepening search
d. Iterative broadening/deepening search
2. Informed Search
3. Constraint Satisfaction Search
4. Adversary Search
Search tree
Consider the explicit state space graph shown in the figure.
One may list all possible paths, eliminating cycles from the paths, and we would get the complete
search tree from a state space graph. Let us examine certain terminology associated with a search
tree. A search tree is a data structure containing a root node, from where the search starts. Every
node may have 0 or more children. If a node X is a child of node Y, node Y is said to be a parent of
node X.
The nodes that the algorithm has generated are kept in a data structure called OPEN or fringe.
Initially only the start node is in OPEN. The search starts with the root node. The algorithm picks a
node from OPEN for expanding and generates all the children of the node. Expanding a node from
OPEN results in a closed node. Some search algorithms keep track of the closed nodes in a data
structure called CLOSED.
A solution to the search problem is a sequence of operators that is associated with a path from a
start node to a goal node. The cost of a solution is the sum of the arc costs on the solution path. For
large state spaces, it is not practical to represent the whole space. State space search makes explicit
a sufficient portion of an implicit state space graph to find a goal node. Each node represents a
partial solution path from the start node to the given node. In general, from this node there are
many possible paths that have this partial path as a prefix.
The search process constructs a search tree, where
• root is the initial state and
• leaf nodes are nodes
• not yet expanded (i.e., in fringe) or
• having no successors (i.e., “dead-ends”)
Search tree may be infinite because of loops even if state space is small
The search problem will return as a solution a path to a goal node. Finding a path is important in
problems like path finding, solving 15-puzzle, and such other problems. There are also problems
like the N-queens problem for which the path to the solution is not important. For such problems
the search problem needs to return the goal state only.
Step 2: A is removed from fringe. The node is expanded, and its children B and C are generated.
They are placed at the back of fringe.
Step 3: Node B is removed from fringe and is expanded. Its children D, E are generated and put at
the back of fringe.
Step 4: Node C is removed from fringe and is expanded. Its children D,G are added to the back end
of fringe.
Step 5: Node D is removed from fringe. Its children C and F are generated and added to the back of
fringe.
Step 6: Node E is removed from fringe. It has no children.
Step 8: G is selected for expansion. It is found to be a goal node. So the algorithm returns the path A
C G by following the parent pointers of the node corresponding to G. The algorithm terminates.
Assume every state has b successors. The root of the search tree generates b nodes at the first
level,each of which generates b more nodes,for a total of b2 at the second level. Each of these
generates b more nodes,yielding b3 nodes at the third level,and so on. Now suppose,that the
solution is at depth d. In the worst case,we would expand all but the last node at level d,generating
bd+1 - b nodes at level d+1.A complete search tree of depth d where each non-leaf node has b
children, has a total of 1 + b + b2 + ... + bd = (b(d+1) - 1)/(b-1) nodes
Uniform Cost Search is the best algorithm for a search problem, which does not involve the use of
heuristics. It can solve any general graph for optimal cost. Uniform Cost Search as it sounds
searches in branches which are more or less the same in cost.
Uniform Cost Search again demands the use of a priority queue. Recall that Depth First Search used
a priority queue with the depth upto a particular node being the priority and the path from the root
to the node being the element stored. The priority queue used here is similar with the priority being
the cumulative cost upto the node. Unlike Depth First Search where the maximum depth had the
maximum priority, Uniform Cost Search gives the minimum cumulative cost the maximum priority
Now let us apply the algorithm on the above search tree and see what it gives us. We will go
through each iteration and look at the final output. Each element of the priority queue is written as
[path,cumulative cost].4
Ex : 2
Depth First Search
The depth first search algorithm puts newly generated nodes in the front of OPEN. This results in
expanding the deepest node first. Thus the nodes in OPEN follow a LIFO order (Last In First Out).
OPEN is thus implemented using a stack data structure.
Properties of Depth First Search
Let us now examine some properties of the DFS algorithm. The algorithm takes exponential time. If
N is the maximum depth of a node in the search space, in the worst case the algorithm will take time
O(bd). However the space taken is linear in the depth of the search tree, O(bN).
Note that the time taken by the algorithm is related to the maximum depth of the search tree. If the
search tree has infinite depth, the algorithm may not terminate. This can happen if the search space
is infinite. It can also happen if the search space contains cycles. The latter case can be handled by
checking for cycles in the algorithm. Thus Depth First Search is not complete.
________________________________________________________________
Depth Limited Search
A variation of Depth First Search circumvents the above problem by keeping a depth bound. Nodes
are only expanded if they have depth less than the bound. This algorithm is known as depth-limited
search.The depth limit solves the infinite path problem.Depth limited search will be nonoptimal if
we choose l > d. Its time complexity is O(bl) and its space complexity is O(bl). Depth-first-search can
be viewed as a special case of depth-limited search with l = infinite
___________________________________________________________________
Iterative Deepening Search
Iterative deepening search (or iterative-deepening-depth-first-search) is a general strategy often
used in combination with depth-first-search,that finds the better depth limit. It does this by
gradually increasing the limit – first 0,then 1,then 2, and so on – until a goal is found. This will occur
when the depth limit reaches d,the depth of the shallowest goal node. The algorithm is shown in
Figure 2.14.
Iterative deepening combines the benefits of depth-first and breadth-first-search
Like depth-first-search, its memory requirements are modest; O(bd) to be precise.
Like Breadth-first-search, it is complete when the branching factor is finite and optimal when the
path cost is a non decreasing function of the depth of the node.
Procedure
Successive depth-first searches are conducted – each with depth bounds increasing by 1
__________________________________________________________________
Bi-directional search
Suppose that the search problem is such that the arcs are bidirectional. That is, if there is an
operator that maps from state A to state B, there is another operator that maps from state B to state
A. Many search problems have reversible arcs. 8-puzzle, 15-puzzle, path planning etc are examples
of search problems. However there are other state space search formulations which do not have
this property. The water jug problem is a problem that does not have this property. But if the arcs
are reversible, you can see that instead of starting from the start state and searching for the goal,
one may start from a goal state and try reaching the start state. If there is a single state that satisfies
the goal property, the search problems are identical.
How do we search backwards from goal? One should be able to generate predecessor states.
Predecessors of node n are all the nodes that have n as successor. This is the motivation to consider
bidirectional search.
Algorithm: Bidirectional search involves alternate searching from the start state toward the goal
and from the goal state toward the start. The algorithm stops when the frontiers intersect.
A search algorithm has to be selected for each half. How does the algorithm know when the
frontiers of the search tree intersect? For bidirectional search to work well, there must be an
efficient way to check whether a given node belongs to the other search tree.
Bidirectional search can sometimes lead to finding a solution more quickly. The reason can be seen
from inspecting the following figure.
Informed Search
Uninformed search methods that systematically explore the state space and find the goal. They are
inefficient in most cases. Informed search methods use problem specific knowledge, and may be
more efficient. At the heart of such algorithms there is the concept of a heuristic function.
The resulting algorithm is not optimal. The algorithm is also incomplete, and it may fail to find a
solution even if one exists. This can be seen by running greedy search on the following example. A
good heuristic for the route-finding problem would be straight-line distance to the goal.
Let us run the greedy search algorithm for the graph given in Figure 2. The straight line distance
heuristic estimates for the nodes are shown in Figure 1.
A* Algorithm
Ex : 2
A* search: properties
The algorithm A* is admissible. This means that provided a solution exists, the first solution found
by A* is an optimal solution. A* is admissible under the following conditions:
• In the state space graph
o Every node has a finite number of successors
o Every arc in the graph has a cost greater than some ε> 0
• Heuristic function: for every node n, h(n) ≤ h*(n)
A* is optimally efficient for a given heuristic – of the optimal search algorithms that expand search
paths from the root node, it can be shown that no other optimal algorithm will expand fewer nodes
and find a solution.
However, the number of nodes searched still exponential in the worst case.
Unfortunately, estimates are usually not good enough for A* to avoid having to expand an
exponential number of nodes to find the optimal solution. In addition, A* must keep all nodes it is
considering in memory.
A* is still much more efficient than uninformed methods. It is always better to use a heuristic
function with higher values as long as it does not overestimate.
For example, the heuristic shown below is inconsistent, because h(n) = 4, but
cost(n, n') + h(n') = 1 + 2 = 3, which is less than 4. This makes the value of f decrease from node n to
node n':
If a heuristic h is consistent, the f values along any path will be non decreasing:
f(n') = estimated distance from start to goal through n'
= actual distance from start to n + step cost from n to n' + estimated distance from n' to goal
= g(n) + cost(n, n') + h(n')
> g(n) + h(n) because cost(n, n') + h(n') > h(n) by consistency
= f(n)
Therefore f(n') > f(n), so f never decreases along a path.
__________________________________________________________________
AO * (AND-OR) ALGORITHM
In OR graph, several arcs indicate a variety of ways in which the original problem may be
solved.
• Another kind of structure AND-OR graph (tree) is useful for representing the solution of
problems by decomposing them into smaller problems, all of which must then be solved.
• This decomposition generates arcs that we will cal l AND arc. One AND arc may point to any
number of successors, all of which must be solved.
• The proposed structure is called AND–OR graph rather than simply AND graph.
Consider the matrix multiplication of A1,A2 and A3.The problem can be solved as A1(A2A3) and
(A1A2)A3 which is a OR a node because problem can be solved in any way that is a it represents a
choice of nodes. A1(A2A3) can be decomposed into A1 and A2A3.To solve the A1(A2A3) both the
nods A1 and A2A3 has to solve which represents AND node.AND node are represented in the
diagram like Angle. Again (A1A2)A3 decomposed into A1A2 and A3 and it is also a AND node.
The size of A1 is size of 3x4 and its cost is 0 and A2A3 is Size of 4x1(4x10 and
10x1=4x1) ,the cost to solve A2A3 is 40 so the cost to solve
A1( A2A3)is cost of A1+A2A3= 12+40=52 where the right side problem (A1A2)A3 takes cost of
A1A2+A3=30+120=150.So the best way to solve the problem as A1(A2A3) which is minimum cost.
Reason that reducing problems to sub-goals in this way is of such great interest in Artificial
Intelligence research is that this is the way in which humans often go about solving problems.
One area in which goal trees are often used is computer security. A threat tree represents the
possible threats to a computer system, such as a computerized
banking system. If the goal is “steal Edwin’s money from the bank,” you can (guess or convince me
to divulge my PIN) and (steal or copy my card) and so on. The threat tree thus represents the
possible paths an attacker of the system might take and enables security experts to determine the
weaknesses in the system.
Example 3: Games
Goal trees that are used to represent the choices made by players when playing
two-player games, such as chess, checkers, and Go. The root node of a game tree represents the
current position, and this is an or-node because I must choose one move to make. The next level
down in the game tree represents the possible choices my opponent might make, and because I
need to consider all possible responses that I might make to that move, this level consists of and-
nodes. Eventually, the leaf nodes represent final positions in the game, and a path through the tree
represents a sequence of moves from start to finish, resulting in a win, loss, or a draw.
The first picture shows the current state n, and the second picture the goal state.
H1(n) = 5 because the tiles 2, 8, 1, 6 and 7 are out of place.
Manhattan Distance Heuristic: Another heuristic for 8-puzzle is the Manhattan distance heuristic.
This heuristic sums the distance that the tiles are out of place. The distance of a tile is measured by
the sum of the differences in the x-positions and the y-positions.
For the above example, using the Manhattan distance heuristic,
H2(n) = 1 + 1 + 0 + 0 + 0 + 1 + 1 + 2 = 6
One way to characterize the quality of a heuristic is the effective branching factor b*. If the total
number of nodes expanded by A* for a particular problem is N, and the solution depth is ;d, then b*
is the branching factor that a uniform tree of depth d would have to have in order to ~>contain N
nodes. Thus,
The Heuristics can be invented by the relaxed problems .A problem with less restrictions on the
operators is called a relaxed problem.
One problem with generating new heuristic functions is that one often fails to get one"clearly best"
heuristic. If a collection of admissible heuristics h1...hm is available for a problem, and none of them
dominates any of the others, We can have the best of all worlds, by defining
h(n) = max(h1(n),...,hm(n)).,
__________________________________________________________________________
Heuristic Function
For each block that has the correct support structure: +1 to every block in the support structure.
For each block that has a wrong support structure: −1 to every block in the support structure.
Iterative Improvement and Hill Climbing
Hill climbing get stuck for the following reasons
Local maxima
Once the top of a hill is reached the algorithm will halt since every possible step leads down.
Plateaux:
If the landscape is flat, meaning many states have the same goodness, algorithm degenerates to a
random walk.
Ridges
If the landscape contains ridges, local improvements may follow a zigzag path up the ridge, slowing
down the search.
Remedies:
– Random restart: keep restarting the search from random locations until a goal is found i.e. It
conducts a series of series of local searches from randomly generate the initial states, stopping
when a goal is found.
– Problem reformulation: reformulate the search space to eliminate these problematic features.
The success of hill climbing depends very much on a shape of state space land- scape: if there are
few local maxima and plateaux, random restart hill climbing will find a good solution very quickly.
Game is search problem where action of one agent effects the action of other agent. Game involves
multi-agent environment.
Types of Games
MIN-MAX Algorithm
The min-max algorithm is designed to determine the optimal strategy for MAX, and thus to decide
what the best first move is. The algorithm consists of five steps:
• Generate the whole game tree, all the way down to the terminal states.
• Apply the utility function to each terminal state to get its value.
• Use the utility of the terminal states to determine the utility of the nodes one level higher up in the
search tree.
• Continue backing up the values from the leaf nodes toward the root, one layer at a time.
• Eventually, the backed-up values reach the top of the tree; at that point MAX chooses the move
that leads to the highest value.
This is called the min-max decision, because it maximizes utility under the assumption that the
opponent will play perfectly to minimize it.
Two ply Two player Game tree
Procedure :
Step-1
Step-2
Step :3
3 Ply- 3 Player Game tree
If the maximum depth of the tree is m, and there are b legal moves at each point, then the time
complexity of the min-max algorithm is O(b^m). The algorithm is a depth-first search(although here
the implementation is through recursion rather than using a queue of nodes), so its space
requirements are only linear in m and b.
___________________________________________________________________
Alpha-Beta Pruning Algorithm
Depth first search – only considers nodes along a single path at any time.
α = highest-value choice that we can guarantee for MAX so far in the current subtree.
β = lowest-value choice that we can guarantee for MIN so far in the current subtree.
Update values of α and β during search and prunes remaining branches as soon as the value
is known to be worse than the current α or β value for MAX or MIN.
Example
Example-2
Step-1
Step-2
Step-3
Step-4
Step-5
Step-6
Step-7