DEV Community

Richa Singh
Richa Singh

Posted on

Optimising OptaPlanner for Large-Scale Constraint Solving in Enterprise Applications

Planning engines often perform well during development but slow down when production datasets grow from hundreds to hundreds of thousands of planning entities. This becomes common in workforce scheduling, vehicle routing, manufacturing, and resource allocation systems where every new constraint increases the search space. OptaPlanner addresses these optimisation challenges through heuristic algorithms, incremental score calculation, and configurable solver strategies. At Oodles, we have implemented planning solutions where careful solver tuning produced measurable improvements over default configurations. If you're evaluating custom OptaPlanner implementation services, understanding the optimisation architecture before development begins can help achieve better scalability and solver performance.

Context and Setup

Enterprise optimisation systems typically combine transactional applications with a dedicated planning engine. Business data flows from ERP, CRM, or scheduling platforms into OptaPlanner, which evaluates millions of possible combinations before returning an optimal or near-optimal solution.

A typical architecture includes:

Business application built with Spring Boot or Quarkus
Database storing planning entities and problem facts
Constraint Provider or Constraint Streams defining business rules
OptaPlanner Solver
REST APIs exposing optimised schedules or assignments

One of the biggest performance advantages of OptaPlanner is its incremental score calculation. Rather than recalculating every constraint after each planning move, the solver updates only the affected constraints. According to the official OptaPlanner documentation, this significantly improves solving performance for large optimisation problems compared to recalculating scores from scratch.

Configuring OptaPlanner for Faster Constraint Solving
Step 1: Design Efficient Planning Entities

The quality of optimisation starts with the domain model.

Instead of modelling every business object as a planning entity, identify only the objects whose values actually change during optimisation. Static reference data should remain immutable because unnecessary planning variables increase the search space and slow the solver.

Some recommended practices include:

Keep planning entities lightweight.
Separate immutable reference objects from planning entities.
Minimise planning variables.
Reduce unnecessary shadow variables.
Avoid redundant relationships between entities.

A cleaner domain model allows OptaPlanner to evaluate more planning moves within the same solving window.

Step 2: Configure Incremental Scoring

Incremental score calculation is one of the primary reasons OptaPlanner scales effectively for enterprise planning.

Constraint employeeAvailability(ConstraintFactory factory) {

return factory
    .forEach(Shift.class)
    .filter(shift -> !shift.isEmployeeAvailable())

    // Why: penalise only invalid assignments instead of recalculating everything
    .penalize(HardSoftScore.ONE_HARD);
Enter fullscreen mode Exit fullscreen mode

}

Instead of evaluating every shift repeatedly, only the impacted constraints are recalculated, reducing CPU usage during optimisation.

When building Constraint Streams:

Keep filters simple.
Avoid unnecessary joins.
Reuse common constraints.
Profile score calculation during testing.
Remove duplicate constraint logic.

These practices reduce solver overhead and improve maintainability.

Step 3: Tune Solver Strategies for Enterprise Workloads

Default solver settings are designed for general-purpose optimisation and rarely produce the best performance in production environments.

OptaPlanner offers multiple optimisation algorithms, including:

Construction Heuristics
Local Search
Tabu Search
Simulated Annealing
Late Acceptance
Variable Neighbourhood Search

Selecting the appropriate algorithm depends on the business problem.

For example:

Workforce scheduling often benefits from Tabu Search.
Vehicle routing commonly performs well with Local Search after an initial Construction Heuristic phase.
Manufacturing planning may require multiple optimisation phases to balance production constraints.

Another useful optimisation technique is multithreaded incremental solving. By evaluating planning moves across multiple CPU cores, large optimisation problems can complete significantly faster. As discussed in the DZone analysis of multithreaded incremental constraint solving, parallel move evaluation can reduce solving time for complex planning datasets when configured appropriately.

Real-World Application

In one of our OptaPlanner implementation projects at Oodles, a client needed to generate weekly workforce schedules for more than 8,500 employee shifts while satisfying labour regulations, employee availability, department coverage, and skill-matching constraints.

The initial implementation required approximately 18 minutes to produce an acceptable schedule.

Our engineering team improved performance by:

Refactoring planning entities
Simplifying Constraint Streams
Enabling incremental score calculation
Optimising move selectors
Fine-tuning Local Search termination conditions

The result included:

Planning time reduced from 18 minutes to under 6 minutes
Approximately 67% faster optimisation
More consistent solver scores across repeated executions
Lower infrastructure utilisation during peak scheduling periods

This project demonstrated that improving domain modelling and solver configuration often delivers greater performance gains than simply allocating additional hardware resources.

Key Takeaways

Design planning entities carefully to minimise unnecessary search space.
Incremental score calculation significantly improves OptaPlanner performance.
Choose solver algorithms based on the characteristics of the optimisation problem.
Profile Constraint Streams regularly to eliminate expensive joins and redundant rules.
Performance tuning should rely on benchmarking and profiling rather than assumptions.
Let's Discuss Your Planning Challenges

If you're building scheduling, routing, manufacturing, or resource allocation software and need guidance on solver performance, share your questions in the comments.

For implementation support or enterprise optimisation consulting, connect with our team through OptaPlanner Development Services.

FAQ

1. What is OptaPlanner used for?

OptaPlanner is an open-source constraint solver used for optimisation problems such as workforce scheduling, vehicle routing, manufacturing planning, cloud resource allocation, examination timetabling, and employee rostering where multiple business rules must be satisfied simultaneously.

2. Why is incremental score calculation important?

Incremental score calculation updates only the constraints affected by each planning move instead of recalculating the entire solution. This allows the solver to evaluate many more candidate solutions within the same execution time while reducing CPU consumption.

3. Which optimisation algorithm should I choose in OptaPlanner?

The best algorithm depends on the planning problem. Workforce scheduling commonly benefits from Tabu Search, while routing problems often combine Construction Heuristics with Local Search. Running benchmarks against production-like datasets is the most reliable way to select an optimisation strategy.

4. Can OptaPlanner handle enterprise-scale datasets?

Yes. OptaPlanner is specifically designed for large combinatorial optimisation problems. With efficient planning entities, optimised Constraint Streams, incremental score calculation, and well-tuned solver configurations, it can process thousands of planning entities efficiently.

5. How do I improve OptaPlanner performance without upgrading infrastructure?

Start by simplifying planning entities, reducing unnecessary constraints, profiling Constraint Streams, enabling incremental score calculation, and selecting appropriate solver strategies. These improvements typically provide greater performance gains than adding more CPU or memory alone.

Top comments (0)