Skip to content

Commit eebbc1b

Browse files
committed
Add support for fzn_sliding_among constraints. These are now in the minizinc standard library and replace the previous Gecode-specific among_seq constraints.
1 parent 4f9603d commit eebbc1b

File tree

4 files changed

+27
-11
lines changed

4 files changed

+27
-11
lines changed

changelog.in

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,15 @@ Date: 2020-??-??
6969
[DESCRIPTION]
7070
Let's see.
7171

72+
[ENTRY]
73+
Module: flatzinc
74+
What: change
75+
Rank: minor
76+
[DESCRIPTION]
77+
Add support for fzn_sliding_among constraints. These are now in the
78+
minizinc standard library and replace the previous Gecode-specific
79+
among_seq constraints.
80+
7281
[ENTRY]
7382
Module: flatzinc
7483
What: change
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
% Every subsequence of x of length l has at least m and at most occurrences
2+
% of the value b
3+
predicate gecode_among_seq_bool(array[int] of var bool: x, bool: b,
4+
int: l, int: m, int: n);
5+
6+
predicate fzn_sliding_among_bool(int: low, int: up, int: l, array [int] of var bool: x, bool: b) =
7+
gecode_among_seq_bool(x, b, l, low, up);
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
% Every subsequence of x of length l has at least m and at most occurrences
2+
% of the values in S
3+
predicate gecode_among_seq_int(array[int] of var int: x, set of int: S,
4+
int: l, int: m, int: n);
5+
6+
predicate fzn_sliding_among_int(int: low, int: up, int: l, array [int] of var int: x, set of int: S) =
7+
gecode_among_seq_int(x, S, l, low, up);

gecode/flatzinc/mznlib/gecode.mzn

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -115,28 +115,21 @@ predicate gecode_array_set_element_intersect_in(var set of int: x,
115115
array[int] of var set of int: y,
116116
var set of int: z, set of int: u);
117117

118-
% Every subsequence of x of length l has at least m and at most occurrences
119-
% of the values in S
120-
predicate gecode_among_seq_int(array[int] of var int: x, set of int: S,
121-
int: l, int: m, int: n);
122-
123-
% Every subsequence of x of length l has at least m and at most occurrences
124-
% of the value b
125-
predicate gecode_among_seq_bool(array[int] of var bool: x, bool: b,
126-
int: l, int: m, int: n);
118+
include "sliding_among.mzn";
127119

128120
/** @group gecode.constraints
129121
Every subsequence of \a x of length \a l has at least \a m and at most \a n occurrences
130122
of the values in \a S
131123
*/
132124
predicate among_seq(array[int] of var int: x, set of int: S,
133-
int: l, int: m, int: n) = gecode_among_seq_int(x,S,l,m,n);
125+
int: l, int: m, int: n) = sliding_among(m, n, l, x, S);
126+
134127
/** @group gecode.constraints
135128
Every subsequence of \a x of length \a l has at least \a m and at most \a n occurrences
136129
of the value \a b
137130
*/
138131
predicate among_seq(array[int] of var bool: x, bool: b,
139-
int: l, int: m, int: n) = gecode_among_seq_bool(x,b,l,m,n);
132+
int: l, int: m, int: n) = sliding_among(m, n, l, x, b);
140133

141134
% Circuit constraints
142135
predicate gecode_circuit_cost_array(array[int] of int: c,

0 commit comments

Comments
 (0)