Your SlideShare is downloading. ×
0
Drools planner - 2012-10-23 IntelliFest 2012
Drools planner - 2012-10-23 IntelliFest 2012
Drools planner - 2012-10-23 IntelliFest 2012
Drools planner - 2012-10-23 IntelliFest 2012
Drools planner - 2012-10-23 IntelliFest 2012
Drools planner - 2012-10-23 IntelliFest 2012
Drools planner - 2012-10-23 IntelliFest 2012
Drools planner - 2012-10-23 IntelliFest 2012
Drools planner - 2012-10-23 IntelliFest 2012
Drools planner - 2012-10-23 IntelliFest 2012
Drools planner - 2012-10-23 IntelliFest 2012
Drools planner - 2012-10-23 IntelliFest 2012
Drools planner - 2012-10-23 IntelliFest 2012
Drools planner - 2012-10-23 IntelliFest 2012
Drools planner - 2012-10-23 IntelliFest 2012
Drools planner - 2012-10-23 IntelliFest 2012
Drools planner - 2012-10-23 IntelliFest 2012
Drools planner - 2012-10-23 IntelliFest 2012
Drools planner - 2012-10-23 IntelliFest 2012
Drools planner - 2012-10-23 IntelliFest 2012
Drools planner - 2012-10-23 IntelliFest 2012
Drools planner - 2012-10-23 IntelliFest 2012
Drools planner - 2012-10-23 IntelliFest 2012
Drools planner - 2012-10-23 IntelliFest 2012
Drools planner - 2012-10-23 IntelliFest 2012
Drools planner - 2012-10-23 IntelliFest 2012
Drools planner - 2012-10-23 IntelliFest 2012
Drools planner - 2012-10-23 IntelliFest 2012
Drools planner - 2012-10-23 IntelliFest 2012
Drools planner - 2012-10-23 IntelliFest 2012
Drools planner - 2012-10-23 IntelliFest 2012
Drools planner - 2012-10-23 IntelliFest 2012
Drools planner - 2012-10-23 IntelliFest 2012
Drools planner - 2012-10-23 IntelliFest 2012
Drools planner - 2012-10-23 IntelliFest 2012
Drools planner - 2012-10-23 IntelliFest 2012
Drools planner - 2012-10-23 IntelliFest 2012
Drools planner - 2012-10-23 IntelliFest 2012
Drools planner - 2012-10-23 IntelliFest 2012
Drools planner - 2012-10-23 IntelliFest 2012
Drools planner - 2012-10-23 IntelliFest 2012
Drools planner - 2012-10-23 IntelliFest 2012
Drools planner - 2012-10-23 IntelliFest 2012
Drools planner - 2012-10-23 IntelliFest 2012
Drools planner - 2012-10-23 IntelliFest 2012
Drools planner - 2012-10-23 IntelliFest 2012
Drools planner - 2012-10-23 IntelliFest 2012
Drools planner - 2012-10-23 IntelliFest 2012
Drools planner - 2012-10-23 IntelliFest 2012
Drools planner - 2012-10-23 IntelliFest 2012
Drools planner - 2012-10-23 IntelliFest 2012
Drools planner - 2012-10-23 IntelliFest 2012
Drools planner - 2012-10-23 IntelliFest 2012
Drools planner - 2012-10-23 IntelliFest 2012
Drools planner - 2012-10-23 IntelliFest 2012
Drools planner - 2012-10-23 IntelliFest 2012
Drools planner - 2012-10-23 IntelliFest 2012
Drools planner - 2012-10-23 IntelliFest 2012
Drools planner - 2012-10-23 IntelliFest 2012
Drools planner - 2012-10-23 IntelliFest 2012
Drools planner - 2012-10-23 IntelliFest 2012
Drools planner - 2012-10-23 IntelliFest 2012
Drools planner - 2012-10-23 IntelliFest 2012
Drools planner - 2012-10-23 IntelliFest 2012
Drools planner - 2012-10-23 IntelliFest 2012
Drools planner - 2012-10-23 IntelliFest 2012
Drools planner - 2012-10-23 IntelliFest 2012
Drools planner - 2012-10-23 IntelliFest 2012
Drools planner - 2012-10-23 IntelliFest 2012
Drools planner - 2012-10-23 IntelliFest 2012
Drools planner - 2012-10-23 IntelliFest 2012
Drools planner - 2012-10-23 IntelliFest 2012
Drools planner - 2012-10-23 IntelliFest 2012
Drools planner - 2012-10-23 IntelliFest 2012
Drools planner - 2012-10-23 IntelliFest 2012
Drools planner - 2012-10-23 IntelliFest 2012
Drools planner - 2012-10-23 IntelliFest 2012
Drools planner - 2012-10-23 IntelliFest 2012
Drools planner - 2012-10-23 IntelliFest 2012
Drools planner - 2012-10-23 IntelliFest 2012
Drools planner - 2012-10-23 IntelliFest 2012
Drools planner - 2012-10-23 IntelliFest 2012
Drools planner - 2012-10-23 IntelliFest 2012
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Drools planner - 2012-10-23 IntelliFest 2012

879

Published on

Business resource optimization with Drools Planner

Business resource optimization with Drools Planner

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
879
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
25
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Business resource optimization with Drools Planner Geoffrey De Smet
  • 2. DemoTravelling Salesman Problem Vehicle Routing 2
  • 3. Every organization has planning problems. 3
  • 4. What is a planning problem?  Complete goals  With limited resources  Under constraints 4
  • 5. Hospital employee rostering  Assign each ● Shift  To ● Employee  Constraints ● Employment contracthttp://www.flickr.com/photos/glenpooh/709704564/ ● Free time preferences ● Skills 5
  • 6. DemoEmployee rostering 6
  • 7. Other planning problemsCourse scheduling Hospital bed planning http://www.flickr.com/photos/markhillary/2227726759/ http://www.flickr.com/photos/phelyan/2281095105/ Many more: port planning, airline routing, train composition, task assignment, assembly line planning, satellite bandwidth planning, stock cutting, ... 7
  • 8. Bin packing in the cloud  Assign each ● Process  To ● Server  Constraints ● Hardware requirements ● Minimize server costhttp://www.flickr.com/photos/torkildr/3462607995/ 8
  • 9. Bin packing in the cloud  Assign each ● Process  To ● Server  Constraints ● Hardware requirements ● Minimize server costhttp://www.flickr.com/photos/torkildr/3462607995/ 9
  • 10. Which processes do we assignto this server? 10
  • 11. How did we find that solution? 11
  • 12. First fit by decreasing size 12
  • 13. First fit by decreasing size 13
  • 14. First fit by decreasing size 14
  • 15. First fit by decreasing size 15
  • 16. Another case 16
  • 17. Try FFD again 17
  • 18. Try FFD again 18
  • 19. Try FFD again 19
  • 20. Try FFD again 20
  • 21. FFD failure 21
  • 22. NP complete 22
  • 23. NP complete  No silver bullet known ● Holy grail of computer science ● P == NP ● Probably does not exist ● P != NP  Root problem of all planning problemshttp://www.flickr.com/photos/annguyenphotography/3267723713/ 23
  • 24. Multiple servers... 24
  • 25. Multiple servers... 25
  • 26. Multiple servers... 26
  • 27. Multiple servers... 27
  • 28. Multiple constraints... 28
  • 29. Multiple constraints... 29
  • 30. Multiple constraints... 30
  • 31. Multiple constraints... 31
  • 32. Organizations rarely optimize planning problems. 32
  • 33. Given 2 solutions, which one is better? 33
  • 34. Each Solution has 1 Score 34
  • 35. Each Solution has 1 Score 35
  • 36. Better score => better solution 36
  • 37. Better score => better solution 37
  • 38. Best score => best solution 38
  • 39. Best score => best solution 39
  • 40. Reuse optimization algorithms? 40
  • 41.  Open source (ASL 2.0) Regular releases Reference manual Examples 41
  • 42. DemoCloudBalance example 42
  • 43. Domain model
  • 44. Server 44
  • 45. Serverpublic class Server { private int cpuPower; private int memory; private int networkBandwidth; private int cost; // getters} 45
  • 46. Process 46
  • 47. Process 47
  • 48. Process is a planning entity@PlanningEntitypublic class Process { private int requiredCpuPower; private int requiredMemory; private int requiredNetworkBandwidth; private Server server; @PlanningVariable @ValueRange(... = "serverList") public Server getServer() {...} // getters, setters, clone, equals, hashcode} 48
  • 49. CloudBalance 49
  • 50. Solution class CloudBalancepublic class CloudBalance implements Solution<HardAndSoftScore> { private List<Server> serverList; private List<Process> processList; private HardAndSoftScore score; @PlanningEntityCollectionProperty public List<Process> getProcessList() {...} // getters, setters, clone, getProblemFacts()} 50
  • 51. Score constraints
  • 52. Score calculation Simple Java Incremental Java Drools 52
  • 53. Simple Java score calculation Easy to implement Bridge to an existing scoring system Slowpublic class ... implements SimpleScoreCalculator<CloudBalance> { public Score calculateScore(CloudBalance cb) { ... }} 53
  • 54. Incremental Java score calculation Fast ● Solution changes => only score delta is recalculated Hard to implement ● Much boilerplate code 54
  • 55. Drools score calculation Also incremental => fast ● but no boilerplate code Integration opportunities ● Guvnor repository ● DSL: natural language constraints ● Decision tables 55
  • 56. DRL soft constraint: server costrule "serverCost" when // there is a server $s : Server($c : cost) // there is a processes on that server exists Process(server == $s) then // lower soft score by $cend 56
  • 57. DRL hard constraint: CPU powerrule "requiredCpuPowerTotal" when // there is a server $s : Server($cpu : cpuPower) // with too little CPU for its processes $total : Number(intValue > $cpu) from accumulate( Process(server == $s, $requiredCpu : requiredCpuPower), sum($requiredCpu) ) then // lower hard score by ($total - $cpu)end 57
  • 58. Solving it
  • 59. Solver configuration by XML<solver> <solutionClass>...CloudBalance</solutionClass> <planningEntityClass>...Process</> <scoreDirectorFactory> <scoreDefinitionType>HARD_AND_SOFT</> <scoreDrl>...ScoreRules.drl</scoreDrl> </scoreDirectorFactory> <!-- optimization algorithms --></solver> 59
  • 60. SolvingXmlSolverFactory factory = new XmlSolverFactory( "...SolverConfig.xml");Solver solver = factory.buildSolver();solver.setPlanningProblem(cloudBalance);solver.solve();cloudBalance = (CloudBalance) solver.getBestSolution(); 60
  • 61. Optimization algorithms
  • 62. Brute Force 62
  • 63. Brute Force config<solver> ... <bruteForce /></solver> 63
  • 64. Brute force scalability 12 processes = 17 minutes * 680 9 processes = 1.5 seconds 6 processes = 15 ms * 100 64
  • 65. Plan 1200 processeswith brute force? 65
  • 66. First Fit 66
  • 67. First Fit config<solver> ... <constructionHeuristic> <constructionHeuristicType>FIRST_FIT</> </constructionHeuristic></solver> 67
  • 68. First Fit Decreasing 68
  • 69. First Fit Decreasing config<solver> ... <constructionHeuristic> <constructionHeuristicType>FIRST_FIT_DECREASING</> </constructionHeuristic></solver>@PlanningEntity(difficultyComparatorClass = ProcessDifficultyComparator.class)public class Process { ...} 69
  • 70. First Fit scalability 70
  • 71. Local Search comes afterConstruction Heuristics 71
  • 72. Local Search comes after Construction Heuristics<solver> ... <constructionHeuristic> <constructionHeuristicType>FIRST_FIT_DECREASING</> </constructionHeuristic> <localSearch> ... <localSearch></solver> 72
  • 73. Local Search 73
  • 74. Local Search Algorithms (Hill climbing) Tabu Search Simulated Annealing Late Acceptance Details explained Friday 4:15 PM 74
  • 75. Local Search results 75
  • 76. Cost ($) reduction  Compared to First Fit ● First Fit Decreasing ● 49 480 $ = 4 % ● Tabu Search ● 160 860 $ = 14 % ● Simulated annealing ● 128 950 $ = 11 %  Few constraints ● => low ROI 76
  • 77. Benchmarker toolkit 77
  • 78. Organizations rarely optimize planning problems. 78
  • 79. http://www.flickr.com/photos/techbirmingham/345897594/Organizations waste resources. 79
  • 80. Summary
  • 81. Summary Drools Planner optimizes business resources Adding constraints is easy and scalable Switching/combining algorithms is easy 81
  • 82. Try an example! 82
  • 83. Q&A Drools Planner homepage: ● http://www.jboss.org/drools/drools-planner Reference manual: ● http://www.jboss.org/drools/documentation Download this presentation: ● http://www.jboss.org/drools/presentations Twitter: @geoffreydesmet Google+: Geoffrey De Smet 83

×