Can someone help me to understand a couple of things in the mini zinc tutorial:
function set of $T: 'intersect'(set of $T: x, set of $T: y)
This return the intersection of sets x and y . Obviously x and y are sets - but what does $T mean in this context?
function var set of int: 'union'(var set of int: x, var set of int: y)
Return the union of sets x and y. from what I understand x is a set of integers and y is also a set of integers - but what does 'var set of int' mean? what is 'var' ?
function set of $U: array_union(array [$T] of set of $U: x)
Return the union of the sets in array x. Could you explain:
function set of $U
and:
array_union(array [$T] of set of $U: x)
$T
or $U
means any type. $T
can be int
, float
, etc. If it says int
, then you must supply a int
, but if it says $T
, you can supply any type.
In the expression function set of $U: array_union(array [$T] of set of $U: x)
, $U
and $T
can be different types but in function set of $T: 'intersect'(set of $T: x, set of $T: y)
all $T
have to be the same. Different variables for $
just means that they can be a different type. Same variable $
name and all need to have the same type.
Example: function set of float: array_union(array [int] of set of float: x)
and function set of int: 'intersect'(set of int: x, set of int: y)
.
array [$T]
is a bit special and just means that the array can be of any dimension. i.e array [int]
, array [int,int]
or array [int,int,int,int,int]
etc. So array [$T] of set of $U
means that we have an array of size $T
, for example [int,int]
, a two dimensional array. This array is filled with sets of any type. For example sets of integers, for example {1,4,7,145}.
var int
and int
are different types. int
is just regular numbers. var int
is variable integers, i.e those varaibles that MiniZinc are trying to assign a value to and solve the problem.
For example var 1..150: age
or
var int: age
if we want to solve some age problem.