Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
4899ea7
Expose missing native propagators through MiniZinc and FlatZinc
zayenz Oct 10, 2026
55ac4f2
Align nooverlap index validation and document public native bindings
zayenz Oct 10, 2026
374dabe
Complete native API coverage on the updated inter-distance base
zayenz Oct 10, 2026
85dd5e2
Preserve standard product behavior in non-root contexts
zayenz Oct 10, 2026
c1e34cf
Remove change-specific MiniZinc audit document
zayenz Oct 10, 2026
ed4223d
Bound FlatZinc divmod results before native posting
zayenz Oct 10, 2026
fdec18d
Infer MiniZinc divmod result domains before flattening
zayenz Oct 10, 2026
1521f47
Regenerate configure for rounding-aware float compilation
zayenz Oct 10, 2026
4234d6d
Keep compiler rounding policy unchanged in registry update
zayenz Oct 10, 2026
2159bc9
Round fixed-base float power bounds explicitly with MPFR
zayenz Oct 10, 2026
e30fd4c
Document Gecode MiniZinc predicate contracts
zayenz Oct 10, 2026
27b84bb
Keep constraint implementation comments focused on behavior
zayenz Oct 10, 2026
c55d360
Format MiniZinc registry declarations and predicate bodies
zayenz Oct 10, 2026
ce7f210
Preserve include order in the formatted solver hook
zayenz Oct 10, 2026
26fd648
Keep standard MiniZinc globals in the standard library
zayenz Oct 11, 2026
0ed8936
Give native MiniZinc extensions modelling interfaces
zayenz Oct 11, 2026
58378d1
Describe the revised MiniZinc library scope
zayenz Oct 11, 2026
f8a3b7c
Indent multiline MiniZinc conditional headers
zayenz Oct 11, 2026
1937782
Align split conditions after the MiniZinc if keyword
zayenz Oct 11, 2026
c7a9235
Trim redundant MiniZinc extensions and handle empty set sequences
zayenz Oct 12, 2026
9bcef8a
Use the float harness for exact fixed-base power examples
Oct 12, 2026
f70f5f9
Simplify MiniZinc hooks and native registry posters
Oct 12, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -1157,6 +1157,7 @@ FLATZINCTESTSRC0 = \
test/flatzinc/bugfix_r7854.cpp \
test/flatzinc/empty_domain_1.cpp \
test/flatzinc/empty_domain_2.cpp \
test/flatzinc/native-registry.cpp \
test/flatzinc/int_set_as_type1.cpp \
test/flatzinc/int_set_as_type2.cpp \
test/flatzinc/issue166.cpp \
Expand Down
21 changes: 21 additions & 0 deletions changelog.in
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,27 @@ Date: unreleased
[DESCRIPTION]
This is the development changelog for the next Gecode release.

[ENTRY]
Module: flatzinc
What: new
Rank: major
[DESCRIPTION]
Use standard MiniZinc FlatZinc hooks for native conditionals, count inequalities,
nondeterministic regular, and optional distinctness and scheduling. Expose
additional arithmetic, distance, rectangle, and set constraints through
documented modelling predicates with typed FlatZinc bindings. Add annotations
for basic, advanced, and combined propagation algorithms, and minimum-distance
actor organization.

[ENTRY]
Module: float
What: bug
Rank: minor
[DESCRIPTION]
Keep exact fixed-base power and logarithm solutions using explicitly rounded
MPFR bounds, handle base-one powers, and remove an invalid shared-variable
shortcut.

[ENTRY]

Module: int
Expand Down
1 change: 1 addition & 0 deletions cmake/GecodeSources.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,7 @@ set(GECODE_TEST_SOURCES
test/flatzinc/eq20.cpp
test/flatzinc/factory_planning_instance.cpp
test/flatzinc/golomb.cpp
test/flatzinc/native-registry.cpp
test/flatzinc/int_set_as_type1.cpp
test/flatzinc/int_set_as_type2.cpp
test/flatzinc/issue166.cpp
Expand Down
31 changes: 20 additions & 11 deletions gecode/flatzinc/flatzinc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2647,19 +2647,28 @@ namespace Gecode { namespace FlatZinc {
#endif
IntPropLevel
FlatZincSpace::ann2ipl(AST::Node* ann) {
int ipl = IPL_DEF;
if (ann) {
if (ann->hasAtom("val") || ann->hasAtom("value_propagation"))
return IPL_VAL;
if (ann->hasAtom("domain") || ann->hasAtom("domain_propagation"))
return IPL_DOM;
if (ann->hasAtom("bounds") ||
ann->hasAtom("bounds_propagation") ||
ann->hasAtom("boundsR") ||
ann->hasAtom("boundsD") ||
ann->hasAtom("boundsZ"))
return IPL_BND;
}
return IPL_DEF;
ipl = IPL_VAL;
else if (ann->hasAtom("domain") || ann->hasAtom("domain_propagation"))
ipl = IPL_DOM;
else if (ann->hasAtom("bounds") ||
ann->hasAtom("bounds_propagation") ||
ann->hasAtom("boundsR") ||
ann->hasAtom("boundsD") ||
ann->hasAtom("boundsZ"))
ipl = IPL_BND;
if (ann->hasAtom("gecode_full_propagation"))
ipl |= IPL_FULL;
else {
if (ann->hasAtom("gecode_basic_propagation"))
ipl |= IPL_BASIC;
if (ann->hasAtom("gecode_advanced_propagation"))
ipl |= IPL_ADVANCED;
}
}
return static_cast<IntPropLevel>(ipl);
}

DFA
Expand Down
62 changes: 62 additions & 0 deletions gecode/flatzinc/mznlib/fzn_all_different_int_opt.mzn
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
%
% Main authors:
% Mikael Zayenz Lagerkvist <lagerkvist@gecode.dev>
%
% Copyright:
% Mikael Zayenz Lagerkvist, 2026
%
% This file is part of Gecode, the generic constraint
% development environment:
% http://www.gecode.dev
%
% Permission is hereby granted, free of charge, to any person obtaining
% a copy of this software and associated documentation files (the
% "Software"), to deal in the Software without restriction, including
% without limitation the rights to use, copy, modify, merge, publish,
% distribute, sublicense, and/or sell copies of the Software, and to
% permit persons to whom the Software is furnished to do so, subject to
% the following conditions:
%
% The above copyright notice and this permission notice shall be
% included in all copies or substantial portions of the Software.
%
% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
% EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
% MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
% NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
% LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
% OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
% WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
%
%

predicate gecode_all_different_optional(
array[int] of var int: x,
array[int] of var bool: present,
);

predicate fzn_all_different_int_opt(array[int] of var opt int: xs) =
if length(xs) = 0 then
true
else
% Fixed absent values have no deopt value; their integer is ignored.
gecode_all_different_optional(
[if is_fixed(x) /\ absent(fix(x)) then 0 else deopt(x) endif | x in xs],
[occurs(x) | x in xs],
)
endif;

% Reification has no native optional-distinct propagator.
predicate fzn_all_different_int_opt_reif(
array[int] of var opt int: xs,
var bool: b,
) =
let {
array[index_set(xs)] of var int: values = array1d(
index_set(xs),
[if is_fixed(x) /\ absent(fix(x)) then 0 else deopt(x) endif | x in xs],
);
} in
b <-> forall (i, j in index_set(xs) where i < j) (
(occurs(xs[i]) /\ occurs(xs[j])) -> values[i] != values[j]
);
46 changes: 46 additions & 0 deletions gecode/flatzinc/mznlib/fzn_all_equal_int_reif.mzn
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
%
% Main authors:
% Mikael Zayenz Lagerkvist <lagerkvist@gecode.dev>
%
% Copyright:
% Mikael Zayenz Lagerkvist, 2026
%
% This file is part of Gecode, the generic constraint
% development environment:
% http://www.gecode.dev
%
% Permission is hereby granted, free of charge, to any person obtaining
% a copy of this software and associated documentation files (the
% "Software"), to deal in the Software without restriction, including
% without limitation the rights to use, copy, modify, merge, publish,
% distribute, sublicense, and/or sell copies of the Software, and to
% permit persons to whom the Software is furnished to do so, subject to
% the following conditions:
%
% The above copyright notice and this permission notice shall be
% included in all copies or substantial portions of the Software.
%
% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
% EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
% MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
% NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
% LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
% OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
% WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
%
%

predicate gecode_not_all_equal_int(array[int] of var int: xs);

predicate fzn_all_equal_int_reif(array[int] of var int: xs, var bool: b) =
if is_fixed(b) /\ not fix(b) then
gecode_not_all_equal_int(xs)
else
b <-> (if length(xs) = 0 then
true
else
forall (i in index_set(xs)) (
xs[i] = xs[min(index_set(xs))]
)
endif)
endif;
59 changes: 59 additions & 0 deletions gecode/flatzinc/mznlib/fzn_alldifferent_except.mzn
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
%
% Main authors:
% Mikael Zayenz Lagerkvist <lagerkvist@gecode.dev>
%
% Copyright:
% Mikael Zayenz Lagerkvist, 2026
%
% This file is part of Gecode, the generic constraint
% development environment:
% http://www.gecode.dev
%
% Permission is hereby granted, free of charge, to any person obtaining
% a copy of this software and associated documentation files (the
% "Software"), to deal in the Software without restriction, including
% without limitation the rights to use, copy, modify, merge, publish,
% distribute, sublicense, and/or sell copies of the Software, and to
% permit persons to whom the Software is furnished to do so, subject to
% the following conditions:
%
% The above copyright notice and this permission notice shall be
% included in all copies or substantial portions of the Software.
%
% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
% EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
% MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
% NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
% LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
% OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
% WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
%
%

include "global_cardinality_low_up.mzn";
include "fzn_all_different_int.mzn";

predicate gecode_all_different_except(array[int] of var int: x, int: except_value);

predicate fzn_alldifferent_except(array[int] of var int: xs, set of int: except) =
if length(xs) = 0 then
true
elseif card(except) = 1 then
if min(except) < lb_array(xs) \/ min(except) > ub_array(xs) then
% Drop irrelevant exceptions before FlatZinc checks integer limits.
fzn_all_different_int(xs)
else
gecode_all_different_except(xs, min(except))
endif
elseif forall (i in index_set(xs)) (has_bounds(xs[i])) then
% Native distinct supports one exception; retain the standard translation
% for larger exception sets.
let {
set of int: values = dom_array(xs) diff except;
} in
global_cardinality(xs, set2array(values), [0 | i in values], [1 | i in values])
else
forall (i, j in index_set(xs) where i < j) (
(xs[i] in except /\ xs[j] in except) \/ xs[i] != xs[j]
)
endif;
55 changes: 35 additions & 20 deletions gecode/flatzinc/mznlib/fzn_alldifferent_except_0.mzn
Original file line number Diff line number Diff line change
@@ -1,24 +1,39 @@
include "global_cardinality_low_up_closed.mzn";
%
% Main authors:
% Mikael Zayenz Lagerkvist <lagerkvist@gecode.dev>
%
% Copyright:
% Mikael Zayenz Lagerkvist, 2026
%
% This file is part of Gecode, the generic constraint
% development environment:
% http://www.gecode.dev
%
% Permission is hereby granted, free of charge, to any person obtaining
% a copy of this software and associated documentation files (the
% "Software"), to deal in the Software without restriction, including
% without limitation the rights to use, copy, modify, merge, publish,
% distribute, sublicense, and/or sell copies of the Software, and to
% permit persons to whom the Software is furnished to do so, subject to
% the following conditions:
%
% The above copyright notice and this permission notice shall be
% included in all copies or substantial portions of the Software.
%
% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
% EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
% MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
% NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
% LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
% OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
% WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
%
%

/** @group globals.alldifferent
include "fzn_alldifferent_except.mzn";

/** @group globals.alldifferent
Constrain the array of integers \a vs to be all different except those
elements that are assigned the value 0.
*/
predicate fzn_alldifferent_except_0(array[int] of var int: vs) =
if length(vs)==0 then true
else
let {
int: l = lb_array(vs);
int: u = ub_array(vs);
} in
if l != -infinity /\ u != infinity then
global_cardinality_low_up_closed(vs, [i | i in l..u],
[0 | i in l..u],
[if i==0 then length(vs) else 1 endif | i in l..u]
)
else
forall(i, j in index_set(vs) where i < j) (
(vs[i] != 0 /\ vs[j] != 0) -> vs[i] != vs[j]
)
endif
endif;
predicate fzn_alldifferent_except_0(array[int] of var int: vs) = fzn_alldifferent_except(vs, {0});
47 changes: 47 additions & 0 deletions gecode/flatzinc/mznlib/fzn_array_set_intersect.mzn
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
%
% Main authors:
% Mikael Zayenz Lagerkvist <lagerkvist@gecode.dev>
%
% Copyright:
% Mikael Zayenz Lagerkvist, 2026
%
% This file is part of Gecode, the generic constraint
% development environment:
% http://www.gecode.dev
%
% Permission is hereby granted, free of charge, to any person obtaining
% a copy of this software and associated documentation files (the
% "Software"), to deal in the Software without restriction, including
% without limitation the rights to use, copy, modify, merge, publish,
% distribute, sublicense, and/or sell copies of the Software, and to
% permit persons to whom the Software is furnished to do so, subject to
% the following conditions:
%
% The above copyright notice and this permission notice shall be
% included in all copies or substantial portions of the Software.
%
% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
% EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
% MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
% NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
% LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
% OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
% WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
%
%

predicate gecode_array_set_intersect(
array[int] of var set of int: x,
var set of int: y,
);

% The intersection of an empty array is undefined in the standard library.
predicate fzn_array_set_intersect(
array[int] of var set of int: x,
var set of int: y,
) =
if length(x) = 0 then
false
else
gecode_array_set_intersect(x, y)
endif;
Loading
Loading