Introduction to Rule-based Applications

4,852 views
4,566 views

Published on

Published in: Technology, Business
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
4,852
On SlideShare
0
From Embeds
0
Number of Embeds
44
Actions
Shares
0
Downloads
96
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Introduction to Rule-based Applications

  1. 1. eBusiness Technologies (ebTech) Introduction to Rule-based Applications Adrian Giurca, eBusiness Technologies, Craiova, March 2009 Dr. Adrian Giurca Brandenburg University of Technology Cottbus, Germany
  2. 2. Who I am <ul><ul><li>Adrian Giurca (42 years old ) </li></ul></ul><ul><ul><li>I was with University of Craiova from 1990 </li></ul></ul><ul><ul><li>From 2005 I work at Brandenburg University of Technology in Cottbus, Germany </li></ul></ul><ul><ul><li>During the years, I taught Logic Programming , Software Engineering , Web Technologies , eBusiness Technologies , Semantic Web , and others. </li></ul></ul><ul><li>http://adrian-giurca.blogspot.com/ </li></ul><ul><li>http://inf.ucv.ro/~giurca </li></ul><ul><li>http://www.informatik.tu-cottbus.de/~agiurca </li></ul>Adrian Giurca, eBusiness Technologies, Craiova, March 2009
  3. 3. This lecture is about rule based applications <ul><ul><li>Rules are best used in applications with a dynamic business logic i.e. applications where changes in the business logic are frequently and they need to be immediately reflected in the application behavior . </li></ul></ul><ul><ul><li>Rules applies successfully in domains such as: </li></ul></ul><ul><ul><ul><li>insurance ( insurance rating ), </li></ul></ul></ul><ul><ul><ul><li>financial services ( loans , claims routing and management , fraud detection ), </li></ul></ul></ul><ul><ul><ul><li>government ( tax calculations ), </li></ul></ul></ul><ul><ul><ul><li>telecom customer ( care and billing ), </li></ul></ul></ul><ul><ul><ul><li>e-commerce ( personalizing the user's experience , recommender systems , auctions ) </li></ul></ul></ul>Adrian Giurca, eBusiness Technologies, Craiova, March 2009
  4. 4. The student main activity: Ask questions <ul><ul><li>Whenever you need please ask questions! </li></ul></ul><ul><ul><li>(I have many open questions too... ) </li></ul></ul><ul><ul><ul><li>Stop me and ask... </li></ul></ul></ul><ul><ul><ul><li>Maybe you'll get an answer (If I have one...) </li></ul></ul></ul><ul><ul><ul><li>Or I will answer you in the next lecture </li></ul></ul></ul><ul><ul><li>You can ask in RO. I'm pleased to speak RO </li></ul></ul><ul><ul><li>Slides are in English (they are not just for you) </li></ul></ul>Adrian Giurca, eBusiness Technologies, Craiova, March 2009
  5. 5. Your knowledge on rules <ul><ul><li>Do you know rule languages? </li></ul></ul>Adrian Giurca, eBusiness Technologies, Craiova, March 2009 Prolog, Lisp, Guru, Godel, Mercury,... <ul><ul><li>Do you use rule languages? </li></ul></ul>Prolog, Lisp, Guru,... <ul><ul><li>What rule-based applications you built? </li></ul></ul>?
  6. 6. What do you know about programming? Adrian Giurca, eBusiness Technologies, Craiova, March 2009 Modeling UML,... Languages Java, C, C++, ... Paradigms Procedural, OOP, Functional, Declarative, ... Methodologies RUP, Extreme, Agile,...
  7. 7. What's your preferred programming model? Adrian Giurca, eBusiness Technologies, Craiova, March 2009 Modeling UML? Languages Java? Paradigms OOP? Methodologies Agile?
  8. 8. Embedding rules in Java – Using Libraries <ul><ul><li>Prolog 2 Java: </li></ul></ul><ul><ul><ul><li>SWI-Prolog JPL: </li></ul></ul></ul><ul><ul><ul><li>http://www.swi-rolog.org/packages/jpl/ </li></ul></ul></ul><ul><ul><ul><li>JProlog: </li></ul></ul></ul><ul><ul><ul><li>http://www.cs.kuleuven.ac.be/~bmd/PrologInJava/ </li></ul></ul></ul><ul><ul><li>And many others... </li></ul></ul><ul><li>But: </li></ul><ul><ul><li>Did you used them ever ? </li></ul></ul><ul><ul><li>Are they easy to be used ? </li></ul></ul><ul><ul><li>What about the programming model ? How you design your application? </li></ul></ul>Adrian Giurca, eBusiness Technologies, Craiova, March 2009
  9. 9. Business community use natural language (NL) to express rules <ul><ul><li>If all of the following are true, then the car's potential theft rating is low: </li></ul></ul><ul><ul><ul><li>car's price is less that $20,000, </li></ul></ul></ul><ul><ul><ul><li>car model is not on the list of 'High Theft Probability Auto'. </li></ul></ul></ul><ul><ul><li>If the car has no airbags, then the car's potential occupant injury rating is extremely high. </li></ul></ul><ul><ul><li>If the driver is a young driver, is married and located in CA, NY or VA, then increase policy premium by $700. </li></ul></ul>Adrian Giurca, eBusiness Technologies, Craiova, March 2009
  10. 10. Logic programming (LP) is great <ul><ul><li>Has a well established semantics </li></ul></ul><ul><ul><li>Well known engine(s) </li></ul></ul><ul><ul><li>You have to learn the syntax and (at least) the operational semantics </li></ul></ul><ul><ul><li>With LP background one can easily understand other solutions </li></ul></ul>Adrian Giurca, eBusiness Technologies, Craiova, March 2009 <ul><ul><li>Can you model the above rules in Prolog? </li></ul></ul><ul><ul><li>Can you use them in an insurance scoring application ? </li></ul></ul><ul><ul><li>Can you change the rules at runtime ? </li></ul></ul>
  11. 11. Slide No. 11 <ul><ul><li>This is Slide No. 11 (half time) and we don't know yet how to use rules in a large application?! </li></ul></ul><ul><li>(Yet) Open Questions : </li></ul><ul><ul><li>How to model such an application? Which modeling language I have to use? </li></ul></ul><ul><ul><li>Which rule library to use? </li></ul></ul><ul><ul><li>How to separate the rules </li></ul></ul><ul><ul><li>logic from the rest of application </li></ul></ul><ul><ul><li>logic? </li></ul></ul><ul><ul><li>How to debug the application? </li></ul></ul><ul><ul><li>How to maintain/re-factor? </li></ul></ul>Adrian Giurca, eBusiness Technologies, Craiova, March 2009
  12. 12. This Course Goals <ul><ul><li>To learn you basic rule modeling </li></ul></ul><ul><ul><li>To introduce the basics of a Java-based rule engine: </li></ul></ul>Adrian Giurca, eBusiness Technologies, Craiova, March 2009 A project of
  13. 13. Facts about Drools <ul><ul><li>Open-Source, Forward-Chaining Production Rule System </li></ul></ul><ul><ul><li>Reuse rules across applications and Service-Oriented Architectures </li></ul></ul><ul><ul><li>The runtime provides dynamic assertion and remove of rules </li></ul></ul><ul><ul><li>Offers support for temporal rules that are executed within specified time periods or constraints </li></ul></ul><ul><ul><li>Drools Rule Language (DRL) uses Java to express field constraints, functions, and consequences </li></ul></ul><ul><ul><li>Drools Workbench IDE features include syntax coloring, outline view, basic rule validation and error reporting </li></ul></ul><ul><ul><li>Blog: http://blog.athico.com/ </li></ul></ul>Adrian Giurca, eBusiness Technologies, Craiova, March 2009
  14. 14. Rules are based on domain vocabularies <ul><ul><li>Many software engineers design vocabularies using UML </li></ul></ul>Adrian Giurca, eBusiness Technologies, Craiova, March 2009 <ul><ul><li>UML class diagrams can be straightforward mapped to Java. </li></ul></ul>
  15. 15. Can we use UML to design rules? <ul><ul><li>If the driver is a young driver, is married and located in CA, NY or VA, then increase policy premium by $700. </li></ul></ul>Adrian Giurca, eBusiness Technologies, Craiova, March 2009 Conditions Variables Actions Rule Symbol
  16. 16. URML–UML-based language for rule modeling <ul><ul><li>URML supports modeling of </li></ul></ul><ul><ul><ul><li>derivation rules (aka Prolog rules), </li></ul></ul></ul><ul><ul><ul><li>production rules (aka Expert Systems rules) </li></ul></ul></ul><ul><ul><ul><li>reaction rules (Event-Condition-Action rules). </li></ul></ul></ul><ul><ul><li>A rule is represented graphically as a circle with a rule identifier . </li></ul></ul><ul><ul><li>Incoming arrows represent rule conditions or triggering events </li></ul></ul><ul><ul><li>Outgoing arrows represent rule conclusions or produced actions . </li></ul></ul><ul><ul><li>Ask me later if you are interested! </li></ul></ul>Adrian Giurca, eBusiness Technologies, Craiova, March 2009
  17. 17. Drools Rule Language (is almost Java!!) rule &quot;DP_01&quot; agenda-group &quot;driver-premium&quot; salience 10 when //If young driver, married and located in //one of CA, NY or VA $driver:YoungDriver( maritalStatus == MaritalStatus.MARRIED, usState == &quot;CA&quot; || == &quot;NY&quot; || == &quot;VA&quot;, $policy:vehicleInsurancePolicy) then //increase policy premium by $700 $policy.setPremium($policy.getPremium()+ 700); $driver.setPolicy($policy) drools.modifyObject($driver); end Adrian Giurca, eBusiness Technologies, Craiova, March 2009
  18. 18. Can you write this rule using logic ? (Of course) IF youngDriver($driver)AND maritalStatus($driver, &quot;married&quot;) AND (usState($driver, &quot;CA&quot;) OR usState($driver, &quot;NY&quot;) OR usState($driver, &quot;VA&quot;)) AND vehicleInsurancePolicy($driver, $policy) AND THEN premium($policy, $premium) AND retract(premium($policy, $premium)) AND retract(vehicleInsurancePolicy($driver, $policy)) AND assert(premium($policy, $premium+700)) AND assert(vehicleInsurancePolicy($driver, $policy)) Adrian Giurca, eBusiness Technologies, Craiova, March 2009 <ul><ul><li>Logic works fine. Is enough. </li></ul></ul>
  19. 19. What about this representation? IF driver($driver, type(&quot;youngDriver&quot;), maritalStatus(&quot;married&quot;), vehicleInsurancePolicy(policy($premium)) )AND .... Adrian Giurca, eBusiness Technologies, Craiova, March 2009 <ul><ul><li>Logic works fine?! Is enough?! Hmm... </li></ul></ul><ul><ul><li>How can I connect my rules with already existent Java classes in my application? </li></ul></ul><ul><ul><li>Add more classes... Mappings... Increase complexity... </li></ul></ul><ul><ul><li>Better use a Java syntax for rules... and a Java-based rule engine! </li></ul></ul>
  20. 20. Many commercial usages of rule engines <ul><ul><li>IBM Rules (former ILOG Rules), http://www.ilog.com/ </li></ul></ul><ul><ul><li>Oracle Business Rules, http://www.oracle.com/technology/products/ias/business_rules </li></ul></ul><ul><ul><li>Fair Isaac, http://www.fairisaac.com/ </li></ul></ul><ul><ul><li>Innovations, http://www.innovations.de/ </li></ul></ul><ul><ul><li>Pegasystems, http://www.pega.com/ </li></ul></ul><ul><ul><li>Computer Associates, http://www.ca.com/ </li></ul></ul><ul><ul><li>Gensym, http://www.gensym.com/ </li></ul></ul><ul><ul><li>Corticon, http://www.corticon.com/ </li></ul></ul>Adrian Giurca, eBusiness Technologies, Craiova, March 2009
  21. 21. Do you like rule-based applications? <ul><ul><li>Attend the next lecture </li></ul></ul><ul><ul><ul><li>Tomorrow at 4PM in the same room </li></ul></ul></ul>Adrian Giurca, eBusiness Technologies, Craiova, March 2009

×