drools planner chtijug 2010
TRANSCRIPT
![Page 1: Drools Planner Chtijug 2010](https://reader031.vdocuments.mx/reader031/viewer/2022013118/555c261bd8b42a09438b4c9b/html5/thumbnails/1.jpg)
Ch’ti JUGCh’ti JUG
Jboss Drools&
Drools Planner
21 janvier 2010
![Page 2: Drools Planner Chtijug 2010](https://reader031.vdocuments.mx/reader031/viewer/2022013118/555c261bd8b42a09438b4c9b/html5/thumbnails/2.jpg)
Ch’ti JUGCh’ti JUG
![Page 3: Drools Planner Chtijug 2010](https://reader031.vdocuments.mx/reader031/viewer/2022013118/555c261bd8b42a09438b4c9b/html5/thumbnails/3.jpg)
Ch’ti JUGCh’ti JUG ● Editeur de logiciels exclusivement dédiés aux enseignes du Retail
● Création en 1986
● 35 M€ de CA en 2008 (+20 %/an en moyenne depuis 5 ans)
● 34 % à l’International
● 5 sites en France dont le siège à Roubaix. (Paris, Belfort,
Antibes, Vannes)
● 5 filiales hors hexagone : Shanghai, Portugal, Espagne, Tunisie, Pologne en cours
● Une expérience éprouvée dans 60 pays
![Page 4: Drools Planner Chtijug 2010](https://reader031.vdocuments.mx/reader031/viewer/2022013118/555c261bd8b42a09438b4c9b/html5/thumbnails/4.jpg)
Ch’ti JUGCh’ti JUG
44
Effectifs : 430 collaborateurs dans le monde, 360 en France, 300 ressources basées à Roubaix
0
10
20
30
40
50
60
70
80
90
100
Effectifs
Experts Metiers
Directeur de Projet
Chef de Projet Métier
Chef de ProjetTechniques
Formateur et @learning
Directeurs de Produits
Développeurs
Recette et Qualification
Hot Line
Préparateurs etdéploiements
![Page 5: Drools Planner Chtijug 2010](https://reader031.vdocuments.mx/reader031/viewer/2022013118/555c261bd8b42a09438b4c9b/html5/thumbnails/5.jpg)
Ch’ti JUGCh’ti JUG Storeland pilote l’ensemble de votre supply chain étendue
![Page 6: Drools Planner Chtijug 2010](https://reader031.vdocuments.mx/reader031/viewer/2022013118/555c261bd8b42a09438b4c9b/html5/thumbnails/6.jpg)
Ch’ti JUGCh’ti JUG
Cylande a accompagné l’équipe de France
de Judo à Pékin
Le judo véhicule des valeurs
CYLANDE partenaire de la FFJ
![Page 7: Drools Planner Chtijug 2010](https://reader031.vdocuments.mx/reader031/viewer/2022013118/555c261bd8b42a09438b4c9b/html5/thumbnails/7.jpg)
Ch’ti JUGCh’ti JUG
Lauréat du Prix PME France CHINE ACFCI / CCIFC Une croissance résolument tournée vers l’international
![Page 8: Drools Planner Chtijug 2010](https://reader031.vdocuments.mx/reader031/viewer/2022013118/555c261bd8b42a09438b4c9b/html5/thumbnails/8.jpg)
Ch’ti JUGCh’ti JUG
Automated planningwith Drools Planner
Geoffrey De SmetDrools Planner lead
"Do more with less."
![Page 9: Drools Planner Chtijug 2010](https://reader031.vdocuments.mx/reader031/viewer/2022013118/555c261bd8b42a09438b4c9b/html5/thumbnails/9.jpg)
Ch’ti JUGCh’ti JUG Agenda
Use cases of automated planning• N queens• Bin packaging• Employee shift rostering• Examination timetabling
Find the best solution• With Drools Planner
Calculate the score of a solution• With Drools
![Page 10: Drools Planner Chtijug 2010](https://reader031.vdocuments.mx/reader031/viewer/2022013118/555c261bd8b42a09438b4c9b/html5/thumbnails/10.jpg)
Ch’ti JUGCh’ti JUG Agenda
Use cases of automated planning• N queens• Bin packaging• Employee shift rostering• Examination timetabling
Find the best solution• With Drools Planner
Calculate the score of a solution• With Drools
![Page 11: Drools Planner Chtijug 2010](https://reader031.vdocuments.mx/reader031/viewer/2022013118/555c261bd8b42a09438b4c9b/html5/thumbnails/11.jpg)
Ch’ti JUGCh’ti JUG N Queens: use case
Place n queens on a n-sized chess board No 2 queens can attack each other
![Page 12: Drools Planner Chtijug 2010](https://reader031.vdocuments.mx/reader031/viewer/2022013118/555c261bd8b42a09438b4c9b/html5/thumbnails/12.jpg)
Ch’ti JUGCh’ti JUG N queens: partially solved
Score -1 for every 2 queens that can attack each other
Score = -2
![Page 13: Drools Planner Chtijug 2010](https://reader031.vdocuments.mx/reader031/viewer/2022013118/555c261bd8b42a09438b4c9b/html5/thumbnails/13.jpg)
Ch’ti JUGCh’ti JUG N queens: an optimal solution
Score = 0
![Page 14: Drools Planner Chtijug 2010](https://reader031.vdocuments.mx/reader031/viewer/2022013118/555c261bd8b42a09438b4c9b/html5/thumbnails/14.jpg)
Ch’ti JUGCh’ti JUG N queens: demo
Not optimized!• Hello world example
Not a realplanning problem• I can make an
optimal solutionfor any n queenswithout a computer
• See Wikipedia
![Page 15: Drools Planner Chtijug 2010](https://reader031.vdocuments.mx/reader031/viewer/2022013118/555c261bd8b42a09438b4c9b/html5/thumbnails/15.jpg)
Ch’ti JUGCh’ti JUG
![Page 16: Drools Planner Chtijug 2010](https://reader031.vdocuments.mx/reader031/viewer/2022013118/555c261bd8b42a09438b4c9b/html5/thumbnails/16.jpg)
Ch’ti JUGCh’ti JUG NP complete
Yellow item goes in first (or last)• Why?• Not the largest size• Not the largest side• So why?
NP complete• A given solution can be verified fast• No efficient way to find a solution
• Is there even a solution?
![Page 17: Drools Planner Chtijug 2010](https://reader031.vdocuments.mx/reader031/viewer/2022013118/555c261bd8b42a09438b4c9b/html5/thumbnails/17.jpg)
Ch’ti JUGCh’ti JUG Real world bin packaging
Not just 5 items• 1000+ items
Not just 1 container• 100+ containers• Different container types
More constraints...• Distribute weight evenly• Not all fireworks in the same container• ...
![Page 18: Drools Planner Chtijug 2010](https://reader031.vdocuments.mx/reader031/viewer/2022013118/555c261bd8b42a09438b4c9b/html5/thumbnails/18.jpg)
Ch’ti JUGCh’ti JUG
![Page 19: Drools Planner Chtijug 2010](https://reader031.vdocuments.mx/reader031/viewer/2022013118/555c261bd8b42a09438b4c9b/html5/thumbnails/19.jpg)
Ch’ti JUGCh’ti JUG Hard constraints
Hard constraints must be fulfilled For example:
• Ensure continuous service• At least 1 emergency nurse at any given time
• Labor laws• Every 24 hours: at least 11 hours rest• Every 7 days: at least 35 hours rest
• No shifts during approved vacation
![Page 20: Drools Planner Chtijug 2010](https://reader031.vdocuments.mx/reader031/viewer/2022013118/555c261bd8b42a09438b4c9b/html5/thumbnails/20.jpg)
Ch’ti JUGCh’ti JUG Soft constraints
Soft constraints should be fulfilled as much as possible• Only after the hard constraints are fulfilled
Each soft constraint is weighted For example:
• Fair night work assignment: weight 5• Forward rotation: weight 10• Nurse preferences: weight 1
• Ann dislikes Saturday night shifts• Beth dislikes Wednesday afternoon shifts
![Page 21: Drools Planner Chtijug 2010](https://reader031.vdocuments.mx/reader031/viewer/2022013118/555c261bd8b42a09438b4c9b/html5/thumbnails/21.jpg)
Ch’ti JUGCh’ti JUG Hard and soft score
Solution A B C Hard constraints
• 11 hours rest 1 0 0 Soft constraints
• Fair night workassignment 0 1000 1
• Weight 5• Nurse preferences 0 0 4000
• Weight 1 Total score -1H/0S 0H/-5000S 0H/-4005S
• A < B < C• C is the best solution
![Page 22: Drools Planner Chtijug 2010](https://reader031.vdocuments.mx/reader031/viewer/2022013118/555c261bd8b42a09438b4c9b/html5/thumbnails/22.jpg)
Ch’ti JUGCh’ti JUG
![Page 23: Drools Planner Chtijug 2010](https://reader031.vdocuments.mx/reader031/viewer/2022013118/555c261bd8b42a09438b4c9b/html5/thumbnails/23.jpg)
Ch’ti JUGCh’ti JUG Hard constraints
Exam conflict: 2 exams that share students should not occur in the same period.
Room capacity: A room's seating capacity should suffice at all times.
Period duration: A period's duration should suffice for all of its exams.
Period related hard constraints should be fulfilled:
• Coincidence: 2 exams should use the same period (but possibly another room).
• Exclusion: 2 exams should not use the same period.
• After: 1 exam should occur in a period after another exam's period.
Room related hard constraints should be fulfilled:
• Exclusive: 1 exam should not have to share its room with any other exam.
![Page 24: Drools Planner Chtijug 2010](https://reader031.vdocuments.mx/reader031/viewer/2022013118/555c261bd8b42a09438b4c9b/html5/thumbnails/24.jpg)
Ch’ti JUGCh’ti JUG Soft constraints
2 exams in a row.
2 exams in a day.
Period spread: 2 exams that share studentsshould be a number of periods apart.
Mixed durations: 2 exams that share a roomshould not have different durations.
Front load: Large exams should be scheduledearlier in the schedule.
Period penalty: Some periods have a penalty when used.
Room penalty: Some rooms have a penalty when used.
![Page 25: Drools Planner Chtijug 2010](https://reader031.vdocuments.mx/reader031/viewer/2022013118/555c261bd8b42a09438b4c9b/html5/thumbnails/25.jpg)
Ch’ti JUGCh’ti JUG Examination demo
International timetabling competition 2007• Finished 4th (back then)
7 minutes• CPU depended
Real word test data 14 constraints
• 7 hard constraints• 7 soft constraints
![Page 26: Drools Planner Chtijug 2010](https://reader031.vdocuments.mx/reader031/viewer/2022013118/555c261bd8b42a09438b4c9b/html5/thumbnails/26.jpg)
Ch’ti JUGCh’ti JUG Other use cases
Vehicle routing• Freight routing
Scheduling• Course, meeting, conference scheduling• Appointment and resource scheduling• Sport scheduling
Storage organizing Machine queue planning ...
![Page 27: Drools Planner Chtijug 2010](https://reader031.vdocuments.mx/reader031/viewer/2022013118/555c261bd8b42a09438b4c9b/html5/thumbnails/27.jpg)
Ch’ti JUGCh’ti JUG Why use Drools Planner?
Open source• ASL (business-friendly)
Maven-ready (JBoss repository) Documentation
• Reference manual• Examples
JBoss Drools community support• User mailing list, issue tracking, …• Blog & twitter (#droolsplanner)
![Page 28: Drools Planner Chtijug 2010](https://reader031.vdocuments.mx/reader031/viewer/2022013118/555c261bd8b42a09438b4c9b/html5/thumbnails/28.jpg)
Ch’ti JUGCh’ti JUG Agenda
Use cases of automated planning• N queens• Bin packaging• Employee shift rostering• Examination timetabling
Find the best solution• With Drools Planner
Calculate the score of a solution• With Drools
![Page 29: Drools Planner Chtijug 2010](https://reader031.vdocuments.mx/reader031/viewer/2022013118/555c261bd8b42a09438b4c9b/html5/thumbnails/29.jpg)
Ch’ti JUGCh’ti JUGBrute force
for (periodOfExam1 : periodList) { exam1.setPeriod(periodOfExam1); for (roomOfExam1 : roomList) { exam1.setRoom(roomOfExam1);
for (periodOfExam2 : periodList) { exam2.setPeriod(periodOfExam2); for (roomOfExam2 : roomList) { exam2.setRoom(roomOfExam2); ... for (periodOfExamN : periodList) { examN.setPeriod(periodOfExamN); for (roomOfExamN : roomList) { examN.setRoom(roomOfExamN);
Score score = calculateScore(solution); cloneIfScoreIsBetter(solution, score);
} } } }…} }
![Page 30: Drools Planner Chtijug 2010](https://reader031.vdocuments.mx/reader031/viewer/2022013118/555c261bd8b42a09438b4c9b/html5/thumbnails/30.jpg)
Ch’ti JUGCh’ti JUG Needle in a haystack
How many possible solutions?• 1096 exams• 80 periods• 28 rooms
> habitants in Lille per km²?• 6 483 hab./km²
Source: wikipedia
![Page 31: Drools Planner Chtijug 2010](https://reader031.vdocuments.mx/reader031/viewer/2022013118/555c261bd8b42a09438b4c9b/html5/thumbnails/31.jpg)
Ch’ti JUGCh’ti JUG Needle in a haystack
How many possible solutions?• 1096 exams• 80 periods• 28 rooms
> humans?• 7.000.000.000 humans
Source: NASA (wikipedia)
![Page 32: Drools Planner Chtijug 2010](https://reader031.vdocuments.mx/reader031/viewer/2022013118/555c261bd8b42a09438b4c9b/html5/thumbnails/32.jpg)
Ch’ti JUGCh’ti JUG Needle in a haystack
How many possible solutions?• 1096 exams• 80 periods• 28 rooms
> minimum atoms in the observable universe?• 10^80 atoms
Source: NASA and ESA (wikipedia)
![Page 33: Drools Planner Chtijug 2010](https://reader031.vdocuments.mx/reader031/viewer/2022013118/555c261bd8b42a09438b4c9b/html5/thumbnails/33.jpg)
Ch’ti JUGCh’ti JUG Needle in a haystack
How many possible solutions?• 1096 exams• 80 periods• 28 rooms
> atoms in the universeif every atom is a universe of atoms?• (10^80)^80 = 10^6400
Source: NASA and ESA (wikipedia)
![Page 34: Drools Planner Chtijug 2010](https://reader031.vdocuments.mx/reader031/viewer/2022013118/555c261bd8b42a09438b4c9b/html5/thumbnails/34.jpg)
Ch’ti JUGCh’ti JUG Do the math
1 exam• 80 periods and 28 rooms• 80 * 28 = 2240 ways to schedule 1 exam
2 exams• 2240 * 2240 = 5.017.600
3 exams• 2240 * 2240 * 2240 = 11.239.424.000
1096 exams• 2240 * 2240 * … * 2240• 2240^1096 = a little over 10^3671
![Page 35: Drools Planner Chtijug 2010](https://reader031.vdocuments.mx/reader031/viewer/2022013118/555c261bd8b42a09438b4c9b/html5/thumbnails/35.jpg)
Ch’ti JUGCh’ti JUG A little over10^3671
74443724674464882011383315953154621497427697455114051316288269134692843108344990310502102147434076562448130852404428098553211787226818492436455899991484967631419697684165817985739661390634926254859096857258977301840109249945418286726701389433250396830489437134122748296147216955996361597777271017137683780046154870127217758740223489170130893779085381647394360334935333289368078384002213161233225755719910067066354676237665251240673552315376749902467736827879981604429943150088424040897721698276067946148250230917492054728443158872165054373936157659332956136774730870081258025518405492389480888615900164269035398348299000380567467552410280857265893710574057117390411923324486282853392817922617168734507604739703552080299261320457186755798353796720329958815466662988845983738466048902038122152381226870228697167564520947170314014038670253281783219898668392349799158354071694433128608374231159613003286648446078922185727592075724811
![Page 36: Drools Planner Chtijug 2010](https://reader031.vdocuments.mx/reader031/viewer/2022013118/555c261bd8b42a09438b4c9b/html5/thumbnails/36.jpg)
Ch’ti JUGCh’ti JUG A little over10^3671
6048135772412471854625105630495358121952017974176215221261550607694499282872000580072957918546796819172012885232741311107156500439895658139217642528073069419950416303276042981944782604076520149545429082567515199635531168668927010363569188258631683061394017239747010858770816458215631819437872729831119114113689168267734458648249288525981253268712682909721892541332433788104618254995718184937280503163787574781545179918774455713682720486085676323080374894817073654077307783490409626446740500738118392110173307114879831341215304834099815901166729699407017252645417836852601401021510814954906747082633216854492531462935276329826288243709434523924561625262847747165433198090950514642269855008208195099600705166755800356942782663732953126879621138033542807009649872210605061596144967082523007946872878429586274134471258439206305573503782097081716925686154420223798946020972887359043006100852387795351482973307623581925846555002793841
![Page 37: Drools Planner Chtijug 2010](https://reader031.vdocuments.mx/reader031/viewer/2022013118/555c261bd8b42a09438b4c9b/html5/thumbnails/37.jpg)
Ch’ti JUGCh’ti JUG A little over10^3671
412819475399046707554915331636124476210270759983783881007403725028189106738399600287059413396296063538199837169373556801830583664641156130483672354172652266198330743819868438588044621805009480956563538464893798379308830824383808936545111608312964868056598674131595193654957707706822143338172833633019666638035983430262037019665125647894212392790462389810030266845803079031515302062019379538886948677023472435462645765005804746816166402399340231002187005109182016211164762492991719240503935116392473986075551679379460553477047460526845933176425584932086637889540004159744719173226633548555732700361980207696413126618655189183160162357390484834785168386038147341617149224158994590819150108545695234158875676738936645877760000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
![Page 38: Drools Planner Chtijug 2010](https://reader031.vdocuments.mx/reader031/viewer/2022013118/555c261bd8b42a09438b4c9b/html5/thumbnails/38.jpg)
Ch’ti JUGCh’ti JUG A little over10^3671
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
![Page 39: Drools Planner Chtijug 2010](https://reader031.vdocuments.mx/reader031/viewer/2022013118/555c261bd8b42a09438b4c9b/html5/thumbnails/39.jpg)
Ch’ti JUGCh’ti JUG A little over10^3671
0000000000000000000000000000000000000000000000000000000000000000000000000000
The search space is big!• Compare with WWW size
• 22 020 000 000 pages
Each possible solution• 1096+ exams scheduled into
• 80 periods• 28 rooms
• Still need to calculate the score
![Page 40: Drools Planner Chtijug 2010](https://reader031.vdocuments.mx/reader031/viewer/2022013118/555c261bd8b42a09438b4c9b/html5/thumbnails/40.jpg)
Ch’ti JUGCh’ti JUG Throw hardware at it?
If 10^9 scores calculated per ms• Not possible 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^3671 / 10^20• = 10^3651 years
CPU 1000 times faster• It becomes 10^3648 years
![Page 41: Drools Planner Chtijug 2010](https://reader031.vdocuments.mx/reader031/viewer/2022013118/555c261bd8b42a09438b4c9b/html5/thumbnails/41.jpg)
Ch’ti JUGCh’ti JUG A dose of reality
Find the optimal solution?• Of a real world planning problem?
Not in our lifetimes! Who cares?
• Beat the human planner(s) (=easy)• Spend less resources
• Save more money• Save the environment
• Make more people happy
• Never ending competition
![Page 42: Drools Planner Chtijug 2010](https://reader031.vdocuments.mx/reader031/viewer/2022013118/555c261bd8b42a09438b4c9b/html5/thumbnails/42.jpg)
Ch’ti JUGCh’ti JUG Smarter brute force?
Eliminate subtrees• Branch and bound• Still too many for loops• Still takes forever
for (periodOfExam2 : periodList) { exam2.setPeriod(periodOfExam2); if (exam1.shareStudentWith(exam2) && periodOfExam1.equals(periodOfExam2)) { continue; // bug: best solution might break a hard constraint } ...
![Page 43: Drools Planner Chtijug 2010](https://reader031.vdocuments.mx/reader031/viewer/2022013118/555c261bd8b42a09438b4c9b/html5/thumbnails/43.jpg)
Ch’ti JUGCh’ti JUG 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)
Metaheuristic• Move things around
• Start from result of deterministic algorithm
• Drools Planner implementations• More time = better score
![Page 44: Drools Planner Chtijug 2010](https://reader031.vdocuments.mx/reader031/viewer/2022013118/555c261bd8b42a09438b4c9b/html5/thumbnails/44.jpg)
Ch’ti JUGCh’ti JUG Deterministic: N queens
Demo Not feasible
• Not optimal
Good initialization• Jump 10 meter into the pool
![Page 45: Drools Planner Chtijug 2010](https://reader031.vdocuments.mx/reader031/viewer/2022013118/555c261bd8b42a09438b4c9b/html5/thumbnails/45.jpg)
Ch’ti JUGCh’ti JUG Deterministic: examination
List<Exam> sortedExamList = sortExamsOnDifficulty(examList);for (exam : sortedExamList) { // Determine best remaining spot Score bestScoreOfExam = - INFINITY; for (period : periodList) { exam.setPeriod(period); for (room : roomList) { exam.setRoom(room);
Score score = calculateScore(solution); if (score > bestScoreOfExam) { bestScoreOfExam = score; ... store bestPeriod, bestRoom } } } … assign exam to bestPeriod, bestRoom}
![Page 46: Drools Planner Chtijug 2010](https://reader031.vdocuments.mx/reader031/viewer/2022013118/555c261bd8b42a09438b4c9b/html5/thumbnails/46.jpg)
Ch’ti JUGCh’ti JUG Metaheuristic algorithms
Local search: 1st, 2nd, 3rd and 4th in ITC 2007• Simple local search (Hill climbing)• Tabu search
• Local search ++
• Simulated annealing• Great deluge• ...
Genetic algorithms: 5th in ITC 2007 Ant colony optimization ...
![Page 47: Drools Planner Chtijug 2010](https://reader031.vdocuments.mx/reader031/viewer/2022013118/555c261bd8b42a09438b4c9b/html5/thumbnails/47.jpg)
Ch’ti JUGCh’ti JUG Move things around
Move = from solution A to solution B• Change the row of 1 queen
• Give 2 queens each others rows• ...
![Page 48: Drools Planner Chtijug 2010](https://reader031.vdocuments.mx/reader031/viewer/2022013118/555c261bd8b42a09438b4c9b/html5/thumbnails/48.jpg)
Ch’ti JUGCh’ti JUG 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
![Page 49: Drools Planner Chtijug 2010](https://reader031.vdocuments.mx/reader031/viewer/2022013118/555c261bd8b42a09438b4c9b/html5/thumbnails/49.jpg)
Ch’ti JUGCh’ti JUG Metaheuristic: local search
![Page 50: Drools Planner Chtijug 2010](https://reader031.vdocuments.mx/reader031/viewer/2022013118/555c261bd8b42a09438b4c9b/html5/thumbnails/50.jpg)
Ch’ti JUGCh’ti JUG
![Page 51: Drools Planner Chtijug 2010](https://reader031.vdocuments.mx/reader031/viewer/2022013118/555c261bd8b42a09438b4c9b/html5/thumbnails/51.jpg)
Ch’ti JUGCh’ti JUG Local optima
1) Deterministic StartingSolutionInitializer 2) Simple local search 3) Stuck in local optimum!
Source: Wikipedia
![Page 52: Drools Planner Chtijug 2010](https://reader031.vdocuments.mx/reader031/viewer/2022013118/555c261bd8b42a09438b4c9b/html5/thumbnails/52.jpg)
Ch’ti JUGCh’ti JUG Tabu search = local 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
![Page 53: Drools Planner Chtijug 2010](https://reader031.vdocuments.mx/reader031/viewer/2022013118/555c261bd8b42a09438b4c9b/html5/thumbnails/53.jpg)
Ch’ti JUGCh’ti JUG Drool planner configuration
<selector> <selector> <moveFactoryClass>...PeriodChangeMoveFactory</...> <relativeSelection>0.002</relativeSelection> </selector> ... <selector> <moveFactoryClass>...ExamSwitchMoveFactory</...> <relativeSelection>0.002</relativeSelection> </selector> </selector> <accepter> <completeSolutionTabuSize>1000</completeSolutionTabuSize> <completeMoveTabuSize>7</completeMoveTabuSize> </accepter> <forager> <foragerType>MAX_SCORE_OF_ALL</foragerType> </forager>
![Page 54: Drools Planner Chtijug 2010](https://reader031.vdocuments.mx/reader031/viewer/2022013118/555c261bd8b42a09438b4c9b/html5/thumbnails/54.jpg)
Ch’ti JUGCh’ti JUG Termination
Synchronous (configured)• Max timeMillis/seconds/minutes/hours spend• Score attained• Max step count• Max unimproved step count
Asynchronous (from another thread)• planner.terminateEarly();
![Page 55: Drools Planner Chtijug 2010](https://reader031.vdocuments.mx/reader031/viewer/2022013118/555c261bd8b42a09438b4c9b/html5/thumbnails/55.jpg)
Ch’ti JUGCh’ti JUG Double time !=> double score
Softscore
Time (hours:minutes)
Examination test data 7
![Page 56: Drools Planner Chtijug 2010](https://reader031.vdocuments.mx/reader031/viewer/2022013118/555c261bd8b42a09438b4c9b/html5/thumbnails/56.jpg)
Ch’ti JUGCh’ti JUG Benchmarker utility
Battle of different planner configurations• Different algorithms (tabu search, ...)• Different moves• Different settings
On multiple datasets Results are ranked:
• Best one wins
Coming soon:• Graph: best score over time
![Page 57: Drools Planner Chtijug 2010](https://reader031.vdocuments.mx/reader031/viewer/2022013118/555c261bd8b42a09438b4c9b/html5/thumbnails/57.jpg)
Ch’ti JUGCh’ti JUG Agenda
Use cases of automated planning• N queens• Bin packaging• Employee shift rostering• Examination timetabling
Find the best solution• With Drools Planner
Calculate the score of a solution• With Drools
![Page 58: Drools Planner Chtijug 2010](https://reader031.vdocuments.mx/reader031/viewer/2022013118/555c261bd8b42a09438b4c9b/html5/thumbnails/58.jpg)
Ch’ti JUGCh’ti JUG JAVA vs SQL vs DRL
for (q1 : queenList) { for (q2 : queenList) { if (q1.getId() < q2.getId() && q1.getY() == q2.getY()) { ... } }}
select *from Queen q1, Queen q2where q1.id < q2.id and q1.y = q2.y;
rule "multipleQueensHorizontal" when $q1 : Queen($id : id, $y : y); $q2 : Queen(id > $id, y == $y);
![Page 59: Drools Planner Chtijug 2010](https://reader031.vdocuments.mx/reader031/viewer/2022013118/555c261bd8b42a09438b4c9b/html5/thumbnails/59.jpg)
Ch’ti JUGCh’ti JUG N queens: score rule
rule "multipleQueensHorizontal" when $q1 : Queen($id : id, $y : y); $q2 : Queen(id > $id, y == $y); then insertLogical(new IntConstraintOccurrence( "multipleQueensHorizontal", ConstraintType.NEGATIVE_HARD, 1, $q1, $q2));end
![Page 60: Drools Planner Chtijug 2010](https://reader031.vdocuments.mx/reader031/viewer/2022013118/555c261bd8b42a09438b4c9b/html5/thumbnails/60.jpg)
Ch’ti JUGCh’ti JUG Score rule isolation
rule "multipleQueensHorizontal" when $q1 : Queen($id : id, $y : y); $q2 : Queen(id > $id, y == $y); then ...endrule "multipleQueensAscendingDiagonal" when $q1 : Queen($id : id, $ascendingD : ascendingD); $q2 : Queen(id > $id, ascendingD == $ascendingD); then ...endrule "multipleQueensDescendingDiagonal" when $q1 : Queen($id : id, $descendingD : descendingD); $q2 : Queen(id > $id, descendingD == $descendingD); then ...end
![Page 61: Drools Planner Chtijug 2010](https://reader031.vdocuments.mx/reader031/viewer/2022013118/555c261bd8b42a09438b4c9b/html5/thumbnails/61.jpg)
Ch’ti JUGCh’ti JUG
![Page 62: Drools Planner Chtijug 2010](https://reader031.vdocuments.mx/reader031/viewer/2022013118/555c261bd8b42a09438b4c9b/html5/thumbnails/62.jpg)
Ch’ti JUGCh’ti JUG Examination: period spread
2 exams that share students should be a number of periods apart
rule "periodSpread" when $iw : InstitutionalWeighting(periodSpreadPenality != 0); // For any 2 conflicting exams in the same period ... $topicConflict : TopicConflict($leftT : leftTopic, $rightT : rightTopic); $leftExam : Exam(topic == $leftT, $leftPeriod : period); $rightExam : Exam(topic == $rightT, $rightPeriod : period); // … which are in within the periodSpread eval(Math.abs($leftPeriod.getPeriodIndex() - $rightPeriod.getPeriodIndex()) < ($iw.getPeriodSpreadLength() + 1)); then insertLogical(new IntConstraintOccurrence(... NEGATIVE_SOFT, $topicConflict.getStudentSize() * $iw.getPeriodSpreadPenality(), $leftExam, $rightExam));end
![Page 63: Drools Planner Chtijug 2010](https://reader031.vdocuments.mx/reader031/viewer/2022013118/555c261bd8b42a09438b4c9b/html5/thumbnails/63.jpg)
Ch’ti JUGCh’ti JUG Summary
Drools Planner solves planning problems Adding constraints is easy and scalable Switching/combining algorithms is easy
![Page 64: Drools Planner Chtijug 2010](https://reader031.vdocuments.mx/reader031/viewer/2022013118/555c261bd8b42a09438b4c9b/html5/thumbnails/64.jpg)
Ch’ti JUGCh’ti JUGQ&A
64
Home page• http://www.jboss.org/drools/drools-planner.html
Reference manual• http://www.jboss.org/drools/documentation.html
Blog• http://blog.athico.com/search/label/planner
Twitter• #droolsplanner
![Page 65: Drools Planner Chtijug 2010](https://reader031.vdocuments.mx/reader031/viewer/2022013118/555c261bd8b42a09438b4c9b/html5/thumbnails/65.jpg)
Ch’ti JUGCh’ti JUGThanks for your attention!
65
Home page• http://www.jboss.org/drools/drools-planner.html
Reference manual• http://www.jboss.org/drools/documentation.html
Blog• http://blog.athico.com/search/label/planner
Twitter• #droolsplanner
![Page 66: Drools Planner Chtijug 2010](https://reader031.vdocuments.mx/reader031/viewer/2022013118/555c261bd8b42a09438b4c9b/html5/thumbnails/66.jpg)
Ch’ti JUGCh’ti JUG Licence
Les photos et logos appartiennent à leurs auteurs respectifs
Le contenu de la présentation est sous licence Creative Commons 2.0 France• Contrat Paternité• Pas d'Utilisation Commerciale• Partage des Conditions Initiales à l'Identique
http://creativecommons.org/licenses/by-nc-sa/2.0/fr/
66
![Page 67: Drools Planner Chtijug 2010](https://reader031.vdocuments.mx/reader031/viewer/2022013118/555c261bd8b42a09438b4c9b/html5/thumbnails/67.jpg)
Ch’ti JUGCh’ti JUG Cocktail
Merci pour votre attention Merci à Cylande pour son sponsoring
67