Search code examples
setoutputminizinc

Minizinc: output continuously values of a decision variable set of int


i have an mzn file, that decides for the values of a set of int

var set of int : ids; 

output ["ids:" ++show(ids)]

the output though for example comes as:

ids: 4..7

is it possible to get something like

ids: 4,5,6,7

the continuous values of the set.


Solution

  • This is possible by using the join builtin and a comprehension to turn the set into an array of strings:

    var set of int: ids;
    ...
    output["ids: " ++ join(",", [ "\(i)" | i in fix(ids)] )];
    

    Which will output: ids: 1,2,3,4