1 Defining a Problem as a State Space 1. Define a state space that contains all the possible configurations of the relevant objects. 2. Specify one (or more) state(s) as the initial state(s). 3. Specify one (or more) state(s) as the goal state(s). 4. 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?
2 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.
3 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
4 Production (Rule-Based) System Knowledge Base Inference Engine Working Memory User Interface Agenda
5 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 right- hand side –the activation of one rule may subsequently cause the activation of other rules
6 Example Rules IF … THEN Rules Rule: Red_Light IF the light is red THEN stop Rule: Green_Light IFthe light is green THENgo antecedent (left-hand-side) consequent (right-hand-side) Production Rules the light is red ==> stop the light is green ==> go antecedent (left-hand-side) consequent (right-hand-side)
7 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
8 Control Stategies A good control strategy should have the following properties: –Cause motion –Be systematic
9 The Water Jugs Problem – Search Tree 0, 0 4, 0 4, 3 0, 0 1, 30, 0 4, 00, 34, 30, 31, 0 4, 01, 3 0, 0 0, 1 4, 10, 01, 0 0, 14, 03, 34, 3 0, 3 3, 04, 3 4, 00, 30, 04, 00, 33, 3 3, 00, 34, 34, 2 4, 03, 34, 30, 2 0, 04, 22, 00, 3
10 Blind Search – Breadth First 0, 0 4, 00, 3 4, 31, 33, 04, 31, 03, 3 0, 14, 2 2, 0 4, 10, 2
11 Blind Search – Depth First 0, 0 0, 3 4, 33, 03, 34, 0 4, 2 0, 2 2, 0
12 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)
13 Travelling salesman problem A salesman must visit 5 cities. What is the shortest route? AberdeenBrightonCardiffDoverEdinburgh Aberdeen Brighton Cardiff Dover Edinburgh
14 Travelling salesman problem A BCD CCBBDD CDDBCB No of paths = (n-1)!n=4, p=6 n=5, p=24 n=10, p=362,880
15 Heuristic Search heuristic = rule of thumb A DBC BCDE BD D