Ai Chapter 2
Ai Chapter 2
Introduction
• Problem solving is the major area of concern in Artificial Intelligence.
• It is the process of generating solution from given observed data.
• To solve a particular problem, we need to build a system or a method which can generate
required solution.
• Following four things are required for building such system.
1. Define the problem precisely.
➢ This definition must precisely specify the initial situation (input).
➢ What final situation (output) will constitute the acceptable solution to the
problem.
2. Analyze the problem.
➢ To identify those important features which can have an immense impact
on the appropriateness of various possible techniques for solving the
problem.
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.
3 (x, y) if x > 0 (x-d, y) Pour some water out of the 4 gallon jug
4 (x, y) if y > 0 (x, y-d) Pour some water out of the 3 gallon jug
7 (x, y) if x+y >= 4 and (4, y-(4-x)) Pour water from the 3 gallon jug into the
y>0 4 gallon jug until the 4 gallon jug is full
8 (x, y) if x+y >= 3 and (x-(3-y), 3) Pour water from the 4 gallon jug into the
x>0 3-gallon jug until the 3 gallon jug is full
9 (x, y) if x+y <=4 and (x+y, 0) Pour all the water from the 3 gallon jug
y>0 into the 4 gallon jug
10 (x, y) if x+y <= 3 and (0, x+y) Pour all the water from the 4 gallon jug
x>0 into the 3 gallon jug
• There are several sequences of operators that will solve the problem.
• One of the possible solutions is given as:
Gallons in the 4- Gallons in the 3- Rule applied
gallon jug gallon jug
0 0 2
0 3 9
3 0 2
3 3 7
4 2 5 or 12
0 2 9 0r 11
2 0 --
• 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…
Production System
• Search process forms the core of many intelligence processes.
• So, it is useful to structure AI programs in a way that facilitates describing and performing
the search process.
• Production system provides such structures.
• A production system consists of:
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.
• In order to solve a problem:
o We must first reduce it to the form for which a precise statement can be given. This
can be done by defining the problem’s state space (start and goal states) and a set of
operators for moving that space.
o The problem can then be solved by searching for a path through the space from an
initial state to a goal state.
o The process of solving the problem can usefully be modeled as a production system.
Benefits of Production System
1. Production systems provide an excellent tool for structuring AI programs.
2. Production Systems are highly modular because the individual rules can be added,
removed or modified independently.
3. The production rules are expressed in a natural form, so the statements contained in the
Control Strategies
• Control strategies help us decide which rule to apply next during the process of searching
for a solution to a problem.
• Good control strategy should:
1. It should cause motion
2. It should be Systematic
• Control strategies are classified as:
1. Uninformed/blind search control strategy:
o Do not have additional information about states beyond problem definition.
o Total search space is looked for solution.
o Example: Breadth First Search (BFS), Depth First Search (DFS), Depth Limited
Search (DLS).
2. Informed/Directed Search Control Strategy:
o Some information about problem space is used to compute preference
among the various possibilities for exploration and expansion.
o Examples: Best First Search, Problem Decomposition, A*, Mean end Analysis
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.
1. Is the problem decomposable into a set of independent smaller or easier sub-problems?
➢ 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 :- ∫ 𝑥2 + 3𝑥 + 𝑠𝑖𝑛2𝑥 𝑐𝑜𝑠2𝑥 𝑑𝑥
➢ 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.
2. Can solution steps be ignored or at least undone if they prove unwise?
➢ Problem fall under three classes, (i) ignorable, (ii) recoverable and (iii) irrecoverable.
Gopi Sanghani, CE Department | 2180703 – Artificial Intelligence 10
2 – Problems, State Space Search &
Heuristic Search Techniques
➢ This classification is with reference to the steps of the solution to a problem.
➢ 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.
➢ 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.
➢ Lastly consider the game of chess. If a wrong move is made, it can neither be ignored nor
be recovered. The thing to do is to make the best use of current situation and proceed.
This is an example of an irrecoverable solution steps.
➢ Knowledge of these will help in determining the control structure.
o Ignorable problems can be solved using a simple control structure that never
backtracks.
o Recoverable problems can be solved by a slightly more complicated control strategy
that allows backtracking.
o Irrecoverable problems will need to be solved by a system that expends a great deal
of effort making each decision since decision must be final.
3. Is the problem’s universe predictable?
➢ Problems can be classified into those with certain outcome (eight puzzle and water jug
problems) and those with uncertain outcome (playing cards).
➢ In certain – outcome problems, planning could be done to generate a sequence of
operators that guarantees to lead to a solution.
➢ Planning helps to avoid unwanted solution steps.
➢ For uncertain outcome problems, planning can at best generate a sequence of operators
that has a good probability of leading to a solution.
➢ The uncertain outcome problems do not guarantee a solution and it is often very
expensive since the number of solution paths to be explored increases exponentially
with the number of points at which the outcome cannot be predicted.
➢ Thus one of the hardest types of problems to solve is the irrecoverable, uncertain –
outcome problems (Ex:- Playing cards).
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.
➢ In any path problem, like the water jug and 8 puzzle problems, we are satisfied with the
solution, irrespective of the solution path taken.
➢ 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
Heuristic Function
• 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.
• In each of the previous cases (local maxima, plateaus & ridge), the algorithm reaches a
point at which no progress is being made.
• A solution is,
i. Backtrack to some earlier node and try going in a different direction.
ii. Make a big jump to try to get in a new section.
iii. Moving in several directions at once.
The A* Algorithm
• Best First Search is a simplification of A* Algorithm.
• This algorithm uses following functions:
Observations about A*
o 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.
o 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*
• 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.
Solution: