0% found this document useful (0 votes)
3 views

Module 1 Reference

The document outlines key concepts in artificial intelligence, focusing on problem-solving techniques and search strategies. It discusses the formal description of problems, examples like the Tic Tac Toe and Water Jug problems, and various search algorithms including breadth-first and depth-first search. Additionally, it covers production systems, control strategies, and heuristic search methods, highlighting their advantages and disadvantages.

Uploaded by

Vishwesh J
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Module 1 Reference

The document outlines key concepts in artificial intelligence, focusing on problem-solving techniques and search strategies. It discusses the formal description of problems, examples like the Tic Tac Toe and Water Jug problems, and various search algorithms including breadth-first and depth-first search. Additionally, it covers production systems, control strategies, and heuristic search methods, highlighting their advantages and disadvantages.

Uploaded by

Vishwesh J
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 103

Artificial Intelligence

Module1 :
Syllabus: Problems, Problem Spaces and search,
Heuristic search technique (TextBook1: Ch 1, 2
and 3)
Problems, Problem Space and Search
To build a system to solve a particular problem we need
to do four things:

1. Define the problem precisely ( Precise Specification ,


Initial Situation , Final Situation and Acceptable
Solution )
2. Analyze the problem (Features , Various Possible
techniques , etc)
3. Isolate and represent the task knowledge that is
necessary to solve the problem.
4. Choose the best problem solving techniques and
apply it to the particular problem
Formal Description of a Problem :
In order to provide a formal description of a
problem we must do the following :
1. Define a state space that contains all possible
configuration of the relevant objects
2. Define the initial States
3. Define the Goal /Final States
4. Specify the Rules that describe the action
(operators) available.
Example1: The Tic Tac Toe as a State
Space Search Representation
Answer:
• Configuration of the Board (State Space)
– Board is Vector of 9 squares of 3 X 3 Matrix Form
– Next Move of a Players : X or O
– Board Configuration may change accordingly to each move of the
player
• Initial State : Board is Empty by X’s Turn
• Final States : Three X’s in Row / Three O’s in Row / All Cells Full
• Rules :
– At a time one square can be filled in any direction
– Initial turn is of X
– Out of X and O players who will form the row First will be the winner
– If No Row is formed but the board is filled the Match is draw.
Example 2: A Water Jug Problem :
You are given two jugs a 4 Gallon Jug one and
3 Gallon Jug one .Neither has any measuring
markers on it. There is a pump that can be
used to fill the jugs with water. How can you
get exactly 2 Gallon of Water into the 4 Gallon
Jug .
Solution
• State Space: The state space for this problem can
be described as the set of ordered pairs of
integers (x, y). Where
– x represents the number of Gallons of water in the 4
Gallon Jug , such that x = 0,1,2,3 or 4
– y represent the quantity of water in the 3 gallon jug ,
such that y = 0, 1, 2 or 3.
• Initial State : The Start State is (0,0)
• Goal State : The Final State is (2,n)
• Rules : The Production rule for the Water Jug
Problem is given below :
Rule Rule Descriptions
#
1 (x,y) if x<4 →(4,y) Fill the 4 Gallon Jug
2 (x,y) if y<3 → (x,3) Fill the 3 Gallon Jug
3 (x,y) if x>0 → (x-d,y) Pour Some Water out of 4 Gallon Jug
4 (x,y) if y>0 → (x,y-d) Pour Some Water out of 3 Gallon Jug
5 (x,y) if x>0 → (0,y) Empty the 4 Gallon Jug on the Ground
6 (x,y) if y>0 → (x,0) Empty the 3 Gallon Jug on the Ground
7 (x,y) if x+y ≥ 4 and y>0 → (4,(y-(4-x)) Pour the water from the 3 Gallon Jug into
the 4 Gallon Jug until the 4 Gallon Jug is full
8 (x,y) if x+y ≥3 and x>0 → (x- (3-y),3) Pour water from the 4 Gallon jug into the 3
Gallon jug until the 3 Gallon jug is full
9 (x,y) if x+y ≤ 4 and y>0 → (x+y,0) Pour all the water from the water from the 3
Gallon jug into the 4 Gallon jug.
10 (x,y) if x+y ≤3 and x>0 → (0,x+y) Pour all the water from the 4 G jug into the 3
Gallon jug
11 (0,2) → (2,0 ) Pour the 2 Gallon water from the 3 Gallon
jug into the 4 Gallon Jug
12 (2,y) → (0,y ) Empty the 2 Gallon water in the 4 Gallon Jug
on the Ground.
One Solution to the Problem
Gallons in the 4 Gallon Jug Gallons in the 3 Gallon Jug Rule Applied

0 0 Initial State

0 3 2

3 0 9

3 3 2

4 2 7

0 2 5 or 12

2 0 9 or 11
Production System
• A production system (or production rule system)
is a computer program typically used to provide
some form of artificial intelligence, which consists
primarily of a set of rules about behavior.
• These rules, termed productions, are a basic
representation found useful in automated
planning, expert systems and action selection.
• A production system provides the mechanism
necessary to execute productions in order to
achieve some goal for the system.
S1→A1
S2→A2
Working Memory Pattern S3→A3
S4→A4
-----------
Pattern → Action
----------
Sn→An
The major components of an AI
production system are

i. A Global database:
ii. A Set of production rules:
iii. A Control system/Strategy:
iv . Rule Applier :
Four classes of production systems:-

• 1. A monotonic production system: A system in which the


application of a rule never prevents the later application of another
rule that could have also been applied at the time the first rule was
selected.
• 2. A non monotonic production system: Here the application of
rule prevents later application of the another rule which may not
have been applied at the time the first rule was selected i.e it is a
system in which the above rule is not true i.e , the monotonic
production system rule not true.

3. A partially commutative production system: A production
system in which the application of a particular sequence of rules
transforms state X into state Y.
4. A commutative production system: Is a program which satisfies
both monotonic and partially commutative production System.
Monotonic Non
Monotonic
Partially Theorem Robot
Commutative Proving Navigation
Not Partially Chemical Bridge
Commutative Synthesis
Advantages of Production Systems

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
knowledge base should be the recording of an
expert thinking out loud.
Disadvantages of Production Systems

• 1. Very difficult to analyze the flow of control


within a production system because the
individual rules don’t call each other.
• 2. Several Production systems exist for various
types of problems. The efficiency varies from
problem to problem.
Control Strategies
• A control strategy that determines the order in which
the rules are applied to the database, and provides a
way of resolving any conflicts that can arise when
several rules match at once.
• A good control strategy should have the following
requirement:
– The first requirement is that it causes motion. In a game
playing program the pieces move on the board and in the
water jug problem water is used to fill jugs.
– The second requirement is that it is systematic, this is a
clear requirement for it would not be sensible to fill a jug
and empty it repeatedly nor in a game would it be
advisable to move a piece round and round the board in a
cyclic way.
Search Techniques for Artificial
Intelligence
Search is a central topic in Artificial Intelligence. The
basic search algorithms/techniques can be
classified as follows:
• Uninformed( Blind) search: Breadth-first, Depth-
first, depth limited, iterative deepening, and
bidirectional search
• Informed (Heuristic) search: Generate and Test,
Hill Climbing , Best First Search , Problem
Reduction, Constraint Satisfaction , Means ends
Analysis .
BFS
• Expand all the nodes of one level first. Here
the nodes are expanded one level at a time. In
this type of search, the state space is
represented in form of a tree. In addition, the
solution is obtained by traversing through the
tree.
Example
• Construct a tree with initial state as its root . Generate all the offspring off the
root by applying each of the applicable rules to the initial state. Figure below
shows how tree looks at this point.

(0,0)

(4,0) (0,3)
Now for Each leaf node generate all its successors by
applying all the rules that are appropriate. The tree at this
point is shown in Figure below :

(0,0)

(4,0) (0,3)

(4,3) (0,0) (1,3) (4,3) (0,0) (3,0)


Breadth first search Algorithm
S1. Create a variable called NODE_LIST and set it to the initial state

S2: Until a goal state is found or NODE_LIST is empty


a. Remove the First Element from NODE_LIST and Call it E
I. IF NODE _LIST was empty quit

b. For Each way that each rule can match the state described in E do
I. Apply the rule to generate a new state
II. If the new state is a goal state , quit and return this state
III. Otherwise add the new state to end of NODE_LIST

(0,0)

(0,0)
(4,0) (0,3)

(4,0) (0,3)
(4,3) (0,0) (1,3) (4,3) (0,0) (3,0)
Advantages of BFS
• The breadth first search is not caught in a blind alley. This
means that, it will not follow a single unfruitful path for
very long time or forever, before the path actually
terminates in a state that has no successors. In DFS may
follow single unfruitful path for a very long time.
• In the situations where solution exists, the breadth first
search is guaranteed to find it. Besides this, in the
situations where there are multiple solutions, the BFS finds
the minimal solution. The minimal solution is one that
requires the minimum number of steps. In contrast DFS
may find a long path to a solution in one part of the tree ,
when a shorter path exists in some other , unexplored part
of the tree.
Depth First Search
• Expand one of the nodes at the deepest level.
Water Jug Problem Solution using DFS

(0,0)

(4,0) (0,3)

(1,3) (0,0) (4,3) (4,3) (0,0) (3,0)


(0,0)

(4,0) (0,3)

(1,3)

(1,0)

(0,1)

(4,1)

(2,3)
GOAL
Depth first search 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 successor
signal failure
b. Call DFS with E as the initial state
c. If success is returned , signal success , otherwise continue in this
loop
Advantages of Depth First Search
(DFS)
• DFS requires less memory space since only the
nodes on the current path are stored. In BFS all
the tree that has so far being generated must be
stored
• If care is taken in ordering the alternative
successor states DFS may find a solution without
examining much of the search space at all. In BFS
all parts of the tree must be examined to level n
before any nodes level n+1 can be examined.
Issues in the Design of Search
programs
1. The direction in which to conduct the search
(forward vs backward reasoning)
2. How to select applicable rules (matching)
3. How to represent each node of the search
process (knowledge representation problem
and frame problem)
4. Search tree versus Graph
Heuristic Search
• A heuristic technique (meaning : “Guide” "find" or
"discover"), often called simply a heuristic, is any
approach to problem solving, learning, or discovery
that employs a practical method not guaranteed to
be optimal or perfect, but sufficient for the
immediate goals.
• Where finding an optimal solution is impossible or
impractical, heuristic methods can be used to speed
up the process of finding a satisfactory solution.
• Heuristic are the approximations used to reduce the
search procedure.
Heuristic Search
• Heuristic actually works like a tour guide. E.g. imagine that
you are lost in a jungle and you are searching for road
which can lead you to a particular city.
• In un-informed search the search procedure have no other
information except initial node, goal node and set of legal
moves or rules
• In heuristic search along with this information other
domain specific information is also available like distance
of the current node and the goal node or the cost of
moving from current node to goal node, which can help
the search procedure to find the goal state more quickly
and efficiently that is why this type of search is also known
as informed search.
Following are the problems where
heuristics are applied.
1) Problems for which no exact algorithms are
known and one needs to find an
approximation and satisfying solution .
Example: Speech recognition, and computer
vision etc.
2) Problems for which exact solutions are
known, but computationally they are
infeasible. E.g. chess and cube game
Example
One example of a good general purpose
heuristic is nearest neighbor heuristic applied
to the Travelling Salesman Problem :
1. Arbitrarily select a starting city
2. To select the next city, look at all cities not yet
visited and select the one closest to the current
city. Go to it next
3. Repeat Step 2 until all cities have been visited
Heuristic Function
• h(n), which takes a node n and returns a non-
negative real number that is an estimate of
the path cost from node n to a goal node.
• The heuristic function is a way to inform the
search about the direction to a goal. It
provides an informed way to guess which
neighbor of a node will lead to a goal..
Some Simple Heuristic Functions
• Chess : The material advantage of our side
over the opponent
• Travelling Salesman Program : The sum of the
distances travelled so far
• Tic Tac Toe :
– 1 for each row in which we could win and in
which we already have one piece
– 2 for each such row in which we have two pieces
(Seven) Problem Characteristics
1. Is the problem decomposable?
2. Can solution steps be ignored or undone?
3. Is the universe predictable?
4. Is a good solution absolute or relative?
5. Is the solution a state or a path?
6. What is the role of knowledge?
7. Does the task require human‐interaction?
1. Is the Problem Decomposable
Example : Blocks World
A
C B
A B C
GOAL
START

on(B, table)
on(C, table)
on(A, table)
on(B, C)
on(C, A)
on(A, B)
clear(C)
clear(A)
clear(B)
2. Can the solution step be ignored or not
• In mathematical theorem proving the solution steps
can be ignore. In bridge or chess the solution steps
are not ignorable. Also they are not recoverable. But
in 8 puzzle problem the solution steps are
recoverable.
• Classes of problems
– Ignorable ( Eg: Theorem Proving ) in which solution steps
can be ignored
– Recoverable (Eg: 8 Puzzle ) in which solution steps can be
undone
– Irrecoverable (Eg: Chess) in which solution steps cannot
be undone.
3. Is the Universe Predictable
• Predictable : In 8 puzzle every time we make a
move we know exactly what will happen , this
means that it is possible to plan an entire
sequence of moves and be confident that we
know what the resulting state will be .
(The Universe Out come is Certain)
• Un Predictable : In Playing Bridge , We Cannot
know exactly where all
the cards are or what the other players will do
on their turn. (Uncertain outcome)
4. Is a good solution absolute or relative?

Consider the problem of answering question based on a


database of simple facts, such has the following:
1.Marcus was a man.
2.Marcus was a Pompeian.
3.Marcus was born in 40 A.D.
4.All men are mortal.
5.All Pompeian's died when the volcano erupted in 79 A.D.
6.No mortal lives longer than 150 years.
7.It is now 1991 A.D.
Suppose we ask a question
“ Is Marcus alive? “
Two ways to decide the answer

1 Marcus was a man 1 7 It is now 1991 A.D. 7


4 All men are mortal. 4
5 All Mortal’s died when the volcano erupted in 5
8 Marcus is a mortal 1,4
79 A.D.
3 Marcus was born in 40 A.D. 3
11 All Mortal’s are dead now 7,5
7 It is now 1991 A.D. 7
9 Marcus age is 1951 years 3,7 2 Marcas was pompeian 2

6 No mortal lives longer than 150 years 6 12 Marcus is dead 11,2


10 Marcus is dead 8,6,9

•Any‐path problems can be solved using heuristics that suggest good paths to explore.
•For best‐path problems, much more exhaustive search will be performed
5.Is the solution a state or a path?

• For the problem of the natural language understanding


the solution is a state of the world. Consider the
problem of finding a consistent interpretation for the
sentence “The bank president ate a dish of pasta
salad with the fork “ .
• Contrast to this with the water jug problem, what we
really must report is not the final state but the path
that we found to that state. Thus a statement of
solution to this problem must be a sequence of
operation that produces the final state. This problem
solution is path to the state.
6.What is the role of knowledge?

• Is a large amount of knowledge absolutely required to solve


the problem or is knowledge important only to constrain
the search.
• In 8 puzzle or Chess game we get a solution with the help of
knowledge base. (Rules for determining the legal moves).
• But when we consider the problem of scanning daily
newspaper to decide which political party will win in
upcoming election, it would have to know such things as
– The name of the candidate of each party
– Major issues/achievement to support party
– Major issues to oppose the party
– And so on –
7.Does the task require human‐interaction?

• Solitary problem, in which there is no intermediate


communication and no demand for an explanation
of the reasoning process.
• Conversational problem, in which intermediate co
mmunication is to provide either additional assistan
ce to the computer or additional information to the
user.
Problem Classification
• There is a variety of problem‐solving methods, but th
ere is no one single way of solving all problems.
• Not all new problems should be considered as totally
new. Solutions of similar problems can be exploited.
• Broad classes to which the problems falls is
associated with a generic control strategy that is
appropriate for solving the problems.
– Classification: Medical diagnosis tasks, Diagnosis of fault
in mechanical devices.
– Propose and Refine : Design and Planning Problems
Heuristic Search

1. Generate‐and‐test
2. Hill climbing
3. Best‐first search
4. Problem reduction
5. Constraint satisfaction
6. Means‐ends analysis
1. Generate‐and‐Test
Algorithm
1. Generate a possible solution.
2. Test to see if this is actually a solution by
comparing to the set of acceptable goal states.
3. If a solution has been found, quit.
Otherwise, return to step 1.
Generate-And-Test

2017/8/27 EIE426-AICV 51
Generate‐and‐Test

• It may be a systematic form or random form.


– In systematic form it is simply an exhaustive
search of the problem space.
– The random form is also known as the British
Museum method a reference to a method for
finding an object in the British Museum by
wandering randomly.
.
Example - Traveling Salesman Problem
(TSP)
• Traveler needs to visit n cities.
• Know the distance between each pair of cities.
• Want to know the shortest route that visits all
the cities once.
• n=80 will take millions of years to solve
exhaustively!

53
TSP Example

A 6 B
1 2
5 3

D 4 C

54
Generate-and-test Example

• TSP - generation of possible


solutions is done in
lexicographical order of A B C D

cities:
1. A - B - C - D B C D
2. A - B - D - C
3. A - C - B - D
C D B D C B
4. A - C - D - B
...
D C D B B C
55
2.Hill Climbing
• Hill Climbing is a variant of generate and test in
which feedback from the test procedure is used
to help the generator decide which direction to
move in the search space.
• Following are the different types of Hill Climbing
algorithm.
1. Simple Hill Climbing
2. Steepest Ascent Hill Climbing
3. Simulated Healing
2.1 Simple Hill Climbing
– Use heuristic to move only to states that are better than the current state.
– Always move to better state when possible.
– The process ends when all operators have been applied and none of the resulting states are better
than the current state
The simplest way to implement hill climbing is as follows.

Algorithm: Simple Hill Climbing (Local Search)

I. 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 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 a 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.
2.2 Steepest-Ascent Hill Climbing
• A variation on simple hill climbing.
• Instead of moving to the first state that is better,
move to the best possible state that is one move
away.
• The order of operators does not matter.
• Not just climbing to a better state, climbing up
the steepest slope.
2.2 Steepest-Ascent Hill Climbing
(Gradient Search)
Algorithm: Steepest-Ascent Hill Climbing
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 SUCCESSOR (S ) be a state such that any possible successor of the current
state (CS) will be better than S.
(b) For each operator that applies to the current state do:
(i) Apply the operator and generate a new state (NS).
(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 CS, then set CS to S.
Problems with hill
climbing
1. Local maximum, or
the foothill problem:
there is a peak, but it is
lower than the highest
peak in the whole
space. Solutions to Problem
2. The plateau problem: • Backtrack to some earlier node and
all local moves are try going in a different direction
equally unpromising,
and all peaks seem far • Make a big jump in some direction
to try to get to a new section of the
away. search space.
3. The ridge problem: • Apply two or more rules before
almost every move doing the test. This corresponds to
takes us down. moving in several directions at once.
2.3 Simulated Annealing
• Physical Annealing : Physical substances are
melted and then gradually cooled until some
solid state is reached. The goal is to produce a
minimal-energy state.
• Annealing schedule: If the temperature is
lowered sufficiently slowly, then the goal will be
attained.
• The probability for a transition to a higher energy
state: e-E/kT.

61
Simulated Annealing Algorithm
1. Evaluate the initial state. If it is a goal state , then return it and quit. Otherwise
set initial state as the current state.
2. Initialize BEST SO FAR to the current state.
3. Initialize T according to the annealing schedule.
4. Loop until a solution is found or there are no new operators left to be applied:
a. Select and applies a new operator which has not yet applied .
b. Evaluate the new state:
- If the new state is goal state , then return it and quit.
- If it is not a goal state and better than the current state then make
it as the current state. Also set BEST–So- FAR to this new state.
- If it is not better than the current state, then
Compute E = Val(current state) - Val(new state) make it the
current state with probability P = e-E/kT
c. Revise T as necessary according to the annealing schedule
5. Return BEST –So-FAR as the answer.

62
3 Best First Search
• At each step of the best-first search process, we
select the most promising of the nodes we have
generated so far.
– This is done by applying an appropriate heuristic
function to each of them.
– We then expand the chosen node by using the rules to
generate its successors.
• If one of them is a solution, we can quit.
• If not, all those new nodes are added to the set of nodes
generated so far.
• Again the most promising node is selected and the process
continues
Best First Search Algorithm

I. Start with OPEN containing just the initial state.


2. Until a goal is found or there are no nodes left
on OPEN do:
(a) Pick the best node on OPEN.
(b) Generate its successors.
(c) For each successor do:
(i) If it has not been generated before,
evaluate it, add it to OPEN, and record its
parent.
(ii) If it has been generated before, change
the parent if this new path is better than
the previous one. In that case, update the
cost of getting to this node and to any
successors that this node may already,
have.

OR Graphs for Best First Search


A* Search
• A* (A star) is the most widely known form of
Best-First search
– It evaluates nodes by combining g(n) and h(n)
i.e Evaluate Function f(n) = g(n) + h(n)
– Where
• g(n) = cost so far to reach n
• h(n) = estimated cost from n to goal
• f(n) = estimated total cost of path through n to goal

65
A* Algorithm
1. Start with OPEN holding the initial nodes.
2. Pick the BEST node on OPEN such that
f(n) = g(n) + h(n) is minimal.
3. If BEST is goal node quit and return the path
from initial to BEST Otherwise
4. Remove BEST from OPEN and all of BEST's
children, labeling each with its path from
initial node.
Advantages
• It is complete and optimal.
• It is the best one from other techniques.
• It is used to solve very complex problems.
• It is optimally efficient, i.e. there is no
other optimal algorithm guaranteed to
expand fewer nodes than A*.
Disadvantages
• This algorithm is complete if the branching
factor is finite and every action has fixed cost.
• The speed execution of A* search is highly
dependant on the accuracy of the heuristic
algorithm that is used to compute h (n).
• It has complexity problems.
The A* procedure
A simple search problem: S is the start node, G is the goal
node, the real distances are shown.
4 4
A B C
3
S 5 5
4 G
3.5
D 2 E 4
F

A lower-bound estimate of the straight line distance to G could be as follows (note that
we do not need it for F): City Straight Line Distance to Goal
City (h(n))
A B 5.8 C S 11.5
10.1 3.4 A 10.1
S B 5.8
11.5 G
9.2 C 3.4
3.5 D 9.2
D E 7.1 F
E 7.1
F 3.5
G 0
Hill-climbing happens to
succeed here:
S
4 4
A B C 10.1 9.2
3
S 5 5 A D
4 G
3.5
2 4 10.1
D E F 11.5 7.1

A S E
City Straight Line Distance to Goal City (h(n))
S 11.5
5.8 9.2 3.5
A 10.1 B D F
B 5.8
C 3.4 7.1 0.0
D 9.2
E 7.1 E G
F 3.5
G 0
A*, step 1 The A* procedure
S
f(n) = h(n) + g(n)
3+10.1 4+9.2

4 4 A D
A B C
3
S 5 5
4 G
3.5 City Straight Line Distance to Goal
D 2 E 4
F City (h(n))
S 11.5
A 10.1
B 5.8
C 3.4
D 9.2
E 7.1
F 3.5
G 0
A*, step 2 The A* procedure
S f(n) = h(n) + g(n)
13.1 13.2

A D

4 4 3+4+5.8 3+5+9.2
A B C
3
B D
S 5 5
4 G
3.5
D 2 E 4
F

City Straight Line Distance to Goal


City (h(n))
S 11.5
A 10.1
B 5.8
C 3.4
D 9.2
E 7.1
F 3.5
G 0
A*, step 3
The A* procedure
f(n) = h(n) + g(n)
4 4
A B C
3
S
S 5 5
4 G
3.5 13.1 13.2
2 4
D E F
A D

12.8 17.2
City Straight Line Distance to Goal
City (h(n))
B D
S 11.5
A 10.1 3+4+4+3.4 3+4+5+7.1
B 5.8
C 3.4 C E
D 9.2
E 7.1
F 3.5
G 0
A*, step 4
The A* procedure
f(n) = h(n) + g(n)
4 4
A B C
3
S
S 5 5
4 G 13.1 13.2
3.5
D 2 E 4
F
A D

12.8 17.2 4+5+10.1


City Straight Line Distance to Goal
City (h(n)) B D A
S 11.5
A 10.1 14.4 19.1 4+2+7.1
B 5.8
C 3.4 C E E
D 9.2
E 7.1
F 3.5
G 0
A*, step 5
The A* procedure
f(n) = h(n) + g(n)
4 4
A B C
3 S
S 5 5
4 G 13.1 13.2
3.5
D 2 E 4
F A D

12.8 17.2 19.1


City Straight Line Distance to Goal
City (h(n)) B D A
S 11.5
14.4 19.1 13.1
A 10.1
B 5.8
C 3.4 C E E
D 9.2
4+2+5+5.8 4+2+4+3.5
E 7.1
F 3.5
B F
G 0
A*, step 6 The A* procedure
f(n) = h(n) + g(n)

4 4 S
A B C
3 13.1 13.2
S 5 5
4 G
3.5 A D
D 2 E 4
F 12.8 17.2 19.1

B D A
City Straight Line Distance to Goal
City (h(n)) 14.4 19.1 13.1
S 11.5
A 10.1 C E E
B 5.8
C 3.4 16.8 13.5
D 9.2
E 7.1 B F
F 3.5
G 0

G
4. Problem Reduction
• In problem reduction, a complex
problem is broken down or decomposed
into a set of primitive sub problem;
solutions for these primitive sub-
problems are easily obtained. The
solutions for all the sub problems
collectively give the solution for the
complex problem
• The problem Reduction technique can be
represented using AndOR Graph.
The Problem-Reduction (Goal Reduction) Method

2017/8/27 78
A Decomposable Problem

2017/8/27 EIE426-AICV 79
Problem Reduction

Goal: Acquire TV set

Goal: Steal TV set Goal: Earn some money Goal: Buy TV set

AND-OR Graphs

80
Problem Reduction
• To represent problem reduction techniques we
need to use an AND-OR graph/tree
• AND NODES successors must all be achieved,.
• OR NODES where one of the successors must be
achieved (i.e., they are alternatives).
• This decomposition or reduction, generates arcs
that we call AND arcs.
• One AND arc may point to a number of successor
nodes, all of which must be solved in order for the
arc to point to a solution.
Problem Reduction Algorithm using
AndOR Graphs /AO* Algorithm
1. Start with initial node say N
2. Expand the node with all possible successors say Ns1,Ns2,Ns3,---
Nsn each representing the simple sub solutions.
3. Categorize the Successors into AND Node successors and OR
Node Successors.
4. Estimate the Objective function f(N) w.r.t all solvable nodes of OR
Node and AND Node successors.
1. For AND Node f(N)) =  [ f(Nsi) + c(N, Nsi) ]
2. For OR Node f(N) = min { f(Nsi) + c(N,Nsi) } where Nsi
represents successor of N
5. Select the optimal successor which have solution .
6. Repeat the Steps from 2 for selected optimal successor until the
goal is reached.
Problem Reduction: AO*
Example 1
A A 6
5 9
B C D
3 4 5

A 9 A 11
9 12
B C D 10 B 6 C D 10
3 4 4
E F G H E F
4 4 5 7 4 4

83
Problem Reduction: AO*
Example 2

A 11 A 14

B 13 C 10 B 13 C 15

D 5 E 6 F 3 D 5 E 6 F 3

G 5 G 10

Necessary backward propagation H 9

84
Advantages Disadvantages
• It is an optimal algorithm. • Sometimes for
unsolvable nodes, it
• If traverse according to can’t find the optimal
the ordering of nodes. path.
• It can be used for both OR • Its complexity is more
and AND graph. than other algorithms.
Difference between A* and AO*
Algorithm
• A* algorithm is a OR graph algorithm and
• AO* is a AND-OR graph algorithm.
• In OR graph algorithm it just find only one
solution
• But in the AND-OR graph algorithm it
finds more than one solution by ANDing
two or more branches.
5.Constraint Satisfaction Problem

• A CSP is a problem composed of a finite set of variables, each of


which is associated with a finite domain, and a set of constraints.
• CPS is a search procedure that operates in a space of constraint
state. Constraints in the initial state are originally given in the given
problem. Any state is a goal state that has been constrained
‘enough’ where ‘enough’ means that each letter has been assigned
a unique numeric value.
• The solution process in CSP contains cycles wherein the following
things are done on each cycle :
• Propagate the constraints using rules that correspond to the arithmetic
properties
• Guess a value for some letter whose value is not yet determined.
Constrains Satisfaction Algorithm
1. Propagate available constraints
a. All objects should be opened and must be assigned values in a
complete solution
b. Repeat the succeeding steps until inconsistency or all objects
assigned valid values
• Select an object and strengthen this object as much as possible by a
set of constraints that is applied to the object.
• If the set of constraints is not matched from the previous set, then
open all objects that share any of these constraints.
• Remove selected objects
2. Return Solution, if the union of constraints exposed above
defines a solution.
3. Otherwise return failure , if the union of constraints
discovered above defines a contradiction
Example 1: Cryptarithmetic Problems
• The problem is to plot integers from 0 to 9 for
the alphabet specified in the crypt arithmetic
problems with following constraints :
1. No two alphabets should have the same integer
value .
2. Having allotted the different values for different
alphabets we have to perform the arithmetic
operations specified in the problem.
Example : Cryptarithmetic
Assign numbers to letters so that the sum is correct

Solution
FORTY 29786
F=2, O=9
+ TEN + 850 R=7, T=8
+ TEN + 850 Y=6, E=5
S I XTY 31486 N=0, I=1
X=4
• State space: All letters and all numbers assigned to the letters
• Operations: replace all occurrences of a letter with a digit not
already there
• Initial State: Letters that make words, integers
• Goal State: only digits, sum is correct
• Solution:
Example
Step 1: Here Y+N+N = Y ;
FORTY So N is either 0 or 5 Also , T + E + E = T;
So E is either 0 or 5 , Also E is 5 and N is 0.
+ TEN So c1 = 0 , c2 = 1
+ TEN
Step2 : 1+ R+T+T = X with a carry c3 and c3 =2
S I XTY O+2 = I
Here , O must be a higher number
O = 9 and I = 1
I+F=S
29786 T and R must be higher numbers
+ 850 Then only we get a carry c3 = 2
So T = 8 and R = 7
+ 850
31486 Step3: Just Assume F = 2 , Then S= 3
Other Examples
SEND 8542 9567
+ MORE + 0915 + 1085
MONEY 09457 10652

DONALD 526485
+ G E R A LD + 1 9 7485
RO B ERT 7 2 3970

CROSS 96233
+ ROADS + 62513
DANGER 158746
Example: Map-Coloring

• Variables WA, NT, Q, NSW, V, SA, T


• Domains Di = {red,green,blue}
• Constraints: adjacent regions must have different colors
• e.g., WA ≠ NT, or (WA,NT) in {(red,green),(red,blue),(green,red),
(green,blue),(blue,red),(blue,green)}
Example: Map-Coloring

• Solutions are complete and consistent


assignments, e.g., WA = red, NT = green,Q =
red,NSW = green,V = red,SA = blue,T = green
6. Means End Analysis
• MEA is a technique that was first used in
general problems solver by Newell and Simon.
• It is a problem solving method in which the
solution with minimum difference between
the current state and the goal state is
determined.
Means-Ends Analysis Algorithm

 Until the goal is reached or no more procedures are available,


1. Describe the current state, the goal state, and Calculate the difference
between the two.
2. Use the difference, to select a promising procedure.
 Use the promising procedure and update the current state.
 If the goal is reached, announce success; otherwise, announce
failure.

Key idea is to reduce difference between the current state


and the goal state.
The Task:

A robot moves a desk with two things on it from one


room to another.

2017/8/27 EIE426-AICV 97
A Robot’s Operators
Operator Preconditions Results
PUSH(obj, loc) at(robot,obj)^ at(obj, loc)^
large(obj)^ at(robot, loc)
clear(obj)^
armempty
CARRY(obj, loc) at(robot,obj) ^ at(obj, loc)^
small(obj) at(robot, loc)

WALK(loc) none at(robot, loc)


PICKUP(obj) at(robot, obj) holding(obj)
PUTDOWN(obj) holding(obj)  holding(obj)
PLACE(obj1, obj2) at(robot, obj2)^ on(obj1, obj2)
holding(obj1)

2017/8/27 EIE426-AICV 98
A Difference Table
Operators

differences

99
The Progress of the Means-Ends Analysis Method

2017/8/27
Algorithm: Means-Ends Analysis
(CURRENT, GOAL)
1. Compare CURRENT with GOAL. If there are no differences between
them then return.
2. Otherwise, select the most important difference and reduce it
doing the following until success or failure is signaled:
a. Select an as yet untried operator O that is applicable to the current
difference. If there are no such operators, then signal failure.
b. Attempt to apply O to CURRENT. Generate descriptions of two states:
O-START, a state in which O's preconditions are satisfied and ORESULT,
the state that would result if O were applied in O-START.
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.
Problem-Reduction and Mean End Analysis

PolyU Bejing U

PolyU HK Airport

HK Airport Bejing Airport


Walk Taxi Train

Bejing Airport Bejing U Means-ends analysis

Problem reduction

2017/8/27
History of AI

Timeline of major AI events

2017/8/27 EIE426-AICV 103

You might also like