Questions relating to the Google CP-SAT solver, available through OR-Tools.
Questions tagged [cp-sat-solver]
105 questions
12
votes
1 answer
Which solver do Googles OR-Tools Modules for CSP and VRP use?
I am currently evaluating googles or-tools and just noticed that it's not really a solver on its own but mainly an interface to other solvers. What I'd like to know is which solvers this framework uses for constraint and routing problems.
I have…

javaguy
- 149
- 1
- 6
10
votes
3 answers
Boolean operations on constraints in Google or-tools library
I'm beginner in constraint programming and I'm using Google or-tools library in my c# program.
I want to add following constraint to my solver:
((t1 >= 12 && t1 <= 15) || (t2 >= 16 && t2 <= 18)) && ( t1 + t2 ) < 30
So I write following piece of…

Masoud
- 8,020
- 12
- 62
- 123
7
votes
1 answer
Can the CP solver be initialised at a specific point?
I am using the CP-Sat solver to optimise a timetable I am making. However, this now takes a long time to solve. Is it possible to seed the solver with an old result, to act as a starting point, with the goal of reducing the time required to find the…

Andrew
- 539
- 5
- 20
7
votes
1 answer
Employees shift problem - link missions together
I have a list of Employee and a list of Mission.
Each mission have a start time and a duration.
In the cp model (Google CpSat, from or-tools package), I defined shifts = Dictionary<(int,int),IntVar>, where shifts[(missionId, employeeId)] == 1 if and…

Antoine C.
- 3,730
- 5
- 32
- 56
3
votes
0 answers
Or-tools CP-SAT solver: How can i ensure a mandatory 3 shift break?
I am fairly new to the topic but I have started to implement a shift scheduler using this example: https://developers.google.com/optimization/scheduling/employee_scheduling
Now I want to add the following constrain: after five shifts there needs to…

Henrike
- 31
- 4
3
votes
1 answer
Constraint optimization in python with OR Tools: How to enforce a multi level constraint?
I have an optimization problem where I have a list of lists of "BoolVar" objects. So something like this:
[[BoolVar1,BoolVar2],[BoolVar3, BoolVar4],[BoolVar5,BoolVar6]]
I need to evaluate the following:
(BoolVar1 && BoolVar2) || (BoolVar3 &&…

ThaNoob
- 520
- 7
- 23
3
votes
0 answers
Constraint to Balance Daily Coverage
Here's a simplified version of my problem formulation:
from ortools.sat.python import cp_model
def solve_shift_scheduling():
num_employees = 6
num_weeks = 4
shifts = ['.', 'M']
fixed_assignments = [
(0, 1, 0),
(0,…

shaterr
- 31
- 3
3
votes
1 answer
Ceiling in CP-SAT
In a scheduling problem. I want to assign vacations proportionally to the days worked. Right now I have a working solution using multiple boolean flags but it doesn't scale very well.
from ortools.sat.python import cp_model
from math import…

Stradivari
- 2,626
- 1
- 9
- 21
2
votes
2 answers
Adding multiple choice constraints to cp_model, ortools
I'm following this tutorial https://developers.google.com/optimization/scheduling/job_shop of the Job Shop problem as I have a similar task, except I need an extra constraint which I can't figure out how to add. I want to add a constraint that (in…

data24
- 21
- 2
2
votes
1 answer
How to build my own global constraint with the CP-SAT solver of OR-tools?
I am a phd candidate in data mininig, and i have to create a global constraint with ORtools for a data mining purpose.
The problem is that there is a lack of documentation about creating your own global constraint with CP-Sat in the internet, and i…

djawed bkh
- 21
- 5
2
votes
1 answer
OR-Tools employee scheduling: maximising consecutive shifts
I've been studying the OR-Tools Employee Scheduling example and would like to change it so that the model would allow employees to be assigned to multiple shifts per day and at the same time give preference to solutions
where an employee is assigned…

marko
- 622
- 1
- 6
- 16
2
votes
1 answer
Using Google OR Tools CP-SAT Solver Log To Improve Optimization Runtime (Python)
I am struggling a tad bit with understanding how I might use the search log from my CP-SAT solver to improve the runtime by setting the subsolvers, initial solving strategy, etc. I am unsure how to specify these such things. I set the number of…

Steve White
- 41
- 5
2
votes
0 answers
How to speed-up Ortools during creation of variables
I have a very large problem and I am facing computational time issues even in the declaration of the variables in OrTools (>10minutes).
Here is a peace of my code
x = {}
for i in setI:
for j in setJ:
x[i,j] = model.NewIntVar(0, 1,…

rapha123
- 179
- 9
2
votes
1 answer
Multiply / add Google OR Tools IntVar's and Constants in Java
I currently started working with Google OR Tools CP-Sat Solver in Java and facing Problems with simple mathematical equations including constants and the OR-Tools internal "IntVar".
A Small Example of my Problem:
// Variables
IntVar a =…

F. G.
- 56
- 1
- 5
2
votes
1 answer
Evaluating a custom function when a solution is proposed by ORTOOLS
I am pretty new to OR-TOOLS in Python. I have made several tutorial examples, but I am facing issues trying to model my problem.
Let's see we have a bin packing problem, in which I need to find the fewest bins that will hold all the items in…

Víctor Martínez
- 854
- 2
- 11
- 29