Logo
The MiniZinc Handbook
  • 1. Overview
  • 2. A MiniZinc Tutorial
  • 3. User Manual
  • 4. Reference Manual
    • 4.1. Specification of MiniZinc
    • 4.2. The MiniZinc library
      • 4.2.1. Standard Library
      • 4.2.2. Global constraints
        • 4.2.2.1. All-Different and related constraints
        • 4.2.2.2. Lexicographic constraints
        • 4.2.2.3. Sorting constraints
        • 4.2.2.4. Channeling constraints
        • 4.2.2.5. Counting constraints
        • 4.2.2.6. Array-related constraints
        • 4.2.2.7. Set-related constraints
        • 4.2.2.8. Mathematical constraints
        • 4.2.2.9. Packing constraints
        • 4.2.2.10. Scheduling constraints
        • 4.2.2.11. Graph constraints
        • 4.2.2.12. Extensional constraints (table, regular etc.)
        • 4.2.2.13. Machine learning constraints
        • 4.2.2.14. Deprecated constraints
      • 4.2.3. FlatZinc builtins
      • 4.2.4. Additional declarations for Gecode
      • 4.2.5. Additional declarations for Chuffed
      • 4.2.6. MiniZincIDE tools
      • 4.2.7. MiniZinc definitions for the MiniZinc diversity extension.
      • 4.2.8. Experimental Features
    • 4.3. Interfacing Solvers to Flatzinc
    • 4.4. Machine-readable JSON output format
The MiniZinc Handbook
  • 4. Reference Manual
  • 4.2. The MiniZinc library
  • 4.2.2. Global constraints
  • 4.2.2.1. All-Different and related constraints

4.2.2.1. All-Different and related constraints

In this section: all_different, all_different_except, all_different_except_0, all_disjoint, all_equal, nvalue, symmetric_all_different.

all_different

1.  predicate all_different(array [$X] of var $$E: xs, set of $$E: except)

2.  predicate all_different(array [$X] of var set of $$E: xs)

3.  predicate all_different(array [$X] of var opt $$E: xs)
  1. Constrain the elements in the array xs to be pairwise different, except for those that take a value in the set except (values in except may occur any number of times).

  2. Constrain the elements in the array xs to be pairwise different.

  3. Constrain the non-absent elements in the array xs to be pairwise different. The absent value <> is allowed to occur multiple times.

all_different_except

predicate all_different_except(array [$X] of var $$E: xs,
                               set of $$E: except)

Constrain the elements of the array xs to be pairwise different except for those values that appear in the set except.

This constraint is deprecated. Use all_different(xs, except) instead.

all_different_except_0

predicate all_different_except_0(array [$X] of var int: xs)

Constrain the elements of the array xs to be pairwise different except for those elements that are assigned the value 0.

This constraint is deprecated. Use all_different(xs, {0}) instead.

all_disjoint

predicate all_disjoint(array [$X] of var set of $$E: xs)

Constrain the array of sets of integers xs to be pairwise disjoint.

all_equal

predicate all_equal(array [$X] of var $$E: xs)
predicate all_equal(array [$X] of var set of $$E: xs)

Constrain the elements of the array xs to be all equal.

nvalue

1.  predicate nvalue(var int: n, array [$X] of var $$E: xs)

2.  predicate nvalue(var int: n, array [$X] of var opt $$E: xs)

3.  function var int: nvalue(array [$X] of var $$E: xs)

4.  function var int: nvalue(array [$X] of var opt $$E: xs)
1, 2.

Requires that the number of distinct values in xs is n.

3, 4.

Returns the number of distinct values in xs.

symmetric_all_different

predicate symmetric_all_different(array [int] of var int: xs)

Requires the array of integers xs to be all different, and for all i, xs[i]=j \(\rightarrow\) xs[j]=i.

Previous Next

© Copyright 2016, 2017, 2018, 2019, 2020 Peter J. Stuckey, Kim Marriott, Guido Tack.

Creative Commons License