Mark   Proctor Project Lead T he SkyNet funding bill is passed.
The system goes online on August 4th, 1997.
Human decisions are removed from strategic defense.
SkyNet begins to learn at a geometric rate.
It becomes self-aware at 2:14am Eastern time, August 29th
In a panic, they try to pull the plug.
And, Skynet fights back
Agenda Community
History
Declarative Programming
Drools Expert
Drools Fustion
jBPM
Roadmap
Boot Camps San Francisco 2009 (40+ attendees) Sponsored by Third Pillar
Sun, FAMC, OSDE, Kaseya, Fedex, TU Group, Intermountain Healthcare, Gap, Sony Pictures, Lockheed Martin, Kaiser, HP, Wells Fargo, US Navy Research, FOLIOfn, Boeing ..... San Diego 2010 (80+ attendess) Sponsored by US Navy
5 day event, with 2 days focus on the healthcare industry
OSDE, AT&T, SAIC, US Navy Research, Kaiser, Clinica, Intermountain Healthcare, GE Healthcare, VA, Boeing, Nationwide ....
Books Introduction to Expert Systems Peter Jackson Expert Systems, Principles and Programming Joseph C. Giarratano and Gary D. Riley
Oh And There are Drools Books Too
History
It All Started Here Birth of CDSS Clinical Decision Support Systems 1970s 1980s Dendral Baobab Mycin Guidon Neomycin Teiresias Puff Emycin WM Sacon Centaur Wheeze Gravida Clot Oncocin
Because Not Everyone  Is As Smart As He Is
Business Rules Engines 1980s 2010s 1990s 2000s OPS5 ART Clips Jess Drools 2 JRules Drools 3 Drools 4 Drools 5
Drools History Drools 2 Rete like XML Scripting language Drools 3  Based on Clips functionality
Iterative improves to JRules syntax with Clips functionality Drools 4 More declarative
Basic functional programming feature with “from”
Basic Rule Flow
Basic BRMS Drools 5 Improved functional programming with 'accumulate'
More Advanced Rule Flow integration
Complex Event Process Temporal Comparators
Sliding Time Windows Production ready BRMS (Guvnor)
Drools History Drools 5.1 Differential Diff (true modify) Drools 5.2 Freeform expressions between patterns
Multi-function accumulates
Prolog like derivation queries
Decision tables and rule templates (Guvnor)
Pure GWT (Guvnor) Drools 5.3 ...
Declarative Programming
Integrated Systems Semantic  Ontologies Rules Event Processes Workflows Rules  Workflows Event Processes Semantic  Ontologies
Integrated Systems
Rules and processes loosely coupled tightly coupled specific generic Decision Services Process Rules SCOPE COUPLING ?
Business Logic Lifecycle
Declarative Programming Production Rule Systems PRD (forward chaining) Reactive
when Alarm( status == “alert” )  then send( “warning” ) Logic Programming LP (backward chaining) Query
descendant( “mary”, “jane”) Functional Programming FP Map,Fold, Filter
avg([12, 16, 4, 6]) Returns single value 9.5 round([10.3, 4.7, 7.8] ) Returns List [10, 5, 8] Description Logic Person Has Name and    LivesAt Address
Concepts Overview
Concepts Overview
Concepts Overview
Drools Expert
Classes
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
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”
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 { }
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
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
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
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
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
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
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” ) )
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
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
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
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
Backward Chaining query  isContainedIn( String x, String y ) Location ( x, y; ) or (  Location (  z , y; )  and   ?isContainedIn ( x,  z ; ) ) end rule  reactiveLook when Here ( place : place)  ?isContainedIn ( place,  &quot;keys&quot; ; ) then System.out.println(  &quot;We have found your keys&quot;  ); end
Drools Fusion
Drools Fusion: Enables... Event Detection: From an event cloud or set of streams, select all the meaningful events, and only them. [Temporal] Event Correlation: Ability to correlate events and facts declaring both temporal and non-temporal constraints between them.
Ability to reason over event aggregation. Event Sequencing: A -> ( B OR C ) -> D Event Abstraction: Ability to compose complex events from atomic events AND reason over them
Drools Fusion: Features Support to Event semantics: Usually immutable, but not enforced
Strong temporal relationships
Managed lifecycle
Point-in-time and Interval events Time semantics Discrete Temporal relationships All 13 operators defined by James Allen (+ negations)
Event Driven Architecture (EDA) “ Event Driven Architecture (EDA)  is a software architecture pattern promoting the  production ,  detection ,  consumption  of, and  reaction  to events. An  event  can be defined as &quot;a significant change in state&quot;[1]. For example, when a consumer purchases a car, the car's state changes from &quot;for sale&quot; to &quot;sold&quot;. A car dealer's system architecture may treat this state change as an event to be produced, published, detected and consumed by various applications within the architecture.”
CEP vs EDA vs SOA CEP  is component of  EDA
EDA  is  **not**  SOA 2.0
Complementary  architectures
Metaphor In our  body : SOA is used to build our  muscles and organs
EDA is used to build our  sensory system
$c : Custumer( type == “VIP ) BuyOrderEvent( customer == $c )  from entry-point  “Home Broker Stream” Scalability EntryPoint entryPoint = session. getEntryPoint ( “Home Broker Stream” ); entryPoint.insert( event ) ; So lets allow multiple named entry points for those streams So now we can insert different streams concurrently Patterns can now optional specify their entry-point.  When not specified uses the “default” entry-point
declare StockTick @role( event ) end declare StockTick @role( event ) @timestamp( timestampAttr ) companySymbol : String stockPrice : double timestampAttr : long end Automatic Life-Cycle Management Just use the declare statement to declare a type as an event and it will be retracted when it is no longer needed  The declare statement can also specify an internal model, that external objects/xml/csv map on to. We support Smooks and JAXB
$c  : Custumer( type == “VIP ) $oe : BuyOrderEvent( customer == $c )  from entry-point “Home Broker Stream” BuyAckEvent( relatedEvent == $oe.id, this  after[1s, 10s]  $oe )  from entry-point “Stock Trader Stream” coincides
before
after
meets
metby overlaps
overlappedby
during
includes starts
startedby
finishes
finishedby Operators The Full set of Operators are supported BackAckEvent must occur between 1s and 10s ' after'  BuyOrderEvent
Drools Fusion: Temporal Reasoning
Drools Fusion: Temporal Reasoning
$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
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
Aggregations acc (  $s : StockTicker( symbol == “RHAT”  )  over window:time ( 5s ); $min :  min ( $s.price ), $min :  min ( $s.price ), $avg :  avg ( $s.price ); $min > 10 &&  $max < 20 &&  $avg > 16 ) Over 5 seconds functions Accumlate over data Guard constraint
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
CEP Applied at FedEx Custom Critical Time specific deliveries for critical freight
Exclusive use non-stop door-to-door services
Blended Surface and Air services to minimize cost and transit time
Extra care in handling and specially equipped vehicles Temperature Control, Secured Services, Hazardous Material, Constant Surveillance * Presented by Adam Mollemkopf at ORF 2009
CEP Applied at FedEx Custom Critical * Presented by Adam Mollemkopf at ORF 2009
CEP Applied at FedEx Custom Critical * Presented by Adam Mollemkopf at ORF 2009
CEP Applied at FedEx Custom Critical * Presented by Adam Mollemkopf at ORF 2009
CEP Applied at FedEx Custom Critical * Presented by Adam Mollemkopf at ORF 2009
CEP Applied at FedEx Custom Critical * Presented by Adam Mollemkopf at ORF 2009
CEP Applied at FedEx Custom Critical * Presented by Adam Mollemkopf at ORF 2009
CEP Applied at FedEx Custom Critical * Presented by Adam Mollemkopf at ORF 2009 At least 50% of Alerts can be reasoned automatically, promoting staff savings and improved Customer and Driver experiences.
Risk Avoidance via pro-active monitoring Reduction in insurance claims and shipment service failures Minimum 30% efficiency gains in shipment monitoring , saving at least 15% of Operations staff cost.
CEP Applied at FedEx Custom Critical Some numbers (from early 2010): 24 x 7 sessions, no downtime
Average of 500k+ facts/events concurrently in memory Business hours: 1M+ facts/events concurrently Response time for reasoning cycles: Average: 150 ms
Peak: 1.2 sec Several hundred rules
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?
TMS and Inference Bad Monolithic
Leaky
Brittle integrity - manual maintenance
TMS and Inference A rule “logically” inserts an object
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
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
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
TMS and Inference Good De-couple knowledge responsibilities
Encapsulate knowledge
Provide semantic abstractions for those encapsulation
Integrity robustness – truth maintenance
Some decisions are complex What insurance premium should I charge?

rules, events and workflow

  • 1.
    Mark Proctor Project Lead T he SkyNet funding bill is passed.
  • 2.
    The system goesonline on August 4th, 1997.
  • 3.
    Human decisions areremoved from strategic defense.
  • 4.
    SkyNet begins tolearn at a geometric rate.
  • 5.
    It becomes self-awareat 2:14am Eastern time, August 29th
  • 6.
    In a panic,they try to pull the plug.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
    Boot Camps SanFrancisco 2009 (40+ attendees) Sponsored by Third Pillar
  • 16.
    Sun, FAMC, OSDE,Kaseya, Fedex, TU Group, Intermountain Healthcare, Gap, Sony Pictures, Lockheed Martin, Kaiser, HP, Wells Fargo, US Navy Research, FOLIOfn, Boeing ..... San Diego 2010 (80+ attendess) Sponsored by US Navy
  • 17.
    5 day event,with 2 days focus on the healthcare industry
  • 18.
    OSDE, AT&T, SAIC,US Navy Research, Kaiser, Clinica, Intermountain Healthcare, GE Healthcare, VA, Boeing, Nationwide ....
  • 19.
    Books Introduction toExpert Systems Peter Jackson Expert Systems, Principles and Programming Joseph C. Giarratano and Gary D. Riley
  • 20.
    Oh And Thereare Drools Books Too
  • 21.
  • 22.
    It All StartedHere Birth of CDSS Clinical Decision Support Systems 1970s 1980s Dendral Baobab Mycin Guidon Neomycin Teiresias Puff Emycin WM Sacon Centaur Wheeze Gravida Clot Oncocin
  • 23.
    Because Not Everyone Is As Smart As He Is
  • 24.
    Business Rules Engines1980s 2010s 1990s 2000s OPS5 ART Clips Jess Drools 2 JRules Drools 3 Drools 4 Drools 5
  • 25.
    Drools History Drools2 Rete like XML Scripting language Drools 3 Based on Clips functionality
  • 26.
    Iterative improves toJRules syntax with Clips functionality Drools 4 More declarative
  • 27.
    Basic functional programmingfeature with “from”
  • 28.
  • 29.
    Basic BRMS Drools5 Improved functional programming with 'accumulate'
  • 30.
    More Advanced RuleFlow integration
  • 31.
    Complex Event ProcessTemporal Comparators
  • 32.
    Sliding Time WindowsProduction ready BRMS (Guvnor)
  • 33.
    Drools History Drools5.1 Differential Diff (true modify) Drools 5.2 Freeform expressions between patterns
  • 34.
  • 35.
  • 36.
    Decision tables andrule templates (Guvnor)
  • 37.
    Pure GWT (Guvnor)Drools 5.3 ...
  • 38.
  • 39.
    Integrated Systems Semantic Ontologies Rules Event Processes Workflows Rules Workflows Event Processes Semantic Ontologies
  • 40.
  • 41.
    Rules and processesloosely coupled tightly coupled specific generic Decision Services Process Rules SCOPE COUPLING ?
  • 42.
  • 43.
    Declarative Programming ProductionRule Systems PRD (forward chaining) Reactive
  • 44.
    when Alarm( status== “alert” ) then send( “warning” ) Logic Programming LP (backward chaining) Query
  • 45.
    descendant( “mary”, “jane”)Functional Programming FP Map,Fold, Filter
  • 46.
    avg([12, 16, 4,6]) Returns single value 9.5 round([10.3, 4.7, 7.8] ) Returns List [10, 5, 8] Description Logic Person Has Name and LivesAt Address
  • 47.
  • 48.
  • 49.
  • 50.
  • 51.
  • 52.
    rule “increase balancefor 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
  • 53.
    rule “increase balancefor 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”
  • 54.
    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 { }
  • 55.
    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
  • 56.
    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
  • 57.
    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
  • 58.
    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
  • 59.
    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
  • 60.
    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
  • 61.
    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” ) )
  • 62.
    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
  • 63.
    Accumulate CE Patternsand 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
  • 64.
    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
  • 65.
    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
  • 66.
    Backward Chaining query isContainedIn( String x, String y ) Location ( x, y; ) or ( Location ( z , y; ) and ?isContainedIn ( x, z ; ) ) end rule reactiveLook when Here ( place : place) ?isContainedIn ( place, &quot;keys&quot; ; ) then System.out.println( &quot;We have found your keys&quot; ); end
  • 67.
  • 68.
    Drools Fusion: Enables...Event Detection: From an event cloud or set of streams, select all the meaningful events, and only them. [Temporal] Event Correlation: Ability to correlate events and facts declaring both temporal and non-temporal constraints between them.
  • 69.
    Ability to reasonover event aggregation. Event Sequencing: A -> ( B OR C ) -> D Event Abstraction: Ability to compose complex events from atomic events AND reason over them
  • 70.
    Drools Fusion: FeaturesSupport to Event semantics: Usually immutable, but not enforced
  • 71.
  • 72.
  • 73.
    Point-in-time and Intervalevents Time semantics Discrete Temporal relationships All 13 operators defined by James Allen (+ negations)
  • 74.
    Event Driven Architecture(EDA) “ Event Driven Architecture (EDA) is a software architecture pattern promoting the production , detection , consumption of, and reaction to events. An event can be defined as &quot;a significant change in state&quot;[1]. For example, when a consumer purchases a car, the car's state changes from &quot;for sale&quot; to &quot;sold&quot;. A car dealer's system architecture may treat this state change as an event to be produced, published, detected and consumed by various applications within the architecture.”
  • 75.
    CEP vs EDAvs SOA CEP is component of EDA
  • 76.
    EDA is **not** SOA 2.0
  • 77.
  • 78.
    Metaphor In our body : SOA is used to build our muscles and organs
  • 79.
    EDA is usedto build our sensory system
  • 80.
    $c : Custumer(type == “VIP ) BuyOrderEvent( customer == $c ) from entry-point “Home Broker Stream” Scalability EntryPoint entryPoint = session. getEntryPoint ( “Home Broker Stream” ); entryPoint.insert( event ) ; So lets allow multiple named entry points for those streams So now we can insert different streams concurrently Patterns can now optional specify their entry-point. When not specified uses the “default” entry-point
  • 81.
    declare StockTick @role(event ) end declare StockTick @role( event ) @timestamp( timestampAttr ) companySymbol : String stockPrice : double timestampAttr : long end Automatic Life-Cycle Management Just use the declare statement to declare a type as an event and it will be retracted when it is no longer needed The declare statement can also specify an internal model, that external objects/xml/csv map on to. We support Smooks and JAXB
  • 82.
    $c :Custumer( type == “VIP ) $oe : BuyOrderEvent( customer == $c ) from entry-point “Home Broker Stream” BuyAckEvent( relatedEvent == $oe.id, this after[1s, 10s] $oe ) from entry-point “Stock Trader Stream” coincides
  • 83.
  • 84.
  • 85.
  • 86.
  • 87.
  • 88.
  • 89.
  • 90.
  • 91.
  • 92.
    finishedby Operators TheFull set of Operators are supported BackAckEvent must occur between 1s and 10s ' after' BuyOrderEvent
  • 93.
  • 94.
  • 95.
    $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
  • 96.
    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
  • 97.
    Aggregations acc ( $s : StockTicker( symbol == “RHAT” ) over window:time ( 5s ); $min : min ( $s.price ), $min : min ( $s.price ), $avg : avg ( $s.price ); $min > 10 && $max < 20 && $avg > 16 ) Over 5 seconds functions Accumlate over data Guard constraint
  • 98.
    Aggregations Rule Enginesdo 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
  • 99.
    CEP Applied atFedEx Custom Critical Time specific deliveries for critical freight
  • 100.
    Exclusive use non-stopdoor-to-door services
  • 101.
    Blended Surface andAir services to minimize cost and transit time
  • 102.
    Extra care inhandling and specially equipped vehicles Temperature Control, Secured Services, Hazardous Material, Constant Surveillance * Presented by Adam Mollemkopf at ORF 2009
  • 103.
    CEP Applied atFedEx Custom Critical * Presented by Adam Mollemkopf at ORF 2009
  • 104.
    CEP Applied atFedEx Custom Critical * Presented by Adam Mollemkopf at ORF 2009
  • 105.
    CEP Applied atFedEx Custom Critical * Presented by Adam Mollemkopf at ORF 2009
  • 106.
    CEP Applied atFedEx Custom Critical * Presented by Adam Mollemkopf at ORF 2009
  • 107.
    CEP Applied atFedEx Custom Critical * Presented by Adam Mollemkopf at ORF 2009
  • 108.
    CEP Applied atFedEx Custom Critical * Presented by Adam Mollemkopf at ORF 2009
  • 109.
    CEP Applied atFedEx Custom Critical * Presented by Adam Mollemkopf at ORF 2009 At least 50% of Alerts can be reasoned automatically, promoting staff savings and improved Customer and Driver experiences.
  • 110.
    Risk Avoidance viapro-active monitoring Reduction in insurance claims and shipment service failures Minimum 30% efficiency gains in shipment monitoring , saving at least 15% of Operations staff cost.
  • 111.
    CEP Applied atFedEx Custom Critical Some numbers (from early 2010): 24 x 7 sessions, no downtime
  • 112.
    Average of 500k+facts/events concurrently in memory Business hours: 1M+ facts/events concurrently Response time for reasoning cycles: Average: 150 ms
  • 113.
    Peak: 1.2 secSeveral hundred rules
  • 114.
    TMS and Inferencerule &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?
  • 115.
    TMS and InferenceBad Monolithic
  • 116.
  • 117.
    Brittle integrity -manual maintenance
  • 118.
    TMS and InferenceA rule “logically” inserts an object
  • 119.
    When the ruleis 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 Inferencerule &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 Inferencerule &quot;Issue Child Bus Pass&quot; when $p : Person ( ) not ( ChildBusPass ( person == $p ) ) then requestChildBusPass( $p ); end The truth maintenance cascades
  • 122.
    TMS and InferenceGood De-couple knowledge responsibilities
  • 123.
  • 124.
    Provide semantic abstractionsfor those encapsulation
  • 125.
    Integrity robustness –truth maintenance
  • 126.
    Some decisions arecomplex What insurance premium should I charge?