Union of the solutions

9 views
Skip to first unread message

Xiaofeng Yang

unread,
Jan 28, 2026, 10:57:59 PM (12 days ago) Jan 28
to MiniZinc
Hi, all

We can simply write a model like 

var 1..4: x;
var 1..4: y;
var 1..4: z;
constraint x < y /\ y < z;
solve satisfy;
output [show(x) ++ " " ++ show(y) ++ " " ++ show(z)];

and get the feasible solutions of x,y,z like below

1 2 3
1 2 4
1 3 4
2 3 4

Now I need to collect the unions of all solutions of specific variables. For examples, the union of x is {1,2}, and the union of y is {2,3} and the union of z is {3,4}. It just like do a SELECT operation on all the solutions.

The real model might be very complex, or the number of all solution might be large. So I cannot compute the unions of the variables after I got all the output of the solutions.

Are there any simple ways to get the unions of the variables?

Thanks in advance

Mohamed H. Ibrahim

unread,
Feb 2, 2026, 1:10:28 PM (7 days ago) Feb 2
to MiniZinc
Hi,

You cold print all solutions and doe the union yourself in a programming language over the output. 
would that work for you?
Reply all
Reply to author
Forward
0 new messages