OptaPlanner logo
  • Download
  • Learn
    • Documentation
    • Videos
    • Slides
    • Training

    • Use cases
    • Compatibility
    • Testimonials and case studies
  • Get help
  • Blog
  • Source
  • Team
  • Services
  • KIE
    • Drools
    • OptaPlanner
    • jBPM
    • Kogito
  • Star
  • T
  • L
  • F
  • YT
Fork me on GitHub

What is the bottleneck in my Solver?

Fri 12 February 2016
Avatar Geoffrey De Smet
Geoffrey De Smet

Twitter LinkedIn GitHub

OptaPlanner lead

Once we have a vanilla setup of an OptaPlanner project, where should we invest our time to improve it? How can I get a better solution faster? What’s preventing my solver to scale better? How can I track down my bottleneck?

The scapegoat: machine performance

“We need faster hardware.” It is the typical knee-jerk reaction to any performance problem. However, for most optimization problems, throwing hardware at the problem doesn’t help much (in part because of the size of the search space).

For example, presume that the score of the best solution evolves like this over time:

bestScoreStatistic

At any point in time (X axis), it shows the score of the best solution (Y axis) found until then. Notice that if our hardware is twice as fast (so if we need only half the amount of time), we’d get the score we’re currently getting at 2 mins 30 secs, which is about the same as the score we’re getting after 5 minutes. So throwing hardware at the problem would hardly improve the solution. In this case, performance isn’t the bottleneck.

Measure, don’t guess

Instead of wildly guessing at the problem, it’s better to configure the Solver in the OptaPlanner Benchmarker and let it generate a useful benchmark report. In that report, look at the best score over time graph (similar to the one shown above) and check if you can see any of these 3 patterns on it:

letTheBestScoreStatisticGuideYou
  • If performance is the bottleneck (left pattern), check your benchmark report for the average calculation count per second. It’s probably too low, maybe due to a bottleneck in just one of your score constraints. Using faster hardware well help in this case (although improving score calculation speed is usually better).

  • If local optima are the problem (middle pattern), try adding coarse-grained moves (but don’t remove the fine-grained moves).

  • If the optimization algorithm is the problem (right pattern), try different optimization algorithms in the solver configuration.

A JVM profiler (such as JProfiler or VisualVM) can be very helpful in the first case, but not in the other 2 cases.

Conclusion

When facing a performance or scalability challenge, don’t randomly improve parts of your code. Remember that premature optimization is the root of all evil. Instead, let the OptaPlanner Benchmarker guide you and fix the biggest bottlenecks first.


Permalink
 tagged as insight benchmark algorithm

Comments

Visit our forum to comment
AtomNews feed
Don’t want to miss a single blog post?
Follow us on
  • T
  • L
  • F
Blog archive
Latest release
  • 8.23.0.Final released
    Thu 23 June 2022
Upcoming events
    Add event / Archive
Latest blog posts
  • Run OptaPlanner workloads on OpenShift, part I.
    Thu 9 June 2022
    Radovan Synek
  • OptaPlanner deprecates score DRL
    Thu 26 May 2022
    Lukáš Petrovický
  • Real-time planning meets SolverManager
    Mon 7 March 2022
    Radovan Synek
  • OptaPlanner documentation turns over a new leaf
    Tue 26 October 2021
    Radovan Synek
  • Order picking optimization in warehouses and supermarkets with OptaPlanner
    Thu 14 October 2021
    Walter Medvedeo
  • Monitor OptaPlanner solvers through Micrometer
    Tue 12 October 2021
    Christopher Chianelli
  • A new AI constraint solver for Python: OptaPy
    Tue 5 October 2021
    Christopher Chianelli
  • Blog archive
Latest videos
  • Host your OptaPlanner app on OpenShift (Kubernetes)
    Mon 7 February 2022
    Geoffrey De Smet
  • OptaPlanner - A fast, easy-to-use, open source AI constraint solver for software developers
    Mon 31 January 2022
  • Order picking planning with OptaPlanner
    Fri 31 December 2021
    Anna Dupliak
  • AI lesson scheduling on Quarkus with OptaPlanner
    Thu 18 November 2021
    Geoffrey De Smet
  • Maintenance scheduling
    Fri 12 November 2021
    Geoffrey De Smet
  • Optimized order picking in warehouses and supermarkets
    Tue 26 October 2021
    Walter Medvedeo
  • A modern OO/FP constraint solver
    Tue 14 September 2021
    Geoffrey De Smet
  • Video archive

OptaPlanner is open. All dependencies of this project are available under the Apache Software License 2.0 or a compatible license. OptaPlanner is trademarked.

This website was built with JBake and is open source.

Community

  • Blog
  • Get Help
  • Team
  • Governance
  • Academic research

Code

  • Build from source
  • Issue tracker
  • Release notes
  • Upgrade recipes
  • Logo and branding

KIE projects

  • Drools rule engine
  • OptaPlanner constraint solver
  • jBPM workflow engine
  • Kogito Business Automation platform
CC by 3.0 | Privacy Policy
Sponsored by Red Hat