haz
haz

Reputation: 790

How to quantify over all subsets in MiniZinc

I would like to create a constraint for every subset of a set of integers in MiniZinc, along the lines of this...

constraint forall (S subset C, k in M) (
    % Some constraint over the set S, and integer k
);

I'd also like to use the cardinality of S in the constraint, and C is just a set of integers. Is there a syntax for subset that I can use? (the above model doesn't work).

Upvotes: 1

Views: 604

Answers (1)

Dekker1
Dekker1

Reputation: 5786

Currently there are no generators for arrays/sets of sets; thus there is no viable way of iterating over all subsets of a given set, other than manually listing the power set in a datafile.

In most cases the model can be re-formulated so that these generators are not necessary. Consider, for example, using a variable set instead:

var set of C: S;
% or if you want to declare S in a different way:
% var set of 0..100: S; % Different declaration
% constraint S subset C;
forall (k in M) {
  % some cool constraints
}

This would enable you to make models including constraints stating "There is such a set S, such that all constraints hold."

Upvotes: 2

Related Questions