8. Custom constraints: the alldifferent_except_0 constraint

The global alldifferent_except_0 constraint is exactly as its name says: an alldifferent constraint except for the variables that have a 0 value. Although this constraint is already implemented in or-tools[1], we will spend the whole chapter dissecting this constraint and learn how to implement our own customized version.

Classes under scrutiny:

Files:

You can find the code in the directory documentation/tutorials/cplusplus/chap4.

The files inside this directory are:

Content:























































Footnote

[1]

The implemented constraint is a little bit more general and doesn’t consider 0 as a special value. We’ll discuss this constraint in the section The alldifferent_except_0 constraint.

Google or-tools
open source library

User's Manual

Google search

Search:

Welcome

Tutorial examples

Chapters

Part I: Basics
Part II: Customization
Part III: Routing
Part IV: Technicalities
Appendices