SlideShare a Scribd company logo
1 of 49
Geoffrey De Smet
Pushing the rule engine
to its limits
with Drools Planner
2
Agenda
๎€Š Drools Platform overview
๎€Š Use cases
โ— Bin packaging
โ— What is NP complete?
โ— Employee shift rostering
โ— Hard and soft constraints
โ— Patient admission schedule
โ— How many possible solutions?
๎€Š Algorithms
โ— Meta-heuristics
๎€Š Benchmarking
Drools Platform
Overview
4
Business Logic Integration
Business
Logic
Integration
Platform
Rule
engine
Workflow
Complex event
processing
(CEP)
Business Rule
Management System
(BRMS)
Automated
planning
(jBPM 5)
Use cases
What are planning problems?
6
New office furniture... 1 car
7
Half hour later...
8
Wasted space
9
10
11
12
13
14
Hard constraint implementation
// a nurse can only work one shift per day
rule "oneShiftPerDay"
when
$left : EmployeeAssignment(
$employee : employee,
$shiftDate : shiftDate,
$leftId : id
);
$right : EmployeeAssignment(
employee == $employee,
shiftDate == $shiftDate,
id > $leftId);
then
// Lower the hard score with a weight ...
end
15
16
Soft constraint implementation
rule "dayOffRequest"
when
$dayOffRequest : DayOffRequest(
$employee : employee,
$shiftDate : shiftDate,
$weight : weight
);
$employeeAssignment : EmployeeAssignment(
employee == $employee,
shiftDate == $shiftDate
);
then
// Lower the soft score with the weight $weight ...
end
17
18
Patient admission schedule
Hard constraints
No 2 patients in same bed in same night
Room gender limitation
Department minimum or maximum age
Patient requires specific room equipment(s)
Soft constraints
Patient prefers maximum room size
Department specialization
Room specialization
Patient prefers specific room equipment(s)
19
Needle in a haystack
How many possible solutions?
310 beds
in 105 rooms
in 4 departments
84 nights
2750 patients (admissions)
Numbers from a real dataset
20
Needle in a haystack
How many possible solutions?
310 beds
in 105 rooms
in 4 departments
84 nights
2750 patients (admissions)
> works of art in the Louvre?
35 000 works of art
Source: wikipedia
21
Needle in a haystack
How many possible solutions?
310 beds
in 105 rooms
in 4 departments
84 nights
2750 patients (admissions)
> humans?
7 000 000 000 humans
Source: NASA (wikipedia)
22
Needle in a haystack
How many possible solutions?
310 beds
in 105 rooms
in 4 departments
84 nights
2750 patients (admissions)
> minimum atoms in the
observable universe?
10^80
Source: NASA and ESA (wikipedia)
23
Needle in a haystack
How many possible solutions?
310 beds
in 105 rooms
in 4 departments
84 nights
2750 patients (admissions)
> atoms in the universe
if every atom is a universe
of atoms?
(10^80)^80 = 10^6400
Source: NASA and ESA (wikipedia)
24
Needle in a haystack
How many possible solutions?
310 beds
in 105 rooms
in 4 departments
84 nights
2750 patients (admissions)
A little over 10^6851
25
Do the math
1 patient
310 beds
310 ways to schedule 1 patient
2 patients
310 * 310 = 96 100
3 patients
310 * 310 * 310 = 29 791 000
2750 patients
310 * 310 * ... * 310
310^2750
= a little over 10^6851
26
A little over 10^6851
17565400009613647714189309909847019528176031676612802408947467896773536824694320
25377105894429532838896584732142182052033826938421876324335318655320329177415624
34019697177044291997231955740197313574392215860109009013187756616189881491857442
89903563474940721372704649669447515706252843900344472960295273324597346780837674
88697227533874455473777198677633776549677388281039595554235192833141437843928340
51328923587442242154997922875864744269141114570273352582691671031946927906652177
66902628732489519488236496931246157419949856522543510386164584826962224171420152
25565850232385350464349705325292272792440640617915932702527496869105242581827012
17106705526418375034351087944819610624220027292887379804041858752339124281780095
58605680683578864680145557998942327371019832139824665975180911386722774004539981
34278552385168663637443267160148549642311093017595330858041676796683206809536596
46569395830894437089458443238882278162963824641222099807169369905394994720275907
38400791514217875461942733015467480308665074008529461146577114465977072581447925
88212290682716057000722801705649967418814850790871678616492253646749058716362694
56894529270615321506374546152336416456127910274106084164763806424690851439804640
67453971429400369608313929289399595696359958354101721624055729520838609453039985
59272628937624385694142906376790391997713872443251360270344814604597056658507680
95764769840369232215532708782795742398666571567290512950859701002128560257873450
34666683590797377984104207041334053480226788236770435009014979334517769826461063
28117889455452701285996652060625309878869936718080636701237289582496335799276496
97991233610444564616874109815224930933169104649370892996558804470140748763978122
10684054337706530175130912335567383560436635091489083375525519539844805718811296
85807650768511219249940528633766810704609502399987122465510787717422067936021241
05730014911043812216621387647568988345883813404108921585448372002290085339308167
94663631470201197595487045022087615873490295940409113638894083753062801416644858
27
A little over 10^6851
70757942487218045035508810158461046502812782292385633846174494690914238485407798
37976573852840248463244968564240141089763763217269495446550923090738150172870668
68402081731644263484686141346509306107283418762923467113106773326485539514229919
89751468506508069513397904821612697383659788320905691994864296149528670873271380
18006650770249052559419638332728972636228024127885657959189574420249964658137384
98299648678707389648424263725804209284739296524664530660893065815727451390562561
81505240205578741292314133858985615181677968313683876880079649763914095651402272
04777610845144506688836696844897279181666903094579081039689572524839918882203466
75664835223276850061950801785251074912552450542389767056205475823297598574505575
83834141364747838395082871684183199560673441708538602779816347949276957201268066
62737283137076807355893467941027682428304918329951886951690865417997171855081020
26756284570976172802328890960381286165431282000890478132235199027141966946398442
73986565523012106816309974964021700560537928432528631741787455155275823033005847
63710721074772137206636934675415209083984961138990816735390734923436827652228741
07306375553429574524282669680025732278499336914490634182865013110363140489605282
49465982665132492491072491788618403253474529440348798670244615185355092357283764
93638760707623418191667075526942154653033728468983877312232305317179427144435853
36388068489698718841685828476130163980130066330161405037431756112554842734192914
35502775849577615159921009571496639402549077872124227731739936370100132762333353
47390808021571900433548715701062002052376364885669272869945947160341077659253581
65207459958613365778774312937767961242646970494187951860105460569752264242274554
46011031581123438684685838655333776830823720356749120051129394691394743488410658
61354353779545576065515784960221442891508405618131446589507592449826384604047449
56226545521579338675725427458383708893912437023584592443865610814799055455700844
91443709439642235090455604548030317754849613813010298858282615659336373785985294
28
A little over 10^6851
58667337266411706925088329158776619790296442059252886388879455197093987039774900
08729398961010317200010000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
29
A little over 10^6851
00000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000
The search space is big!
Compare with WWW size
22 020 000 000 pages
Each possible solution
2750 patients scheduled into 310 beds
Still need to calculate the score! => Drools Expert
Algorithms
Operational research is fun.
31
Brute force?
Throw hardware at it?
Calculate 10^9 scores per ms
Impossible today!
31 579 200 000 ms in 1 year
< 10^11 ms in 1 year
10^9 * 10^11 scores per year
= 10^20 scores per year
How many years? 10^6851 / 10^20
= 10^6831 years
CPU 1000 times faster
It becomes 10^6828 years
32
Smarter brute force?
๎€Š Eliminate subtrees
โ— Branch and bound
โ— Still too many for loops
โ— Still takes forever
for (bedOfPatient1 : bedList) {
patient1.setBed(bedOfPatient1);
for (bedOfPatient2 : bedList) {
patient2.setBed(bedOfPatient2);
if (patient1.shareNightWith(patient2)
&& bedOfPatient1.equals(bedOfPatient2)) {
continue;
// bug: best solution might break a hard constraint
}
for (bedOfPatient3 : bedList) {
...
33
2 patients in the same bed
1 patient
0 of 310 (no chance)
2 patients
310 of 96 100
= 1 of 310
3 patients
620 of 29 791 000
= 1 of 48 050
2750 patients
310*2750*2749/2 of 310^2750
< 1 of 310^2740
34
Imperfect algorithms
(mimic a human)
๎€Š Deterministic
โ— First in, first assigned, never changed
โ— Easy to implement
โ— Drools Planner score support
โ— Fixed time (for example 18 seconds)
๎€Š Meta-heuristic
โ— Move things around
โ— Start from result of deterministic algorithm
โ— Drools Planner implementations
โ— More time = better score
35
N Queens: use case
๎€Š Place n queens on a n-sized chess board
๎€Š No 2 queens can attack each other
โ— Score -1 for every 2 queens that can attack each other
Score = -2 Score = 0
36
Move things around
๎€Š Move = from solution A to solution B
โ— Change the row of 1 queen
โ— Give 2 queens each others rows
โ— ...
Score = -6 Score = -4
37
Thank you statefull rule engine!
38
All moves from one solution
๎€Š Number of moves < number of solutions
โ— N queens
โ— n*n < n^n
โ— 4 queens
โ— 16 < 256
โ— 8 queens
โ— 64 < 16777216
โ— 64 queens
โ— 4096 < 10^116
39
Local search 1/2
40
Local search
2/2
๎€Š Search path
โ— Not a tree
41
Local optima
๎€Š 1) Deterministic StartingSolutionInitializer
๎€Š 2) Simple local search
๎€Š 3) Stuck in local optimum!
Source: Wikipedia
Score function
42
Local search++
๎€Š Tabu Search
โ— Solution tabu (high tabu size)
โ— Been there, no need to go there again
โ— Move tabu (low tabu size)
โ— Done that recently, no need to do that again
โ— Property tabu (low tabu size)
โ— Changed that recently,
no need to change that again
๎€Š Simulated annealing
๎€Š Great deluge, late acceptance, โ€ฆ
๎€Š Hyper heuristics
Benchmarker
Measure, don't guess.
44
Benchmarker utility
45
CPU power VS algorithms
more CPU power
better
algorithm
deterministic algorithm
46
Free speed upgrades
from the rule engine
๎€Š Differential update (AKA true modify)
โ— Drools 5.0: update = retract (remove) + assert (insert)
โ— Drools 5.1: real update (released in Q3 2010)
โ— Uses less memory and reduces garbage collector stress
โ— Improves performance
โ— Update is mostly used in statefull environments
Statefull memory drools 5.0
with Drools Planner 5.1
Statefull memory drools 5.1
with Drools Planner 5.1
Summary
48
Summary
๎€Š Drools Planner solves planning problems
๎€Š Adding constraints is easy and scalable
๎€Š Switching/combining algorithms is easy
49
Q & A
Questions?
Useful links
Website
http://www.jboss.org/drools/
Reference manual
http://www.jboss.org/drools/documentation.html
Blog
http://blog.athico.com/
Mailing lists (forum interface through nabble.com)
http://www.jboss.org/drools/lists.html

More Related Content

Viewers also liked

OpenTable Competitive Strategy Analysis
OpenTable Competitive Strategy AnalysisOpenTable Competitive Strategy Analysis
OpenTable Competitive Strategy AnalysisFernando Pernica
ย 
No Reservation? No Problem! OpenTable and Marketing Cloud at Your Service
No Reservation? No Problem! OpenTable and Marketing Cloud at Your ServiceNo Reservation? No Problem! OpenTable and Marketing Cloud at Your Service
No Reservation? No Problem! OpenTable and Marketing Cloud at Your ServiceSalesforce Marketing Cloud
ย 
Class diagram railway reservation system
Class diagram railway reservation systemClass diagram railway reservation system
Class diagram railway reservation systemmuthumeenakshim
ย 
Activity diagram railway reservation system
Activity diagram railway reservation systemActivity diagram railway reservation system
Activity diagram railway reservation systemmuthumeenakshim
ย 
Usecase diagram railway reservation system
Usecase diagram railway reservation systemUsecase diagram railway reservation system
Usecase diagram railway reservation systemmuthumeenakshim
ย 
Data processing platforms architectures with Spark, Mesos, Akka, Cassandra an...
Data processing platforms architectures with Spark, Mesos, Akka, Cassandra an...Data processing platforms architectures with Spark, Mesos, Akka, Cassandra an...
Data processing platforms architectures with Spark, Mesos, Akka, Cassandra an...Anton Kirillov
ย 
Air ticket reservation system presentation
Air ticket reservation system presentation Air ticket reservation system presentation
Air ticket reservation system presentation Smit Patel
ย 
Lambert Roadef2007 Slides
Lambert Roadef2007 SlidesLambert Roadef2007 Slides
Lambert Roadef2007 Slideslamberttony
ย 
State diagram railway reservation system
State diagram railway reservation systemState diagram railway reservation system
State diagram railway reservation systemmuthumeenakshim
ย 
Hotel Reservation System Project
Hotel Reservation System ProjectHotel Reservation System Project
Hotel Reservation System Projectraj_qn3
ย 
The slide deck we used to raise half a million dollars
The slide deck we used to raise half a million dollarsThe slide deck we used to raise half a million dollars
The slide deck we used to raise half a million dollarsBuffer
ย 
SEOmoz Pitch Deck July 2011
SEOmoz Pitch Deck July 2011SEOmoz Pitch Deck July 2011
SEOmoz Pitch Deck July 2011Rand Fishkin
ย 

Viewers also liked (14)

OpenTable Competitive Strategy Analysis
OpenTable Competitive Strategy AnalysisOpenTable Competitive Strategy Analysis
OpenTable Competitive Strategy Analysis
ย 
No Reservation? No Problem! OpenTable and Marketing Cloud at Your Service
No Reservation? No Problem! OpenTable and Marketing Cloud at Your ServiceNo Reservation? No Problem! OpenTable and Marketing Cloud at Your Service
No Reservation? No Problem! OpenTable and Marketing Cloud at Your Service
ย 
Open table pdf
Open table pdfOpen table pdf
Open table pdf
ย 
Class diagram railway reservation system
Class diagram railway reservation systemClass diagram railway reservation system
Class diagram railway reservation system
ย 
Activity diagram railway reservation system
Activity diagram railway reservation systemActivity diagram railway reservation system
Activity diagram railway reservation system
ย 
Usecase diagram railway reservation system
Usecase diagram railway reservation systemUsecase diagram railway reservation system
Usecase diagram railway reservation system
ย 
Data processing platforms architectures with Spark, Mesos, Akka, Cassandra an...
Data processing platforms architectures with Spark, Mesos, Akka, Cassandra an...Data processing platforms architectures with Spark, Mesos, Akka, Cassandra an...
Data processing platforms architectures with Spark, Mesos, Akka, Cassandra an...
ย 
Air ticket reservation system presentation
Air ticket reservation system presentation Air ticket reservation system presentation
Air ticket reservation system presentation
ย 
Lambert Roadef2007 Slides
Lambert Roadef2007 SlidesLambert Roadef2007 Slides
Lambert Roadef2007 Slides
ย 
State diagram railway reservation system
State diagram railway reservation systemState diagram railway reservation system
State diagram railway reservation system
ย 
Operational reseach ppt
Operational reseach pptOperational reseach ppt
Operational reseach ppt
ย 
Hotel Reservation System Project
Hotel Reservation System ProjectHotel Reservation System Project
Hotel Reservation System Project
ย 
The slide deck we used to raise half a million dollars
The slide deck we used to raise half a million dollarsThe slide deck we used to raise half a million dollars
The slide deck we used to raise half a million dollars
ย 
SEOmoz Pitch Deck July 2011
SEOmoz Pitch Deck July 2011SEOmoz Pitch Deck July 2011
SEOmoz Pitch Deck July 2011
ย 

Similar to Pushing the rule engine to its limits with drools planner (parisjug 2010-11-09)

Drools Planner webinar (2011-06-15): Drools Planner optimizes automated planning
Drools Planner webinar (2011-06-15): Drools Planner optimizes automated planningDrools Planner webinar (2011-06-15): Drools Planner optimizes automated planning
Drools Planner webinar (2011-06-15): Drools Planner optimizes automated planningGeoffrey De Smet
ย 
2010 04-20 san diego bootcamp - drools planner - use cases
2010 04-20 san diego bootcamp - drools planner - use cases2010 04-20 san diego bootcamp - drools planner - use cases
2010 04-20 san diego bootcamp - drools planner - use casesGeoffrey De Smet
ย 
2011-03-09 London - Drools Planner in a nutshell
2011-03-09 London - Drools Planner in a nutshell2011-03-09 London - Drools Planner in a nutshell
2011-03-09 London - Drools Planner in a nutshellGeoffrey De Smet
ย 
Drools Planner Chtijug 2010
Drools Planner Chtijug 2010Drools Planner Chtijug 2010
Drools Planner Chtijug 2010Nicolas Heron
ย 
Introduction to Optimization revised.ppt
Introduction to Optimization revised.pptIntroduction to Optimization revised.ppt
Introduction to Optimization revised.pptJahnaviGautam
ย 
Slight change of plans!
Slight change of plans!Slight change of plans!
Slight change of plans!Miel Vander Sande
ย 
Lecture 2
Lecture 2Lecture 2
Lecture 2chandsek666
ย 
End of Sprint 5
End of Sprint 5End of Sprint 5
End of Sprint 5dm_work
ย 
EOS5 Demo
EOS5 DemoEOS5 Demo
EOS5 Demodm_work
ย 
VRP2013 - Comp Aspects VRP
VRP2013 - Comp Aspects VRPVRP2013 - Comp Aspects VRP
VRP2013 - Comp Aspects VRPVictor Pillac
ย 
Learning by Redundancy: how climate multi-model ensembles can help to fight t...
Learning by Redundancy: how climate multi-model ensembles can help to fight t...Learning by Redundancy: how climate multi-model ensembles can help to fight t...
Learning by Redundancy: how climate multi-model ensembles can help to fight t...matteodefelice
ย 
SLE2015: Distributed ATL
SLE2015: Distributed ATLSLE2015: Distributed ATL
SLE2015: Distributed ATLAmine Benelallam
ย 
2014.10.dartmouth
2014.10.dartmouth2014.10.dartmouth
2014.10.dartmouthQiqi Wang
ย 
Monte Carlo on a Blackpool Budget
Monte Carlo on a Blackpool BudgetMonte Carlo on a Blackpool Budget
Monte Carlo on a Blackpool BudgetPaul Briรซrley
ย 
Tutorial: Formal Methods for Hardware Verification - Overview and Application...
Tutorial: Formal Methods for Hardware Verification - Overview and Application...Tutorial: Formal Methods for Hardware Verification - Overview and Application...
Tutorial: Formal Methods for Hardware Verification - Overview and Application...Peter Breuer
ย 
Lecture04 computer applicationsie1_dratifshahzad
Lecture04 computer applicationsie1_dratifshahzadLecture04 computer applicationsie1_dratifshahzad
Lecture04 computer applicationsie1_dratifshahzadAtif Shahzad
ย 
Mining Version Histories to Guide Software Changes
Mining Version Histories to Guide Software ChangesMining Version Histories to Guide Software Changes
Mining Version Histories to Guide Software ChangesThomas Zimmermann
ย 
Modeling and Reasoning in Event Calculus using Goal-Directed Constraint Answe...
Modeling and Reasoning in Event Calculus using Goal-Directed Constraint Answe...Modeling and Reasoning in Event Calculus using Goal-Directed Constraint Answe...
Modeling and Reasoning in Event Calculus using Goal-Directed Constraint Answe...Universidad Rey Juan Carlos
ย 

Similar to Pushing the rule engine to its limits with drools planner (parisjug 2010-11-09) (20)

Drools Planner webinar (2011-06-15): Drools Planner optimizes automated planning
Drools Planner webinar (2011-06-15): Drools Planner optimizes automated planningDrools Planner webinar (2011-06-15): Drools Planner optimizes automated planning
Drools Planner webinar (2011-06-15): Drools Planner optimizes automated planning
ย 
2010 04-20 san diego bootcamp - drools planner - use cases
2010 04-20 san diego bootcamp - drools planner - use cases2010 04-20 san diego bootcamp - drools planner - use cases
2010 04-20 san diego bootcamp - drools planner - use cases
ย 
2011-03-09 London - Drools Planner in a nutshell
2011-03-09 London - Drools Planner in a nutshell2011-03-09 London - Drools Planner in a nutshell
2011-03-09 London - Drools Planner in a nutshell
ย 
Drools Planner Chtijug 2010
Drools Planner Chtijug 2010Drools Planner Chtijug 2010
Drools Planner Chtijug 2010
ย 
Introduction to Optimization revised.ppt
Introduction to Optimization revised.pptIntroduction to Optimization revised.ppt
Introduction to Optimization revised.ppt
ย 
Blinkdb
BlinkdbBlinkdb
Blinkdb
ย 
Slight change of plans!
Slight change of plans!Slight change of plans!
Slight change of plans!
ย 
Lecture 2
Lecture 2Lecture 2
Lecture 2
ย 
End of Sprint 5
End of Sprint 5End of Sprint 5
End of Sprint 5
ย 
EOS5 Demo
EOS5 DemoEOS5 Demo
EOS5 Demo
ย 
VRP2013 - Comp Aspects VRP
VRP2013 - Comp Aspects VRPVRP2013 - Comp Aspects VRP
VRP2013 - Comp Aspects VRP
ย 
Learning by Redundancy: how climate multi-model ensembles can help to fight t...
Learning by Redundancy: how climate multi-model ensembles can help to fight t...Learning by Redundancy: how climate multi-model ensembles can help to fight t...
Learning by Redundancy: how climate multi-model ensembles can help to fight t...
ย 
SLE2015: Distributed ATL
SLE2015: Distributed ATLSLE2015: Distributed ATL
SLE2015: Distributed ATL
ย 
Data science
Data scienceData science
Data science
ย 
2014.10.dartmouth
2014.10.dartmouth2014.10.dartmouth
2014.10.dartmouth
ย 
Monte Carlo on a Blackpool Budget
Monte Carlo on a Blackpool BudgetMonte Carlo on a Blackpool Budget
Monte Carlo on a Blackpool Budget
ย 
Tutorial: Formal Methods for Hardware Verification - Overview and Application...
Tutorial: Formal Methods for Hardware Verification - Overview and Application...Tutorial: Formal Methods for Hardware Verification - Overview and Application...
Tutorial: Formal Methods for Hardware Verification - Overview and Application...
ย 
Lecture04 computer applicationsie1_dratifshahzad
Lecture04 computer applicationsie1_dratifshahzadLecture04 computer applicationsie1_dratifshahzad
Lecture04 computer applicationsie1_dratifshahzad
ย 
Mining Version Histories to Guide Software Changes
Mining Version Histories to Guide Software ChangesMining Version Histories to Guide Software Changes
Mining Version Histories to Guide Software Changes
ย 
Modeling and Reasoning in Event Calculus using Goal-Directed Constraint Answe...
Modeling and Reasoning in Event Calculus using Goal-Directed Constraint Answe...Modeling and Reasoning in Event Calculus using Goal-Directed Constraint Answe...
Modeling and Reasoning in Event Calculus using Goal-Directed Constraint Answe...
ย 

More from Geoffrey De Smet

Drools planner - 2012-10-23 IntelliFest 2012
Drools planner - 2012-10-23 IntelliFest 2012Drools planner - 2012-10-23 IntelliFest 2012
Drools planner - 2012-10-23 IntelliFest 2012Geoffrey De Smet
ย 
What is Drools, Guvnor and Planner? 2012 02-17 Brno Dev Conference
What is Drools, Guvnor and Planner? 2012 02-17 Brno Dev ConferenceWhat is Drools, Guvnor and Planner? 2012 02-17 Brno Dev Conference
What is Drools, Guvnor and Planner? 2012 02-17 Brno Dev ConferenceGeoffrey De Smet
ย 
2012 02-04 fosdem 2012 - drools planner
2012 02-04 fosdem 2012 - drools planner2012 02-04 fosdem 2012 - drools planner
2012 02-04 fosdem 2012 - drools plannerGeoffrey De Smet
ย 
JUDCon London 2011 - Bin packing with drools planner by example
JUDCon London 2011 - Bin packing with drools planner by exampleJUDCon London 2011 - Bin packing with drools planner by example
JUDCon London 2011 - Bin packing with drools planner by exampleGeoffrey De Smet
ย 
Applying CEP Drools Fusion - Drools jBPM Bootcamps 2011
Applying CEP Drools Fusion - Drools jBPM Bootcamps 2011Applying CEP Drools Fusion - Drools jBPM Bootcamps 2011
Applying CEP Drools Fusion - Drools jBPM Bootcamps 2011Geoffrey De Smet
ย 
Drools New York City workshop 2011
Drools New York City workshop 2011Drools New York City workshop 2011
Drools New York City workshop 2011Geoffrey De Smet
ย 
JBoss World 2011 - Drools
JBoss World 2011 - DroolsJBoss World 2011 - Drools
JBoss World 2011 - DroolsGeoffrey De Smet
ย 
2011-03-29 London - drools
2011-03-29 London - drools2011-03-29 London - drools
2011-03-29 London - droolsGeoffrey De Smet
ย 
2011-03-29 London - Decision tables in depth (Michael Anstis)
2011-03-29 London - Decision tables in depth (Michael Anstis)2011-03-29 London - Decision tables in depth (Michael Anstis)
2011-03-29 London - Decision tables in depth (Michael Anstis)Geoffrey De Smet
ย 
2011-03-29 London - Why do I need the guvnor BRMS?
2011-03-29 London - Why do I need the guvnor BRMS?2011-03-29 London - Why do I need the guvnor BRMS?
2011-03-29 London - Why do I need the guvnor BRMS?Geoffrey De Smet
ย 
2011-03-24 IDC - Adaptive and flexible processes (Mark Proctor)
2011-03-24 IDC - Adaptive and flexible processes (Mark Proctor)2011-03-24 IDC - Adaptive and flexible processes (Mark Proctor)
2011-03-24 IDC - Adaptive and flexible processes (Mark Proctor)Geoffrey De Smet
ย 
Open source and business rules
Open source and business rulesOpen source and business rules
Open source and business rulesGeoffrey De Smet
ย 
Drooling for drools (JBoss webex)
Drooling for drools (JBoss webex)Drooling for drools (JBoss webex)
Drooling for drools (JBoss webex)Geoffrey De Smet
ย 
Developing applications with rules, workflow and event processing (it@cork 2010)
Developing applications with rules, workflow and event processing (it@cork 2010)Developing applications with rules, workflow and event processing (it@cork 2010)
Developing applications with rules, workflow and event processing (it@cork 2010)Geoffrey De Smet
ย 
Hybrid rule engines (rulesfest 2010)
Hybrid rule engines (rulesfest 2010)Hybrid rule engines (rulesfest 2010)
Hybrid rule engines (rulesfest 2010)Geoffrey De Smet
ย 
st - demystifying complext event processing
st - demystifying complext event processingst - demystifying complext event processing
st - demystifying complext event processingGeoffrey De Smet
ย 
jBPM 5 (JUDCon 2010-10-08)
jBPM 5 (JUDCon 2010-10-08)jBPM 5 (JUDCon 2010-10-08)
jBPM 5 (JUDCon 2010-10-08)Geoffrey De Smet
ย 
Applying complex event processing (2010-10-11)
Applying complex event processing (2010-10-11)Applying complex event processing (2010-10-11)
Applying complex event processing (2010-10-11)Geoffrey De Smet
ย 
Towards unified knowledge management platform (rulefest 2010)
Towards unified knowledge management platform (rulefest 2010)Towards unified knowledge management platform (rulefest 2010)
Towards unified knowledge management platform (rulefest 2010)Geoffrey De Smet
ย 
Drools BeJUG 2010
Drools BeJUG 2010Drools BeJUG 2010
Drools BeJUG 2010Geoffrey De Smet
ย 

More from Geoffrey De Smet (20)

Drools planner - 2012-10-23 IntelliFest 2012
Drools planner - 2012-10-23 IntelliFest 2012Drools planner - 2012-10-23 IntelliFest 2012
Drools planner - 2012-10-23 IntelliFest 2012
ย 
What is Drools, Guvnor and Planner? 2012 02-17 Brno Dev Conference
What is Drools, Guvnor and Planner? 2012 02-17 Brno Dev ConferenceWhat is Drools, Guvnor and Planner? 2012 02-17 Brno Dev Conference
What is Drools, Guvnor and Planner? 2012 02-17 Brno Dev Conference
ย 
2012 02-04 fosdem 2012 - drools planner
2012 02-04 fosdem 2012 - drools planner2012 02-04 fosdem 2012 - drools planner
2012 02-04 fosdem 2012 - drools planner
ย 
JUDCon London 2011 - Bin packing with drools planner by example
JUDCon London 2011 - Bin packing with drools planner by exampleJUDCon London 2011 - Bin packing with drools planner by example
JUDCon London 2011 - Bin packing with drools planner by example
ย 
Applying CEP Drools Fusion - Drools jBPM Bootcamps 2011
Applying CEP Drools Fusion - Drools jBPM Bootcamps 2011Applying CEP Drools Fusion - Drools jBPM Bootcamps 2011
Applying CEP Drools Fusion - Drools jBPM Bootcamps 2011
ย 
Drools New York City workshop 2011
Drools New York City workshop 2011Drools New York City workshop 2011
Drools New York City workshop 2011
ย 
JBoss World 2011 - Drools
JBoss World 2011 - DroolsJBoss World 2011 - Drools
JBoss World 2011 - Drools
ย 
2011-03-29 London - drools
2011-03-29 London - drools2011-03-29 London - drools
2011-03-29 London - drools
ย 
2011-03-29 London - Decision tables in depth (Michael Anstis)
2011-03-29 London - Decision tables in depth (Michael Anstis)2011-03-29 London - Decision tables in depth (Michael Anstis)
2011-03-29 London - Decision tables in depth (Michael Anstis)
ย 
2011-03-29 London - Why do I need the guvnor BRMS?
2011-03-29 London - Why do I need the guvnor BRMS?2011-03-29 London - Why do I need the guvnor BRMS?
2011-03-29 London - Why do I need the guvnor BRMS?
ย 
2011-03-24 IDC - Adaptive and flexible processes (Mark Proctor)
2011-03-24 IDC - Adaptive and flexible processes (Mark Proctor)2011-03-24 IDC - Adaptive and flexible processes (Mark Proctor)
2011-03-24 IDC - Adaptive and flexible processes (Mark Proctor)
ย 
Open source and business rules
Open source and business rulesOpen source and business rules
Open source and business rules
ย 
Drooling for drools (JBoss webex)
Drooling for drools (JBoss webex)Drooling for drools (JBoss webex)
Drooling for drools (JBoss webex)
ย 
Developing applications with rules, workflow and event processing (it@cork 2010)
Developing applications with rules, workflow and event processing (it@cork 2010)Developing applications with rules, workflow and event processing (it@cork 2010)
Developing applications with rules, workflow and event processing (it@cork 2010)
ย 
Hybrid rule engines (rulesfest 2010)
Hybrid rule engines (rulesfest 2010)Hybrid rule engines (rulesfest 2010)
Hybrid rule engines (rulesfest 2010)
ย 
st - demystifying complext event processing
st - demystifying complext event processingst - demystifying complext event processing
st - demystifying complext event processing
ย 
jBPM 5 (JUDCon 2010-10-08)
jBPM 5 (JUDCon 2010-10-08)jBPM 5 (JUDCon 2010-10-08)
jBPM 5 (JUDCon 2010-10-08)
ย 
Applying complex event processing (2010-10-11)
Applying complex event processing (2010-10-11)Applying complex event processing (2010-10-11)
Applying complex event processing (2010-10-11)
ย 
Towards unified knowledge management platform (rulefest 2010)
Towards unified knowledge management platform (rulefest 2010)Towards unified knowledge management platform (rulefest 2010)
Towards unified knowledge management platform (rulefest 2010)
ย 
Drools BeJUG 2010
Drools BeJUG 2010Drools BeJUG 2010
Drools BeJUG 2010
ย 

Recently uploaded

Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
ย 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
ย 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
ย 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
ย 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
ย 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
ย 
Transcript: #StandardsGoals for 2024: Whatโ€™s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: Whatโ€™s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: Whatโ€™s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: Whatโ€™s new for BISAC - Tech Forum 2024BookNet Canada
ย 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
ย 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
ย 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service ๐Ÿธ 8923113531 ๐ŸŽฐ Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service ๐Ÿธ 8923113531 ๐ŸŽฐ Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service ๐Ÿธ 8923113531 ๐ŸŽฐ Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service ๐Ÿธ 8923113531 ๐ŸŽฐ Avail...gurkirankumar98700
ย 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
ย 
Swan(sea) Song โ€“ personal research during my six years at Swansea ... and bey...
Swan(sea) Song โ€“ personal research during my six years at Swansea ... and bey...Swan(sea) Song โ€“ personal research during my six years at Swansea ... and bey...
Swan(sea) Song โ€“ personal research during my six years at Swansea ... and bey...Alan Dix
ย 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
ย 
๐Ÿฌ The future of MySQL is Postgres ๐Ÿ˜
๐Ÿฌ  The future of MySQL is Postgres   ๐Ÿ˜๐Ÿฌ  The future of MySQL is Postgres   ๐Ÿ˜
๐Ÿฌ The future of MySQL is Postgres ๐Ÿ˜RTylerCroy
ย 
WhatsApp 9892124323 โœ“Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 โœ“Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 โœ“Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 โœ“Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
ย 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
ย 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
ย 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
ย 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
ย 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
ย 

Recently uploaded (20)

Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
ย 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
ย 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
ย 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
ย 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
ย 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
ย 
Transcript: #StandardsGoals for 2024: Whatโ€™s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: Whatโ€™s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: Whatโ€™s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: Whatโ€™s new for BISAC - Tech Forum 2024
ย 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
ย 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
ย 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service ๐Ÿธ 8923113531 ๐ŸŽฐ Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service ๐Ÿธ 8923113531 ๐ŸŽฐ Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service ๐Ÿธ 8923113531 ๐ŸŽฐ Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service ๐Ÿธ 8923113531 ๐ŸŽฐ Avail...
ย 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
ย 
Swan(sea) Song โ€“ personal research during my six years at Swansea ... and bey...
Swan(sea) Song โ€“ personal research during my six years at Swansea ... and bey...Swan(sea) Song โ€“ personal research during my six years at Swansea ... and bey...
Swan(sea) Song โ€“ personal research during my six years at Swansea ... and bey...
ย 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
ย 
๐Ÿฌ The future of MySQL is Postgres ๐Ÿ˜
๐Ÿฌ  The future of MySQL is Postgres   ๐Ÿ˜๐Ÿฌ  The future of MySQL is Postgres   ๐Ÿ˜
๐Ÿฌ The future of MySQL is Postgres ๐Ÿ˜
ย 
WhatsApp 9892124323 โœ“Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 โœ“Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 โœ“Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 โœ“Call Girls In Kalyan ( Mumbai ) secure service
ย 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
ย 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
ย 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
ย 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
ย 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
ย 

Pushing the rule engine to its limits with drools planner (parisjug 2010-11-09)

  • 1. Geoffrey De Smet Pushing the rule engine to its limits with Drools Planner
  • 2. 2 Agenda ๎€Š Drools Platform overview ๎€Š Use cases โ— Bin packaging โ— What is NP complete? โ— Employee shift rostering โ— Hard and soft constraints โ— Patient admission schedule โ— How many possible solutions? ๎€Š Algorithms โ— Meta-heuristics ๎€Š Benchmarking
  • 4. 4 Business Logic Integration Business Logic Integration Platform Rule engine Workflow Complex event processing (CEP) Business Rule Management System (BRMS) Automated planning (jBPM 5)
  • 5. Use cases What are planning problems?
  • 9. 9
  • 10. 10
  • 11. 11
  • 12. 12
  • 13. 13
  • 14. 14 Hard constraint implementation // a nurse can only work one shift per day rule "oneShiftPerDay" when $left : EmployeeAssignment( $employee : employee, $shiftDate : shiftDate, $leftId : id ); $right : EmployeeAssignment( employee == $employee, shiftDate == $shiftDate, id > $leftId); then // Lower the hard score with a weight ... end
  • 15. 15
  • 16. 16 Soft constraint implementation rule "dayOffRequest" when $dayOffRequest : DayOffRequest( $employee : employee, $shiftDate : shiftDate, $weight : weight ); $employeeAssignment : EmployeeAssignment( employee == $employee, shiftDate == $shiftDate ); then // Lower the soft score with the weight $weight ... end
  • 17. 17
  • 18. 18 Patient admission schedule Hard constraints No 2 patients in same bed in same night Room gender limitation Department minimum or maximum age Patient requires specific room equipment(s) Soft constraints Patient prefers maximum room size Department specialization Room specialization Patient prefers specific room equipment(s)
  • 19. 19 Needle in a haystack How many possible solutions? 310 beds in 105 rooms in 4 departments 84 nights 2750 patients (admissions) Numbers from a real dataset
  • 20. 20 Needle in a haystack How many possible solutions? 310 beds in 105 rooms in 4 departments 84 nights 2750 patients (admissions) > works of art in the Louvre? 35 000 works of art Source: wikipedia
  • 21. 21 Needle in a haystack How many possible solutions? 310 beds in 105 rooms in 4 departments 84 nights 2750 patients (admissions) > humans? 7 000 000 000 humans Source: NASA (wikipedia)
  • 22. 22 Needle in a haystack How many possible solutions? 310 beds in 105 rooms in 4 departments 84 nights 2750 patients (admissions) > minimum atoms in the observable universe? 10^80 Source: NASA and ESA (wikipedia)
  • 23. 23 Needle in a haystack How many possible solutions? 310 beds in 105 rooms in 4 departments 84 nights 2750 patients (admissions) > atoms in the universe if every atom is a universe of atoms? (10^80)^80 = 10^6400 Source: NASA and ESA (wikipedia)
  • 24. 24 Needle in a haystack How many possible solutions? 310 beds in 105 rooms in 4 departments 84 nights 2750 patients (admissions) A little over 10^6851
  • 25. 25 Do the math 1 patient 310 beds 310 ways to schedule 1 patient 2 patients 310 * 310 = 96 100 3 patients 310 * 310 * 310 = 29 791 000 2750 patients 310 * 310 * ... * 310 310^2750 = a little over 10^6851
  • 26. 26 A little over 10^6851 17565400009613647714189309909847019528176031676612802408947467896773536824694320 25377105894429532838896584732142182052033826938421876324335318655320329177415624 34019697177044291997231955740197313574392215860109009013187756616189881491857442 89903563474940721372704649669447515706252843900344472960295273324597346780837674 88697227533874455473777198677633776549677388281039595554235192833141437843928340 51328923587442242154997922875864744269141114570273352582691671031946927906652177 66902628732489519488236496931246157419949856522543510386164584826962224171420152 25565850232385350464349705325292272792440640617915932702527496869105242581827012 17106705526418375034351087944819610624220027292887379804041858752339124281780095 58605680683578864680145557998942327371019832139824665975180911386722774004539981 34278552385168663637443267160148549642311093017595330858041676796683206809536596 46569395830894437089458443238882278162963824641222099807169369905394994720275907 38400791514217875461942733015467480308665074008529461146577114465977072581447925 88212290682716057000722801705649967418814850790871678616492253646749058716362694 56894529270615321506374546152336416456127910274106084164763806424690851439804640 67453971429400369608313929289399595696359958354101721624055729520838609453039985 59272628937624385694142906376790391997713872443251360270344814604597056658507680 95764769840369232215532708782795742398666571567290512950859701002128560257873450 34666683590797377984104207041334053480226788236770435009014979334517769826461063 28117889455452701285996652060625309878869936718080636701237289582496335799276496 97991233610444564616874109815224930933169104649370892996558804470140748763978122 10684054337706530175130912335567383560436635091489083375525519539844805718811296 85807650768511219249940528633766810704609502399987122465510787717422067936021241 05730014911043812216621387647568988345883813404108921585448372002290085339308167 94663631470201197595487045022087615873490295940409113638894083753062801416644858
  • 27. 27 A little over 10^6851 70757942487218045035508810158461046502812782292385633846174494690914238485407798 37976573852840248463244968564240141089763763217269495446550923090738150172870668 68402081731644263484686141346509306107283418762923467113106773326485539514229919 89751468506508069513397904821612697383659788320905691994864296149528670873271380 18006650770249052559419638332728972636228024127885657959189574420249964658137384 98299648678707389648424263725804209284739296524664530660893065815727451390562561 81505240205578741292314133858985615181677968313683876880079649763914095651402272 04777610845144506688836696844897279181666903094579081039689572524839918882203466 75664835223276850061950801785251074912552450542389767056205475823297598574505575 83834141364747838395082871684183199560673441708538602779816347949276957201268066 62737283137076807355893467941027682428304918329951886951690865417997171855081020 26756284570976172802328890960381286165431282000890478132235199027141966946398442 73986565523012106816309974964021700560537928432528631741787455155275823033005847 63710721074772137206636934675415209083984961138990816735390734923436827652228741 07306375553429574524282669680025732278499336914490634182865013110363140489605282 49465982665132492491072491788618403253474529440348798670244615185355092357283764 93638760707623418191667075526942154653033728468983877312232305317179427144435853 36388068489698718841685828476130163980130066330161405037431756112554842734192914 35502775849577615159921009571496639402549077872124227731739936370100132762333353 47390808021571900433548715701062002052376364885669272869945947160341077659253581 65207459958613365778774312937767961242646970494187951860105460569752264242274554 46011031581123438684685838655333776830823720356749120051129394691394743488410658 61354353779545576065515784960221442891508405618131446589507592449826384604047449 56226545521579338675725427458383708893912437023584592443865610814799055455700844 91443709439642235090455604548030317754849613813010298858282615659336373785985294
  • 28. 28 A little over 10^6851 58667337266411706925088329158776619790296442059252886388879455197093987039774900 08729398961010317200010000000000000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000000000000000000000000000000000
  • 29. 29 A little over 10^6851 00000000000000000000000000000000000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000 The search space is big! Compare with WWW size 22 020 000 000 pages Each possible solution 2750 patients scheduled into 310 beds Still need to calculate the score! => Drools Expert
  • 31. 31 Brute force? Throw hardware at it? Calculate 10^9 scores per ms Impossible today! 31 579 200 000 ms in 1 year < 10^11 ms in 1 year 10^9 * 10^11 scores per year = 10^20 scores per year How many years? 10^6851 / 10^20 = 10^6831 years CPU 1000 times faster It becomes 10^6828 years
  • 32. 32 Smarter brute force? ๎€Š Eliminate subtrees โ— Branch and bound โ— Still too many for loops โ— Still takes forever for (bedOfPatient1 : bedList) { patient1.setBed(bedOfPatient1); for (bedOfPatient2 : bedList) { patient2.setBed(bedOfPatient2); if (patient1.shareNightWith(patient2) && bedOfPatient1.equals(bedOfPatient2)) { continue; // bug: best solution might break a hard constraint } for (bedOfPatient3 : bedList) { ...
  • 33. 33 2 patients in the same bed 1 patient 0 of 310 (no chance) 2 patients 310 of 96 100 = 1 of 310 3 patients 620 of 29 791 000 = 1 of 48 050 2750 patients 310*2750*2749/2 of 310^2750 < 1 of 310^2740
  • 34. 34 Imperfect algorithms (mimic a human) ๎€Š Deterministic โ— First in, first assigned, never changed โ— Easy to implement โ— Drools Planner score support โ— Fixed time (for example 18 seconds) ๎€Š Meta-heuristic โ— Move things around โ— Start from result of deterministic algorithm โ— Drools Planner implementations โ— More time = better score
  • 35. 35 N Queens: use case ๎€Š Place n queens on a n-sized chess board ๎€Š No 2 queens can attack each other โ— Score -1 for every 2 queens that can attack each other Score = -2 Score = 0
  • 36. 36 Move things around ๎€Š Move = from solution A to solution B โ— Change the row of 1 queen โ— Give 2 queens each others rows โ— ... Score = -6 Score = -4
  • 37. 37 Thank you statefull rule engine!
  • 38. 38 All moves from one solution ๎€Š Number of moves < number of solutions โ— N queens โ— n*n < n^n โ— 4 queens โ— 16 < 256 โ— 8 queens โ— 64 < 16777216 โ— 64 queens โ— 4096 < 10^116
  • 40. 40 Local search 2/2 ๎€Š Search path โ— Not a tree
  • 41. 41 Local optima ๎€Š 1) Deterministic StartingSolutionInitializer ๎€Š 2) Simple local search ๎€Š 3) Stuck in local optimum! Source: Wikipedia Score function
  • 42. 42 Local search++ ๎€Š Tabu Search โ— Solution tabu (high tabu size) โ— Been there, no need to go there again โ— Move tabu (low tabu size) โ— Done that recently, no need to do that again โ— Property tabu (low tabu size) โ— Changed that recently, no need to change that again ๎€Š Simulated annealing ๎€Š Great deluge, late acceptance, โ€ฆ ๎€Š Hyper heuristics
  • 45. 45 CPU power VS algorithms more CPU power better algorithm deterministic algorithm
  • 46. 46 Free speed upgrades from the rule engine ๎€Š Differential update (AKA true modify) โ— Drools 5.0: update = retract (remove) + assert (insert) โ— Drools 5.1: real update (released in Q3 2010) โ— Uses less memory and reduces garbage collector stress โ— Improves performance โ— Update is mostly used in statefull environments Statefull memory drools 5.0 with Drools Planner 5.1 Statefull memory drools 5.1 with Drools Planner 5.1
  • 48. 48 Summary ๎€Š Drools Planner solves planning problems ๎€Š Adding constraints is easy and scalable ๎€Š Switching/combining algorithms is easy
  • 49. 49 Q & A Questions? Useful links Website http://www.jboss.org/drools/ Reference manual http://www.jboss.org/drools/documentation.html Blog http://blog.athico.com/ Mailing lists (forum interface through nabble.com) http://www.jboss.org/drools/lists.html