PARALLELIZATION OF EXPERT SYSTEM CS6260 Project Presentation Vinay B Gavirangaswamy What is Expert System? Expert system is a program/application that mimics decision taking ability of a domain expert. Knowledge Base Inference Engine Working Memory User Interface Domain Knowledge Implementation Techniques – Buzz words Bayes Rule Forward-Chaining Bidirectional Search Fuzzy-Set Theory Causal Models Goal-Driven Reasoning Chronological Backtracking Model Driven Reasoning Control Rules Opportunistic Search Semantic Networks Rules Truth Maintenance Systems Dempster-Shafer Uncertainty Management MYCIN Production Systems ‘It’s a set of syntactic and semantic conventions that make it possible to describe things’. Syntax – Set of rules for combining symbols and arrangements of symbols to form expression in a representational language. Semantic – Specifies how constructed expressions should be interpreted. Production Rules Consists of premise-action pairs, for example if P & ...&Pn, 1 then Q & ... & Qm 1 P’s – are called conditions or ‘left-hand side’ Q’s – are called conclusions or ‘right-hand side’ Working Memory (WM): It is to hold data, often in the form of object-attribute-value triples. The Behavior of the Interpreter/Inference Engine Interpreter or inference engine for a set of production rules can be described in term of ‘recognize-act cycle’. 1. Match the calling patterns of rules against elements in working memory. 2. If there is more than one rule that could fire, then decide which one to apply; this is called ‘conflict resolution’. 3. Apply the rule, perhaps adding a new item to WM or deleting an old one, and then go to step (1). Forward Chaining At the Global level of control, production rules are driven forward. Chains forward from condition that we know to be true, towards conclusions which the facts allow us to establish, by matching data in working memory against the left-hand sides of the rules. The mode of chaining describes the way rules are activated by matching WM elements. Related Work Blue DRAGON Analyzes Minimal Invasive (MIS) surgical tasks into primary elements. Kinematics and dynamics of left & right endoscopic tools along with visual surgical scene is used as input to derive model. Decomposed surgical model consists of 30 fully connected finite states Markov model. And its equivalent grammar. Objective learning curve is defined for expert surgeon and trainee using a scoring function (MM). Evaluation is based on distance between the two. Blue DRAGON (Contd.) Fully connected FSD for decomposing MIS Signature of forces, velocities associated with different states Red DRAGON (Blue DRAGON Contd.) CAD Design Actual Machine http://bionics.soe.ucsc.edu/research/surgical_index.html Parallel Implementation of Rule-Based Expert System Or- parallelism: Each rule, whose head unifies with a fact, can be solved in parallel. And-parallelism: Processes execute in parallel to solve each clause of the body. Conflict resolution is the bottle-neck for parallel execution. Rule Based system is described by following attributes 1. a set of parameters ; V v , v ,..., vn , 1 2 2. a set of inputs; V v , v ,..., v V , I I1 I 2 Ik 3. a set of outputs; V v ,v ..., v V , O O1 O 2, Oh 4. domain for parameters : D D , D ,..., Dn . V, D defines state space of system. 1 2 5. System state : At a t , a t ,..., an t , where a t D is the value of v i 1 2 i 6. a set of rules : R R , R ,..., Rm 1 2 such that At 1 R At and R : D D so R is considered as transitio n function Knowledge Base Organization Uses AND/OR graph formalism for the knowledge network Rules and parameters are organized to form a knowledge network. v IN R : a chain is formed between rule and parameter j i v OUT R : a link is formed between rule and parameter j i Knowledge Base Organization (Contd.) Knowledge Base of three rules Knowledge Network A B X Y Z R100 R : IF A 2 THEN X : 2 * A and Y : 2 B IF i R : IF F G THEN Y : 2 3 and Z : 2 * 3 THEN j R : IF A h Y and X 6 THEN Q : 2 * F and R : 3 k IF THEN A B X Y F G Y Z Q R102 A F X Y Q R IF THEN F G Q R R R102 X Y R100 A Z R101 B F G Implementation on shared memory MIMD machine Implemented using tables, markers and message broadcasting. Only forward chaining is used in the inference process. B , B ,..., B Shared memory is divided into number of banks Each parameter is stored in memory bank and rule is loaded into one processor. Rules and parameters do not migrate to other processors and memory banks during execution. 1 2 p Implementation on shared memory MIMD machine (Contd.) 1. 2. Knowledge network is implemented through message broadcasting Execute the actions of the rule being fired If the execution of an action changes the value of parameter, then the processor broadcasts a message, containing parameter-id, to the bus. 3. Processor enters critical section to change value of the parameter. 4. Processor resets the variable counter for the rule to 1. 5. Pickup message broadcasted and update the local parameter values. Rule base partitioning and allocation Each input parameter is associated with probability p l v for the relative frequency that appears in lth position v in input sequence ij ij ij : is the priority of v l f P l k ij ij ij Use and to denote numerical values (min and max) v R with rule and the parameter min/max equations for input and rules are written in matrix form V C R V and R D V E In iteration step R D V E is computed first followed by V C R i s l 1 j t 1 t 1 t 1 t Algorithm of partitioning rules for parallel execution 1. Initialization v V , assign to v ; ij I ij ij v V V , k 1; ij I i R R, assign priority 1 to R ; i i 2. Form the execution time vector E; Form the min/max equations; 3. Use sequential iteration to solve the min/max equations for rule priorites; Sort the rules into a list L according to their priorities; L denotes the priority of the i rule in the list L. 4. For i 1 TO m DO m is the number of rules th i Begin d inf L R for every R such that PROC R ; i k k l k C RA A / index 1; FOR j 2 TO p DO P is the number of procs Begin d inf L R for every R such that PROC R ; i k index i; END; END; Assign L to PROC ; i END. index k l It’s a greedy algorithm Produces good but not necessarily optimal rule assignment to multiprocessors Cost of rule assignment k n n i 1 j 1 ij i j Problem of partitioning and assigning rules to minimize cost C(RA) is NP-complete. Allocating parameter to memory banks Algorithm to allocate memory banks such that they do not cause many memory access conflicts when executed in parallel. Problem of allocating parameter to memory banks to minimize the reference cost is NP-complete and O n developed algorithm has time complexity of 2 Parallel tools for implementing Expert System MultiLisp – interpreter written in Fortran and ported to C extended with constructs for parallel execution and shared memory. Brain Aid Prolog – a parallel PROLOG environment for Transputer systems of 1-512 processors. BeBOP – language combines sequential and parallel Logic Programming (LP), object oriented programming and meta-level programming. Multi-BinProlog –Linda-style parallel extension to BinProlog. References Peter Jackson, Introduction to expert systems, Addison-Wesley Longman Publishing Co., Inc., Boston, MA, 1986 Rosen J., J. D. Brown, L. Chang, M. Barreca, M. Sinanan, B. Hannaford, The Blue DRAGON - A System for Measuring the Kinematics and the Dynamics of Minimally Invasive Surgical Tools In– Vivo, Proceedings of the 2002 IEEE International Conference on Robotics & Automation, Washington DC, USA, May 11-15, 2002. Rosen J., L. Chang, J. D. Brown, B. Hannaford, M. Sinanan, R. Satava, Minimally Invasive Surgery Task Decomposition - Etymology of Endoscopic Suturing, Studies in Health Technology and Informatics Medicine Meets Virtual Reality, vol. 94, pp. 295-301, IOS Press, January 2003. Tao Li, Parallel implementation of rule-based expert systems for interactive applications, Parallel Computing Volume 10, Issue 3, May 1989, Pages 309–318