Advertisement

More Related Content

Advertisement

More from Geoffrey De Smet(19)

Advertisement

2011-03-29 London - drools

  1. The system goes online on August 4th, 1997.
  2. Human decisions are removed from strategic defense.
  3. SkyNet begins to learn at a geometric rate.
  4. It becomes self-aware at 2:14am Eastern time, August 29th
  5. In a panic, they try to pull the plug.
  6. And, Skynet fights back
  7. Community
  8. History
  9. Unified Concept
  10. Expert
  11. Quick Example
  12. Conditional Elements
  13. Truth Maintenance and Inference
  14. Fusion
  15. Open Source
  16. Business Model
  17. Given Enough Eyeballs
  18. Flexibility
  19. Control
  20. Academic / Engineering Bridge
  21. Learning/Exploring
  22. Mastery
  23. Being part of Something
  24. Making a difference
  25. Scratching an itch RSA Animate – Drive: The surprising truth about what motivates us http://www.youtube.com/watch?v=u6XAPnuFjJc
  26. Code commits
  27. Number of Developers
  28. % of internal to external developers
  29. Commitment and health of commercial backers
  30. Professional services
  31. Hiring
  32. Community
  33. Oh And There are Drools Books Too
  34. Many more as haven't updated
  35. OSDE (Argentina's largest healthcare organisation)
  36. Intalio
  37. Director in RuleML group
  38. 5 day event, with 2 days focus on the healthcare industry
  39. OSDE, AT&T, SAIC, US Navy Research, Kaiser, Clinica, Intermountain Healthcare, GE Healthcare, VA, Boeing, Nationwide ....
  40. IRC, Internet Relay Chat
  41. History
  42. It All Started Here Birth of CDSS 1970s 1980s Dendral Baobab Mycin Guidon Neomycin Teiresias Puff Emycin WM Sacon Centaur Wheeze Gravida Clot Oncocin
  43. Because Not Everyone Is As Smart As He Is
  44. Business Rules Engines 1980s 2010s 1990s 2000s OPS5 ART Clips Jess Drools 2 JRules Drools 3 Drools 4 Drools 5
  45. Basic functional programming feature with “from”
  46. Basic Rule Flow
  47. More Advanced Rule Flow integration
  48. Unified Vision Behavioural Modelling
  49. Integrated Systems Semantic Ontologies Rules Event Processes Workflows Rules Workflows Event Processes Semantic Ontologies
  50. Compliments SOA
  51. Unified Vision “ A common platform to model and govern the business logic of the enterprise.”
  52. Unified Vision “ A common platform to model and govern the business logic of the enterprise.”
  53. Business Logic Lifecycle
  54. jBPM3 File file = new File (“.....”); // file to XML process definition ProcessDefinition processDefinition = ProcessDefinition.parseXmlString( IoUtils.FileToString( file ) ); ProcessInstance processInstance = new ProcessInstance(processDefinition); Jess Rete engine = new Rete(); FileReader file = new FileReader("myfile.clp"); Jesp parser = new Jesp(file, engine); parser.parse(false); Esper EPServiceProvider epService = EPServiceProviderManager.getDefaultProvider(); EPStatement countStmt = admin.createEPL( "...." ); countStmt.start(); Knowledge API
  55. Drools Flow KnowledegBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBulider(); kbuilder.addResource( ResourceFactory.newClassPathResource( “myflow.bpmn2”, ResourceType.BPMN2 ); If ( kbuilder.hasErrors() ) { log.error( kbuilder.hasErrors().toString() ); } KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase(); kbase.addKnowledgePackages( kbase.getKnowledgePackages() ); Knowledge API
  56. Drools Expert KnowledegBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBulider(); kbuilder.addResource( ResourceFactory.newClassPathResource( “myrules.drl”, ResourceType.DRL ); If ( kbuilder.hasErrors() ) { log.error( kbuilder.hasErrors().toString() ); } KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase(); kbase.addKnowledgePackages( kbase.getKnowledgePackages() ); Knowledge API
  57. <drools:kbase id=&quot;kbase1&quot;> <drools:resource type=&quot;DRL&quot; source=&quot;classpath:.../testSpring.drl&quot; /> </drools:kbase> <drools:ksession id=&quot;ksession1&quot; type=&quot; stateless &quot; kbase =&quot;kbase1&quot; /> <drools:ksession id=&quot;ksession2&quot; type=&quot; stateful &quot; kbase =&quot;kbase1&quot;/> <camelContext id=&quot;camel&quot;> <route> <from uri=&quot;cxfrs://bean://rsServer&quot;/> <marshal ref=&quot;xstream&quot;/> <to uri=”drools:ksession1” /> <unmarshal ref=&quot;xstream&quot;/> </route> </camelContext> Declarative Services Spring XML and Camel
  58. Event Driven Architectures edBPM + EDM
  59. EDA is used to build our sensory system
  60. Rules and processes loosely coupled tightly coupled specific generic Decision Services Process Rules SCOPE COUPLING ?
  61. Flexible
  62. Adaptive
  63. Domain Overview
  64. Domain Overview
  65. Drools Trunk has a prototype Prolog like query backward chaining capabilities. Stronger Polog like capabilities planned.
  66. Drools 5.0 has some functional capabilities
  67. Drools 5.1, 5.2 will be looking to have strong functional capabilities Hybrid Logic Engine
  68. Planned, See “The Future” Hybrid Logic Engine
  69. Casting Nested Objects
  70. Positional Constraints
  71. POSL - Positional-Slotted Language
  72. Method Calls
  73. Maps and Arrays (Collections)
  74. Collections and XPath like filtering
  75. Free form Expressions
  76. Managed Object Graphs (MOGS)
  77. Nested Patterns and Queries
  78. Queries and Unification
  79. Ontologies and Relations via
  80. Escapes for Dialects
  81. Accumulate Improvements to Support Haskell map/fold/filter and MVEL projection/fold
  82. Otherwise
  83. Branch (Labelled Else)
  84. Rule Execution Groups
  85. Rule Dependency Meta-Rule Language
  86. Parallel Meta-Rule Language
  87. Field Versioning
  88. Logical Closures/OnFalse
  89. Opportunistic Backward Chaining, Lazy Field/Object Values
  90. ...
  91. Drools Expert
  92. Classes
  93. rule “increase balance for AccountPeriod Credits” when ap : AccountPeriod() acc : Account( $accountNo : accountNo ) CashFlow( type == CREDIT, accountNo == $accountNo, date >= ap.start && <= ap.end, $ammount : ammount ) then acc.balance += $amount; end select * from Account acc, Cashflow cf, AccountPeriod ap where acc.accountNo == cf.accountNo and cf.type == CREDIT cf.date >= ap.start and cf.date <= ap.end trigger : acc.balance += cf.amount Credit Cashflow Rule
  94. rule “increase balance for AccountPeriod Credits” when ap : AccountPeriod() acc : Account( $accountNo : accountNo ) CashFlow( type == CREDIT, accountNo == $accountNo, date >= ap.start && <= ap.end, $ammount : ammount ) then acc.balance += $amount; end rule “decrease balance for AccountPeriod Debits” when ap : AccountPeriod() acc : Account( $accountNo : accountNo ) CashFlow( type == DEBIT, accountNo == $accountNo, date >= ap.start && <= ap.end, $ammount : ammount ) then acc.balance -= $amount; end Rules as a “view”
  95. Drools Expert Quick Example Stateless
  96. Definitions public class Applicant { private String name; private int age; private boolean valid; // getter and setter methods here } rule &quot;Is of valid age&quot; when $a : Applicant( age < 18 ) then modify ( $a ) { valid = false }; ends
  97. Building KnowledgeBuilder kbuilder = KnowledgeBuilderFactory .newKnowledgeBuilder(); kbuilder .add( ResourceFactory .newClassPathResource( &quot;licenseApplication.drl&quot; , getClass() ), ResourceType.DRL ); if ( kbuilder .hasErrors() ) { System.err.println( kbuilder .getErrors().toString() ); } kbase .addKnowledgePackages( kbuilder .getKnowledgePackages() );
  98. Executing StatelessKnowledgeSession ksession = kbase .newStatelessKnowledgeSession(); Applicant applicant = new Applicant ( &quot;Mr John Smith&quot; , 16 ); assertTrue ( applicant .isValid() ); ksession .execute( applicant ); assertFalse ( applicant .isValid() ); rule &quot;Is of valid age&quot; when $a : Applicant( age < 18 ) then modify ( $a ) { valid = false }; ends
  99. Drools Expert Quick Example Stateful
  100. Definitions public class Room { private String name // getter and setter methods here } public class Sprinkler { private Room room ; private boolean on ; // getter and setter methods here } public class Fire { private Room room ; // getter and setter methods here } public class Alarm { }
  101. Definitions rule &quot;When there is a fire turn on the sprinkler&quot; when Fire ($room : room) $sprinkler : Sprinkler ( room == $room, on == false ) then modify ( $sprinkler ) { on = true }; println ( &quot;Turn on the sprinkler for room &quot; + $room.name ); end rule &quot;When the fire is gone turn off the sprinkler&quot; when $room : Room ( ) $sprinkler : Sprinkler ( room == $room, on == true ) not Fire ( room == $room ) then modify ( $sprinkler ) { on = false }; println ( &quot;Turn off the sprinkler for room &quot; + $room.name ); end
  102. Definitions rule &quot;Raise the alarm when we have one or more fires&quot; when exists Fire () then insert ( new Alarm () ); println ( &quot;Raise the alarm&quot; ); end rule &quot;Cancel the alarm when all the fires have gone&quot; when not Fire () $alarm : Alarm () then retract ( $alarm ); println ( &quot;Cancel the alarm&quot; ); end
  103. Definitions rule &quot;Status output when things are ok&quot; when not Alarm () not Sprinkler ( on === true ) then println ( &quot;Everything is ok&quot; ); end
  104. Executing String [] names = new String []{ &quot;kitchen&quot; , &quot;bedroom&quot; , &quot;office&quot; , &quot;livingroom&quot; }; Map < String , Room > name2room = new HashMap < String , Room >(); for ( String name : names ){ Room room = new Room ( name ); name2room .put( name , room ); ksession .insert( room ); Sprinkler sprinkler = new Sprinkler ( room ); ksession .insert( sprinkler ); } ksession .fireAllRules() > Everything is ok
  105. Executing Fire kitchenFire = new Fire ( name2room.get( &quot;kitchen&quot; ) ); Fire officeFire = new Fire ( name2room.get( &quot;office&quot; ) ); FactHandle kitchenFireHandle = ksession .insert( kitchenFire ); FactHandle officeFireHandle = ksession .insert( officeFire ); ksession .fireAllRules(); > Raise the alarm > Turn on the sprinkler for room kitchen > Turn on the sprinkler for room office
  106. Executing ksession .retract( kitchenFireHandle ); ksession .retract( officeFireHandle ); ksession .fireAllRules() > Turn off the sprinkler for room office > Turn off the sprinkler for room kitchen > Cancel the alarm > Everything is ok rule &quot;Status output when things are ok&quot; when not Alarm () not Sprinkler ( on === true ) then println ( &quot;Everything is ok&quot; ); end
  107. Conditional Elements
  108. not Bus( color = “red” ) Conditional Elements exists Bus( color = “red” ) forall ( $bus : Bus( floors == 2 ) Bus( this == $bus, color == “red” ) ) forall ( $bus : Bus( color == “red” ) )
  109. Accumulate CE rule &quot;accumulate&quot; when $sum : Number( intValue > 100 ) from accumulate ( Bus( color == &quot;red&quot; , $t : takings ) sum( $t ) ) then print &quot;sum is “ + $sum; end
  110. Accumulate CE Patterns and CE's can be chained with ' from ' rule &quot;collect&quot; when $zipCode : ZipCode() $sum : Number( intValue > 100 ) from accumulate ( Bus( color == &quot;red&quot; , $t : takings ) from $hbn.getNamedQuery( “Find Buses” ) .setParameters( [ “zipCode” : $zipCode ] ) .list(), sum( $t ) ) then print &quot;sum is “ + $sum; end
  111. Timers Calendars
  112. Timers rule “name” timer 1m30s when $l : Light( status == “on” ) then modify ( $l ) { status = “off” }; rule “name” timer (int: 1m30s 0) when $l : Light( status == “on” ) then modify ( $l ) { status = “off” }; When the light is on, and has been on for 1m30s then turn it off Same as above. Interval timer with JDK semantics for initial duration, then repeat duration.
  113. Timers rule “name” timer ( cron: 0 0/15 * * * * ) when Alarm( ) then sendEmail( ”Alert Alert Alert!!!” ) Field Name Mandatory? Allowed Values Allowed Special Characters Seconds YES 0-59 , - * / Minutes YES 0-59 , - * / Hours YES 0-23 , - * / Day of month YES 1-31 , - * ? / L W Month YES 1-12 or JAN-DEC , - * / Day of week YES 1-7 or SUN-SAT , - * ? / L # Year NO empty, 1970-2099 , - * / Send alert every quarter of an hour
  114. Calendars rule &quot;weekdays are high priority&quot; calendars &quot;weekday&quot; timer (int:0 1h) when Alarm() then send( &quot;priority high - we have an alarm” ); end rule &quot;weekend are low priority&quot; calendars &quot;weekend&quot; timer (int:0 4h) when Alarm() then send( &quot;priority low - we have an alarm” ); end Execute now and after 1 hour duration Execute now and after 4 hour duration
  115. Truth Maintenance Inference
  116. TMS and Inference rule &quot;Issue Child Bus Pass&quot; when $p : Person ( age < 16 ) then insert(new ChildBusPass ( $p ) ); end rule &quot;Issue Adult Bus Pass&quot; when $p : Person ( age >= 16 ) then insert(new AdultBusPass ( $p ) ); end Couples the logic What happens when the Child stops being 16?
  117. Leaky
  118. Brittle integrity - manual maintenance
  119. When the rule is no longer true, the object is retracted. when $p : Person ( age < 16 ) then logicalInsert ( new IsChild ( $p ) ) end when $p : Person ( age >= 16 ) then logicalInsert ( new IsAdult ( $p ) ) end de-couples the logic Maintains the truth by automatically retracting
  120. TMS and Inference rule &quot;Issue Child Bus Pass&quot; when $p : Person ( ) IsChild ( person =$p ) then logicalInsert ( new ChildBusPass ( $p ) ); end rule &quot;Issue Adult Bus Pass&quot; when $p : Person ( age >= 16 ) IsAdult ( person =$p ) then logicalInsert ( new AdultBusPass ( $p ) ); end The truth maintenance cascades
  121. TMS and Inference rule &quot;Issue Child Bus Pass&quot; when $p : Person ( ) not ( ChildBusPass ( person == $p ) ) then requestChildBusPass( $p ); end The truth maintenance cascades
  122. Encapsulate knowledge
  123. Provide semantic abstractions for those encapsulation
  124. Integrity robustness – truth maintenance
  125. Fusion
  126. Strong temporal relationships
  127. Managed lifecycle
  128. Drools Fusion: Temporal Reasoning
  129. Drools Fusion: Temporal Reasoning
  130. $c : Custumer( type == “VIP ) $oe : BuyOrderEvent( customer == $c ) from entry-point “Home Broker Stream” not BuyAckEvent( relatedEvent == $oe.id, this after[1s, 10s] $oe ) from entry-point “Stock Trader Stream” Operators Existing Drools 'not' Conditional Elements can be used to detect non-occurrence of events BackAckEvent must occur between 1s and 10s ' after' BuyOrderEvent
  131. Aggregations Rule Engines do not deal with aggregations $n : Number( intValue > 100 ) from accumulate ( $s : StockTicker( symbol == “RHAT” ) over window:time ( 5s ), average ( $s.price ) ) Over 5 seconds Aggregate ticker price for RHAT over last 5 seconds The pattern 'Number' reasons 'from' the accumulate result
  132. CEP Applied at FedEx Custom Critical * Presented by Adam Mollemkopf at ORF 2009
  133. CEP Applied at FedEx Custom Critical * Presented by Adam Mollemkopf at ORF 2009
  134. HAL : Without your space helmet, Dave, you're going to find that rather difficult.
  135. Dave Bowman : HAL, I won't argue with you anymore! Open the doors!
  136. HAL : Dave, this conversation can serve no purpose anymore. Goodbye. Joshua: Greetings, Professor Falken. Stephen Falken : Hello, Joshua. Joshua: A strange game. The only winning move is not to play. How about a nice game of chess?
Advertisement