Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Jess: A Rule-Based Programming Environment Expert System Reporter: Yu Lun Kuo E-mail: [email protected] Date: April 10, 2006 Why Expert System Question of project developer – Program = algorithm + Data Structure (Hard) – Software Engineering • Demand Design Coding (Demand Phase) – Programmer Expert Systems – Rule-based computer programs that capture the knowledge of human experts in their own fields of experience Page 2 Rules A rule is a kind of instruction or command that applies in certain situations Rules are a lot like the if-then statements of traditional programming languages – if part of a rule is often called its left-hand side – then part of a rule is often called its right-hand side if predicate or premises then actions or conclusions • A rule-based system is a system that uses rules to derive conclusions from premises Page 3 Rule Engine A rule engine doesn’t contain any rules until they are programmed in – A rule engine knows how to follow rules, without containing any specific knowledge itself – deployment environment Page 4 Architecture of a Rule-Based System A typical rule engine contains – Inference engine • Forward Chaining – LISP, CLIPS • Backward Chaining - PROLOG – Rule base (knowledge base) – Working memory (fact base) Inference engine consists of – Pattern matcher – Agenda – Execution engine Page 5 Pattern Matcher The working memory contains thousands of facts, and each rule has two or three premises The pattern matcher need to search through millions of combinations of facts to find those combinations that satisfy rules – All the rules are compared to working memory – Decide which ones should be activated during this cycle Page 6 Agenda Inference engine figures out which rules should be fired, it still must decide which rule to fire first – The list of rules that could potentially fire is stored on the agenda – Ex. Give high priority Page 7 Execution Engine The execution engine is the component of a rule engine that fires the rules Some modern rule engines offer a complete programming language you can use define – What happen when a give rules fires Page 8 Conflict Set Conflict Resolution Fired Page 9 Page 10 Jess (Java Expert System Shell) The Java Rule Engine API defined by the javax.rules package – A standard enterprise API for accessing rule engines – Site: http://www.jcp.org/jsr/detail/94.jsp Jess rule engine – A rule engine and scripting language developed at Sandia National Laboratories in Livermore, California in the late 1990s – It can access to all of Java’s powerful APIs for networking, graphics, database access, and so on Page 11 Jess (Cont.) The Jess language can directly access all Java classes and libraries – This allows you to experiment with Java APIs interactively and build up large programs incrementally – Jess is therefore useful in a wide range of situations – Jess can be used in command-line applications, GUI applications, servlets, and applets. Page 12 The most important step in developing a Jess application is to choose an architecture – Pure Jess language, with no Java code – Pure Jess language, but the program accesses Java APIs – Mostly Jess language code, but with some custom Java code in the form of new Jess commands written in Java – Half Jess language code, with a substantial amount of Java code providing custom commands and APIs. Jess provides the main() function – Half Jess language code, with a substantial amount of Java code providing custom commands and APIs. You write the main() function – Mostly Java code, which loads Jess language code at runtime – All Java code, which manipulates Jess entirely through its Java API Page 13 Scripting Java with Jess From Java code, you can access all parts of the Jess library – Easy to embed Jess in any Java application – Use Jess for experimenting with Java APIs • Jess is therefore a kind of scripting language for Java You can create the windows, buttons, and other graphical components with a few lines of Jess code Page 14 Representing facts in Jess The contents of Jess’s working memory are held in your computer’s RAM Most other constructs in Jess, facts are stored as lists Jess offers a set of functions to let a program perform the basic collection operations on the working memory – add, remove, modify, duplicate Page 15 Working memory assert – Add facts to working memory Clear – Clears all of Jess Deffacts – Defines the initial contents of working memory Facts – Display the content of working memory Reset – Initializes the working memory Retract – Removes facts from working memory Watch – Tells Jess to print diagnostics when interesting things happen Page 16