drools @ intellifest 2012
TRANSCRIPT
The 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
Mark ProctorProject Lead
Drools Books
Sample Industries and Users
Investment
Millennium Investment Group (MIG)
Logistics
Fedex
Airline
Sabre
Mortgage
Franklin American
Healthcare
OSDE
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 ....
Integrated Systems
Semantic
OntologiesRulesEventProcessesWorkflowsRules Workflows
EventProcesses
Semantic
Ontologies
Integrated Systems
Drools
Grid
Drools
Planner
Drools
Semantics
Drools
Chance
Drools
Guvnor
Drools
Fusion
JBPM5(Drools Flow)
Drools
Expert
Rules and processes
loosely coupledtightly coupledspecificgenericDecisionServicesProcessRulesSCOPECOUPLING?
Vision
Robotics
Speech
Neural Nets
Rule Base Systems/
Expert System Tools
Understanding
Natural
Language
Some Areas of
Artificial Intelligence
Some Areas of Artificial Intelligence
Knowledge Representation and Reasoning
The study of Knowledge is EpistemologyNature Structure and Origins of Knowledge
Core or AI
Rule based systemsExpert System tools
Knowledge Representation and Reasoning
Facilitate the codification of knowledge into a knowledge base which can be used for reasoning
Knowledege Representation and Reasoning
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
Knowledege Representation and Reasoning
Description LogicMan
Father is a Man
has at least one child
All Fathers have sunday off
Individual == instanceAdhocClasses and properties
added and inferred over time
Does a Man with two children have sundays off?
It All Started Here
Birth of CDSS
DendralBaobabMycinGuidonNeomycinTeiresiasPuffEmycinWMSaconCentaurWheezeGravidaClot
Oncocin
1970s
1980s
Because Not Everyone
Is As Smart As He Is
And some day we'll build him!!!
Concepts Overview
Concepts Overview
Concepts Overview
What is a Rule
rule
when
then
end
Quotes on Rule names are optional if the rule name has no
spaces.salience agenda-group no-loop auto-focus
duration ....RHS can be any valid java. Or MVEL. Other languages
could be added.
What is a Rule
public void helloMark(Person person) {
if ( person.getName().equals( mark ) {
System.out.println( Hello Mark );
}
}
rule Hello Mark
when
Person( name == mark )
then
System.out.println( Hello Mark );
end
LHSRHSspecific passing of instancesMethods that must be called directlyRules can never be called directlySpecific instances cannot be passed.
What is a Pattern
Classes
rule increase balance for AccountPeriod Credits when ap : AccountPeriod() acc : Account( $accountNo : accountNo ) CashFlow( type == CREDIT, accountNo == $accountNo, date >= ap.start && = ap.start and cf.date = ap.start && = ap.start && = ap.start && Everything is ok
Executing
Fire kitchenFire = new Fire( name2room.get( "kitchen" ) );Fire officeFire = new Fire( name2room.get( "office" ) );
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 "Status output when things are ok" when not Alarm() not Sprinkler( on == true ) then println( "Everything is ok" );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 "accumulate"when accumulate( Bus( color == "red", $t : takings ); $sum : sum( $t ) )then print "sum is + $sum;end
accumulate( Bus( color == "red", $t : takings ); $sum : sum( $t ), $min : min( $t ) $max : max( $t ); $min > 100 && $max < 200 )
Timers
rule name timer ( cron: 0 0/15 * * * * )when Alarm( )then sendEmail( Alert Alert Alert!!! )
Field Name Mandatory? Allowed Values Allowed Special CharactersSeconds YES 0-59 , - * /Minutes YES 0-59 , - * /Hours YES 0-23 , - * /Day of month YES 1-31 , - * ? / L WMonth 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 "weekdays are high priority" calendars "weekday" timer (int:0 1h)when Alarm()then send( "priority high - we have an alarm );end
rule "weekend are low priority" calendars "weekend" timer (int:0 4h)when Alarm()then send( "priority low - we have an alarm );end
Execute now and after
1 hour durationExecute now and after
4 hour duration
TMS and Inference
rule "Issue Child Bus Pass"when $p : Person( age < 16 )then insert(new ChildBusPass( $p ) );endrule "Issue Adult Bus Pass"when $p : Person( age >= 16 )then insert(new AdultBusPass( $p ) );end
Couples the logicWhat 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 ) )endwhen $p : Person( age >= 16 )then logicalInsert( new IsAdult( $p ) )end
de-couples the logicMaintains the truth by
automatically retracting
TMS and Inference
rule "Issue Child Bus Pass"when $p : Person( ) IsChild( person =$p )then logicalInsert(new ChildBusPass( $p ) );endrule "Issue Adult Bus Pass"when $p : Person() IsAdult( person =$p )then logicalInsert(new AdultBusPass( $p ) );end
The truth maintenance cascades
TMS and Inference
rule "Issue Child Bus Pass"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
Backward Chaining
query isChild( Person p ) $p := Person( age