Lino Vázquez – PJAS at CERN GS-AIS-HR.  Declarative programming  Rules  Rules Engines  Rete algorithm  Why use rules engines  Drools.

Slides:



Advertisements
Similar presentations
CS101: Introduction to Computer programming
Advertisements

Drools – Diabetes Phenotype Identification
CS 484 – Artificial Intelligence1 Announcements Choose Research Topic by today Project 1 is due Thursday, October 11 Midterm is Thursday, October 18 Book.
Inferences The Reasoning Power of Expert Systems.
Expert System Shells - Examples
1 01/12/2011Knowledge-Based Systems, Paula Matuszek Intro to CLIPS Paula Matuszek CSC 9010, Spring, 2011.
Reasoning System.  Reasoning with rules  Forward chaining  Backward chaining  Rule examples  Fuzzy rule systems  Planning.
Knowledge Engineering.  Process of acquiring knowledge from experts and building knowledge base  Narrow perspective  Knowledge acquisition, representation,
Rule Based Systems Michael J. Watts
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 5 More SQL: Complex Queries, Triggers, Views, and Schema Modification.
Artificial Intelligence Lecture No. 16
Chapter 12: Expert Systems Design Examples
Rule Based Systems Alford Academy Business Education and Computing
Expert System Human expert level performance Limited application area Large component of task specific knowledge Knowledge based system Task specific knowledge.
Lecture 04 Rule Representation
1 Pertemuan 6 RULE-BASED SYSTEMS Matakuliah: H0383/Sistem Berbasis Pengetahuan Tahun: 2005 Versi: 1/0.
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.
Rules and Expert Systems
© C. Kemke1Reasoning - Introduction COMP 4200: Expert Systems Dr. Christel Kemke Department of Computer Science University of Manitoba.
© C. Kemke Control 1 COMP 4200: Expert Systems Dr. Christel Kemke Department of Computer Science University of Manitoba.
Production Rules Rule-Based Systems. 2 Production Rules Specify what you should do or what you could conclude in different situations. Specify what you.
Marakas: Decision Support Systems, 2nd Edition © 2003, Prentice-Hall Chapter Chapter 7: Expert Systems and Artificial Intelligence Decision Support.
EXPERT SYSTEMS Part I.
How does model tracing work? CPI 494 Feb 10 Kurt VanLehn.
Building Knowledge-Driven DSS and Mining Data
CPSC 433 Artificial Intelligence CPSC 433 : Artificial Intelligence Tutorials T01 & T02 Andrew “M” Kuipers note: please include.
CS 561, Session 25 1 Introduction to CLIPS Overview of CLIPS Facts Rules Rule firing Control techniques Example.
ES: Expert Systems n Knowledge Base (facts, rules) n Inference Engine (software) n User Interface.
Introduction to Rule-Based Systems, Expert Systems, Fuzzy Systems Introduction to Rule-Based Systems, Expert Systems, Fuzzy Systems (sections 2.7, 2.8,
Oakkar Fall The Need for Decision Engine Automate business processes Implement complex business decision logic Separation of rules and process Business.
REFACTORING Lecture 4. Definition Refactoring is a process of changing the internal structure of the program, not affecting its external behavior and.
Katanosh Morovat.   This concept is a formal approach for identifying the rules that encapsulate the structure, constraint, and control of the operation.
Chapter 14: Artificial Intelligence Invitation to Computer Science, C++ Version, Third Edition.
EGR 2261 Unit 5 Control Structures II: Repetition  Read Malik, Chapter 5.  Homework #5 and Lab #5 due next week.  Quiz next week.
AS Computing Introduction to Programming. What is a Computer Program? A list of instructions that a computer must work through, in a logical sequence,
Empirical Explorations with The Logical Theory Machine: A Case Study in Heuristics by Allen Newell, J. C. Shaw, & H. A. Simon by Allen Newell, J. C. Shaw,
Production Systems A production system is –a set of rules (if-then or condition-action statements) –working memory the current state of the problem solving,
Knowledge based Humans use heuristics a great deal in their problem solving. Of course, if the heuristic does fail, it is necessary for the problem solver.
Auckland Connected Systems User Group November 19th 2009 Jeffrey Chilberto BizTalk Consultant
 Architecture and Description Of Module Architecture and Description Of Module  KNOWLEDGE BASE KNOWLEDGE BASE  PRODUCTION RULES PRODUCTION RULES 
Drools Sofia Jonsson CADEC2006, Drools, Slide 2 Copyright 2006, Callista Enterprise AB Agenda Rule Engines - History/Background.
Jess: A Rule-Based Programming Environment Reporter: Yu Lun Kuo Date: April 10, 2006 Expert System.
Daniel van Wyk – 3fifteen – SA Developer.Net – Information Worker Group.
Welcome to the Twin Cities BizTalk User Group July 2006.
Logic Programming CSC 358/ Outline Pattern matching Unification Logic programming.
CS62S: Expert Systems Based on: The Engineering of Knowledge-based Systems: Theory and Practice, A. J. Gonzalez and D. D. Dankel.
Inferencing in rule-based systems: forward and backward chaining.
© Donald F. Ferguson, All rights reserved. Topics in Computer Science: Modern Internet Service Oriented Application Development Lecture 8: IPaaS.
RIA to visualize the health of a project Team #4 Midterm presentation February 28,2008.
An Object-Oriented Approach to Programming Logic and Design Chapter 5 Making Decisions.
 Negnevitsky, Pearson Education, Introduction, or what is knowledge? Knowledge is a theoretical or practical understanding of a subject or a domain.
Mostly adopted from Jason Morris notes (Morris Technical Solutions)
Artificial Intelligence
Forward and Backward Chaining
AD Lab Andrews-Dalkilic Data Exploration. AD Lab Outline Architecture What is Bioinformatics? Explore some bioinformatics problems and tools Talk about.
Expert System Seyed Hashem Davarpanah University of Science and Culture.
Programming Logic and Design Fifth Edition, Comprehensive Chapter 6 Arrays.
Summary for final exam Agent System..
Business Rules Engine in Java Introduction to JBoss Rules by Tom Sausner.
Rules: Knowledge Representation & Manipulation
10. A rule based system Forward Chaining based rule base system.
Chapter 7: Introduction to CLIPS
Knowledge Representation
CS62S: Expert Systems Based on:
Jess Architecture Diagram WORKING MEMORY INFERENCE ENGINE EXECUTION ENGINE PATTERN MATCHER RULE BASE Here you can see how all the parts fit.
SAS Essentials How SAS Thinks
CPSC 433 : Artificial Intelligence Tutorials T01 & T02
Rule Engine Concepts and Drools Expert
Adding Uncertainty to a RETE-OO Rule Engine
Martin Rinard, Jiasi Shen, Varun Mangalick
Presentation transcript:

Lino Vázquez – PJAS at CERN GS-AIS-HR

 Declarative programming  Rules  Rules Engines  Rete algorithm  Why use rules engines  Drools

Decribe the “what” instead of the “how” Define the problem, give some conditions and let the system do the rest

 In imperative programming we provide the logic and the control in an algorithm  Implicit sequence  In declarative programming we provide logic and we leave the control to the system  Sequence is “irrelevant”

 Imperative programming 1.Check the battery level of your cellphone 2.If battery is low, go to the bedroom and get the charger from the desk

 Declarative programming ◦ If low level of battery  Get a charger ◦ If need a charger  Get it from the desk ◦ If need something from the desk  Go to the bedroom

Drools 6.0 user’s manual: A Production Rule is a two-part structure to infer conclusions which result in actions.

A rule is an If – Then where the “then” part is an action over knowledge

 The condition is usually simple (Properties of a POJO)  The consequence is a modification of the knowledge, adding more knowledge or ereasing knowledge.  Facts fire rules and consequences work on them

Pattern matcher System that matches facts against rules

 The matching is performed by the “Inference engine” using an algothim (Rete)

 Forward chainning – Data driven  Backward chainning – Goal driven

 Rule base  Inference engine  Working memory

Production Memory (Rules) Working Memory (Facts) Inference Engine Pattern Matcher Agenda

Exit Agenda evaluation Select rule Fire rule Add Delete Edit Activate possible rules No rules Inject facts

Working Memory (Facts) Inference Engine (Rete / Leaps) Pattern Matcher Production Memory (Rules) Agenda

Rule 1 Rule 2 Rule 3 Rule 4 Rule 5 Rule 6 Rule 7 Rule 1 Rule 2 Rule 3 Rule 4 Rule 5 Rule 6 Rule 7 Rule 1 Rule 2 Rule 3 Rule 4 Rule 5 Rule 6 Rule 7 Rule 1 Rule 2 Rule 3 Rule 4 Rule 5 Rule 6 Rule 7 Facts Facts*

Rule 1 Rule 2 Rule 3 Rule 4 Rule 5 Rule 6 Rule 7 Rule 1 Rule 2 Rule 3 Rule 4 Rule 5 Rule 6 Rule 7 Rule 1 Rule 2 Rule 3 Rule 5 Rule 6 Rule 7 Rule 1 Rule 2 Rule 3 Rule 4 Rule 5 Rule 6 Rule 7 Facts Facts* Rule 4

Rule 1 Rule 2 Rule 3 Rule 4 Rule 5 Rule 6 Rule 7 Rule 1 Rule 2 Rule 3 Rule 4 Rule 5 Rule 6 Rule 7 Rule 1 Rule 2 Rule 3 Rule 5 Rule 6 Rule 7 Rule 1 Rule 2 Rule 3 Rule 4 Rule 5 Rule 6 Rule 7 Facts Rule 4

Working Memory (Facts) Inference Engine (Rete / Leaps) Pattern Matcher Production Memory (Rules) Agenda

If a person is 18 years old or older and less than 65, is an adult If a person is an adult, we issue an adult ID card Person (age >= 18, age < 65) Person (isAdult == true)

Person (age >= 18, age < 65) Pattern TypeConstrain FieldRestriction Evaluator Value

 Since 1975  Independent of the number or rules  Heavy memory use

 Rule 1: If a new costumer spends more than 100€ and is his birthday, gets a 20% discount  Rule 2: If a new costumer spends more than 100€, gets a 10% discount

New Costumer More than 100 Birthday Rule 1* Rule 2 Rule 1 New Costumer More than 100

New Costumer More than 100 Birthday Rule 1* Rule 2 Rule 1

New Costumer More than 100 Birthday Rule 1* Rule 2 Rule 1

 Your logic involves significant decision-making  You can write decision rules for your logic  Your logic is complex (3 or more nested if- statements)  Your logic needs to be flexible ◦ During development ◦ After development  Execution speed is not your main goal  You want domain experts to review/maintain the logic

 Born in 2001  Rete algorithm  Bought by Red Hat in 2005  Last stable version 6.1

If a person is 18 years old or older and less than 65, is an adult If a person is an adult, we issue an adult ID card Person (age >= 18, age < 65) Person (isAdult == true)

when $p : Person (age >= 18, < 65) then modify ($p){ setIsAdult(true) } end If a person is 18 years old or older and less than 65, is an adult

when $p : Person (isAdult == true) then logicalInsert(new IdCard($p,‘Adult’); end If a person is an adult, we issue an adult ID card Truth Maintenance

 Conditional Elements ◦ not Person( age >=18) ◦ exists Person( age >=18) ◦ forall (Person( age >=18))

 Keyword ‘from’ when $p : Person( zipcode== “1205”) Car( color == “red” ) from $p.cars when $z : ZipCode() Person() from $hbn.getQuery(“FindPeople”).setParameters([“zipCode” : $z]).list()

 Keyword ‘collect’ when $list : List( intValue > 100) from collect (Person(age >= 18)) then print “People“ + $list; end

 Keyword ‘accumulate’ when $sum : Number( intValue > 100) from accumulate (Person(age >= 18, $s : savings ) sum ($s)) then print “Total savings “ + $sum; end

 Timers & Calendars ◦ Delays and Intervals ◦ Cron  Time operators ◦ before, after, coincides, overlaps, during…  Time windows+aggregations (Keyword ‘over’)

rule “High number of orders” when Number( nbOrders : intValue > 100 ) from accumulate( e: PlaceOrderEvent(session.storeId == “00001”) over window:size(12h), count(e) ) then System.err.println( "WARNING: Number of orders in the last 12 hours > 100: " + nbOrders ); end

Article II 1.01Retirement Age The retirement age shall be as follows: a) For members who joined the Fund on or before 31December 2011, 65 years; b) For members who joined the Fund on or after 1 January 2012, 67 years.

Rule “Retirement age” when $m : Member() JoinedFund(member == $m, date <= “31 –Dec-2011”) then insert(new RetirementAge($m, 65)

Thank you