Defining The Problem As A State Space Search
Defining The Problem As A State Space Search
Defining The Problem As A State Space Search
You are given two jugs , a 4- gallon one and a 3- gallon 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 exact 2 gallons of water into the 4- gallon jug?
The state space for this problem can be described as of ordered pairs
of integers (x, y) , such that x=0,1,2,3 or 4 and y=0,1,2 or 3 , represents the
number of gallons of water in the 4- gallon jug , and y represents the
quantity of water in the 3- gallon jug . The start state is (0,0) . The goal state
is (2,n) for any value of n ( since the problem does not specify how many
gallons need to be in the 3- gallon jug).
The operators to be used to solve the problem can be described as
shown in Fig bellow. They are represented as rules whose left side are
matched against the current state and whose right sides describe the new
state that results from applying the rule.
8- (x,y) (x-(3-y),3)) pour water from the 4- gallon jug into the 3-gallon
If x+y>=3 and x>0 jug until the 3-gallon jug is full
9- (x,y) (x+y,0) pour all the water from the 3 -gallon jug into
If x+y<=4 and y>0 the 3-gallon jug
10- (x,y) (0,x+y) pour all the water from the 4 -gallon jug into
If x+y<=3 and x>0 the 3-gallon jug
11- (0,2) (2,0) pour the 2-gallon from the 3 -gallon jug into
the 4-gallon jug
12- (2,y) (0,x) empty the 2 gallon in the 4 gallon on the ground
1- data base:
-current states .
-goal .
2- operations:
manipulate knowledge base ( using rules , frames , nets).
3-control strategy
-control strategy
-what to do next
Objective:
To achieve goal by applying a sequence of operations of operations to the
initial state .
Example(1):
Example(2):
Eight tile puzzle 2 1 6
Data base: current state of tile 4 8
7 5 3
goal state
1 2 3
8 4
7 6 5
Operations: - move hole up or
move hole down or
move hole left or
move hole right
Control strategy: - choose a direction to move hole at random.
Example(3):
One can visits cities in USA.
A B C D E
A Boston 0 250 1450 1700 300
B New York 250 0 1200 1500 2900
C Miami 1450 1200 0 1600 3300
D Dallas 1700 1500 1600 0 1700
E Sanfrancisco 3000 2900 3300 1700 0
المسافر غير محدد بتغير المصروف والمسافة
Graph search
It is as usually impossible to generate
the whole state space , so a subspace
Generated called the search space.
The search space may grow or
Shrink as processing continues.
Hill climbing
The most problems facing hill climbing are:
1-foothill problem: occurs whenever there are secondary peaks if
it is local, and the user is left with a false source of accomplishment.
2-plateau problem: comes up when there is mostly a flat area
separating the peaks.
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.
The * A algorithm :
1- From a queue of the partial paths .Let the initial queue consist of
the zero
length ,zero step path from the root node to new here .
2- Until the queue is empty or the goal has been reached determine
if the first path in the queue reaches the goal node:
2.a If the first path reaches the goal node ,do nothing .
2.b If the first path does not reach the goal node:
2.b.1 Remove the first path from the queue .
2.b.2 from new paths from the removed one by extending one step .
2.b.3 Add the new paths to the queue .
2.b.4 Sort the queue by the sum of the cost accumulated so far and the
lower-bound estimate of the cost remaining ,with least-cost paths in
front .
2.b.5 If two or more paths reach a common node, delete all those paths
except the one that reaches the common node with the minimum cost .
3-If the goal node has been found ,announce success otherwise announce
failure .