minizinc

how to input null set inside a array with json to minizinc


Thanks a lot . I am trying on input data with json to minizinc . In the mzn file , defined the array :

array[1..14] of set of 1..100 : stationCalendarOffPeriod ;

and input data in json , but error coming .

case 1 : use "{}" for "set of 1..100" , in json

{"stationCalendarOffPeriod":[{},{},{},{},{},{},{},{},{},{},{},{},{},{}]}

error : stationCalendarOffPeriod:0.31: MiniZinc: JSON parsing error: invalid object

case 2 : use "[]" for "set of 1..100" , in json

{"stationCalendarOffPeriod":[[],[],[],[],[],[],[],[],[],[],[],[],[],[]]}

error : :0.0: MiniZinc: type error: arrays cannot be elements of arrays

so how to define set in json to minizinc ?


Solution

  • As stated in the documentation, the JSON input of sets must be given as an object with a single key "set" with a value that lists the values.

    So, for example, the empty set {} is given as {"set": []}, and the set {3,5,7} can be given as {"set": [3,5,7]}.

    When you have many consecutive members, then you can use ranges in the list. For example, 1..5 union 7..12 can be given as {"set": [[1,5],[7,12]]}