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

Giscus Comments

AtomNews feed
Don’t want to miss a single blog post?
Follow us on
  • T
  • L
  • F
Blog archive
Latest release
  • 8.14.0.Final released
    Wed 8 December 2021
Upcoming events
  • DevConf.CZ
    Brno, Czech Republic (virtual) - Fri 28 January 2022
    • Artificial Intelligence on Quarkus: I love it when an OptaPlan comes together by Geoffrey De Smet
  • JFokus
    Stockholm, Sweden - Mon 7 February 2022
    • AI maintenance scheduling with OptaPlanner on Quarkus by Geoffrey De Smet
  • Add event / Archive
Latest blog posts
  • 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
  • How much faster is Java 17?
    Wed 15 September 2021
    Geoffrey De Smet
  • Constraint Streams get some more love
    Thu 19 August 2021
    Lukáš Petrovický
  • Let’s OptaPlan your jBPM tasks (part 2) - BPM Task assigning in the cloud
    Mon 26 July 2021
    Walter Medvedeo
  • Blog archive
Latest videos
  • 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
  • Business processes task optimization in Kogito
    Tue 7 September 2021
    Walter Medvedeo
  • School timetable optimization
    Mon 6 September 2021
    Geoffrey De Smet
  • Schedule incoming calls real-time
    Mon 23 August 2021
    Radovan Synek
  • 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