Domain space of variable (2.3.8. Domain Reflection Functions)

21 views
Skip to first unread message

Andreas Decker

unread,
May 22, 2024, 8:07:50 AMMay 22
to MiniZinc
Hello,
i am relatively new to constraint solving and while reading the documentation I got to this part (https://www.minizinc.org/doc-2.8.4/en/predicates.html#domain-reflection-functions). When i use the example in Listing 2.3.12, i only get the first output. Maybe i misundertstood that part, but i thought I can get both outputs non-deterministic. Or did that change? And if that changed, can i somehow force the second output "D = {0, 1, 2, 3, 4}" to happen?

Thanks for anyone who can help me solve my confusion.
Best Wishes,
Andreas Decker

Jip Dekker

unread,
May 22, 2024, 9:09:32 AMMay 22
to MiniZinc
Hi Andreas,

The MiniZinc compiler is not non-deterministic. It is not strange that you are only seeing a single output. The text, however, tries to warn the users against making assumptions on the information available about domains and the order of executions. We have chosen for the MiniZinc compiler to process constraints in a deterministic order, but it is correct to process MiniZinc in any (topologically correct) order, and we might change the ordering in the future to for example benefit performance.

Cheers,
Jip

Andreas Decker

unread,
May 22, 2024, 9:38:51 AMMay 22
to MiniZinc
Hi Jip,

thanks for the clarification. So if I unterstood you right for the example there:

" var -10..10: x;
constraint x in 0..4;
int: y = lb(x);
set of int: D = dom(x);
solve satisfy;
output ["y = ", show(y), "\nD = ", show(D), "\n"];"

there currently is no way to get the domain of x with the constraint applied, because of the current order of execution?
And if I would like to know the domain of a variable, would i need to iterate through all solutions? Or is there an easier option?

Thanks for any help and best wishes,
Andreas

Jip Dekker

unread,
May 27, 2024, 2:54:04 AMMay 27
to MiniZinc
We don't have any operations that guarantee the order in which constraints will be applied. In the current compiler you can probably influence them quite easily by using constraints in let expressions.

The answer to the second question depends on what you mean. You can have a look at the current domain of a variable during MiniZinc compilation using "trace" statements. If, however, you want to know all possible values that a variable can take in a solution, then you do have to iterate through all solutions.

Reply all
Reply to author
Forward
0 new messages