Integer Variables and Linear Constraints in CP-SAT
Learn how to declare bounded integer variables and add linear (in)equality constraints to a CP-SAT model in Google OR-Tools, and how to check whether a candidate assignment is feasible.
Step 1 of 157%
Tutorial
Integer Variables in CP-SAT
In CP-SAT, an integer variable is a decision variable whose value the solver must choose from a finite range of integers. We declare one with the syntax
This creates a variable named whose domain is the set of integers from to , inclusive on both ends. Both bounds must be integers, and is a string used only for display.
For example, given a model object created with , the lines
declare and In general, the domain of contains exactly
integer values.