Intro to Jess The Java Expert System Shell
- Slides: 32
Intro to Jess The Java Expert System Shell By Jason Morris Technical Solutions
Agenda • What are expert systems? • What are rule-based expert systems? • Introduction to Jess • The Jess Language
Expert Systems… • Are a branch of artificial intelligence. • Simulate human reasoning in some domain. • “Reason” by heuristic or approximate methods. • Explain and justify solutions in user -friendly terms.
Types Of Expert Systems • Neural Networks • Blackboard Systems • Belief (Bayesian) Networks • Case-Based Reasoning • Rule-Based Systems
Rule-Based Expert Systems • Originated from AI research in the 70 s and 80 s. • Problem data stored as facts. • “Reason” using IF…THEN…ELSE rules. • Can “reason” deductively (forwardchaining) or inductively (backwardchaining).
Inference Process 1. Rules and facts compared using pattern matcher. 2. Matched rules activated into a conflict set. 3. Conflict set resolved into agenda (process called conflict resolution). 4. Rule engine fires on agenda. 5. Engine cycles until all rules are satisfied.
The Java Expert System Shell • Developed at Sandia National Laboratories in late 1990 s. • Created by Dr. Ernest J. Friedman. Hill. • Inspired by the AI production rule language CLIPS. • Fully developed Java API for creating rule-based expert systems.
Rule-Based Expert System Architecture • Rule Base (knowledge base) • Working Memory (fact base) • Inference Engine (rule engine)
Rule-Based Expert System Architecture
Inference (Rule) Engines • Pattern Matcher – decides what rules to fire and when. • Agenda – schedules the order in which activated rules will fire. • Execution Engine – responsible for firing rules and executing other code.
Inference Process • Match the facts against the rules. • Choose which rules to fire. • Execute the actions associated with the rules.
Procedural Programming • Traditional programming (BASIC, C, FORTRAN, Pascal, etc. ). • Largely based on functions. • Programmer controls logic. • Sequential and deterministic. • Object-oriented programming is procedural within object methods.
Declarative Programming • New programming paradigm rules. • Programmer does not really control code logic. • Rule engine finds most efficient “path” of code execution. • Replaces hard to maintain nested IF…THEN…ELSE coding.
Obligatory Tradition Your very first Jess program! (printout t “Hello PJUG-ers!” crlf)
Lists in Jess Here are some valid lists in Jess: • (a b c) • (1 2 3) • (+ 2 3) • (“Hello • (foo ? x ; list of tokens ; list of integers ; an expression world!”) ; a string ? y) ; a function call
Jess Variables • Named containers that hold a single value. • Untyped. Begin with a ? mark. • Can change types during lifetime. • Assigned using bind function.
Jess Variables and Lists Everything is a list in Jess! EXAMPLE: Adding two numbers (bind ? x 2) ; assign x = 2 (bind ? y 3) ; assign y = 3 (bind ? result (+ ? x ? y)) ; find sum
Control Flow Common Jess-specific • foreach • if/then/else • while • apply • build • eval • progn
Jess Functions Even functions are lists. (deffunction get-input() “Get user input from console. ” (bind ? s (read)) (return ? s))
Jess Function Example (deffunction area-sphere (? radius) “Calculate the area of a sphere” (bind ? area (* (* (pi) 2)(* ? radius))) (return ? area))
Jess Function Example How do we use this in Jess? (printout t "The surface area of a radius = 2 meter sphere is " + (area-sphere 2) + " m^2")
Working With Facts • Facts have a head and one or more slots. • Slots hold data (can be typed). • Multislots can hold lists. • You can modify slot values at runtime. • Facts are constructed from templates.
Jess Fact Types • Ordered – head only. • Ordered – single slot. • Unordered – multiple slot, like a database record. • Shadow – slots correspond to properties of a Java. Bean.
Deftemplate Used to define the structure of a fact. (deftemplate pattern “A design pattern. ” (slot name) (slot type (default “creation”)) (slot intent) (slot solution))
Asserting Facts store the initial conditions. ; ; Asserting a new “pattern” fact. (printout t “Enter pattern name: ” crlf) (bind ? x get. Input) (assert pattern (name ? x))
All Kinds of Facts ; ; An ordered fact with no slots – a placeholder that indicates state. (assert(answer-is-valid)) ; ; A ordered fact of one slot (assert(weightfactor 0. 75))
Jess Rules… • … are the knowledge-base of the system. • … fire only once on a given set of facts. • … use pattern constraints to match facts. • … are much faster than IF-THEN statements.
Rule Syntax • Rules have a “left-hand” side (LHS) and a “right-hand” side (RHS). • The LHS contains facts fitting certain patterns. • The RHS contains function calls.
Simple Rule Example Checking working memory state. ; ; A not very useful error handler (defrule report-error (error-is-present) => (printout t “There is an error” crlf))
A More Complex Rule Using pattern bindings in rules. ; ; A more useful error handler (defrule report-err ? err <- (is-error (msg ? msg)) => (printout t "Error was: " ? msg crlf) (retract ? err))
More Pattern and Control Tools matching control and structure • Literal / variable • constraints • • Logical • conditional tests • • Predicate functions Salience Modules Defquery Backwardchaining
Q&A Thanks for your attention, and I hope that you try Jess!
- Jess java
- Shell cleanliness shell soundness shell texture shell shape
- Egg parts
- Jess expert system
- Jess java
- Jess expert system
- Jess rules engine
- Jess jess jesus
- Decision support system vs expert system
- An expert system is
- Decision categories
- Java expert witness
- Introduction digestive system
- Digestive system introduction
- Arc system intro
- Solar system intro
- Shell hse management system
- Lab 7-1 scripting in the bash shell
- Architecture of expert system
- Expert system demo
- Rule based system architecture
- Pxdes
- Fuzzy logic
- Expert system life cycle
- Expert system architecture
- Business expert system
- Expert system life cycle
- Sistem pakar folio
- Characteristics of expert system
- Expert system ict
- Expert system in mis
- History of expert system
- Expert system logo