AI(U1)
AI(U1)
UNIT – I
Introduction: History of AI – problem spaces and search- Heuristic Search techniques –Best-first
search- Problem reduction-Constraint satisfaction-Means Ends Analysis. Intelligent agents: Agents
and environment – structure of agents and its functions
Artificial Intelligence
Artificial intelligence is the study of how to make computers do things which, at moment
people do better. Artificial intelligence can be viewed from a variety of perspectives.
From the perspective of intelligence, artificial intelligence is making machines "intelligent"
-- acting as we would expect people to act.
The inability to distinguish computer responses from human responses is called the
Turing test.
Intelligence requires knowledge.
From a business perspective AI is a set of very powerful tools, and methodologies for using
those tools to solve business problems.
1
Artificial Intelligence (AI) is a branch of Science which deals with helping machines finding
solutions to complex problems in a more human-like fashion. This generally involves
borrowing characteristics from human intelligence, and applying them as algorithms in a
computer friendly way. A more or less flexible or efficient approach can be taken depending
on the requirements established, which influences how artificial the intelligent behaviour
appears. AI is generally associated with Computer Science, but it has many important links
with other fields such as Maths, Psychology, Cognition, Biology and Philosophy, among many
others. Our ability to combine knowledge from all these fields will ultimately benefit our
progress in the quest of creating an intelligent artificial being.
AI currently encompasses a huge variety of subfields, from general-purpose areas such as
perception and logical reasoning, to specific tasks such as playing chess, proving mathematical
theorems, writing poetry, and diagnosing diseases. Often, scientists in other fields move
gradually into artificial intelligence, where they find the tools and vocabulary to systematize
and automate the intellectual tasks on which they have been working all their lives. Similarly,
workers in AI can choose to apply their methods to any area of human intellectual endeavour.
In this sense, it is truly a universal field.
AI Problems
Much of the early work in the field of AI focused on formal tasks, such as game playing
and theorem proving.
Game playing and theorem proving share the property that people who do them well
are considered to be displaying Intelligence.
Initially computers could perform well at those tasks simply by being fast at exploring
a large number of solution paths and then selecting the best one.
Humans learn mundane (ordinary) tasks since their birth. They learn by perception,
speaking, using language, and training. They learn Formal Tasks and Expert Tasks
later.
Another early foray into AI focused on commonsense reasoning, which includes
reasoning about physical objects and their relationship to each other, as well as
reasoning about actions and their consequences.
As AI research progressed, techniques for handling large amount of world knowledge
were developed.
New tasks reasonably attempted such as perception, natural language understanding
and problem solving in specialized domains.
Some of the task domains of artificial intelligence are presented in table I.
Earlier, all work of AI was concentrated in the mundane task domain.
Later, it turned out that the machine requires more knowledge, complex knowledge
representation, and complicated algorithms for handling mundane tasks.
2
This is the reason why AI work is more flourishing in the Expert Tasks domain now,
as the expert task domain needs expert knowledge without common sense, which can
be easier to represent and handle.
What is an AI technique?
Artificial intelligence problems span a very broad spectrum. They appear to have very little
in common except that they are hard.
AI Research of earlier decades results into the fact that intelligence requires knowledge.
Knowledge possess following properties:
It is voluminous.
It is not well-organized or well-formatted.
It is constantly changing.
It differs from data. And it is organized in a way that corresponds to its usage.
AI technique is a method that exploits knowledge that should be represented in such a way
that:
Knowledge captures generalization. Situations that share common properties are
grouped together. Without this property, inordinate amount of memory and
modifications will be required.
It can be understood by people who must provide it. Although bulk of data can be
acquired automatically, in many AI domains most of the knowledge must ultimately
be provided by people in terms they understand.
It can easily be modified to correct errors and to reflect changes in the world.
It can be used in many situations even though it may not be totally accurate or
complete.
It can be used to reduce its own volume by narrowing range of possibilities.
1. Search –
o Provides a way of solving problems for which no direct approach is available.
o b. It also provides a framework into which any direct techniques that are available
can be embedded.
2. Use of knowledge – Provides a way of solving complex problems by exploiting the structure
of the objects that are involved.
3. Abstraction –Provides a way of separating important features and variations from many
unimportant ones that would otherwise overwhelm any process.
Classification of AI
1. Weak AI: The study and design of machines that perform intelligent tasks.
Not concerned with how tasks are performed, mostly concerned with performance and
efficiency, such as solutions that are reasonable for NP-Complete problems. E.g., to make
a flying machine, use logic and physics, don’t mimic a bird.
2. Strong AI: The study and design of machines that simulate the human mind to perform
intelligent tasks.
3
Borrow many ideas from psychology, neuroscience. Goal is to perform tasks the
way a human might do them – which makes sense, since we do have models of
human thought and problem solving.
Includes psychological ideas in STM, LTM, forgetting, language, genetics, etc.
Assumes that the physical symbol hypothesis holds.
3. Evolutionary AI. The study and design of machines that simulate simple creatures, and
attempt to evolve and have higher level emergent behavior. For example, ants, bees, etc.
Applications of AI
AI has been dominant in various fields such as −
1. Gaming − AI plays vital role in strategic games such as chess, poker, tic-tac-toe, etc.,
where machine can think of large number of possible positions based on heuristic
knowledge.
2. Natural Language Processing − It is possible to interact with the computer that
understands natural language spoken by humans.
3. Expert Systems − There are some applications which integrate machine, software, and
special information to impart reasoning and advising. They provide explanation and
advice to the users.
4. Computer Vision Systems − These systems understand, interpret, and comprehend
visual input on the computer.
5. Speech Recognition − Some intelligent systems are capable of hearing and
comprehending the language in terms of sentences and their meanings while a human
talks to it. It can handle different accents, slang words, noise in the background, change
in human’s noise, etc.
6. Handwriting Recognition − The handwriting recognition software reads the text written
on paper by a pen or on screen by a stylus. It can recognize the shapes of the letters and
convert it into editable text.
7. Intelligent Robots − Robots are able to perform the tasks given by a human. They have
sensors to detect physical data from the real world such as light, heat, temperature,
movement, sound, bump, and pressure. They have efficient processors, multiple sensors
and huge memory, to exhibit intelligence. In addition, they are capable of learning from
their mistakes and they can adapt to the new environment
1) Hardware Components of AI
a) Pattern Matching
4
b) Logic Representation
c) Symbolic Processing
d) Numeric Processing
e) Problem Solving
f) Heuristic Search
g) Natural Language processing
h) Knowledge Representation
i) Expert System
j) Neural Network
k) Learning
l) Planning
m) Semantic Network
2) Software Components
a) Machine Language
b) Assembly language
c) High level Language
d) LISP Language
e) Fourth generation Language
f) Object Oriented Language
g) Distributed Language
h) Natural Language
i) Particular Problem Solving Language
3) Architectural Components
a) Uniprocessor
b) Multiprocessor
c) Special Purpose Processor
d) Array Processor
e) Vector Processor
f) Parallel Processor
g) Distributed Processor
5
3. Isolate and represent the task knowledge that is necessary to solve the problem.
4. Choose the best problem solving technique and apply it to the particular problem.
The problem can then be solved by using the rules, in combination with an appropriate
control strategy, to move through the problem space until a path from an initial state to
a goal state is found.
This process is known as search.
Search is fundamental to the problem-solving process.
Search is a general mechanism that can be used when more direct method is
not known.
Search also provides the framework into which more direct methods for
solving subparts of a problem can be embedded.
1. It allows for a formal definition of a problem as per the need to convert some given
situation into some desired situation using a set of permissible operations.
2. It permits the problem to be solved with the help of known techniques and control
strategies to move through the problem space until goal state is found.
Problems dealt with in artificial intelligence generally use a common term called 'state'. A state
represents a status of the solution at a given step of the problem solving procedure. The solution
of a problem, thus, is a collection of the problem states. The problem solving procedure applies
an operator to a state to get the next state. Then it applies another operator to the resulting state
to derive a new state. The process of applying an operator to a state and its subsequent transition
to the next state, thus, is continued until the goal (desired) state is derived. Such a method of
solving a problem is generally referred to as state space approach 6
Ex.1:- Consider the problem of Playing Chess
The starting position can be described by an 8 X 8 array square in which each element
square (x, y), (x varying from 1 to 8 & y varying from 1 to 8) describes the board position
of an appropriate piece in the official chess opening position.
The goal is any board position in which the opponent does not have a legal move and his
or her “king” is under attack.
The legal moves provide the way of getting from initial state of final state.
The legal moves can be described as a set of rules consisting of two parts: A left side that
gives the current position and the right side that describes the change to be made to the
board position.
An example is shown in the following figure.
The current position of a chess coin on the board is its state and the set of all possible states
is state space.
One or more states where the problem terminates are goal states.
Chess has approximately 10120 game paths. These positions comprise the problem search
space. Using above formulation, the problem of playing chess is defined as a problem of
moving around in a state space, where each state corresponds to a legal position of the
board.
State space representation seems natural for play chess problem because the set of states,
which corresponds to the set of board positions, is well organized.
A Water Jug Problem: You are given two jugs, a 4-gallon one and a 3-gallon one, a pump
which has unlimited water which you can use to fill the jug, and the ground on which water
may be poured. Neither jug has any measuring markings on it. How can you get exactly 2
gallons of water in the 4-gallon jug?
Here the initial state is (0, 0). The goal state is (2, n) for any value of n.
7
State Space Representation: we will represent a state of the problem as a tuple (x, y)
where x represents the amount of water in the 4-gallon jug and y represents the amount of
water in the 3-gallon jug. Note that 0 ≤ x ≤ 4, and 0 ≤ y ≤ 3.
To solve this we have to make some assumptions not mentioned in the problem. They are:
We can fill a jug from the pump.
We can pour water out of a jug to the ground.
We can pour water from one jug to another.
There is no measuring device available.
Operators – we must define a set of operators that will take us from one state to another.
8
Ex.3:- Consider 8 puzzle problem
The 8 puzzle consists of eight numbered, movable tiles set in a 3x3 frame. One cell of the frame
is always empty thus making it possible to move an adjacent numbered tile into the empty cell.
Such a puzzle is illustrated in following diagram.
The program is to change the initial configuration into the goal configuration.
A solution to the problem is an appropriate sequence of moves, such as “move tiles 5 to the
right, move tile 7 to the left ,move tile 6 to the down” etc…
To solve a problem, we must specify the global database, the rules, and the control strategy.
For the 8 puzzle problem that correspond to three components.
These elements are the problem states, moves and goal.
In this problem each tile configuration is a state.
The set of all possible configuration in the problem space, consists of 3,62,880 different
configurations of the 8 tiles and blank space.
For the 8-puzzle, a straight forward description is a 3X3 array of matrix of numbers.
Initial global database is this description of the initial problem state. Virtually any kind of
data structure can be used to describe states.
A move transforms one problem state into another state.
9
2. move blank up,
3. Move blank to the right and
4. Move blank down.
These moves are modeled by production rules that operate on the state descriptions in
the appropriate manner.
The goal condition forms the basis for the termination.
The control strategy repeatedly applies rules to state descriptions until a description of
a goal state is produced.
It also keeps track of rules that have been applied so that it can compose them into
sequence representing the problem solution.
Problem Characteristics
In order to choose the most appropriate problem solving method, it is necessary to
analyze the problem along various key dimensions.
These dimensions are referred to as problem characteristics discussed below.
A very large and composite problem can be easily solved if it can be broken into smaller
problems and recursion could be used.
For example, we want to solve :- ∫ x2 + 3x + sin2x cos2x dx
This can be done by breaking it into three smaller problems and solving each by
applying specific rules. Adding the results we can find the complete solution.
But there are certain problems which cannot be decomposed into sub-problems.
For example Blocks world problem in which, start and goal state are given as,
Here, solution can be achieved be moving blocks in a sequence such that goal state
can be derived.
Solution steps are interdependent and cannot be decomposed in sub problems.
These two examples, symbolic integration and the blocks world illustrate the
difference between decomposable and non-decomposable problems.
Consider theorem proving. We may later find that it is of no use. We can still proceed
further, since nothing is lost by this redundant step. This is an example of ignorable
solutions steps.
Now consider the 8 puzzle problem tray and arranged in specified order.
10
o While moving from the start state towards goal state, we may make some stupid
move but we can backtrack and undo the unwanted move. This only involves
additional steps and the solution steps are recoverable.
4. Is a good solution to the problem obvious without comparison to all other possible
solutions?
There are two categories of problems - Any path problem and Best path problem.
o In any path problem, like the water jug and 8 puzzle problems, we are satisfied with
the solution, irrespective of the solution path taken.
o Whereas in the other category not just any solution is acceptable but we want the best
path solution.
Like that of traveling sales man problem, which is the shortest path problem.
In any – path problems, by heuristic methods we obtain a solution and we do not explore
alternatives.
Any path problems can often be solved in a reasonable amount of time by using heuristics
that suggest good paths to explore.
For the best-path problems all possible paths are explored using an exhaustive search
until the best path is obtained.
Best path problems are computationally harder.
11
o Finding a consistent interpretation for the sentence “The bank president ate a dish of
pasta salad with the fork”.
We need to find the interpretation but not the record of the processing by which the
interpretation is found.
Contrast this with the water jug problem.In water jug problem, it is not sufficient to report
that we have solved, but the path that we found to the state (2, 0). Thus the statement of a
solution to this problem must be a sequence of operations that produces the final state.
1. Solitary in which the computer will be given a problem description and will produce an
answer, with no intermediate communication and with the demand for an explanation of
the reasoning process. Simple theorem proving falls under this category. Given the basic
rules and laws, the theorem could be proved, if one exists.
Problem Classification
Actual problems are examined from the point of view of all these questions; it becomes
apparent that there are several broad classes into which the problems fall.
1. The direction in which to conduct the search (forward versus backward reasoning). If the
search proceeds from start state towards a goal state, it is a forward search or we can also
search from the goal.
2. How to select applicable rules (Matching). Production systems typically spend most of their
time looking for rules to apply. So, it is critical to have efficient procedures for matching
rules against states.
3. How to represent each node of the search process (knowledge representation problem).
12
Production System
The production system is a model of computation that can be applied to implement search algorithms
and model human problem solving. Such problem solving knowledge can be packed up in the form
of little quanta called productions.
A production is a rule consisting of a situation recognition part and an action part. A production is a
situation-action pair in which the left side is a list of things to watch for and the right side is a list of
things to do so.
When productions are used in deductive systems, the situation that trigger productions are specified
combination of facts. The actions are restricted to being assertion of new facts deduced directly from
the triggering combination. Production systems may be called premise conclusion pairs rather than
situation action pair.
1. A set of rules, each consisting of a left side that determines the applicability of the rule and
a right side that describes the operation to be performed if that rule is applied.
2. One or more knowledge/databases that contain whatever information is appropriate for the
particular task. Some parts of the database may be permanent, while other parts of it may
pertain only to the solution of the current problem.
3. A control strategy that specifies the order in which the rules will be compared to the database
and a way of resolving the conflicts that arise when several rules match at once.
4. A rule applier which is the computational system that implements the control strategy and
applies the rules.
13
along with a control system and a database. The control system serves as a rule interpreter and
sequencer. The database acts as a context buffer, which records the conditions evaluated by the
rules and information on which the rules act. The production rules are also known as condition
– action, antecedent – consequent, pattern – action, situation – response, feedback – result pairs.
For example,
If (you have an exam tomorrow)
THEN (study the whole night)
Expressiveness and intuitiveness: In real world, many times situation comes like “if this
happen-you will do that”, “if this is so-then this should happen” and many more. The
production rules essentially tell us what to do in a given situation.
1. Simplicity: The structure of each sentence in a production system is unique and uniform as
they use “IF-THEN” structure. This structure provides simplicity in knowledge representation.
This feature of production system improves the readability of production rules.
2. Modularity: This means production rule code the knowledge available in discrete pieces.
Information can be treated as a collection of independent facts which may be added or deleted
from the system with essentially no deletetious side effects.
3. Modifiability: This means the facility of modifying rules. It allows the development of
production rules in a skeletal form first and then it is accurate to suit a specific application.
4. Knowledge intensive: The knowledge base of production system stores pure knowledge.
This part does not contain any type of control or programming information. Each production
rule is normally written as an English sentence; the problem of semantics is solved by the very
structure of the representation.
2. Inefficiency: During execution of a program several rules may active. A well devised control
strategy reduces this problem. As the rules of the production system are large in number and
they are hardly written in hierarchical manner, it requires some forms of complex search
through all the production rules for each cycle of control program.
14
3. Absence of learning: Rule based production systems do not store the result of the problem
for future use. Hence, it does not exhibit any type of learning capabilities. So for each time for
a particular problem, some new solutions may come.
4. Conflict resolution: The rules in a production system should not have any type of conflict
operations. When a new rule is added to a database, it should ensure that it does not have any
conflicts with the existing rules.
1. Monotonic Production System: the application of a rule never prevents the later
application of another rule that could also have been applied at the time the first rule was
selected. i.e., rules are independent.
Monotonic learning is when an agent may not learn any knowledge that contradicts what it
already knows. For example, it may not replace a statement with its negation. Thus, the
knowledge base may only grow with new facts in a monotonic fashion. The advantages of
monotonic learning are:
1. Greatly simplified truth-maintenance
2. Greater choice in learning strategies
3. Partially commutative Production system: a production system with the property that
if application of a particular sequence of rules transforms state x to state y, then
allowable permutation of those rules, also transforms state x into state y.
15
Control Strategies
Control strategies help us decide which rule to apply next during the process of searching
for a solution to a problem.
Problem solving in artificial intelligence may be characterized as a systematic search through a range of
possible actions in order to reach some predefined goal or solution. In AI problem solving by search
algorithms is quite common technique. In the coming age of AI it will have big impact on the technologies
of the robotics and path finding. It is also widely used in travel planning. A search algorithm takes a
problem as input and returns the solution in the form of an action sequence. Once the solution is found,
the actions it recommends can be carried out. This phase is called as the execution phase. After
formulating a goal and problem to solve the agent cells a search procedure to solve it. A problem can be
defined by 5 components.
a) The initial state: The state from which agent will start.
b) The goal state: The state to be finally reached.
c) The current state: The state at which the agent is present after starting from the initial state.
d) Successor function: It is the description of possible actions and their outcomes.
e) Path cost: It is a function that assigns a numeric cost to each path.
Example: Breadth First Search (BFS), Depth First Search (DFS), Depth Limited
Search (DLS).
16
Uninformed Search
Concept:
Step 1: Traverse the root node
Step 2: Traverse all neighbours of root node.
Step 3: Traverse all neighbours of neighbours of the root node.
Step 4: This process will continue until we are getting the goal node.
Algorithm:
1. Create a variable called NODE-LIST and set it to initial state.
2. Until a goal state is found or NODE-LIST is empty do:
i. Remove the first element from NODE-LIST and call it E. If NODE-LIST
was empty, quit.
ii. For each way that each rule can match the state described in E do:
a. Apply the rule to generate a new state.
b. If the new state is a goal state, quit and return this state.
c. Otherwise, add the new state to the end of NODE-LIST.
17
Depth First Search (DFS)
DFS is also an important type of uninformed search. DFS visits all the vertices in the graph.
This type of algorithm always chooses to go deeper into the graph. After DFS visited all the
reachable vertices from a particular sources vertices it chooses one of the remaining
undiscovered vertices and continues the search. DFS reminds the space limitation of breath
first search by always generating next a child of the deepest unexpanded nodded. The data
structure stack or last in first out (LIFO) is used for DFS. One interesting property of DFS is
that, discover and finish time of each vertex from a parenthesis structure. If we use one open
parenthesis when a vertex is finished then the result is properly nested set of parenthesis.
Concept:
Step 1: Traverse the root node.
Step 2: Traverse any neighbour of the root node.
Step 3: Traverse any neighbour of neighbour of the root node.
Step 4: This process will continue until we are getting the goal node.
Algorithm:
1. If the initial state is a goal state, quit and return success
2. Otherwise, do the following until success or failure is signaled:
a. Generate a successor, E, of initial state. If there are no more successors, signal failure.
b. Call Depth-First Search, with E as the initial state
c. If success is returned, signal success. Otherwise continue in this loop.
18
Brute Force or Blind Search
Brute force or blind search is a uniformed exploration of the search space and it does not
explicitly take into account either planning efficiency or execution efficiency. Blind search is
also called uniform search. It is the search which has no information about its domain. The
only thing that a blind search can do is to differentiate between a non-goal state and a goal
state. These methods do not need domain knowledge but they are less efficient in result.
Uniform strategies don’t use any information about how a close a node might be to a goal.
They differ in the order that the nodes are expanded. The most important brute force techniques
are breadth first search, depth first search, uniform search and bidirectional search. All brute
force techniques must take (bd time and use o (d) space. This technique is not as efficient as
compared to other algorithms.
Greedy Search
This algorithm uses an approach which is quite similar to the best first search algorithm. It is a
simple best first search which reduces the estimated cost of reach the goal. Basically it takes
the closest node that appears to be closest to the goal. This search starts with the initial matrix
and makes very single possible changes then looks at the change it made to the score. This
search then applies the change till the greatest improvement. The search continues until no
further improvement can be made. The greedy search never makes never makes a lateral move
.It uses minimal estimated cost h (n) to the goal state as measure which decreases the search
time but the algorithm is neither complete nor optimal. The main advantage of this search is
that it is simple and finds solution quickly. The disadvantages are that it is not optimal,
susceptible to false start.
In order to solve many hard problems efficiently, it is often necessary to compromise the
requirements of mobility and systematically and to construct a control structure that is no
longer guaranteed to find the best answer but will always find a very good answer.
Usually very hard problems tend to have very large search spaces. Heuristics can be used
to limit search process.
There are good general purpose heuristics that are useful in a wide variety of problem
domains.
Special purpose heuristics exploit domain specific knowledge.
For example nearest neighbor heuristics for shortest path problem. It works by selecting
locally superior alternative at each step.
Applying nearest neighbor heuristics to Travelling Salesman Problem:
This procedure executes in time proportional to N2, where N is the number of cities to be
visited.
19
Heuristic Function
Heuristic search algorithm uses information about the problem to help directing the path
through the search space. These searches uses some functions that estimate the cost from
the current state to the goal presuming that such function is efficient.
A heuristic function is a function that maps from problem state descriptions to measure of
desirability usually represented as number. The purpose of heuristic function is to guide
the search process in the most profitable directions by suggesting which path to follow
first when more than is available
Well-designed heuristic functions can provides a fairly good estimate of whether a path is
good or not. (“ The sum of the distances traveled so far" is a simple heuristic function in
the traveling salesman problem)
Heuristic function maps from problem state descriptions to measures of desirability, usually
represented as numbers.
Which aspects of the problem state are considered, how those aspects are evaluated, and
the weights given to individual aspects are chosen in such a way that the value of the
heuristic function at a given node in the search process gives as good an estimate as possible
of whether that node is on the desired path to a solution.
Well-designed heuristic functions can play an important part in efficiently guiding a search
process toward a solution.
Every search process can be viewed as a traversal of a directed graph, in which the nodes
represent problem states and the arcs represent relationships between states.
The search process must find a path through this graph, starting at an initial state and ending
in one or more final states.
Domain-specific knowledge must be added to improve search efficiency. Information about
the problem includes the nature of states, cost of transforming from one state to another,
and characteristics of the goals.
This information can often be expressed in the form of heuristic evaluation function.
In general, heuristic search improve the quality of the path that are exported.
Using good heuristics we can hope to get good solutions to hard problems such as the
traveling salesman problem in less than exponential time.
A Heuristic technique helps in solving problems, even though there is no guarantee that it will
never lead in the wrong direction. There are heuristics of every general applicability as well as
domain specific. The strategies are general purpose heuristics. In order to use them in a specific
domain they are coupler with some domain specific heuristics. There are two major ways in
which domain - specific, heuristic information can be incorporated into rule-based search
procedure.
20
HEURISTIC SEARCH
A heuristic search improves the efficiently of the search process, but sacrifices the claims of
completeness. But they improve the quality of the paths that are explored. Using good
heuristics we can get good solutions to hard problems, such as the traveling salesman problem.
For real world problems, it is often hard to measure precisely the goodness of a particular
solution. For instance, answers to questions like “Why has inflation increased?” cannot be
precise.
ii) For real world problems it is often useful to introduce heuristics based on relatively
unstructured knowledge. This is because often a mathematical analysis is not possible. Without
heuristics, it is not possible to tackle combinatorial explosion. Moreover, we go for optimum
solution that satisfy some set of requirements. We stop with satisfactory solutions even though
there might be better solutions.
Ex.A good example of this is the search for a taking space. Most people will stop as soon as
there find a fairly good space, even if there must be a slightly better space or ahead.
Introduction:- Many if the problems are too complex to be solvable by direct techniques. They
have to be solved only by suitable heuristic search techniques. Though the heuristic techniques
can be described independently, they are domain specific. They are called " Weak Methods",
since they are vulnerable to combinatorial explosion. Even so, they provide the frame work
into which domain specific knowledge can be placed.
Every search process can be viewed as a traversal of a directed graph, in which the nodes
represent problem states and the arcs represent relationships between states. The search process
must find a path through this graph, starting at an initial state and ending in one or more final
states. The following issues have to be considered before going for a search.
Heuristic techniques are called weak methods, since they are vulnerable to combinatorial
21
explosion. Even then these techniques continue to provide framework into which domain
specific knowledge can be placed, either by hand or as a result of learning. The following are
some general purpose control strategies (often called weak methods).
I. Generate-and-Test
Generate-and-test search algorithm is a very simple algorithm that guarantees to find a
solution if done systematically and there exists a solution.
Algorithm:
1. Generate a possible solution. For some problems, this means generating a particular point
in the problem space. For others it means generating a path from a start stat.
2. Test to see if this is actually a solution by comparing the chosen point or the endpoint of
the chosen path to the set of acceptable goal states.
3. If a solution has been found, quit, Otherwise return to step 1.
It is a depth first search procedure since complete solutions must be generated before
they can be tested.
In its most systematic form, it is simply an exhaustive search of the problem space.
It operates by generating solutions randomly.
This is a variety of depth-first (generate - and - test) search. A feedback is used here to decide
on the direction of motion in the search space. In the depth-first search, the test function will
merely accept or reject a solution. But in hill climbing the test function is provided with a
heuristic function which provides an estimate of how close a given state is to goal state. The
hill climbing test procedure is as follows:
22
1. Generate the first proposed solution as done in depth-first procedure. See if it is a
solution. If so quit, else continue.
2. From this solution generate new set of solutions use, some application rules
3. For each element of this set
4. Take the best element so far generated and use it as the next proposed solution. This
step corresponds to move through the problem space in the direction Towards the goal
state.
5. Go back to step 2
Hill climbing is often used when a good heuristic function is available for evaluating states
but when no other useful knowledge is available.
The key difference between Simple Hill climbing and Generate-and-test is the use of
evaluation function as a way to inject task specific knowledge into the control process.
Algorithm:
1. Evaluate the initial state. If it is also goal state, then return it and quit. Otherwise
continue with the initial state as the current state.
2. Loop until a solution is found or until there are no new operators left to be applied in
the current state:
a. Select an operator that has not yet been applied to the current state and apply it
to produce a new state.
b. Evaluate the new state
i. If it is the goal state, then return it and quit.
ii. If it is not a goal state but it is better than the current state, then make it
the current state.
iii. If it is not better than the current state, then continue in the loop.
Algorithm
1. Evaluate the initial state. If it is also a goal state, then return it and quit. Otherwise, continue
with the initial state as the current state.
2. Loop until a solution is found or until a complete iteration produces no change to current
state:
a. Let S be a state such that any possible successor of the current state will be better
than S.
23
b. For each operator that applies to the current state do:
i. Apply the operator and generate a new state
ii. Evaluate the new state. If it is a goal state, then return it and quit. If not,
compare it to S. If it is better, then set S to this state. If it is not better,
leave S alone.
c. If the S is better than the current state, then set current state to S.
Sometimes this procedure may lead to a position, which is not a solution, but from which there
is no move that improves things. This will happen if we have reached one of the following
three states.
(a) A "local maximum” which is a state better than all its neighbors, but is not better than
some other states farther away. Local maxim sometimes occur within sight of a solution. In
such cases they are called “Foothills".
(b) A "plateau'' which is a flat area of the search space, in which neighboring states have the
same value [a plateau is a flat area of the search space in which, a whole set of neighboring
states have the same values]. On a plateau, it is not possible to determine the best direction in
which to move by making local comparisons.
(c) A "ridge" which is an area in the search that is higher than the surrounding areas, but
cannot be searched in a simple move. It is a special kind of local maximum. It is an area of the
search space that is higher than surrounding areas and that itself has slop.
In each of the previous cases (local maxima, plateaus & ridge), the algorithm reaches a point
at which no progress is being made.
(a) Back track to some earlier nodes and try a different direction. This is a good way of dealing
with local maxim.
(b) Make a big jump at some direction to a new area in the search. This can be done by applying
two more rules of the same rule several times, before testing. This is a good strategy is dealing
with plate and ridges.
24
(c) Moving in several directions at once.
Hill climbing becomes inefficient in large problem spaces, and when combinatorial explosion
occurs. But it is a useful when combined with other methods.
Best-first search in its most general form is a simple heuristic search algorithm. “Heuristic”
here refers to a general problem-solving rule or set of rules that do not guarantee the best
solution or even any solution, but serves as a useful guide for problem-solving. Best-first search
is a graph-based search algorithm (Dechter and Pearl, 1985), meaning that the search space can
be represented as a series of nodes connected by paths.
Best-first search is an algorithm that traverses a graph in search of one or more goal nodes. The
defining characteristic of this search is that, unlike DFS or BFS (which blindly
examines/expands a cell without knowing anything about it or its properties), best-first search
uses an evaluation function (sometimes called a "heuristic") to determine which object is the
most promising, and then examines this object. This "best first" behavior is implemented with
a Priority Queue.
DFS is good because it allows a solution to be found without expanding all competing
branches. BFS is good because it does not get trapped on dead end paths.
Best first search combines the advantages of both DFS and BFS into a single method.
One way of combining BFS and DFS is to follow a single path at a time, but switch
paths whenever some competing path looks more promising than the current one does.
OR Graphs
It is sometimes important to search graphs so that duplicate paths will not be pursued.
An algorithm to do this will operate by searching a directed graph in which each node
represents a point in problem space.
Each node will contain:
Description of problem state it represents
Indication of how promising it is
Parent link that points back to the best node from which it came
List of nodes that were generated from it
Parent link will make it possible to recover the path to the goal, once the goal is found.
The list of successors will make it possible, if a better path is found to an already existing
node, to propagate the improvement down to its successors.
This is called OR-graph, since each of its branches represents an alternative problem
solving path.
Implementation of OR graphs
We need two lists of nodes:
OPEN – nodes that have been generated and have had the heuristic function applied to
them but which have not yet been examined. OPEN is actually a priority queue in which
the elements with the highest priority are those with the most promising value of the
heuristic function.
CLOSED- nodes that have already been examined. We need to keep these nodes in
memory if we want to search a graph rather than a tree, since whenever a new node is
25
generated; we need to check whether it has been generated before.
Applications
Best-first search and its more advanced variants have been used in such applications as games
and web crawlers.
In a web crawler, each web page is treated as a node, and all the hyperlinks on the page are
treated as unvisited successor nodes. A crawler that uses best-first search generally uses an
evaluation function that assigns priority to links based on how closely the contents of their
parent page resemble the search query
In games, best-first search may be used as a path-finding algorithm for game characters.
For example, it could be used by an enemy agent to find the location of the player in the
game world. Some games divide up the terrain into “tiles” which can either be blocked or
unblocked. In such cases, the search algorithm treats each tile as a node, with the
neighbouring unblocked tiles being successor nodes, and the goal node being the
destination tile.
26
The A* Algorithm
Best First Search is a simplification of A* Algorithm. The algorithm searches a directed graph
in which each node represents a point in the problem space. Each node will contain a
description of the problem state it represents and it will have links to its parent nodes and
successor nodes. In addition it will also indicate how best it is for the search process. A*
algorithm uses have been generated, heuristic functions applied to them, but successors not
generated. The list CLOSED contains nodes which have been examined, i.e., their successors
generated.
27
Observations about A*
Role of g function: This lets us choose which node to expand next on the basis of not only
of how good the node itself looks, but also on the basis of how good the path to the node
was.
h’, the distance of a node to the goal. If h’ is a perfect estimator of h, then A* will converge
immediately to the goal with no search.
Admissibility of A*
A heuristic function h’(n) is said to be admissible if it never overestimates the cost of
getting to a goal state. i.e. if the true minimum cost of getting from node n to a goal
state is C then h must satisfy: h’(n) ≤ C
If h’ is a perfect estimator of h, then A* will converge immediately to the goal state
with no search.
If h’ never overestimates h, then A* algorithm is guaranteed to find an optimal path if
one exists.
Problem Reduction
AND-OR graphs
AND-OR graph (or tree) is useful for representing the solution of problems that can be
solved by decomposing them into a set of smaller problems, all of which must then be
solved.
This decomposition or reduction generates arcs that we call AND arcs.
One AND arc may point to any numbers of successor nodes. All of which must then be
solved in order for the arc to point solution
In order to find solution in an AND-OR graph we need an algorithm similar to best –
first search but with the ability to handle the AND arcs appropriately.
o We define FUTILITY, if the estimated cost of solution becomes greater than the value of
FUTILITY then we abandon the search, FUTILITY should be chosen to correspond to a
threshold.
o Following figure shows AND arcs are indicated with a line connection all the components.
28
And such a value is not necessary because of the top-down traversing of the edge which
guarantees that only nodes that are on the best path will ever be considered for
expansion.
Algorithm: AO*
1. Let GRAPH consist only of the node representing the initial state. Call this node INIT,
Compute VINIT.
2. Until INIT is labeled SOLVED or until INIT's h' value becomes greater than FUTILITY,
repeat the following procedure:
a. Trace the labeled arcs from INIT and select for expansion one of the as yet
unexpanded nodes that occurs on this path. Call the selected node NODE.
b. Generate the successors of NODE. If there are none, then assign FUTILITY as the
h' value of NODE. This is equivalent to saying that NODE is not solvable. If there are
successors, then for each one (called SUCCESSOR) that is not also an ancestor of
NODE do the following:
i. Add SUCCESSOR to GRAPH
ii. If SUCCESSOR is a terminal node, label it SOLVED and assign it an h' value
of 0
c. Propagate the newly discovered information up the graph by doing the following: Let
S be a set of nodes that have been labeled SOLVED or whose h' values have been
changed and so need to have values propagated back to their parents. Initialize 5 to
NODE. Until S is empty, repeat the, following procedure:
ii. Compute the cost of each of the arcs emerging from CURRENT. The cost of
each arc is equal to the sum of the h' values of each of the nodes at the end of
the arc plus whatever the cost of the arc itself is. Assign as CURRENT'S new h'
value the minimum of the costs just computed for the arcs emerging from it.
iii. Mark the best path out of CURRENT by marking the arc that had the
minimum cost as computed in the previous step.
iv. Mark CURRENT SOLVED if all of the nodes connected to it through the
new labeled arc have been labeled SOLVED.
29
VI. Constraint Satisfaction
Constraint satisfaction is a search procedure that operates in a space of constraint sets.
The initial state contains the constraints that are originally given in the problem
description.
A goal state is any state that has been constrained “enough” where “enough” must be
defined for each problem.
For example, in cryptarithmetic problems, enough means that each letter has been
assigned a unique numeric value.
Constraint Satisfaction problems in AI have goal of discovering some problem state
that satisfies a given set of constraints.
Design tasks can be viewed as constraint satisfaction problems in which a design must
be created within fixed limits on time, cost, and materials.
Constraint Satisfaction is a two-step process:
1. First constraints are discovered and propagated as far as possible throughout the
system.
2. Then if there is still not a solution, search begins. A guess about something is
made and added as a new constraint.
The solution process proceeds in cycles. At each cycle, two significant things are done:
1. Constraints are propagated by using rules that correspond to the properties of arithmetic.
2. A value is guessed for some letter whose value is not yet determined.
30
Algorithm: Constraint Satisfaction
1. Propagate available constraints. To do this first set OPEN to set of all objects that must have
values assigned to them in a complete solution. Then do until an inconsistency is detected or
until OPEN is empty:
a. Select an object OB from OPEN. Strengthen as much as possible the set of constraints
that apply to OB.
b. If this set is different from the set that was assigned the last time OB was examined
or if this is the first time OB has been examined, then add to OPEN all objects that share
any constraints with OB.
c. Remove OB from OPEN.
2. If the union of the constraints discovered above defines a solution, then quit and report the
solution.
3. If the union of the constraints discovered above defines a contradiction, then return the
failure.
4. If neither of the above occurs, then it is necessary to make a guess at something in order to
proceed. To do this loop until a solution is found or all possible solutions have been eliminated:
a. Select an object whose value is not yet determined and select a way of strengthening
the constraints on that object.
b. Recursively invoke constraint satisfaction with the current set of constraints
augmented by strengthening constraint just selected.
Most of the search strategies either reason forward of backward however, often a mixture of
the two directions is appropriate. Such mixed strategy would make it possible to solve the major
parts of problem first and solve the smaller problems that arise when combining them together.
Such a technique is called "Means - Ends Analysis".
The means -ends analysis process centres around finding the difference between current state
and goal state. The problem space of means - ends analysis has an initial state and one or more
goal state, a set of operate with a set of preconditions their application and difference functions
that computes the difference between two state a(i) and s(j). A problem is solved using means
- ends analysis by
1. Computing the current state s1 to a goal state s2 and computing their difference D12.
2. Satisfy the preconditions for some recommended operator op is selected, then to reduce the
difference D12.
31
3. The operator OP is applied if possible. If not the current state is solved a goal is created and
means- ends analysis is applied recursively to reduce the sub goal.
4. If the sub goal is solved state is restored and work resumed on the original problem.
(the first AI program to use means - ends analysis was the GPS General problem solver)
Means- ends analysis is useful for many human planning activities. Consider the example of
planning for an office worker. Suppose we have a different table of three rules:
1. If in our current state we are hungry, and in our goal state we are not hungry, then either the
"visit hotel" or "visit Canteen” operator is recommended.
2. If our current state we do not have money, and if in your goal state we have money, then the
"Visit our bank" operator or the "Visit secretary" operator is recommended.
3. If our current state we do not know where something is , need in our goal state we do know,
then either the "visit office enquiry" , "visit secretary" or "visit co-worker " operator is
recommended.
c. If
(FIRST-PART MEA( CURRENT, O-START))
and
(LAST-PART MEA(O-RESULT, GOAL))
are successful, then signal success and return the result of concatenating
FIRST-PART, O, and LAST-PART.
32
INTELLIGENT AGENTS
For an increasingly large number of applications, we require systems that can decide for
themselves what they need to do in order to satisfy their design objectives. Such computer
systems are known as agents. Agents that must operate robustly in rapidly changing,
unpredictable, or open environments, where there is a significant possibility that actions can
fail are known as intelligent agents, or sometimes autonomous agents. An AI system is
composed of an agent and its environment. The agents act in their environment. The
environment may contain other agents.
An agent is a computer system that is situated in some environment, and that is capable of
autonomous action in this environment in order to meet its design objectives.
An intelligent agent is one that is capable of flexible autonomous action in order to meet its design
objectives. The Flexibility includes:
reactivity: intelligent agents are able to perceive their environment, and respond in a timely
fashion to changes that occur in it in order to satisfy their design objectives;
pro-activeness: intelligent agents are able to exhibit goal-directed behaviour by taking the
initiative in order to satisfy their design objectives;
Social ability: intelligent agents are capable of interacting with other agents (and possibly
humans) in order to satisfy their design objectives.
33
Agent Terminology
Performance Measure of Agent − It is the criteria, which determines how successful
an agent is.
Behavior of Agent − It is the action that agent performs after any given sequence of
percepts.
Percept − It is agent’s perceptual inputs at a given instance.
Percept Sequence − It is the history of all that an agent has perceived till date.
Agent Function − It is a map from the precept sequence to an action.
Rationality
Rationality is nothing but status of being reasonable, sensible, and having good sense of
judgment.
Rationality is concerned with expected actions and results depending upon what the agent has
perceived. Performing actions with the aim of obtaining useful information is an important
part of rationality.
34
Model Based Reflex Agents
They use a model of the world to choose their actions. They maintain an internal state.
Model − The knowledge about “how the things happen in the world”.
Internal State − It is a representation of unobserved aspects of current state depending on
percept history.
Updating the state requires the information about −
How the world evolves.
How the agent’s actions affect the world.
35
Utility Based Agents
They choose actions based on a preference (utility) for each state. Goals are inadequate when
−
There are conflicting goals, out of which only few can be achieved.
Goals have some uncertainty of being achieved and you need to weigh likelihood of
success against the importance of a goal.
Nature of Environments
Some programs operate in the entirely artificial environment confined to keyboard input,
database, computer file systems and character output on a screen.
In contrast, some software agents (software robots or softbots) exist in rich, unlimited softbots
domains. The simulator has a very detailed, complex environment. The software agent
needs to choose from a long array of actions in real time. A softbot designed to scan the online
preferences of the customer and show interesting items to the customer works in the real as
well as an artificial environment.
The most famous artificial environment is the Turing Test environment, in which one real
and other artificial agents are tested on equal ground. This is a very challenging environment
as it is highly difficult for a software agent to perform as well as a human.
Turing Test
The success of an intelligent behavior of a system can be measured with Turing Test.
Two persons and a machine to be evaluated participate in the test. Out of the two
persons, one plays the role of the tester. Each of them sits in different rooms. The tester
is unaware of who is machine and who is a human. He interrogates the questions by
typing and sending them to both intelligences, to which he receives typed responses.
This test aims at fooling the tester. If the tester fails to determine machine’s response
from the human response, then the machine is said to be intelligent.
36
Properties of Environment
Discrete / Continuous − If there are a limited number of distinct, clearly defined, states
of the environment, the environment is discrete (For example, chess); otherwise it is
continuous (For example, driving).
Static / Dynamic − If the environment does not change while an agent is acting, then
it is static; otherwise it is dynamic.
Single agent / Multiple agents − The environment may contain other agents which
may be of the same or different kind as that of the agent.
Accessible / Inaccessible − If the agent’s sensory apparatus can have access to the
complete state of the environment, then the environment is accessible to that agent.
37