OptaPlanner logo
  • Download
  • Learn
    • Documentation
    • Videos

    • Use cases
    • Compatibility
    • Testimonials and case studies
  • Get help
  • Blog
  • Source
  • Team
  • Services
  • 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 creator

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
  • 9.44.0.Final released
    Wed 6 September 2023
Upcoming events
    Add event / Archive
Latest blog posts
  • Scaling Up Vehicle Routing Problem with planning list variable and Nearby Selector
    Thu 27 April 2023
    Anna Dupliak
  • OptaPlanner 9 has been released
    Mon 24 April 2023
    Radovan Synek
  • OptaPlanner 9 is coming
    Tue 21 February 2023
    Lukáš Petrovický
  • Farewell - a new lead
    Tue 15 November 2022
    Geoffrey De Smet
  • Run OptaPlanner workloads on OpenShift, part II
    Wed 9 November 2022
    Radovan Synek
  • Bavet - A faster score engine for OptaPlanner
    Tue 6 September 2022
    Geoffrey De Smet
  • Run OptaPlanner workloads on OpenShift, part I.
    Thu 9 June 2022
    Radovan Synek
  • Blog archive
Latest videos
  • The Vehicle Routing Problem
    Fri 23 September 2022
    Geoffrey De Smet
  • Introduction to OptaPlanner AI constraint solver
    Thu 25 August 2022
    Anna Dupliak
  • On schedule: Artificial Intelligence plans that meet expectations
    Sat 23 July 2022
    Geoffrey De Smet
  • 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
  • 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
CC by 3.0 | Privacy Policy
Sponsored by Red Hat