Mordecai
Mordecai

Reputation: 13

How to initialise a variable with a specific domain of numbers in MiniZinc?

In MiniZinc, we initialise a domain of values using for example:

var 2..6: X;

However, if the values required are only [2, 4, 6] excluding 3 and 5, how does one initialise such a domain for the variable?

Upvotes: 0

Views: 153

Answers (1)

hakank
hakank

Reputation: 6854

Use the set notation {...} to enumerate the valid domain, i.e. curly braces, not brackets.

var {2,4,6}: x;

Note: 2..6 is the same as (or rather a shorthand of) {2,3,4,5,6}.

This is discussed a little more in the MiniZinc Tutorial.

Upvotes: 3

Related Questions