Flemming Juel Jensen
Flemming Juel Jensen

Reputation: 17

What are Global Constraints in constraint programming?

I see that ORTools and CpOptimizer both use global constraints. I know it speeds up the search a lot, but what does it actually do? Like what is the difference between me using (1) or (2) below;

Example for the AllDifferent constraint:

1) x1 != x2, x2 != x3, x1 != x3

and

2) AllDifferent(x1, x2, x3)

???

Upvotes: 0

Views: 217

Answers (1)

Laurent Perron
Laurent Perron

Reputation: 11064

None. We rebuild the all-different cliques. Still, it will be faster for presolve if you use the AllDifferent formulation.

Now, the CP-SAT is a based on a SAT solver, and prefers Boolean variables. In your case, you can try removing integer variables, and use arrays of Boolean variables with a sum (boolvars) <= 1.

Upvotes: 1

Related Questions