简体   繁体   中英

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)

???

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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM