Defining a Problem as a State Space 1. 2. 3. 4. Define a state space that contains all the possible configurations of the relevant objects. Specify one (or more) state(s) as the initial state(s). Specify one (or more) state(s) as the goal state(s). Specify a set of rules that describe available actions (operators), considering: What assumptions are present in the informal problem description? How general should the rules be? How much of work required to solve the problem should be precompiled and represented in the rules? 1 Production Systems A set of rules (Knowledge Base) : – LHS RHS (if-part then-part) – Pattern Action – Antecedent Consequent knowledge/databases containing information (temporal/permanent) required to solve the current task. (Working Memory) A control strategy to specify the order of testing patterns and resolving possible conflicts (Inference Engine) A rule applier. 2 Production System Major Components knowledge base – contains essential information about the problem domain – often represented as facts and rules inference engine – mechanism to derive new knowledge from the knowledge base and the information provided by the user – often based on the use of rules 3 Production (Rule-Based) System User Interface Knowledge Base Inference Engine Agenda Working Memory 4 Rule-Based System knowledge is encoded as IF … THEN rules – these rules can also be written as production rules the inference engine determines which rule antecedents are satisfied – the left-hand side must “match” a fact in the working memory satisfied rules are placed on the agenda rules on the agenda can be activated (“fired”) – an activated rule may generate new facts through its righthand side – the activation of one rule may subsequently cause the activation of other rules 5 Example Rules IF … THEN Rules Rule: Red_Light IF the light is red THEN stop Rule: Green_Light IF the light is green THEN go antecedent (left-hand-side) consequent (right-hand-side) Production Rules antecedent (left-hand-side) the light is red ==> stop consequent the light is green ==> go (right-hand-side) 6 Inference Engine Cycle describes the execution of rules by the inference engine – match update the agenda – add rules whose antecedents are satisfied to the agenda – remove non-satisfied rules from agendas – conflict resolution select the rule with the highest priority from the agenda – execution perform the actions on the consequent of the selected rule remove the rule from the agenda the cycle ends when – no more rules are on the agenda, or – an explicit stop command is encountered 7 Control Stategies A good control strategy should have the following properties: – Cause motion – Be systematic 8 The Water Jugs Problem – Search Tree 0,0 0,3 0,0 4,0 4,0 4,3 0,3 3,0 4,0 0,3 4,0 0,0 3,3 3,0 3,3 4,2 4,3 0,3 4,2 0,2 2,0 0,0 4,3 4,3 0,3 4,0 1,3 0,3 4,0 1,0 0,1 0,0 0,1 1,3 4,1 4,0 0,0 0,3 4,3 0,0 1,0 3,3 4,3 9 Blind Search – Breadth First 0,0 0,3 4,0 4,3 3,0 3,3 4,3 1,3 1,0 4,2 0,2 0,1 4,1 2,0 10 Blind Search – Depth First 0,0 0,3 4,3 4,0 3,0 3,3 4,2 0,2 2,0 11 Breadth-first vs. depth-first search Depth-first: – requires less memory – may find a solution without searching much of the search space Breadth-first: – will not get trapped exploring a blind alley – guaranteed to find solution (if one exists) – will find minimal solution (if more than one exist) 12 Travelling salesman problem A salesman must visit 5 cities. What is the shortest route? Aberdeen Brighton Cardiff Dover Edinburgh Aberdeen 0 594 524 619 127 Brighton 594 0 184 78 467 Cardiff 524 184 0 233 395 Dover 619 78 233 0 493 Edinburgh 127 467 395 493 0 13 Travelling salesman problem A 594 619 B C 524 184 78 184 233 C D B D 233 233 D C 1011 905 78 D 786 No of paths = (n-1)! D 233 C 78 184 78 B 184 B B C 835 1036 881 n=4, p=6 n=5, p=24 n=10, p=362,880 14 Heuristic Search heuristic = rule of thumb A 594 B C 524 127 619 D E 467 B 395 C 184 B 493 D 233 D 78 784 D 15