Questions relating to the Google CP-SAT solver, available through OR-Tools.
Questions tagged [cp-sat-solver]
105 questions
2
votes
1 answer
Or-Tools CP-SAT solver export/import: how to access vars after loading a model?
Using the Python interface to the OR-Tools CP-CAT solver (reference), I would like to be able to save a cp_model, load it at a later time or from a different process, and continue interacting with it.
I'm able to serialize a model into a Protubuf,…

etov
- 2,972
- 2
- 22
- 36
2
votes
1 answer
Seeding the CP-SAT solver
In googles OR-tools library, the "Original" CP-Solver (discussed here: https://developers.google.com/optimization/cp/original_cp_solver) can be reseeded using .ReSeed(). However, the newer version, CP-SAT cannot.
My assumption is that CP-SAT will…

Andrew
- 539
- 5
- 20
1
vote
2 answers
ORTools / Python : How to keep track of the amount of some variables in the solve process?
First, I want to precise I'm not a pro dev. I have some really basics knowledge, and this is my first real coding Project. ( and i guess i didnt choose the easiest one ) This is a Python(3) project.
I wanted to create a tool for a famous football…

Bastien_F
- 9
- 2
1
vote
1 answer
When resulting in an infeasible model, what tips are there to break down the nexus of the issue
I am new to using or-tools and I have been tasked with minimizing a quadratic objective function with lots of IntVar variables. I don't know where to start breaking down what the problem could be concerning an infeasable model and welcome any tips…

Tejas
- 11
- 1
1
vote
1 answer
Python ortools | Add Exactly 2 instead if AddExactlyOne
I'm using AddExactlyOne from Python or-tools CP-SAT for the nurses scheduling problem.
(Using the from ortools.sat.python import cp_model code at the bottom of the link)
However, this code used AddExactlyOne to assign exact only one nurse in a…

MG G
- 3
- 1
1
vote
0 answers
OR-Tools CP-Sat: Efficiently optimize toward an average value
I'm new to OR-Tools and CP-Sat I'm looking for guidance on how to most efficiently optimize sums of variables toward a common average value. Here's a very simplified example to help explain:
from ortools.sat.python import cp_model
from random import…

schwartz721
- 767
- 7
- 19
1
vote
1 answer
Spreading out shift assignments in constraint solver (ortools)
I used the Google OR-Tools Employee Scheduling script (thanks by the way) to make a on-call scheduler. Everything works fine and it is doing what it is supposed to. It makes sure each person works about the same amount of "shifts" (two week…

D.Wills
- 81
- 8
1
vote
1 answer
ortools - CP-SAT : how to fetch the feasible solution if the best incumbent solution does not change after 'x' seconds
I am solving integer programming problem leveraging CP-SAT solver (ortools). Looking at the logs, I notice that the solver finds the solution that actually is optimal (proven later), but spends a lot of time in proving optimality. Essentially, the…

Bhartendu Awasthi
- 440
- 3
- 13
1
vote
0 answers
CP-SAT MODEL_INVALID The divisor cannot span across zero in constraint
Dears, I need your help on that CP-SAT implementation. Here a simplified version of what I'm doing:
assume that I have 3 boolean decision variables: x1, x2, x3 and boolean coefficents a1 a2 a3
model.Add(num == a1*x1+a2*x2+a3*x3)
model.Add(denom ==…

stefano guerrieri
- 133
- 10
1
vote
1 answer
Does the Google OR-Tools CP-SAT support relaxation method to sovle MIQP?
I applied the CP-SAT sovler to sovle a MIQP problem, and it found a optimat result successfully. Do I need to further consider the relaxation method for the problem? Does the CP-SAT sovler support relaxation?

user19508782
- 13
- 4
1
vote
1 answer
Google OR Tools OnlyEnforceIf
I got a problem for using onlyenforceif to set up constraint.
work[employee , shift , day] is the BoolVar indicating the scheduling status for each staff each day.
I would like to set a limit that for staff who worked on shift A on day 1 and shift B…

Carson
- 85
- 6
1
vote
1 answer
Constraint on uniqueness for Assignement Optimization Problem using OR-Tools CP-SAT Solver
The problem I am trying to solve is pretty similar to the one described in the OR-tools documentation: https://developers.google.com/optimization/assignment/assignment_example#cp_sat_solution.
I have 15 workers that I need to assign to 5 tasks. The…

Oli
- 43
- 7
1
vote
1 answer
Google OR-Tools library: Type Error GetOrMakeIndex
I'm studying the google OR-Tools library and I came across this problem that I can't understand.
First of all, I get the same error if I copy and paste the code from the nqueens example in the official guide.
I propose as an example the classic…

pofferbacco
- 126
- 6
1
vote
1 answer
Using NewBoolVar in Google OR-Tools
I am wondering the syntax for logical constraints in Google OR-Tools. I have a nurse scheduling project I have done in CPLEX that I am translating over to Google OR-Tools. I have come across the documentation for channeling constraints in Google…

Steve White
- 41
- 5
1
vote
1 answer
Find the right Google OR-Tools algorithm
I have to find the set of integers that minimize this objective function:
The costraints are:
every x must be a non-negative integer
T, A and B are double known numbers.
I have been looking at the OR-Tools C++ library in order to solve this…

AathakA
- 117
- 7