In the Resource-Constrained Project Scheduling Problem (RCPSP), a project consists of a set of tasks that have to be scheduled. Each task has a given duration and cannot be interrupted. There are precedence constraints between the tasks: each task must end before any of its successors can start. There are a set of renewable resources. Each task has a given resource requirement or weight (possibly zero) on each resource, representing the amount of resource it consumes while it is being processed. Each resource has a given maximum capacity: it can process several tasks at once, but the sum of the processed tasks’ weights can never exceed this maximum capacity. The goal is to find a schedule that minimizes the makespan: the time when all tasks have been processed.

This page illustrates how LocalSolver outperforms traditional general-purpose optimization solvers on this challenging problem. Since MIP solvers like Gurobi struggle to reach feasibility on this problem, we compare LocalSolver’s performance with the CP-SAT solver of Google OR-Tools 9.5, known as a state-of-the-art Constraint Programming (CP) solver.

## Input data

This benchmark focuses on large-scale instances of the Resource-Constrained Project Scheduling Problem (RCPSP). We use the RG300 instances introduced by Debels and Vanhoucke in . There are 480 instances comprising 300 tasks each, representing different situations and configurations.

## Mathematical models of the Resource-Constrained Project Scheduling Problem (RCPSP)

### Constraint Programming (CP) model

The results reported for OR-Tools are obtained using the RCPSP example provided with the OR-Tools library. The model uses interval decision variables to represent the tasks and cumulative constraints to represent the resources.

### LocalSolver model

The LocalSolver model relies on interval decisions to model the tasks. The cumulative resource constraints can be formulated as follows: for each resource, the amount consumed by the tasks being processed must never exceed the resource’s capacity. To model these constraints, we sum up, for each resource and each instant t, the weights of the tasks that start before t and end after t. To ensure that the constraint is respected at each instant, we use a variadic `and `operator over the whole time horizon.

``````function model() {
// Interval decisions: time range of each task

// Precedence constraints between the tasks
for[i in 0...nbTasks][s in 0...nbSuccessors[i]] {
}

// Makespan: end of the last task

// Cumulative resource constraints
for [r in 0...nbResources] {
constraint and(0...makespan,
}

// Minimize the makespan
minimize makespan;
}``````

## Google OR-Tools and LocalSolver results on the Resource-Constrained Project Scheduling Problem (RCPSP)

We compare both solvers’ performance in 1 minute of running time, after which we measure the gap to the best known solution in %. We use LocalSolver 12.0 and the CP-SAT solver of Google OR-Tools 9.5. Both are used with default parameters. We ran them on a server equipped with an Xeon 8375C (8 cores, 2.9 GHz, 55MB cache) and 32GB RAM.

On average, LocalSolver achieves a 2.6% gap to the best known solution, while OR-Tools only reaches an 8.1% gap.

LocalSolver OR-Tools
Average gap 2.6% 8.1%
Average gap to the best known solution in 60s.

The table below shows the number of instances where each solver reaches a solution below a particular gap. For example, LocalSolver always finds a solution with a gap to the best known solution below 10%, but OR-Tools only does so for 59% of the instances.

LocalSolver OR-Tools
Gap < 20% 100% 97%
Gap < 15% 100% 81%
Gap < 10% 100% 59%
Gap < 5% 81% 43%
Gap < 2.5% 54% 28%
Gap < 1% 35% 18%
Percentage of instances below a certain gap to the best known solution within 1 minute.

## Conclusion

LocalSolver offers a concise and straightforward approach to the Resource-Constrained Project Scheduling Problem (RCPSP) based on integer decision variables. The resulting model provides much better solutions than OR-Tools 9.5 on large-scale instances of the RCPSP.

You can find the complete model of the Resource-Constrained Project Scheduling Problem (RCPSP) and many other scheduling problems in Python, Java, C#, and C++ in our Example Tour.