waterjug problem

5
KNOWLEDGE-BASED PROBLEM SOLVING - 1: RULE-BASED PROBLEM SOLVING %------------------------------------------------------------- --------------- World Knowledge World knowledge can be of many kinds, e.g., associative, episodic and semantic. One kind of world knowledge is knowledge about the possible actions in a given world. Example: The Water Jug Problem Problem: You are given two jugs, a 4-gallon one and a 3-gallon one. Neither has any measuering marks on it. There is a pump that can be used to fill the jugs with water. How can you get exactly 2 gallons of water in the 4-gallon jug? In the water jug problem, one possible action is to pump water into the 4 gallon jug until the jug is full. %---------------------------------------- Knowledge Representation A state in this problem may be represented as a two-tuple (x,y), where: x stands for the amount of water in the 4-gallon jug, and y denotes the amount of water in the 3-gallon jug. The initial state is <0,0> and the goal state is (2,0)

Upload: vikas11031992

Post on 24-Dec-2015

215 views

Category:

Documents


0 download

DESCRIPTION

The famous water jug problem is explained in detail and method of solving

TRANSCRIPT

Page 1: Waterjug Problem

KNOWLEDGE-BASED PROBLEM SOLVING - 1:RULE-BASED PROBLEM SOLVING  %---------------------------------------------------------------------------- World Knowledge  World knowledge can be of many kinds, e.g., associative, episodic andsemantic. One kind of world knowledge is knowledge about the possible actions ina given world. Example: The Water Jug Problem Problem: You are given two jugs, a 4-gallon one and a 3-gallonone. Neither has any measuering marks on it. There is a pump that canbe used to fill the jugs with water. How can you get exactly 2 gallonsof water in the 4-gallon jug? In the water jug problem, one possible action is to pump water intothe 4 gallon jug until the jug is full. %----------------------------------------Knowledge Representation  A state in this problem may be represented as a two-tuple (x,y), where: x stands for the amount of water in the 4-gallon jug, and y denotes the amount of water in the 3-gallon jug. The initial state is <0,0> and the goal state is (2,0) An operator (i.e., knowledge of an action possible in the world) canbe represented in the LANGUAGE of PRODUCTION RULES. For this example, all ten basic operations in the water jug problemcan be represented in the language of production rules as follows: R1: (x,y) --> (4,y)    if x < 4R2: (x,y) --> (x,3)    if y < 3R3: (x,y) --> (x-d,y)    if x > 0R4: (x,y) --> (x,y-d)    if y > 0R5: (x,y) --> (0,y)    if x > 0

Page 2: Waterjug Problem

R6: (x,y) --> (x,0)    if y > 0R7: (x,y) --> (4,y-(4-x))    if x+y >= 4 and y > 0R8: (x,y) --> (x-(3-y),y)    if x+y >= 3 and x > 0R9: (x,y) --> (x+y,0)    if x+y =< 4 and y > 0R10: (x,y) --> (0,x+y)    if x+y =< 3 and x > 0 The general form of productions looks like this: <antecendent1, antecedent2, ... antecedentN> (condition1, condition2, ...)---> (consequent1, consequent2, consequentM)where the conditions on the antecedents specify the applicability ofan operation Note that production rules offer one language for representingASSOCIATIVE knowledge including that of operations (that is, knowledgeof the actions that can be performed in the world). %---------------------------------------------------------------------------- Control in Rule-Based Problem Solving  In addition to world knowledge, problem solving requires controlknowledge which helps decide what to next (e.g., which state to expandnext, which operator to apply among the applicable operators etc.) Different kinds of control knowledge make for different searchstrategies and can give rise to quite different solutions. The control strategy of rule-based problem solving consists of fourmain steps:(i) Match the antecedents and conditions of the available productionrules with the current state, and select the applicable rules. (ii) If more than one rule is applicable, then select a rule based ontwo factors:    (a) the problem solving should cause some change to the current state     (b) the problem solving should not go back to a previous state (iii) If, after consideration of the above two factors, more than onerule is applicable to the current state, then select a rule at random (iv) apply the selected rule to the current state, go to the next state,and repeat the process. 

Page 3: Waterjug Problem

The application of this strategy gives the following possible solutionto the water jug problem:          x        y        Rule                         applied s1      0       0                        R2s2      0       3                        R9s3      3        0                        R2s4      3        3                        R7s5      4        2                        R5s6      0       2                        R9s7      2        0  %---------------------------------------------------------------------------- Representation of Problem Solving The problem space is a ``virtual'' space that can be generated byapplying combinations of the operators.  Problem solving, i.e., searchthrough a problem space, can be represented as a tree. The problem solving in the water jug example can be represented as thefollowing tree:     <0,0>                 /  \               R1    R2              <0,3>             /  |...\            /   |... \           R1   R4...  R9                      <3,0>                      /  |  \                    /   |   \                   R2   R3   R5                <3,3>               /  |...\...              /   |... \...             R1   R3    R7                          <4,2>                      /  |...\...                     /   |... \...

Page 4: Waterjug Problem

                    R2   R3    R5                              <0,2>                                      /  |  \                            /   |   \                           R1   R7   R9                                    <2,0> %---------------------------------------------------------------------------- Production Systems A production system consists of three main elements: (i) a rule base,(ii) a rule applier and selector that instantiates the controlstrategy, and (iii) a working memory that keeps track of the currentstate of problem solving.  The working memory may maintain information about the original goal,the current subgoal, and the current state.