Logo
2.7.0
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.3. Interfacing Solvers to Flatzinc
    • 4.4. Machine-readable JSON output format
The MiniZinc Handbook
  • Docs »
  • 4. Reference Manual »
  • 4.2. The MiniZinc library »
  • 4.2.2. Global constraints »
  • 4.2.2.6. Array-related constraints

4.2.2.6. Array-related constraints¶

In this section: element, member, write, writes, writes_seq.

element¶

predicate element(var $$E: i, array [$$E] of var bool: x, var bool: y)
predicate element(var $$E: i,
                  array [$$E] of var float: x,
                  var float: y)
predicate element(var $$E: i, array [$$E] of var $$T: x, var $$T: y)
predicate element(var $$E: i,
                  array [$$E] of var set of $$T: x,
                  var set of $$T: y)
Constrains i to be the index of the element y in the array x.

member¶

1.  predicate member(array [int] of var bool: x, var bool: y)

2.  predicate member(array [int] of var float: x, var float: y)

3.  predicate member(array [int] of var $$E: x, var $$E: y)

4.  predicate member(array [int] of var set of $$E: x, var set of $$E: y)

5.  predicate member(var set of $$E: x, var $$E: y)
1-4.
Requires that y occurs in the array x.
  1. Requires that y occurs in the set x.

write¶

predicate write(array [$$E] of var int: I,
                var int: i,
                var int: v,
                array [$$E] of var int: O)

Creates a new array O from an input array I with a change at position i to take value v

I is an array of integers O is an array of integers with same index set as I i is an index for I v is an integer value

writes¶

1.  predicate writes(array [$$X] of var int: I,
                     array [$$Y] of var int: P,
                     array [$$Y] of var int: V,
                     array [$$X] of var int: O)

2.  function array [$$X] of var int: writes(array [$$X] of var int: I,
                                            array [$$Y] of var int: P,
                                            array [$$Y] of var int: V)
  1. Creates a new array O from an input array I with a simultaneous change at positions P to values V

    I is an array of integers O is an array of integers with same index set as I P is an array of index values in I V is an array of integer values

  2. Returns a new array from an input array I with a simultaneous change at positions P to values V

    I is an array of integers P is an array of index values in I V is an array of integer values

writes_seq¶

predicate writes_seq(array [$$X] of var int: I,
                     array [$$Y] of var int: P,
                     array [$$Y] of var int: V,
                     array [$$X] of var int: O)

Creates a new array O from an input array I with a sequence of changes at positions P to take values V

I is an array of integers O is an array of integers with same index set as I P is an array of index values in I V is an array of integer values

Next Previous

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

Creative Commons License