JESS : Java Expert System Shell

Slides:



Advertisements
Similar presentations
Automated Deduction resolution (Otter) backward-chaining (Prolog)
Advertisements

The CLIPS Programming Tool History of CLIPS –Influenced by OPS5 and ART –Implemented in C for efficiency and portability –Developed by NASA, distributed.
Expert System Shells - Examples
Samad Paydar Ferdowsi University of Mashhad.  C Language Integrated Production System (CLIPS)  A tool for building expert systems  An expert system.
1 01/12/2011Knowledge-Based Systems, Paula Matuszek Intro to CLIPS Paula Matuszek CSC 9010, Spring, 2011.
Chapter 8 Pattern Matching
Chapter 7: Introduction to CLIPS
Introduction to CLIPS (Chapter 7) Fact List (contains data) Knowledge Base (contains rules) Inference Engine (controls execution)
Mary Lou Maher MIT Fall 2002 Jess: A Production System Language Agent-Based Virtual Worlds.
1 Chapter 9 Rules and Expert Systems. 2 Chapter 9 Contents (1) l Rules for Knowledge Representation l Rule Based Production Systems l Forward Chaining.
Jess Presentation by Chun Ping Wang. What is Jess? Jess is an expert system shell made for java. Rete pattern algorithm. Purpose. –Jess is best use for.
CS 561, Session 25 1 Introduction to CLIPS Overview of CLIPS Facts Rules Rule firing Control techniques Example.
COMP 14: Intro. to Intro. to Programming May 23, 2000 Nick Vallidis.
Intro to Jess The Java Expert System Shell By Jason Morris Morris Technical Solutions.
Intro to Jess The Java Expert System Shell By Jason Morris Morris Technical Solutions.
3.1 Documentation & Java Language Elements Purpose of documentation Assist the programmer with developing the program Assist other programers who.
CSM-Java Programming-I Spring,2005 Introduction to Objects and Classes Lesson - 1.
Review Topics Test 1. Background Topics Definitions of Artificial Intelligence & Turing Test Physical symbol system hypothesis vs connectionist approaches.
1 Programming a Knowledge Based Application. 2 Overview.
Java: Chapter 1 Computer Systems Computer Programming II.
Chapter 7: Introduction to CLIPS Expert Systems: Principles and Programming, Fourth Edition.
CSC 212 Object-Oriented Programming and Java Part 1.
Artificial Intelligence Lecture No. 17 Dr. Asad Ali Safi ​ Assistant Professor, Department of Computer Science, COMSATS Institute of Information Technology.
The string data type String. String (in general) A string is a sequence of characters enclosed between the double quotes "..." Example: Each character.
Expert Systems An Introduction to Expert Systems and CLIPS by Charles Weddle.
Hello.java Program Output 1 public class Hello { 2 public static void main( String [] args ) 3 { 4 System.out.println( “Hello!" ); 5 } // end method main.
Artificial Intelligence LECTURE 2 ARTIFICIAL INTELLIGENCE LECTURES BY ENGR. QAZI ZIA 1.
Applied Computing Technology Laboratory QuickStart C# Learning to Program in C# Amy Roberge & John Linehan November 7, 2005.
Copyright © 2010 Certification Partners, LLC -- All Rights Reserved Perl Specialist.
Jess: A Rule-Based Programming Environment Reporter: Yu Lun Kuo Date: April 10, 2006 Expert System.
Java Expert System Shell JESS 報告者 : 江梓安. Why we need an expert systems? Conventional programming languages Conventional programming languages Complex.
Copyright © Curt Hill Structured Data What this course is about.
Artificial Intelligence as Representation and Search.
Datatypes, Variables, Constants Flash Class. What Does ActionScript Do? Automates Examples: – Tells animation what to do button is clicked – Turn off.
Expert Systems Chapter 7 Introduction to CLIPS Entering and Exiting CLIPS A> CLIPS  CLIPS (V6.5 09/01/97) CLIPS> exit exit CLIPS> (+ 3 4)  7 CLIPS>
BEGINNING PROGRAMMING.  Literally – giving instructions to a computer so that it does what you want  Practically – using a programming language (such.
Applied Computing Technology Laboratory QuickStart Java Learning to Program in Java Dr. Tom Way October 21, 2005.
Copyright © 2003 ProsoftTraining. All rights reserved. Perl Fundamentals.
1 Knowledge Based Systems (CM0377) Lecture 10 (Last modified 19th March 2001)
Intro to Jess The Java Expert System Shell By Jason Morris Morris Technical Solutions.
 In the java programming language, a keyword is one of 50 reserved words which have a predefined meaning in the language; because of this,
Artificial Intelligence Lecture No. 19 Dr. Asad Ali Safi ​ Assistant Professor, Department of Computer Science, COMSATS Institute of Information Technology.
How to execute Program structure Variables name, keywords, binding, scope, lifetime Data types – type system – primitives, strings, arrays, hashes – pointers/references.
Chapter 12© copyright Janson Industries Java Server Faces ▮ Explain the JSF framework ▮ SDO (service data objects) ▮ Facelets ▮ Pagecode classes.
An Introduction to Java – Part 1 Erin Hamalainen CS 265 Sec 001 October 20, 2010.
Chapter 1 Java Programming Review. Introduction Java is platform-independent, meaning that you can write a program once and run it anywhere. Java programs.
Mostly adopted from Jason Morris notes (Morris Technical Solutions)
Onlinedeeneislam.blogspot.com1 Design and Analysis of Algorithms Slide # 1 Download From
Intelligent systems Lecture 11 Tools for development of Expert Systems.
The CLIPS Expert System Shell Dr Nicholas Gibbins
Summary for final exam Agent System..
 It is a pure oops language and a high level language.  It was developed at sun microsystems by James Gosling.
Introduction to CLIPS 2 Session 13 Course: T0273 – EXPERT SYSTEMS Year: 2014.
Information and Computer Sciences University of Hawaii, Manoa
Integration Part 2 Intelligent Systems Integration Part 2
Name Spaces: ALL versus OOL
Intelligent Systems JESS constructs.
Intro to Jess The Java Expert System Shell
Chapter No. : 1 Introduction to Java.
Chapter 7: Introduction to CLIPS
Programming Language Concepts (CIS 635)
Server-Side Application and Data Management IT IS 3105 (Spring 2010)
Intro to Jess The Java Expert System Shell
Chapter 1: Computer Systems
بسم الله الرحمن الرحیم آموزش نرم افزار CLIPS
JESS (Java Expert System Shall)
Jess Knowledge, Influence, Behavior
Intro to Jess The Java Expert System Shell
CPE/CSC 481: Knowledge-Based Systems
Introduction to Data Structure
Presentation transcript:

JESS : Java Expert System Shell Mark Maslyn mmaslyn@msn.com

Java Expert System Shell Java Application A “Rules-Engine” Developed by Ernest Friedman-Hill at Sandia National Laboratory Processes “Jess” Scripting Language Can by called by Java Programs or act as a Java Command Interpreter

Java and JESS Jess Calls Java JESS Java Calls Jess Java App

JESS Uses Templates (data structure definitions) Facts (templates with data values) Rules (logic and program flow) Commands (to the JESS shell) Java Beans

"Hello World" in JESS c:\>java jess.Main Jess, the Java Expert System Shell Copyright (C) 2001 E.J. Friedman Hill and the Sandia Corporation Jess Version 6.1p7 5/7/2004 Jess>(printout t "Hello World" crlf) Hello World Jess>

Jess Can Call Java Functions (bind ?frame (new JFrame “Pumps Demo”)) (call (?frame getContentPane) setLayout(new GridLayout 2 3))

Java Calling JESS import jess.*; ... Rete engine = new Rete( ); engine.executeCommand ( “(printout t \”Hello Word\” crlf)”);

Jess Value Types RU.FLOAT RU.INTEGER RU.LONG RU.LIST RU.STRING float, double long, short, int, byte, char Same A Java array String, char, Character Wrapper classes

Returning Values import jess.*; ... Rete engine = new Rete( ); Value result = engine.executeCommand ( “(+ 2 2 )”); System.out.println(result.intValue(null));

Steps to Solve A Problem With Jess Define Templates and Facts Write Rules Run Jess

Templates (Data Structures) (deftemplate employee “employees in the database” (slot name) (slot gender) (slot job_title))

Facts (Structures with Values (employee (name John Smith) (gender male) (job_title programmer))

defrule example_rule LHS => RHS Rule Syntax: if (LHS) then RHS defrule example_rule LHS => RHS if (left hand side) conditions are true then clauses on the right hand side are executed

Example Rule “if” (LHS) rule name “then” (RHS) (defrule change-baby-if-wet ?wet <- (baby-is-wet) => (change-baby) (retract ?wet)) “then” (RHS)

Rule Conditions Can’t Call Functions NO (defrule equals (eq 1 1) => (printout t “1 and 1 are equal” crlf)) YES (defrule equals (test (eq 1 1) ) => (printout t “1 and 1 are equal” crlf))

Search Space Problems Jess Can Solve Constraint or Search Space Problems (e.g. Logic, Scheduling)

4 Golfers Logic Problem Four Golfers: Fred, Joe, Bob and Tom are in line at the tee Golfer to Fred's right is wearing blue pants Joe is second in line Bob is wearing plaid pants Tom isn't in position 1 or 4 Tom is wearing orange pants

Step 1: Define Templates (deftemplate pants-color (slot person) (slot color)) (deftemplate golfer-position (slot person) (slot position)) (pants-color (person Bob) (color red)) (golfer-position (person Bob) (position 2))

Step 2: Write JESS rules to generate combinations as “facts” (defrule generate-combos => (foreach ?name (create$ Fred Joe Bob Tom) (foreach ?color (create$ red blue plaid orange) (assert (pants-color (person ?name) (color ?color)))) (foreach ?golfer-position (create$ 1 2 3 4) (assert (golfer-position (person ?name) (position ?pos))))))

Step 3: Run JESS to find solution. (defrule find-solution ;; The golfer to Fred's right is wearing blue pants. (position (person Fred) (position ?p1)) (pants-color (person Fred) (color ?c1)) ... => (printout t Fred " " ?p1 " " ?c1 crlf) (printout t Joe " " ?p2 " " ?c2 crlf) (printout t Bob " " ?p3 " " ?c3 crlf) (printout t Tom " " ?p4 " " ?c4 crlf) )

Logic Problem Demo

Search Tree

Rules Engine Jess Can Act As a “Rules Engine” For Expert System Type Problems (e.g. Diagnosis, Configuration, Personalization)

Rule Engines Contain Rule base Working memory Inference engine

Asimov's 3 Laws of Robotics 1) A robot may not injure a human being or, through inaction allow a human being to come to harm. 2) A robot must obey orders given it by human beings except where such orders would conflict with the First Law.

3 Laws (Continued) 3) A robot must protect its own existence as long as such protection does not conflict with the First or Second Laws.

Robots Existence Rule (defrule third_law (first_law_obeyed) (second_law_obeyed) => protect_robots_existence)

Animals Expert System Demo

“Shadow” Facts and Java Beans JESS fact Java Bean (employee (name “John Smith”) (gender Male) (job_title programmer))

Shadow Facts Java Bean public class dimmerSwitch { private int brightness = 0; public int getBrightness( ) { return brightness; } public void setBrightness( int value ) { brightness = value; } }

Adding the Java Bean to Jess... Step 1: Generate a Jess template with defclass (defclass dimmer dimmerSwitch) Step 2: Create and bind an instance of this class in Jess (bind ?ds (new dimmerSwitch)) (definstance dimmer ?ds)

Calling the Java Bean... Step 3: Call the Java Bean methods (call ?ds setBrightness 10 ))

Customization and Filtering Customer in DB? Customer Name, Address Java App DB Packages Credit Score Promos JESS Web Service Rules Filtered Results

Lookup Customer and Credit Score Customer in DB? Customer Name, Address Java App DB Packages Credit Score JESS Promos Web Service Rules Filtered Results

Load Packages, Promotions and Rules Customer in DB? Customer Name, Address Java App DB Packages Credit Score Promos JESS Web Service Rules Filtered Results

Example Packages by Partner Price Description SBC Free-For-All 49.95 TV with no equipment to buy! Digital Home Advantage 29.95  Connect up to 2 TV's free! Sprint America's Top 60 34.95 America's Top 60 Cable Channels! 59.95 America's Top 100 America's Top 100 Cable Channels! Qwest 39.95

Packages and Promotions Templates deftemplate package (slot partner) (slot name) (slot desc) (slot price)) deftemplate promotion (slot partner) (slot name) (slot desc) (slot amount))

Retrieve Packages By Partner Rule (assert (package-partner Sprint)) ;; example partner name … ;; find all packages with Sprint as the partner (defrule get-packages (prod-partner ?p) (package (partner ?p)(name ?n) (desc ?d) (price ?pr)) => (assert (results ?p ?n ?d ?pr)))

Filter Packages By Credit Score Rule (assert (credit-score 620)) … (defrule filter-by-credit-score (credit-score ?c) ?f<-(results (partner ?p)(name ?n)(desc ?d) (price ?pr)) (test (and (< ?c 650)(> ?pr 39.95))) => (retract ?f))

Use Rules to Filter Packages and Promotions Customer in DB? Customer Name, Address Java App DB Packages Credit Score JESS Promos Web Service Rules Filtered Results

JESS Pros and Cons Pros Very Flexible System Free for Government or Academic Use Source Code Available Very Fast Rete Algorithm Planned Integration with Eclipse Cons Lisp – like syntax Limited GUI interface – New Interface in 7.0

Jess Resources Jess Home Page herzberg.ca.sandia.gov/jess/index.shtml Jess In Action (Book) www.manning.com/friedman-hill My Website www.sawatchsoftware.com (click on the Jess link)