Questions relating to the Google CP-SAT solver, available through OR-Tools.
Questions tagged [cp-sat-solver]
105 questions
1
vote
0 answers
Convert OR Tools IntervalVars into Binary List
Good Morning,
I'm trying to find a way to convert IntervalVars into a List of BooleanVars with or tools in order to use the binary list as a sort of field in which the booleans indicate where the Interval is located in the window between time 0 and…

m_c_frank
- 46
- 7
1
vote
1 answer
Google OR tools: how to evaluate complex or multi-level boolean constraints
Set up
I am using the google OR tools as a constraint programming solver:
from ortools.sat.python import cp_model
I have defined the following BoolVars
model = cp_model.CpModel()
a = model.NewBoolVar("a")
b = model.NewBoolVar("b")
c =…

ThaNoob
- 520
- 7
- 23
1
vote
1 answer
ORTOOLS - CPSAT - Objective to minimize a value by intervals
I my model in ORTools CPSAT, I am computing a variable called salary_var (among others). I need to minimize an objective. Let’s call it « taxes ».
to compute the taxes, the formula is not linear but organised this way:
if salary_var below 10084,…

Sébastien D
- 31
- 4
1
vote
1 answer
How to implement CPSat addDifferent with IntVar and LinearExpression in Java
I'm back at Linear Expressions with Google Or Tools CP Sat in Java.
Clunky doesn't describe it even close, Java is a mess here.
My goal is to add a constant to my IntVar and exclude this value for the next IntVar.
(Btw. it's already awkward how i…

F. G.
- 56
- 1
- 5
1
vote
1 answer
How to calculate the "AddAbsEquality" or "AddMultiplicationEqualit" using Google's CP-SAT solver for non-linear optimization?
My goal is to recover the data sequence based on a predicted sequence. Let us say the original sequence of data is x_org = [10, 20, 30, 40, 50] but I receive the randomized data as x_ran = [50, 40, 20, 10, 30]. Now, my goal is to recover the pattern…

Md Hasan Shahriar
- 53
- 7
1
vote
0 answers
CPU usage of CP-SAT solver with num_search_workers = 8
Dears,
I have a question, If I have a 32-core CPU and use CP-SAT with num_search_workers = 8, how many CPU core am I using?
thanks

stefano guerrieri
- 133
- 10
1
vote
1 answer
Does the domain of an IntVar affect the performance of a CP-SAT solver
Dears,
I normally specify big IntVar even if they are not needed:
model.NewIntVar(-93372036854775808, 9123372036854775807, 'test')
Does it affect the performances of the Solver or is it irrelevant? I mean is it better to limit the domain of the…

stefano guerrieri
- 133
- 10
1
vote
2 answers
Google ortools CP-SAT maximize takes too long
I am trying to solve a scheduling problem. As input I have the number of workers and the number of shifts.
After that I place all the constraints, including:
everyone has to work around the same amount of shifts,
everyone has to take all the given…

ARE MERE
- 21
- 4
1
vote
1 answer
ORTOOLS CP SAT - XOR and AND combined
I am still learning ORTOOLS CP-SAT which is a great tool!
I am getting into boolean operations difficulties.
For instance in Python, I have an array of an array of expressions (I mean BoundedLinearExpression) organized like this:
my_list = [ […

Sébastien D
- 31
- 4
1
vote
2 answers
Count variables and constraints PuLP and CP-Sat
Does anyone know how I can get a print of the number of variables and constraints created in each optimization problem created in Python both CP-Sat and PuLP?
Thank you

Giulietta
- 21
- 2
1
vote
1 answer
addDivisionEquality with Java google or-tools CP-SAT
I need to add the following constraint using google CP-SAT solver:
(x+y+z)/(x+y+z+k) < 10
The addDivisionEquality method signature is:
Constraint addDivisionEquality (IntVar target, IntVar num, IntVar denom)
Where
IntVar target =…

forhas
- 11,551
- 21
- 77
- 111
1
vote
0 answers
How to model conditional summation (like sumif in Excel) in CP-SAT?
I am trying to model a variant of Job Shop problem in CP-SAT. In this problem, the machines have capacities >=1 so I can NOT directly use AddNoOverlap constraint from CP-SAT.
The decision variables are START and FINISH times of job operations on…

ashwin zade
- 11
- 1
1
vote
0 answers
Detecting termination in CP-SAT
I was exploring the CP-SAT APIs for fetching all solution for given set of constraints.
As per the API documentation, onSolutionCallback() function is called for every solution found. However if I need to find all solutions for a given model, is…

sdare
- 237
- 1
- 2
- 9
1
vote
1 answer
Using CP-SAT Solver for non-linear objective function
I'm trying to use CP-SAT solver with some variables: x,y. I want to maximise an objective function of the form x**2-y*x with some constraints. I'm getting
TypeError: unsupported operand type(s) for ** or pow(): 'IntVar' and
'int'
error messages.…

Joseph Doob
- 163
- 15
1
vote
0 answers
OR-Tools, CP-SAT solver - Maximize then maximize
I used https://developers.google.com/optimization/cp/cp_solver to try to resovle a constraint programming problem, and I would like to maximize a function, then maximize another.
I tried to call Maximize twice, but it does not seems to work.
Here is…

Damien IFT
- 73
- 1
- 9