367 questions
Advice
1
vote
1
replies
42
views
CPSAT Linear Optimization Behaviour
Some resources point to the fact that these constraints are encoded exactly the same way:
model.add_bool_or(b1, b2, b3) # b1 or b2 or b3 must be true
model.add_at_least_one([b1, b2, b3]) # ...
1
vote
1
answer
71
views
Constraints: AddNoOverlap with OnlyEnforceIf
I have set of tasks in a constraint satisfaction problem. These tasks are using a centrifuge. So if they overlap, then they must overlap completely (I can't add tasks while the centrifuge is spinning)....
0
votes
1
answer
104
views
Installing OR-Tools for C++ from Binary on Windows
I installed OR-Tools following these instructions: C++ binary on Windows
Now I am trying to run this example: nurse scheduling problem
I get a compiler error: 'StopSearch': identifier not found
This ...
0
votes
1
answer
98
views
Problem faced in CP-SAT when using OnlyEnforceIf
I have the following excerpt from my Python code
For emp in employees:
Model.Add(d[emp] >= 25) .OnlyEnforceIf(d120[emp])
Model.Add(d[emp] < 25) .OnlyEnforceIf(d121[emp])
It is my ...
0
votes
0
answers
169
views
CP-SAT: normalization for multi-objective optimization
I'm working on a multi-objective optimization problem using CP-SAT, where I combine several objectives into a single objective using a weighted sum approach. All my objective terms are positive-valued,...
-1
votes
1
answer
76
views
How can we apply constraints for a start time in a given time series with Google ORTools?
I have an startTime interval, and a series of shift times like (2025-03-14 08:00-11:00,2025-03-14 11:30-15:00,2025-03-15 08:00-11:00,2025-03-15 11:30-15:00,2025-03-16 08:00-11:00,2025-03-16 11:30-15:...
3
votes
2
answers
449
views
Why is my Z3 and OR-Tools formulation of a problem slower than brute force in Python?
I'm trying to establish an upper bound on a fairly elaborate equation that comes from a tree. It has a small number of of inputs that can be encoded with "one-hot" variables. All numbers are ...
0
votes
1
answer
189
views
VRP in CP-SAT (or tools) using all available vehicles, when a smaller number could have sufficed
I am solving a simple capacitated VRP with CP-SAT solver with 6 vehicles and 17 nodes. The issue that is happening is that the solution ends up using all 6 vehicles, when clearly a smaller number of ...
1
vote
1
answer
402
views
OR-Tools CP-SAT hint completeness is lost after presolve
I am using ortools.sat.python.cp_model (version 9.9) to solve some kind of JSSP. I have heuristics that find me (possibly infeasible) solutions. I test the solutions, choose the best one and use ...
0
votes
1
answer
99
views
How to add piece-wise linear constraint in OR-Tools with CP-SAT solver?
In a task allocation problem, suppose:
We need to allocate 2 tasks to a worker in the following 2 days.
There is only one worker and he can work at most 8 hours a day.
We want to minimize the total ...
0
votes
1
answer
204
views
How to use the sorted() and min() function with OR-Tools in python?
I'm building a Python Sudoku Solver to solve the classic and non-classic sudokus using the cp_model from Google's ortools library. Specifically, I'm trying to write a method that solves a Sudoku ...
-1
votes
1
answer
132
views
How to set maximum consecutive days in OR-Tools CP-SAT?
I manage employees' working days. If an employee works for {consecutive_count} consecutive days, they are given {rest} days off.
ex)
OK [0,1,1,1,1,0,0,1,0,0,0,1,1,1,0,...]
FAIL [0,0, ** 1,1,1,1,0, ** ...
0
votes
1
answer
66
views
What Happens if two variables have the same name?
By mistake, while defining a CP-SAT model, I've created two variables with the same name:
variable1 = model.NewIntVar(0, cp_model.INT32_MAX, "cool_name")
variable2 = model.NewIntVar(0, ...
0
votes
1
answer
93
views
Max 2d-Array Size in minizinc with or-tools CP-SAT
define 2d-array as following in minizinc :
array[1..400,1..400] of var int : en_b ;
run with Or-tools CP-SAT 9.11 as backend ,
get error with "=====UNKNOWN=====" .
PS. 9.11 is default with ...
0
votes
1
answer
187
views
OR Tools cp sat flexible jobshop with flexible durations optimal solution not found
I am trying to combine the flexible job shop optimization with flexible durations based on machine calendars like here: https://groups.google.com/g/or-tools-discuss/c/DA_4Pniwhn8/m/BH2vO5K1BgAJ
My ...
0
votes
1
answer
163
views
How can we achieve prioritization of tasks with OR-Tools?
I have two tasks to plan for the next two days in the shopfloor.
There is only one operator in the shopfloor and this operator can do only one task a day in these two days.
The tasks are of different ...
0
votes
1
answer
67
views
OR-tools CP-SAT - implement presence_literal constraint
From the attached seminar (timestamped), if you constrain the sum of all presence_literals * interval_size to be less than the makespan, the proven problems number of problems rises according to the ...
0
votes
1
answer
438
views
Efficiency of MiniZinc + CP-SAT (from OR-Tools) compared to CP-SAT alone
I'd be interested to use MiniZinc for its in-browser experience & its support of many solvers, but at the same time I find CP-SAT (from OR-Tools) really efficient and I'd like to be sure that by ...
0
votes
2
answers
139
views
CP-SAT | OR-Tools: at most one of two different arrays (OR-ed). How to declare constraint?
I have two arrays of model variables - arr1 and arr2. I would like to declare a constraint that would forbid a situation when there is at least 1 true in arr1 AND at least 1 true in arr2. (There can ...
0
votes
1
answer
59
views
How to add a constraint that a linear expression is outside bounds that are variables?
I want to add the constraint that abs(x) >= y with x and y being variables.
The following code fails because AddBoolOr doesn't suppport BoundedLinearExpression as arguments.
model = cp_model....
3
votes
2
answers
603
views
Using a CP sat solver, I want to use 2 conditions in an "OnlyEnforceIf" but can't find how
I am using a CP-sat solver by google or tools and I am adding some constraints to my variables.
There is a constraints that should be enforce if 2 bool variables are True. However I can't manage to ...
0
votes
1
answer
182
views
Or-tools: How to use BoolVar/ Change bounds of exisitng IntVar
I wanted to expand the job shop problem for the CP-Sat Solver by adding optional tasks,that don't have to be executed. But my problem is that I don't really know how "remove" a task from the ...
0
votes
0
answers
61
views
Affecting people to tasks using a CP-SAT solver
I am currently using a cp-sat solver from google or-tools in python.
I am using it to plan tasks in a schedule and to affect people to this task. So my variables are tasks that require a set of skills,...
0
votes
1
answer
452
views
Wildly inconsistent performance of CP-SAT solver
I ran the CP-SAT solver three consecutive times on my model. The wall times were:
0h07m41s
0h39m45s
2h17m42s
There is almost 18x difference in runtime from the fastest to the slowest. There were no ...
0
votes
1
answer
679
views
or-tools optimization/parallelization of VRP?
I apologize if people feel like this stuff have already been explained plenty of times. But after an extensive search I am still not sure exactly what is what, or which information is still correct.
...