diff --git a/.github/ci/generated-source-freshness.sh b/.github/ci/generated-source-freshness.sh index 58e6d37482..d85f577366 100755 --- a/.github/ci/generated-source-freshness.sh +++ b/.github/ci/generated-source-freshness.sh @@ -171,9 +171,17 @@ generated_files=( gecode/flatzinc/lexer.yy.cpp ) +# Flex builds number the #line directives that name the output file itself +# differently: Debian's count one line further than Homebrew's. Those numbers +# carry no meaning, so the comparison ignores them. +without_output_line_numbers() { + sed -E 's|^#line [0-9]+ "gecode/flatzinc/lexer\.yy\.cpp"$|#line "gecode/flatzinc/lexer.yy.cpp"|' "$1" +} + stale=0 for file in "${generated_files[@]}"; do - if cmp -s "$repo_root/$file" "$source_copy/$file"; then + if cmp -s <(without_output_line_numbers "$repo_root/$file") \ + <(without_output_line_numbers "$source_copy/$file"); then continue fi if [ "$mode" = update ]; then diff --git a/.github/ci/qt-gist-consumer-smoke.sh b/.github/ci/qt-gist-consumer-smoke.sh index 37b43d18d8..fc4fc23fde 100644 --- a/.github/ci/qt-gist-consumer-smoke.sh +++ b/.github/ci/qt-gist-consumer-smoke.sh @@ -63,12 +63,12 @@ cat > "$work/main.cpp" <<'EOF' #include #ifdef GECODE_HAS_SET_VARS -using SetCompare = std::string (*)(std::string, Gecode::SetVar, Gecode::SetVar); +using SetCompare = std::string (*)(const std::string&, Gecode::SetVar, Gecode::SetVar); SetCompare set_compare = &Gecode::Gist::Comparator::compare; #endif #ifdef GECODE_HAS_FLOAT_VARS -using FloatCompare = std::string (*)(std::string, Gecode::FloatVar, Gecode::FloatVar); +using FloatCompare = std::string (*)(const std::string&, Gecode::FloatVar, Gecode::FloatVar); FloatCompare float_compare = &Gecode::Gist::Comparator::compare; #endif diff --git a/.github/ci/qt5-gist-consumer-smoke.sh b/.github/ci/qt5-gist-consumer-smoke.sh index 9978dc9c60..bd3a3dcaa0 100644 --- a/.github/ci/qt5-gist-consumer-smoke.sh +++ b/.github/ci/qt5-gist-consumer-smoke.sh @@ -53,12 +53,12 @@ cat > "$work/main.cpp" <<'EOF' #include #ifdef GECODE_HAS_SET_VARS -using SetCompare = std::string (*)(std::string, Gecode::SetVar, Gecode::SetVar); +using SetCompare = std::string (*)(const std::string&, Gecode::SetVar, Gecode::SetVar); SetCompare set_compare = &Gecode::Gist::Comparator::compare; #endif #ifdef GECODE_HAS_FLOAT_VARS -using FloatCompare = std::string (*)(std::string, Gecode::FloatVar, Gecode::FloatVar); +using FloatCompare = std::string (*)(const std::string&, Gecode::FloatVar, Gecode::FloatVar); FloatCompare float_compare = &Gecode::Gist::Comparator::compare; #endif diff --git a/changelog.in b/changelog.in index 86eb6924c7..c6aa06e70c 100644 --- a/changelog.in +++ b/changelog.in @@ -76,6 +76,146 @@ Date: unreleased This release contains breaking changes. See the entries below for the changes downstream code needs. +[ENTRY] +Module: kernel +What: change +Rank: minor +[DESCRIPTION] +The Rnd constructor taking a seed is explicit. Code that passes a number where +a Rnd is expected, such as INT_VAR_RND(1U), must now write Rnd(1U). The implicit +conversion also accepted floating-point values, which hid the bug in +IntBoolVarBranch fixed in this release. + +[ENTRY] +Module: flatzinc +What: bug +Rank: minor +[DESCRIPTION] +IntBoolVarBranch keeps its decay factor, which was discarded so that AFC and +action used a decay of 1. The default branchers follow the -decay option, which +only search annotations honoured before. + +[ENTRY] +Module: flatzinc +What: bug +Rank: minor +[DESCRIPTION] +Choices from set_search and set_default_search print the relations of their +value selection. Before, set_search printed none, and set_default_search printed +"in" and "not in" the wrong way round for outdomain_min and outdomain_max. + +[ENTRY] +Module: flatzinc +What: bug +Rank: minor +[DESCRIPTION] +Searching for an extension to introduced variables follows the default search +annotations after the space has been cloned, and no longer leaks the random +number generator of a random selection. + +[ENTRY] +Module: int +What: bug +Rank: minor +[DESCRIPTION] +The assign overloads for integer and Boolean variables with tie-breaking +variable selection link. The Boolean overload now takes BoolBranchFilter and +BoolVarValPrint arguments, as the overload without tie-breaking does. + +[ENTRY] +Module: int +What: bug +Rank: minor +[DESCRIPTION] +Assigning integer and Boolean variables follows the variable selection, which +was ignored unless a tie-breaking selection was also in effect. Models that +pass a selection to assign, such as the job-shop example, now assign variables +in that order and can find different solutions first. + +[ENTRY] +Module: set +What: bug +Rank: minor +[DESCRIPTION] +Assigning set variables follows the variable selection, which was ignored +unless a tie-breaking selection was also in effect. + +[ENTRY] +Module: float +What: bug +Rank: minor +[DESCRIPTION] +Assigning float variables follows the variable selection, which was ignored +unless a tie-breaking selection was also in effect. + +[ENTRY] +Module: int +What: bug +Rank: minor +[DESCRIPTION] +values_reflect for the domain of an integer variable links. + +[ENTRY] +Module: set +What: bug +Rank: minor +[DESCRIPTION] +The default constructors of SetVarGlbValues, SetVarLubValues, and +SetVarUnknownValues link. + +[ENTRY] +Module: float +What: bug +Rank: minor +[DESCRIPTION] +Constructing FloatValArgs from an initializer list links. + +[ENTRY] +Module: search +What: bug +Rank: minor +[DESCRIPTION] +The declaration of the pbs engine builder takes the engine as a template +argument, as its definition does. Calling it with only the space type failed +to link and is now a compile error. + +[ENTRY] +Module: int +What: bug +Rank: minor +[DESCRIPTION] +Multi-dimensional bin_packing throws Int::OutOfLimits for fewer than one +dimension. It divided by zero for zero dimensions, and a negative number of +dimensions now gives Int::OutOfLimits instead of Int::ArgumentSizeMismatch. + +[ENTRY] +Module: int +What: bug +Rank: minor +[DESCRIPTION] +Two-dimensional element throws Int::TooFewArguments for an empty array, as +one-dimensional element does, instead of Int::VariableEmptyDomain from an +internal variable or Int::ArgumentSizeMismatch. It throws +Int::ArgumentSizeMismatch for a width or height that is not positive and when +the product overflows, where it could post a failing or wrong constraint. + +[ENTRY] +Module: set +What: bug +Rank: minor +[DESCRIPTION] +Two-dimensional element throws Set::ArgumentSizeMismatch for a width or height +that is not positive and when the product overflows, where it could post a +failing or wrong constraint. + +[ENTRY] +Module: set +What: documentation +Rank: minor +[DESCRIPTION] +Document the exceptions that sequence and element with an integer index throw +for an empty array and for sets outside the limits. + [ENTRY] Module: kernel What: change @@ -150,6 +290,16 @@ constructor and its bool conversion. Support::BitSetData::operator== is now defaulted and takes its argument by const reference. Int::LDSB::Literal now also has ==, !=, <=, >, and >=. +[ENTRY] +Module: kernel +What: bug +Rank: minor +[DESCRIPTION] +Fix shrinking with Space::realloc and Region::realloc. The size of the removed +tail was computed with the wrong sign, so shrinking destroyed objects past the +block and handed memory outside it to the space. Space::realloc for pointers +also used the size of the pointed-to type, which lost pointers on growing. + [ENTRY] Module: int What: bug @@ -171,7 +321,7 @@ GECODE_VERSION_NUMBER instead, or Gecode_VERSION from the CMake package. [MORE] CMake now generates config.hpp with configure_file. Feature macros that were defined as empty, such as GECODE_HAS_FLOAT_VARS, are now defined as 1; tests -with #ifdef behave as before. +of whether they are defined behave as before. [ENTRY] Module: support diff --git a/cmake/GecodeSources.cmake b/cmake/GecodeSources.cmake index 8b87e07b39..0a82bb1979 100644 --- a/cmake/GecodeSources.cmake +++ b/cmake/GecodeSources.cmake @@ -316,6 +316,7 @@ set(GECODE_TEST_SOURCES test/flatzinc/blocksworld_instance_1.cpp test/flatzinc/blocksworld_instance_2.cpp test/flatzinc/bool_clause.cpp + test/flatzinc/branching.cpp test/flatzinc/bug232.cpp test/flatzinc/bug319.cpp test/flatzinc/bugfix_r6746.cpp diff --git a/docs/cmake-build.md b/docs/cmake-build.md index c75aa025c4..a453d15d2a 100644 --- a/docs/cmake-build.md +++ b/docs/cmake-build.md @@ -245,6 +245,13 @@ cmake -S . -B build/asan-ubsan \ cmake --build build/asan-ubsan --target check ``` +On macOS, `std::thread` stacks are 512 KiB, while the main thread has 8 MiB, and +the check targets run `gecode-test` on worker threads. In a Debug build with +AddressSanitizer, forced inlining gives some propagators a frame of about +400 KiB, so a test can overflow its worker stack. This is a limit of that build, +not unbounded recursion. Use an optimized sanitizer build, or run +`gecode-test -threads 1` on the main thread. + ## Using Gecode From Other CMake Projects ### Recommended aggregate target diff --git a/examples/sudoku-instances.hh b/examples/sudoku-instances.hh index 958ea683b9..950554c381 100644 --- a/examples/sudoku-instances.hh +++ b/examples/sudoku-instances.hh @@ -1799,8 +1799,6 @@ namespace { * 1 to 36. A file may contain several puzzles, one after the other; * select one with \c -param \c instance=K. See Instance::Spec for the * spec language. - * - * \relates Sudoku */ const char* instance_spec = R"(format sudoku diff --git a/gecode/flatzinc/branch.hpp b/gecode/flatzinc/branch.hpp index a2d6f99ee4..828f361c2a 100644 --- a/gecode/flatzinc/branch.hpp +++ b/gecode/flatzinc/branch.hpp @@ -334,7 +334,7 @@ namespace Gecode { namespace FlatZinc { template forceinline - IntBoolBrancher::IntBoolBrancher(Space& home, IntBoolBrancher& b) + IntBoolBrancher::IntBoolBrancher(Space& home, IntBoolBrancher& b) : IntBoolBrancherBase(home, b), merit(home, b.merit) {} template diff --git a/gecode/flatzinc/flatzinc.cpp b/gecode/flatzinc/flatzinc.cpp index 461c879b2c..c797bb5ef2 100644 --- a/gecode/flatzinc/flatzinc.cpp +++ b/gecode/flatzinc/flatzinc.cpp @@ -133,9 +133,22 @@ namespace Gecode { namespace FlatZinc { float_varsel(std::move(float_varsel0)), float_valsel(std::move(float_valsel0)) #endif { + home.notice(*this, AP_DISPOSE); } /// Copy constructor - AuxVarBrancher(Space& home, AuxVarBrancher& b) : Brancher(home, b), done(b.done) {} + AuxVarBrancher(Space& home, AuxVarBrancher& b) + : Brancher(home, b), done(b.done), int_varsel(b.int_varsel), int_valsel(b.int_valsel), + bool_varsel(b.bool_varsel), bool_valsel(b.bool_valsel) +#ifdef GECODE_HAS_SET_VARS + , + set_varsel(b.set_varsel), set_valsel(b.set_valsel) +#endif +#ifdef GECODE_HAS_FLOAT_VARS + , + float_varsel(b.float_varsel), float_valsel(b.float_valsel) +#endif + { + } /// %Choice that only signals failure or success class Choice : public Gecode::Choice { @@ -269,7 +282,21 @@ namespace Gecode { namespace FlatZinc { } /// Delete brancher and return its size size_t - dispose(Space&) override { + dispose(Space& home) override { + home.ignore(*this, AP_DISPOSE); + int_varsel.~TieBreak(); + int_valsel.~IntValBranch(); + bool_varsel.~TieBreak(); + bool_valsel.~BoolValBranch(); +#ifdef GECODE_HAS_SET_VARS + set_varsel.~SetVarBranch(); + set_valsel.~SetValBranch(); +#endif +#ifdef GECODE_HAS_FLOAT_VARS + float_varsel.~TieBreak(); + float_valsel.~FloatValBranch(); +#endif + (void)Brancher::dispose(home); return sizeof(*this); } }; @@ -668,7 +695,7 @@ namespace Gecode { namespace FlatZinc { } SetValBranch - annotation_to_set_val_branch(AST::Node* ann, std::string r0, std::string r1, const Rnd& rnd) { + annotation_to_set_val_branch(AST::Node* ann, std::string& r0, std::string& r1, const Rnd& rnd) { (void)rnd; if (AST::Atom* s = dynamic_cast(ann)) { if (s->id == "indomain_min") { @@ -746,7 +773,7 @@ namespace Gecode { namespace FlatZinc { } FloatValBranch - annotation_to_float_val_branch(AST::Node* ann, std::string r0, std::string r1) { + annotation_to_float_val_branch(AST::Node* ann, std::string& r0, std::string& r1) { if (AST::Atom* s = dynamic_cast(ann)) { if (s->id == "indomain_split") { r0 = "<="; @@ -1066,17 +1093,17 @@ namespace Gecode { namespace FlatZinc { std::ostream& err) { double decay = opt.decay(); Rnd rnd = opt.rnd(); - TieBreak def_int_varsel = INT_VAR_AFC_SIZE_MAX(0.99); - IntBoolVarBranch def_intbool_varsel = int_bool_var_afc_size_max(0.99); + TieBreak def_int_varsel = INT_VAR_AFC_SIZE_MAX(decay); + IntBoolVarBranch def_intbool_varsel = int_bool_var_afc_size_max(decay); IntValBranch def_int_valsel = INT_VAL_MIN(); std::string def_int_rel_left = "="; std::string def_int_rel_right = "!="; - TieBreak def_bool_varsel = BOOL_VAR_AFC_MAX(0.99); + TieBreak def_bool_varsel = BOOL_VAR_AFC_MAX(decay); BoolValBranch def_bool_valsel = BOOL_VAL_MIN(); std::string def_bool_rel_left = "="; std::string def_bool_rel_right = "!="; #ifdef GECODE_HAS_SET_VARS - SetVarBranch def_set_varsel = SET_VAR_AFC_SIZE_MAX(0.99); + SetVarBranch def_set_varsel = SET_VAR_AFC_SIZE_MAX(decay); SetValBranch def_set_valsel = SET_VAL_MIN_INC(); std::string def_set_rel_left = "in"; std::string def_set_rel_right = "not in"; diff --git a/gecode/float.hh b/gecode/float.hh index 5f372f150a..26087a6b9a 100644 --- a/gecode/float.hh +++ b/gecode/float.hh @@ -1970,9 +1970,8 @@ namespace Gecode { * * \ingroup TaskModelFloatBranch */ - GECODE_FLOAT_EXPORT void assign(Home home, const FloatVarArgs& x, const FloatVarBranch& vars, - const FloatAssign& vals, FloatBranchFilter bf = nullptr, - FloatVarValPrint vvp = nullptr); + GECODE_FLOAT_EXPORT void assign(Home home, const FloatVarArgs& x, FloatVarBranch vars, const FloatAssign& vals, + FloatBranchFilter bf = nullptr, FloatVarValPrint vvp = nullptr); /** * \brief Assign all \a x with tie-breaking variable selection \a vars and value selection \a vals * diff --git a/gecode/float/arithmetic/min-max.hpp b/gecode/float/arithmetic/min-max.hpp index b38ebeaeb7..afb6fa79a5 100644 --- a/gecode/float/arithmetic/min-max.hpp +++ b/gecode/float/arithmetic/min-max.hpp @@ -180,7 +180,7 @@ namespace Gecode { namespace Float { namespace Arithmetic { template forceinline - NaryMax::NaryMax(Space& home, NaryMax& p) + NaryMax::NaryMax(Space& home, NaryMax& p) : NaryOnePropagator(home, p) {} template diff --git a/gecode/float/arithmetic/sqr-sqrt.hpp b/gecode/float/arithmetic/sqr-sqrt.hpp index 92521bda0a..2713d5a750 100644 --- a/gecode/float/arithmetic/sqr-sqrt.hpp +++ b/gecode/float/arithmetic/sqr-sqrt.hpp @@ -123,7 +123,7 @@ namespace Gecode { namespace Float { namespace Arithmetic { template forceinline - Sqr::Sqr(Space& home, Sqr& p) + Sqr::Sqr(Space& home, Sqr& p) : BinaryPropagator(home, p) {} template diff --git a/gecode/float/array.hpp b/gecode/float/array.hpp index 7c04244b24..0618133a8c 100644 --- a/gecode/float/array.hpp +++ b/gecode/float/array.hpp @@ -56,6 +56,11 @@ namespace Gecode { forceinline FloatValArgs::FloatValArgs(const std::vector& x) : ArgArray(x) {} + + forceinline + FloatValArgs::FloatValArgs(std::initializer_list x) + : ArgArray(x) {} + template forceinline FloatValArgs::FloatValArgs(InputIterator first, InputIterator last) diff --git a/gecode/float/bool/ite.hpp b/gecode/float/bool/ite.hpp index c63b5bd213..3ed0018efb 100644 --- a/gecode/float/bool/ite.hpp +++ b/gecode/float/bool/ite.hpp @@ -46,7 +46,7 @@ namespace Gecode { namespace Float { namespace Bool { template forceinline - Ite::Ite(Space& home, Ite& p) + Ite::Ite(Space& home, Ite& p) : Propagator(home, p) { b.update(home, p.b); x0.update(home, p.x0); diff --git a/gecode/float/branch.cpp b/gecode/float/branch.cpp index f7c39c23c8..bf77f56190 100644 --- a/gecode/float/branch.cpp +++ b/gecode/float/branch.cpp @@ -96,13 +96,14 @@ namespace Gecode { } void - assign(Home home, const FloatVarArgs& x, const FloatVarBranch& vars, const FloatAssign& vals, FloatBranchFilter bf, + assign(Home home, const FloatVarArgs& x, FloatVarBranch vars, const FloatAssign& vals, FloatBranchFilter bf, FloatVarValPrint vvp) { using namespace Float; if (home.failed()) return; + vars.expand(home, x); ViewArray xv(home, x); - ViewSel* vs[1] = {new (home) ViewSelNone(home, vars)}; + ViewSel* vs[1] = {Branch::view_selection(home, vars)}; post_view_value_brancher( home, xv, vs, Branch::value_selection_commit(home, vals), std::move(bf), std::move(vvp)); } @@ -124,7 +125,7 @@ namespace Gecode { vars.d = FLOAT_VAR_NONE(); vars.d.expand(home, x); if (vars.b.select() == FloatVarBranch::SEL_NONE) { - assign(home, x, vars.a, vals, std::move(bf), std::move(vvp)); + assign(home, x, std::move(vars.a), vals, std::move(bf), std::move(vvp)); } else { ViewArray xv(home, x); ValSelCommitBase* vsc = Branch::value_selection_commit(home, vals); diff --git a/gecode/float/rel/lq-le.hpp b/gecode/float/rel/lq-le.hpp index 8679dc2aa6..5fcc1e5a1e 100644 --- a/gecode/float/rel/lq-le.hpp +++ b/gecode/float/rel/lq-le.hpp @@ -58,7 +58,7 @@ namespace Gecode { namespace Float { namespace Rel { template forceinline - Lq::Lq(Space& home, Lq& p) + Lq::Lq(Space& home, Lq& p) : BinaryPropagator(home, p) {} template @@ -101,7 +101,7 @@ namespace Gecode { namespace Float { namespace Rel { template forceinline - Le::Le(Space& home, Le& p) + Le::Le(Space& home, Le& p) : BinaryPropagator(home, p) {} template diff --git a/gecode/int.hh b/gecode/int.hh index b4a61a4036..37ac8b8223 100644 --- a/gecode/int.hh +++ b/gecode/int.hh @@ -1792,8 +1792,10 @@ namespace Gecode { * Throws an exception of type Int::OutOfLimits, if * the integers in \a n exceed the limits in Int::Limits. * - * Throws an exception of type Int::ArgumentSizeMismatch, if - * \f$ w\cdot h\neq|a|\f$. + * Throws an exception of type Int::TooFewArguments, if \a a is empty. + * + * Throws an exception of type Int::ArgumentSizeMismatch, if \a w or + * \a h is not positive or \f$ w\cdot h\neq|a|\f$. */ GECODE_INT_EXPORT void element(Home home, const IntSharedArray& a, IntVar x, int w, IntVar y, int h, IntVar z, IntPropLevel ipl = IPL_DEF); @@ -1807,8 +1809,10 @@ namespace Gecode { * Throws an exception of type Int::OutOfLimits, if * the integers in \a n exceed the limits in Int::Limits. * - * Throws an exception of type Int::ArgumentSizeMismatch, if - * \f$ w\cdot h\neq|a|\f$. + * Throws an exception of type Int::TooFewArguments, if \a a is empty. + * + * Throws an exception of type Int::ArgumentSizeMismatch, if \a w or + * \a h is not positive or \f$ w\cdot h\neq|a|\f$. */ GECODE_INT_EXPORT void element(Home home, const IntSharedArray& a, IntVar x, int xoff, int w, IntVar y, int yoff, int h, IntVar z, IntPropLevel ipl = IPL_DEF); @@ -1821,8 +1825,10 @@ namespace Gecode { * Throws an exception of type Int::OutOfLimits, if * the integers in \a n exceed the limits in Int::Limits. * - * Throws an exception of type Int::ArgumentSizeMismatch, if - * \f$ w\cdot h\neq|a|\f$. + * Throws an exception of type Int::TooFewArguments, if \a a is empty. + * + * Throws an exception of type Int::ArgumentSizeMismatch, if \a w or + * \a h is not positive or \f$ w\cdot h\neq|a|\f$. */ GECODE_INT_EXPORT void element(Home home, const IntSharedArray& a, IntVar x, int w, IntVar y, int h, BoolVar z, IntPropLevel ipl = IPL_DEF); @@ -1836,8 +1842,10 @@ namespace Gecode { * Throws an exception of type Int::OutOfLimits, if * the integers in \a n exceed the limits in Int::Limits. * - * Throws an exception of type Int::ArgumentSizeMismatch, if - * \f$ w\cdot h\neq|a|\f$. + * Throws an exception of type Int::TooFewArguments, if \a a is empty. + * + * Throws an exception of type Int::ArgumentSizeMismatch, if \a w or + * \a h is not positive or \f$ w\cdot h\neq|a|\f$. */ GECODE_INT_EXPORT void element(Home home, const IntSharedArray& a, IntVar x, int xoff, int w, IntVar y, int yoff, int h, BoolVar z, IntPropLevel ipl = IPL_DEF); @@ -1853,8 +1861,10 @@ namespace Gecode { * Throws an exception of type Int::OutOfLimits, if * the integers in \a n exceed the limits in Int::Limits. * - * Throws an exception of type Int::ArgumentSizeMismatch, if - * \f$ w\cdot h\neq|a|\f$. + * Throws an exception of type Int::TooFewArguments, if \a a is empty. + * + * Throws an exception of type Int::ArgumentSizeMismatch, if \a w or + * \a h is not positive or \f$ w\cdot h\neq|a|\f$. */ GECODE_INT_EXPORT void element(Home home, const IntVarArgs& a, IntVar x, int w, IntVar y, int h, IntVar z, IntPropLevel ipl = IPL_DEF); @@ -1871,8 +1881,10 @@ namespace Gecode { * Throws an exception of type Int::OutOfLimits, if * the integers in \a n exceed the limits in Int::Limits. * - * Throws an exception of type Int::ArgumentSizeMismatch, if - * \f$ w\cdot h\neq|a|\f$. + * Throws an exception of type Int::TooFewArguments, if \a a is empty. + * + * Throws an exception of type Int::ArgumentSizeMismatch, if \a w or + * \a h is not positive or \f$ w\cdot h\neq|a|\f$. */ GECODE_INT_EXPORT void element(Home home, const IntVarArgs& a, IntVar x, int xoff, int w, IntVar y, int yoff, int h, IntVar z, IntPropLevel ipl = IPL_DEF); @@ -1885,8 +1897,10 @@ namespace Gecode { * Throws an exception of type Int::OutOfLimits, if * the integers in \a n exceed the limits in Int::Limits. * - * Throws an exception of type Int::ArgumentSizeMismatch, if - * \f$ w\cdot h\neq|a|\f$. + * Throws an exception of type Int::TooFewArguments, if \a a is empty. + * + * Throws an exception of type Int::ArgumentSizeMismatch, if \a w or + * \a h is not positive or \f$ w\cdot h\neq|a|\f$. */ GECODE_INT_EXPORT void element(Home home, const BoolVarArgs& a, IntVar x, int w, IntVar y, int h, BoolVar z, IntPropLevel ipl = IPL_DEF); @@ -1900,8 +1914,10 @@ namespace Gecode { * Throws an exception of type Int::OutOfLimits, if * the integers in \a n exceed the limits in Int::Limits. * - * Throws an exception of type Int::ArgumentSizeMismatch, if - * \f$ w\cdot h\neq|a|\f$. + * Throws an exception of type Int::TooFewArguments, if \a a is empty. + * + * Throws an exception of type Int::ArgumentSizeMismatch, if \a w or + * \a h is not positive or \f$ w\cdot h\neq|a|\f$. */ GECODE_INT_EXPORT void element(Home home, const BoolVarArgs& a, IntVar x, int xoff, int w, IntVar y, int yoff, int h, BoolVar z, IntPropLevel ipl = IPL_DEF); @@ -3728,7 +3744,7 @@ namespace Gecode { */ GECODE_INT_EXPORT void bin_packing(Home home, const IntVarArgs& l, const IntVarArgs& b, const IntArgs& s, IntPropLevel ipl = IPL_DEF); - /* \brief Post propagator for multi-dimensional bin packing + /** \brief Post propagator for multi-dimensional bin packing * * In the following \a n refers to the number of items and \a m * refers to the number of bins. @@ -3770,7 +3786,8 @@ namespace Gecode { * is violated: \f$|b|=n\f$, \f$|l|=m\cdot d\f$, \f$|s|=n\cdot d\f$, * and \f$|c|=d\f$. * - Of type Int::ArgumentSame if \a l and \a b share unassigned variables. - * - Of type Int::OutOfLimits if \a s or \a c contains a negative number. + * - Of type Int::OutOfLimits if \a d is less than one or exceeds + * Int::Limits::max, or if \a s or \a c contains a negative number. * * \ingroup TaskModelIntBinPacking */ @@ -5813,7 +5830,7 @@ namespace Gecode { * * \ingroup TaskModelIntBranch */ - GECODE_INT_EXPORT void assign(Home home, const IntVarArgs& x, const IntVarBranch& vars, const IntAssign& vals, + GECODE_INT_EXPORT void assign(Home home, const IntVarArgs& x, IntVarBranch vars, const IntAssign& vals, IntBranchFilter bf = nullptr, IntVarValPrint vvp = nullptr); /** * \brief Assign all \a x with tie-breaking variable selection \a vars and value selection \a vals @@ -5833,7 +5850,7 @@ namespace Gecode { * * \ingroup TaskModelIntBranch */ - GECODE_INT_EXPORT void assign(Home home, const BoolVarArgs& x, const BoolVarBranch& vars, const BoolAssign& vals, + GECODE_INT_EXPORT void assign(Home home, const BoolVarArgs& x, BoolVarBranch vars, const BoolAssign& vals, BoolBranchFilter bf = nullptr, BoolVarValPrint vvp = nullptr); /** * \brief Assign all \a x with tie-breaking variable selection \a vars and value selection \a vals @@ -5841,7 +5858,7 @@ namespace Gecode { * \ingroup TaskModelIntBranch */ GECODE_INT_EXPORT void assign(Home home, const BoolVarArgs& x, TieBreak vars, const BoolAssign& vals, - IntBranchFilter bf = nullptr, IntVarValPrint vvp = nullptr); + BoolBranchFilter bf = nullptr, BoolVarValPrint vvp = nullptr); /** * \brief Assign \a x with value selection \a vals * diff --git a/gecode/int/arithmetic/abs.hpp b/gecode/int/arithmetic/abs.hpp index fbabae2598..614eed8e87 100644 --- a/gecode/int/arithmetic/abs.hpp +++ b/gecode/int/arithmetic/abs.hpp @@ -110,7 +110,7 @@ namespace Gecode { namespace Int { namespace Arithmetic { template forceinline - AbsBnd::AbsBnd(Space& home, AbsBnd& p) + AbsBnd::AbsBnd(Space& home, AbsBnd& p) : BinaryPropagator(home, p) {} template @@ -163,7 +163,7 @@ namespace Gecode { namespace Int { namespace Arithmetic { template forceinline - AbsDom::AbsDom(Space& home, AbsDom& p) + AbsDom::AbsDom(Space& home, AbsDom& p) : BinaryPropagator(home, p) {} template diff --git a/gecode/int/arithmetic/max.hpp b/gecode/int/arithmetic/max.hpp index 198277adf6..e1a480e11d 100644 --- a/gecode/int/arithmetic/max.hpp +++ b/gecode/int/arithmetic/max.hpp @@ -95,7 +95,7 @@ namespace Gecode { namespace Int { namespace Arithmetic { template forceinline - MaxBnd::MaxBnd(Space& home, MaxBnd& p) + MaxBnd::MaxBnd(Space& home, MaxBnd& p) : TernaryPropagator(home, p) {} template @@ -159,7 +159,7 @@ namespace Gecode { namespace Int { namespace Arithmetic { template forceinline - NaryMaxBnd::NaryMaxBnd(Space& home, NaryMaxBnd& p) + NaryMaxBnd::NaryMaxBnd(Space& home, NaryMaxBnd& p) : NaryOnePropagator(home, p) {} template @@ -253,7 +253,7 @@ namespace Gecode { namespace Int { namespace Arithmetic { template forceinline - MaxDom::MaxDom(Space& home, MaxDom& p) + MaxDom::MaxDom(Space& home, MaxDom& p) : TernaryPropagator(home, p) {} template @@ -339,7 +339,7 @@ namespace Gecode { namespace Int { namespace Arithmetic { template forceinline - NaryMaxDom::NaryMaxDom(Space& home, NaryMaxDom& p) + NaryMaxDom::NaryMaxDom(Space& home, NaryMaxDom& p) : NaryOnePropagator(home, p) {} template diff --git a/gecode/int/bin-packing.cpp b/gecode/int/bin-packing.cpp index 4bcd2d4c1d..e119d12700 100644 --- a/gecode/int/bin-packing.cpp +++ b/gecode/int/bin-packing.cpp @@ -65,6 +65,7 @@ namespace Gecode { if (same(l, b)) throw ArgumentSame("Int::binpacking"); + Limits::positive(d, "Int::binpacking"); // The number of items int n = b.size(); diff --git a/gecode/int/bin-packing.hh b/gecode/int/bin-packing.hh index 01b4a4b46e..b47b551703 100644 --- a/gecode/int/bin-packing.hh +++ b/gecode/int/bin-packing.hh @@ -208,9 +208,9 @@ namespace Gecode { namespace Int { namespace BinPacking { static LambdaRange l_rad2(int c); static LambdaRange sanitize_lambda_range(LambdaRange lambda, int n_weights, int max_weight); /// Lower bound - template + template static int calc_dff_lower_bound_single_lambda(const int* weights, int n_weights, int capacity, int lambda); - template + template static int calc_dff_lower_bound(const int* weights, int n_weights, int capacity, int n_not_zero_weights, int max_weight, bool sanitize = false); }; diff --git a/gecode/int/bin-packing/propagate.hpp b/gecode/int/bin-packing/propagate.hpp index d3fcaf0552..1bff5d7f10 100644 --- a/gecode/int/bin-packing/propagate.hpp +++ b/gecode/int/bin-packing/propagate.hpp @@ -355,7 +355,7 @@ namespace Gecode { namespace Int { namespace BinPacking { } } - template + template forceinline int Pack::calc_dff_lower_bound_single_lambda(const int* weights, int n_weights, int capacity, int lambda) { // Transform and sum the weights @@ -370,7 +370,7 @@ namespace Gecode { namespace Int { namespace BinPacking { return static_cast(ceil_div_pp(sum_transformed_weights, static_cast(transformed_capacity))); } - template + template forceinline int Pack::calc_dff_lower_bound(const int* weights, int n_weights, int capacity, int n_not_zero_weights, int max_weight, bool sanitize) { diff --git a/gecode/int/branch.cpp b/gecode/int/branch.cpp index f957127899..5fed8cff21 100644 --- a/gecode/int/branch.cpp +++ b/gecode/int/branch.cpp @@ -130,19 +130,20 @@ namespace Gecode { } void - assign(Home home, const IntVarArgs& x, const IntVarBranch& vars, const IntAssign& vals, IntBranchFilter bf, + assign(Home home, const IntVarArgs& x, IntVarBranch vars, const IntAssign& vals, IntBranchFilter bf, IntVarValPrint vvp) { using namespace Int; if (home.failed()) return; + vars.expand(home, x); ViewArray xv(home, x); - ViewSel* vs[1] = {new (home) ViewSelNone(home, vars)}; + ViewSel* vs[1] = {Branch::view_selection(home, vars)}; post_view_value_brancher(home, xv, vs, Branch::value_selection_commit(home, vals), std::move(bf), std::move(vvp)); } void - branch(Home home, const IntVarArgs& x, TieBreak vars, const IntAssign& vals, IntBranchFilter bf, + assign(Home home, const IntVarArgs& x, TieBreak vars, const IntAssign& vals, IntBranchFilter bf, IntVarValPrint vvp) { using namespace Int; if (home.failed()) @@ -158,7 +159,7 @@ namespace Gecode { vars.d = INT_VAR_NONE(); vars.d.expand(home, x); if (vars.b.select() == IntVarBranch::SEL_NONE) { - assign(home, x, vars.a, vals, std::move(bf), std::move(vvp)); + assign(home, x, std::move(vars.a), vals, std::move(bf), std::move(vvp)); } else { ViewArray xv(home, x); if (vars.c.select() == IntVarBranch::SEL_NONE) { @@ -243,13 +244,14 @@ namespace Gecode { } void - assign(Home home, const BoolVarArgs& x, const BoolVarBranch& vars, const BoolAssign& vals, BoolBranchFilter bf, + assign(Home home, const BoolVarArgs& x, BoolVarBranch vars, const BoolAssign& vals, BoolBranchFilter bf, BoolVarValPrint vvp) { using namespace Int; if (home.failed()) return; + vars.expand(home, x); ViewArray xv(home, x); - ViewSel* vs[1] = {new (home) ViewSelNone(home, vars)}; + ViewSel* vs[1] = {Branch::view_selection(home, vars)}; post_view_value_brancher(home, xv, vs, Branch::value_selection_commit(home, vals), std::move(bf), std::move(vvp)); } @@ -271,7 +273,7 @@ namespace Gecode { vars.d = BOOL_VAR_NONE(); vars.d.expand(home, x); if (vars.b.select() == BoolVarBranch::SEL_NONE) { - assign(home, x, vars.a, vals, std::move(bf), std::move(vvp)); + assign(home, x, std::move(vars.a), vals, std::move(bf), std::move(vvp)); } else { ViewArray xv(home, x); ValSelCommitBase* vsc = Branch::value_selection_commit(home, vals); diff --git a/gecode/int/branch/merit.hpp b/gecode/int/branch/merit.hpp index b528411416..0d74845f9c 100644 --- a/gecode/int/branch/merit.hpp +++ b/gecode/int/branch/merit.hpp @@ -35,7 +35,7 @@ namespace Gecode { namespace Int { namespace Branch { // Minimum merit template forceinline - MeritMin::MeritMin(Space& home, const VarBranch::Var>& vb) + MeritMin::MeritMin(Space& home, const VarBranch& vb) : MeritBase(home, vb) {} template forceinline @@ -50,7 +50,7 @@ namespace Gecode { namespace Int { namespace Branch { // Maximum merit template forceinline - MeritMax::MeritMax(Space& home, const VarBranch::Var>& vb) + MeritMax::MeritMax(Space& home, const VarBranch& vb) : MeritBase(home, vb) {} template forceinline @@ -65,7 +65,7 @@ namespace Gecode { namespace Int { namespace Branch { // Size merit template forceinline - MeritSize::MeritSize(Space& home, const VarBranch::Var>& vb) + MeritSize::MeritSize(Space& home, const VarBranch& vb) : MeritBase(home, vb) {} template forceinline @@ -80,7 +80,7 @@ namespace Gecode { namespace Int { namespace Branch { // Degree over size merit template forceinline - MeritDegreeSize::MeritDegreeSize(Space& home, const VarBranch::Var>& vb) + MeritDegreeSize::MeritDegreeSize(Space& home, const VarBranch& vb) : MeritBase(home, vb) {} template forceinline @@ -95,7 +95,7 @@ namespace Gecode { namespace Int { namespace Branch { // AFC over size merit template forceinline - MeritAFCSize::MeritAFCSize(Space& home, const VarBranch::Var>& vb) + MeritAFCSize::MeritAFCSize(Space& home, const VarBranch& vb) : MeritBase(home, vb), afc(vb.afc()) {} template forceinline @@ -121,7 +121,7 @@ namespace Gecode { namespace Int { namespace Branch { // Action over size merit template forceinline - MeritActionSize::MeritActionSize(Space& home, const VarBranch::Var>& vb) + MeritActionSize::MeritActionSize(Space& home, const VarBranch& vb) : MeritBase(home, vb), action(vb.action()) {} template forceinline @@ -146,7 +146,7 @@ namespace Gecode { namespace Int { namespace Branch { // CHB over size merit template forceinline - MeritCHBSize::MeritCHBSize(Space& home, const VarBranch::Var>& vb) + MeritCHBSize::MeritCHBSize(Space& home, const VarBranch& vb) : MeritBase(home, vb), chb(vb.chb()) {} template forceinline @@ -171,7 +171,7 @@ namespace Gecode { namespace Int { namespace Branch { // Minimum regret merit template forceinline - MeritRegretMin::MeritRegretMin(Space& home, const VarBranch::Var>& vb) + MeritRegretMin::MeritRegretMin(Space& home, const VarBranch& vb) : MeritBase(home, vb) {} template forceinline @@ -186,7 +186,7 @@ namespace Gecode { namespace Int { namespace Branch { // Maximum regret merit template forceinline - MeritRegretMax::MeritRegretMax(Space& home, const VarBranch::Var>& vb) + MeritRegretMax::MeritRegretMax(Space& home, const VarBranch& vb) : MeritBase(home, vb) {} template forceinline diff --git a/gecode/int/branch/val-commit.hpp b/gecode/int/branch/val-commit.hpp index 3e866cbc5b..2400a3d5ee 100644 --- a/gecode/int/branch/val-commit.hpp +++ b/gecode/int/branch/val-commit.hpp @@ -34,7 +34,7 @@ namespace Gecode { namespace Int { namespace Branch { template forceinline - ValCommitEq::ValCommitEq(Space& home, const ValBranch::Var>& vb) + ValCommitEq::ValCommitEq(Space& home, const ValBranch& vb) : ValCommit(home, vb) {} template forceinline @@ -61,7 +61,7 @@ namespace Gecode { namespace Int { namespace Branch { template forceinline - ValCommitLq::ValCommitLq(Space& home, const ValBranch::Var>& vb) + ValCommitLq::ValCommitLq(Space& home, const ValBranch& vb) : ValCommit(home, vb) {} template forceinline @@ -88,7 +88,7 @@ namespace Gecode { namespace Int { namespace Branch { template forceinline - ValCommitGq::ValCommitGq(Space& home, const ValBranch::Var>& vb) + ValCommitGq::ValCommitGq(Space& home, const ValBranch& vb) : ValCommit(home, vb) {} template forceinline @@ -115,7 +115,7 @@ namespace Gecode { namespace Int { namespace Branch { template forceinline - ValCommitGr::ValCommitGr(Space& home, const ValBranch::Var>& vb) + ValCommitGr::ValCommitGr(Space& home, const ValBranch& vb) : ValCommit(home, vb) {} template forceinline diff --git a/gecode/int/branch/val-sel.hpp b/gecode/int/branch/val-sel.hpp index b4eda819c3..258193c933 100644 --- a/gecode/int/branch/val-sel.hpp +++ b/gecode/int/branch/val-sel.hpp @@ -34,7 +34,7 @@ namespace Gecode { namespace Int { namespace Branch { template forceinline - ValSelMin::ValSelMin(Space& home, const ValBranch::Var>& vb) + ValSelMin::ValSelMin(Space& home, const ValBranch& vb) : ValSel(home, vb) {} template forceinline @@ -48,7 +48,7 @@ namespace Gecode { namespace Int { namespace Branch { template forceinline - ValSelMax::ValSelMax(Space& home, const ValBranch::Var>& vb) + ValSelMax::ValSelMax(Space& home, const ValBranch& vb) : ValSel(home, vb) {} template forceinline @@ -62,7 +62,7 @@ namespace Gecode { namespace Int { namespace Branch { template forceinline - ValSelMed::ValSelMed(Space& home, const ValBranch::Var>& vb) + ValSelMed::ValSelMed(Space& home, const ValBranch& vb) : ValSel(home, vb) {} template forceinline @@ -76,7 +76,7 @@ namespace Gecode { namespace Int { namespace Branch { template forceinline - ValSelAvg::ValSelAvg(Space& home, const ValBranch::Var>& vb) + ValSelAvg::ValSelAvg(Space& home, const ValBranch& vb) : ValSel(home, vb) {} template forceinline @@ -90,7 +90,7 @@ namespace Gecode { namespace Int { namespace Branch { template forceinline - ValSelRnd::ValSelRnd(Space& home, const ValBranch::Var>& vb) + ValSelRnd::ValSelRnd(Space& home, const ValBranch& vb) : ValSel(home, vb), r(vb.rnd()) {} template forceinline diff --git a/gecode/int/channel/dom.hpp b/gecode/int/channel/dom.hpp index 01849aaa59..481987af0f 100644 --- a/gecode/int/channel/dom.hpp +++ b/gecode/int/channel/dom.hpp @@ -167,7 +167,7 @@ namespace Gecode { namespace Int { namespace Channel { template forceinline - Dom::Dom(Space& home, Dom& p) + Dom::Dom(Space& home, Dom& p) : Base, Offset, PC_INT_DOM>(home, p) {} template diff --git a/gecode/int/channel/val.hpp b/gecode/int/channel/val.hpp index 214e94a938..fc08481bf3 100644 --- a/gecode/int/channel/val.hpp +++ b/gecode/int/channel/val.hpp @@ -184,7 +184,7 @@ namespace Gecode { namespace Int { namespace Channel { template forceinline - Val::Val(Space& home, Val& p) + Val::Val(Space& home, Val& p) : Base, Offset, PC_INT_VAL>(home, p) {} template diff --git a/gecode/int/circuit/base.hpp b/gecode/int/circuit/base.hpp index 20e7ba80bd..f990320fa8 100644 --- a/gecode/int/circuit/base.hpp +++ b/gecode/int/circuit/base.hpp @@ -41,7 +41,7 @@ namespace Gecode { namespace Int { namespace Circuit { template forceinline - Base::Base(Space& home, Base& p) + Base::Base(Space& home, Base& p) : NaryPropagator(home, p), start(p.start) { o.update(p.o); y.update(home, p.y); diff --git a/gecode/int/circuit/dom.hpp b/gecode/int/circuit/dom.hpp index c26237f764..1e449bf4a7 100644 --- a/gecode/int/circuit/dom.hpp +++ b/gecode/int/circuit/dom.hpp @@ -43,7 +43,7 @@ namespace Gecode { namespace Int { namespace Circuit { template forceinline - Dom::Dom(Space& home, Dom& p) + Dom::Dom(Space& home, Dom& p) : Base(home, p) {} template diff --git a/gecode/int/circuit/val.hpp b/gecode/int/circuit/val.hpp index a1a1b9eaff..8969737ca0 100644 --- a/gecode/int/circuit/val.hpp +++ b/gecode/int/circuit/val.hpp @@ -43,7 +43,7 @@ namespace Gecode { namespace Int { namespace Circuit { template forceinline - Val::Val(Space& home, Val& p) + Val::Val(Space& home, Val& p) : Base(home, p) {} template diff --git a/gecode/int/element.cpp b/gecode/int/element.cpp index d4b582cac6..84f0973dfc 100644 --- a/gecode/int/element.cpp +++ b/gecode/int/element.cpp @@ -254,6 +254,15 @@ namespace Gecode { } namespace { + /// Check that \a n elements form a non-empty matrix of width \a w and height \a h + void + check_matrix(int n, int w, int h) { + if (n == 0) + throw Int::TooFewArguments("Int::element"); + if ((w < 1) || (h < 1) || (static_cast(w) * h != n)) + throw Int::ArgumentSizeMismatch("Int::element"); + } + IntVar pair(Home home, IntVar x, int w, IntVar y, int h) { IntVar xy(home, 0, w * h - 1); @@ -281,8 +290,7 @@ namespace Gecode { void element(Home home, const IntSharedArray& a, IntVar x, int w, IntVar y, int h, IntVar z, IntPropLevel ipl) { using namespace Int; - if (a.size() != w * h) - throw Int::ArgumentSizeMismatch("Int::element"); + check_matrix(a.size(), w, h); GECODE_POST; element(home, a, pair(home, x, w, y, h), z, ipl); } @@ -291,8 +299,7 @@ namespace Gecode { element(Home home, const IntSharedArray& a, IntVar x, int xoff, int w, IntVar y, int yoff, int h, IntVar z, IntPropLevel ipl) { using namespace Int; - if (a.size() != w * h) - throw Int::ArgumentSizeMismatch("Int::element"); + check_matrix(a.size(), w, h); GECODE_POST; element(home, a, pair_with_offsets(home, x, xoff, w, y, yoff, h), z, ipl); } @@ -300,8 +307,7 @@ namespace Gecode { void element(Home home, const IntSharedArray& a, IntVar x, int w, IntVar y, int h, BoolVar z, IntPropLevel ipl) { using namespace Int; - if (a.size() != w * h) - throw Int::ArgumentSizeMismatch("Int::element"); + check_matrix(a.size(), w, h); GECODE_POST; element(home, a, pair(home, x, w, y, h), z, ipl); } @@ -310,8 +316,7 @@ namespace Gecode { element(Home home, const IntSharedArray& a, IntVar x, int xoff, int w, IntVar y, int yoff, int h, BoolVar z, IntPropLevel ipl) { using namespace Int; - if (a.size() != w * h) - throw Int::ArgumentSizeMismatch("Int::element"); + check_matrix(a.size(), w, h); GECODE_POST; element(home, a, pair_with_offsets(home, x, xoff, w, y, yoff, h), z, ipl); } @@ -319,8 +324,7 @@ namespace Gecode { void element(Home home, const IntVarArgs& a, IntVar x, int w, IntVar y, int h, IntVar z, IntPropLevel ipl) { using namespace Int; - if (a.size() != w * h) - throw Int::ArgumentSizeMismatch("Int::element"); + check_matrix(a.size(), w, h); GECODE_POST; element(home, a, pair(home, x, w, y, h), z, ipl); } @@ -329,8 +333,7 @@ namespace Gecode { element(Home home, const IntVarArgs& a, IntVar x, int xoff, int w, IntVar y, int yoff, int h, IntVar z, IntPropLevel ipl) { using namespace Int; - if (a.size() != w * h) - throw Int::ArgumentSizeMismatch("Int::element"); + check_matrix(a.size(), w, h); GECODE_POST; element(home, a, pair_with_offsets(home, x, xoff, w, y, yoff, h), z, ipl); } @@ -338,8 +341,7 @@ namespace Gecode { void element(Home home, const BoolVarArgs& a, IntVar x, int w, IntVar y, int h, BoolVar z, IntPropLevel ipl) { using namespace Int; - if (a.size() != w * h) - throw Int::ArgumentSizeMismatch("Int::element"); + check_matrix(a.size(), w, h); GECODE_POST; element(home, a, pair(home, x, w, y, h), z, ipl); } @@ -348,8 +350,7 @@ namespace Gecode { element(Home home, const BoolVarArgs& a, IntVar x, int xoff, int w, IntVar y, int yoff, int h, BoolVar z, IntPropLevel ipl) { using namespace Int; - if (a.size() != w * h) - throw Int::ArgumentSizeMismatch("Int::element"); + check_matrix(a.size(), w, h); GECODE_POST; element(home, a, pair_with_offsets(home, x, xoff, w, y, yoff, h), z, ipl); } diff --git a/gecode/int/extensional/dfa.hpp b/gecode/int/extensional/dfa.hpp index b07fe7c05c..7cab49768c 100644 --- a/gecode/int/extensional/dfa.hpp +++ b/gecode/int/extensional/dfa.hpp @@ -71,8 +71,6 @@ namespace Gecode { void fill(void); /// Initialize automaton implementation with \a nt transitions DFAI(int nt); - /// Initialize automaton implementation as empty - GECODE_INT_EXPORT DFAI(void); /// Delete automaton implemenentation ~DFAI(void) override; }; diff --git a/gecode/int/extensional/layered-graph.hpp b/gecode/int/extensional/layered-graph.hpp index 748c27f64a..4232166d54 100644 --- a/gecode/int/extensional/layered-graph.hpp +++ b/gecode/int/extensional/layered-graph.hpp @@ -85,8 +85,7 @@ namespace Gecode { namespace Int { namespace Extensional { } template forceinline typename LayeredGraph::State& - LayeredGraph::i_state( - int i, const typename LayeredGraph::Edge& e) { + LayeredGraph::i_state(int i, const Edge& e) { return i_state(i, e.i_state); } template @@ -102,8 +101,7 @@ namespace Gecode { namespace Int { namespace Extensional { } template forceinline typename LayeredGraph::State& - LayeredGraph::o_state( - int i, const typename LayeredGraph::Edge& e) { + LayeredGraph::o_state(int i, const Edge& e) { return o_state(i, e.o_state); } template @@ -178,8 +176,7 @@ namespace Gecode { namespace Int { namespace Extensional { } template forceinline void - LayeredGraph::IndexRange::add( - const typename LayeredGraph::IndexRange& ir) { + LayeredGraph::IndexRange::add(const IndexRange& ir) { _fst = std::min(_fst, ir._fst); _lst = std::max(_lst, ir._lst); } diff --git a/gecode/int/ldsb.cpp b/gecode/int/ldsb.cpp index 52e77ffd87..1180b09f93 100644 --- a/gecode/int/ldsb.cpp +++ b/gecode/int/ldsb.cpp @@ -140,7 +140,7 @@ namespace Gecode { return value_sequence_symmetry(a, n); } SymmetryHandle - values_reflect(const IntVar& x) { + values_reflect(IntVar x) { return values_reflect(x.min(), x.max()); } } // namespace Gecode diff --git a/gecode/int/ldsb.hh b/gecode/int/ldsb.hh index 22643517c7..dc41a66fc7 100644 --- a/gecode/int/ldsb.hh +++ b/gecode/int/ldsb.hh @@ -197,7 +197,7 @@ namespace Gecode { namespace Int { namespace LDSB { /// Constructor for creation VariableSymmetryImp(Space& home, int* vs, unsigned int n); /// Copy constructor - VariableSymmetryImp(Space& home, const VariableSymmetryImp& other); + VariableSymmetryImp(Space& home, const VariableSymmetryImp& other); /// Disposal size_t dispose(Space& home) override; /// Left-branch update @@ -258,7 +258,7 @@ namespace Gecode { namespace Int { namespace LDSB { /// Constructor for creation VariableSequenceSymmetryImp(Space& home, int* _indices, unsigned int n, unsigned int seqsize); /// Copy constructor - VariableSequenceSymmetryImp(Space& home, const VariableSequenceSymmetryImp& s); + VariableSequenceSymmetryImp(Space& home, const VariableSequenceSymmetryImp& s); /// Disposal size_t dispose(Space& home) override; /// Search left-branch update diff --git a/gecode/int/ldsb/brancher.hpp b/gecode/int/ldsb/brancher.hpp index 28f2d14bc3..8b59e29a2a 100644 --- a/gecode/int/ldsb/brancher.hpp +++ b/gecode/int/ldsb/brancher.hpp @@ -77,10 +77,10 @@ namespace Gecode { namespace Int { namespace LDSB { } template - LDSBBrancher::LDSBBrancher( - Home home, ViewArray& x, ViewSel* vs[n], ValSelCommitBase* vsc, SymmetryImp** syms, - int nsyms, BranchFilter::Var> bf, - VarValPrint::Var, Val> vvp) + LDSBBrancher::LDSBBrancher(Home home, ViewArray& x, ViewSel* vs[n], + ValSelCommitBase* vsc, + SymmetryImp** syms, int nsyms, + BranchFilter bf, VarValPrint vvp) : ViewValBrancher(home, x, vs, vsc, std::move(bf), std::move(vvp)), _syms(syms), _nsyms(nsyms), _prev_pos(-1) { home.notice(*this, AP_DISPOSE, true); @@ -98,8 +98,7 @@ namespace Gecode { namespace Int { namespace LDSB { template forceinline - LDSBBrancher::LDSBBrancher(Space& home, - LDSBBrancher& b) + LDSBBrancher::LDSBBrancher(Space& home, LDSBBrancher& b) : ViewValBrancher(home, b), _nsyms(b._nsyms), _prev_pos(b._prev_pos) { if (_nsyms > 0) { _syms = home.alloc*>(_nsyms); diff --git a/gecode/int/linear/int-bin.hpp b/gecode/int/linear/int-bin.hpp index 00910edd23..dde13cfe0a 100644 --- a/gecode/int/linear/int-bin.hpp +++ b/gecode/int/linear/int-bin.hpp @@ -46,7 +46,7 @@ namespace Gecode { namespace Int { namespace Linear { template forceinline - LinBin::LinBin(Space& home, LinBin& p) + LinBin::LinBin(Space& home, LinBin& p) : Propagator(home, p), c(p.c) { x0.update(home, p.x0); x1.update(home, p.x1); @@ -97,7 +97,7 @@ namespace Gecode { namespace Int { namespace Linear { template forceinline - ReLinBin::ReLinBin(Space& home, ReLinBin& p) + ReLinBin::ReLinBin(Space& home, ReLinBin& p) : Propagator(home, p), c(p.c) { x0.update(home, p.x0); x1.update(home, p.x1); @@ -147,7 +147,7 @@ namespace Gecode { namespace Int { namespace Linear { template forceinline - EqBin::EqBin(Space& home, EqBin& p) + EqBin::EqBin(Space& home, EqBin& p) : LinBin(home, p) {} template @@ -214,7 +214,7 @@ namespace Gecode { namespace Int { namespace Linear { template forceinline - ReEqBin::ReEqBin(Space& home, ReEqBin& p) + ReEqBin::ReEqBin(Space& home, ReEqBin& p) : ReLinBin(home, p) {} template @@ -268,7 +268,7 @@ namespace Gecode { namespace Int { namespace Linear { template forceinline - NqBin::NqBin(Space& home, NqBin& p) + NqBin::NqBin(Space& home, NqBin& p) : LinBin(home, p) {} template @@ -319,7 +319,7 @@ namespace Gecode { namespace Int { namespace Linear { template forceinline - LqBin::LqBin(Space& home, LqBin& p) + LqBin::LqBin(Space& home, LqBin& p) : LinBin(home, p) {} template @@ -360,7 +360,7 @@ namespace Gecode { namespace Int { namespace Linear { template forceinline - GqBin::GqBin(Space& home, GqBin& p) + GqBin::GqBin(Space& home, GqBin& p) : LinBin(home, p) {} template @@ -401,7 +401,7 @@ namespace Gecode { namespace Int { namespace Linear { template forceinline - ReLqBin::ReLqBin(Space& home, ReLqBin& p) + ReLqBin::ReLqBin(Space& home, ReLqBin& p) : ReLinBin(home, p) {} template diff --git a/gecode/int/linear/int-dom.hpp b/gecode/int/linear/int-dom.hpp index ad89368707..80e8c4d22d 100644 --- a/gecode/int/linear/int-dom.hpp +++ b/gecode/int/linear/int-dom.hpp @@ -370,7 +370,7 @@ namespace Gecode { namespace Int { namespace Linear { template forceinline - DomEq::DomEq(Space& home, DomEq& p) + DomEq::DomEq(Space& home, DomEq& p) : Lin(home, p) {} template diff --git a/gecode/int/linear/int-nary.hpp b/gecode/int/linear/int-nary.hpp index e655fcaba9..cd8fdf2f95 100644 --- a/gecode/int/linear/int-nary.hpp +++ b/gecode/int/linear/int-nary.hpp @@ -114,7 +114,7 @@ namespace Gecode { namespace Int { namespace Linear { template forceinline - ReLin::ReLin(Space& home, ReLin& p) + ReLin::ReLin(Space& home, ReLin& p) : Lin(home, p) { b.update(home, p.b); } @@ -300,7 +300,7 @@ namespace Gecode { namespace Int { namespace Linear { template forceinline - Eq::Eq(Space& home, Eq& p) + Eq::Eq(Space& home, Eq& p) : Lin(home, p) {} /** @@ -412,7 +412,7 @@ namespace Gecode { namespace Int { namespace Linear { template forceinline - ReEq::ReEq(Space& home, ReEq& p) + ReEq::ReEq(Space& home, ReEq& p) : ReLin(home, p) {} template @@ -480,7 +480,7 @@ namespace Gecode { namespace Int { namespace Linear { template forceinline - Nq::Nq(Space& home, Nq& p) + Nq::Nq(Space& home, Nq& p) : Lin(home, p) {} /** @@ -613,7 +613,7 @@ namespace Gecode { namespace Int { namespace Linear { template forceinline - Lq::Lq(Space& home, Lq& p) + Lq::Lq(Space& home, Lq& p) : Lin(home, p) {} /** @@ -795,7 +795,7 @@ namespace Gecode { namespace Int { namespace Linear { template forceinline - ReLq::ReLq(Space& home, ReLq& p) + ReLq::ReLq(Space& home, ReLq& p) : ReLin(home, p) {} template diff --git a/gecode/int/linear/int-ter.hpp b/gecode/int/linear/int-ter.hpp index e9a304e4dc..bce16de750 100644 --- a/gecode/int/linear/int-ter.hpp +++ b/gecode/int/linear/int-ter.hpp @@ -47,7 +47,7 @@ namespace Gecode { namespace Int { namespace Linear { template forceinline - LinTer::LinTer(Space& home, LinTer& p) + LinTer::LinTer(Space& home, LinTer& p) : Propagator(home, p), c(p.c) { x0.update(home, p.x0); x1.update(home, p.x1); @@ -106,7 +106,7 @@ namespace Gecode { namespace Int { namespace Linear { template forceinline - EqTer::EqTer(Space& home, EqTer& p) + EqTer::EqTer(Space& home, EqTer& p) : LinTer(home, p) {} template @@ -177,7 +177,7 @@ namespace Gecode { namespace Int { namespace Linear { template forceinline - NqTer::NqTer(Space& home, NqTer& p) + NqTer::NqTer(Space& home, NqTer& p) : LinTer(home, p) {} template @@ -228,7 +228,7 @@ namespace Gecode { namespace Int { namespace Linear { template forceinline - LqTer::LqTer(Space& home, LqTer& p) + LqTer::LqTer(Space& home, LqTer& p) : LinTer(home, p) {} template diff --git a/gecode/int/precede.hh b/gecode/int/precede.hh index 25ede5c8ba..4192e73ad4 100644 --- a/gecode/int/precede.hh +++ b/gecode/int/precede.hh @@ -83,7 +83,7 @@ namespace Gecode { namespace Int { namespace Precede { /// Constructor for posting Single(Home home, ViewArray& x, int s, int t, int beta, int gamma); /// Constructor for cloning \a p - Single(Space& home, Single& p); + Single(Space& home, Single& p); public: /// Copy propagator during cloning diff --git a/gecode/int/propagator.hpp b/gecode/int/propagator.hpp index 8f5801bbf6..5e984620d0 100644 --- a/gecode/int/propagator.hpp +++ b/gecode/int/propagator.hpp @@ -156,7 +156,7 @@ namespace Gecode { namespace Int { template forceinline - ReUnaryPropagator::ReUnaryPropagator(Space& home, ReUnaryPropagator& p) + ReUnaryPropagator::ReUnaryPropagator(Space& home, ReUnaryPropagator& p) : Propagator(home, p) { x0.update(home, p.x0); b.update(home, p.b); @@ -210,7 +210,7 @@ namespace Gecode { namespace Int { template forceinline - ReBinaryPropagator::ReBinaryPropagator(Space& home, ReBinaryPropagator& p) + ReBinaryPropagator::ReBinaryPropagator(Space& home, ReBinaryPropagator& p) : Propagator(home, p) { x0.update(home, p.x0); x1.update(home, p.x1); diff --git a/gecode/kernel/branch/filter.hpp b/gecode/kernel/branch/filter.hpp index 9cd42ebf3d..8c5aa1604f 100644 --- a/gecode/kernel/branch/filter.hpp +++ b/gecode/kernel/branch/filter.hpp @@ -97,7 +97,7 @@ namespace Gecode { template forceinline - BrancherFilter::BrancherFilter(BrancherFilter& bf) + BrancherFilter::BrancherFilter(BrancherFilter& bf) : f(bf.f) {} template @@ -143,7 +143,7 @@ namespace Gecode { template forceinline // NOLINTNEXTLINE(modernize-use-equals-default) - BrancherNoFilter::BrancherNoFilter(BrancherNoFilter&) {} + BrancherNoFilter::BrancherNoFilter(BrancherNoFilter&) {} template forceinline BrancherNoFilter:: diff --git a/gecode/kernel/branch/merit.hpp b/gecode/kernel/branch/merit.hpp index 4ba2909e8c..27b9d007a7 100644 --- a/gecode/kernel/branch/merit.hpp +++ b/gecode/kernel/branch/merit.hpp @@ -197,7 +197,7 @@ namespace Gecode { // User-defined function merit template forceinline - MeritFunction::MeritFunction(Space& home, const VarBranch::Var>& vb) + MeritFunction::MeritFunction(Space& home, const VarBranch& vb) : MeritBase(home, vb), f(vb.merit()) { if (!f()) throw InvalidFunction("MeritFunction::MeritFunction"); @@ -227,7 +227,7 @@ namespace Gecode { // Degree merit template forceinline - MeritDegree::MeritDegree(Space& home, const VarBranch::Var>& vb) + MeritDegree::MeritDegree(Space& home, const VarBranch& vb) : MeritBase(home, vb) {} template forceinline @@ -242,7 +242,7 @@ namespace Gecode { // AFC merit template forceinline - MeritAFC::MeritAFC(Space& home, const VarBranch::Var>& vb) + MeritAFC::MeritAFC(Space& home, const VarBranch& vb) : MeritBase(home, vb), afc(vb.afc()) {} template forceinline @@ -269,7 +269,7 @@ namespace Gecode { // Action merit template forceinline - MeritAction::MeritAction(Space& home, const VarBranch::Var>& vb) + MeritAction::MeritAction(Space& home, const VarBranch& vb) : MeritBase(home, vb), action(vb.action()) {} template forceinline @@ -294,7 +294,7 @@ namespace Gecode { // CHB merit template forceinline - MeritCHB::MeritCHB(Space& home, const VarBranch::Var>& vb) + MeritCHB::MeritCHB(Space& home, const VarBranch& vb) : MeritBase(home, vb), chb(vb.chb()) {} template forceinline diff --git a/gecode/kernel/branch/print.hpp b/gecode/kernel/branch/print.hpp index 9a3c2bcf25..d05ec090bc 100644 --- a/gecode/kernel/branch/print.hpp +++ b/gecode/kernel/branch/print.hpp @@ -100,7 +100,7 @@ namespace Gecode { template forceinline - BrancherPrint::BrancherPrint(BrancherPrint& bp) + BrancherPrint::BrancherPrint(BrancherPrint& bp) : p(bp.p) {} template @@ -147,7 +147,7 @@ namespace Gecode { template forceinline // NOLINTNEXTLINE(modernize-use-equals-default) - BrancherNoPrint::BrancherNoPrint(BrancherNoPrint&) {} + BrancherNoPrint::BrancherNoPrint(BrancherNoPrint&) {} template forceinline BrancherNoPrint:: diff --git a/gecode/kernel/branch/val-commit.hpp b/gecode/kernel/branch/val-commit.hpp index a3b6f19df3..f0847c83f8 100644 --- a/gecode/kernel/branch/val-commit.hpp +++ b/gecode/kernel/branch/val-commit.hpp @@ -119,7 +119,7 @@ namespace Gecode { } template forceinline - ValCommitFunction::ValCommitFunction(Space& home, ValCommitFunction& vc) + ValCommitFunction::ValCommitFunction(Space& home, ValCommitFunction& vc) : ValCommit(home, vc), c(vc.c) {} template forceinline ModEvent @@ -127,7 +127,7 @@ namespace Gecode { typename View::VarType y(x.varimp()); GECODE_VALID_FUNCTION(c()); c()(home, a, y, i, n); - return home.failed() ? ES_FAILED : ES_OK; + return home.failed() ? ME_GEN_FAILED : ME_GEN_NONE; } template forceinline NGL* diff --git a/gecode/kernel/branch/view-val.hpp b/gecode/kernel/branch/view-val.hpp index c9f3b7ca3d..46c0f215b2 100644 --- a/gecode/kernel/branch/view-val.hpp +++ b/gecode/kernel/branch/view-val.hpp @@ -231,8 +231,7 @@ namespace Gecode { template forceinline - ViewValBrancher::ViewValBrancher(Space& home, - ViewValBrancher& b) + ViewValBrancher::ViewValBrancher(Space& home, ViewValBrancher& b) : ViewBrancher(home, b), vsc(nullptr), p(b.p) { try { vsc = b.vsc->copy(home); diff --git a/gecode/kernel/core.hpp b/gecode/kernel/core.hpp index 8c476a6738..5c0aa9f982 100644 --- a/gecode/kernel/core.hpp +++ b/gecode/kernel/core.hpp @@ -3259,7 +3259,7 @@ namespace Gecode { } return p; } else { - rfree(b + m, m - n); + rfree(b + m, n - m); return b; } } @@ -3342,7 +3342,7 @@ namespace Gecode { free(b, n); return p; } else { - free(b + m, m - n); + free(b + m, n - m); return b; } } @@ -3401,7 +3401,7 @@ namespace Gecode { template forceinline T** Space::realloc(T** b, long unsigned int n, long unsigned int m) { - return static_cast(rrealloc(b, n * sizeof(T), m * sizeof(T*))); + return static_cast(rrealloc(b, n * sizeof(T*), m * sizeof(T*))); } template forceinline T** @@ -5128,8 +5128,10 @@ namespace Gecode { // Clang incorrectly reports an error on the access to u.idx[1] for BoolVarImp, // even though the access is guarded by pc_max > 0 which implies that the size is sufficient. +#ifdef __clang__ #pragma clang diagnostic push #pragma clang diagnostic ignored "-Warray-bounds" +#endif template forceinline void @@ -5212,7 +5214,9 @@ namespace Gecode { t[0] = static_cast(Support::join_pointer(p0, m0)); } } +#ifdef __clang__ #pragma clang diagnostic pop +#endif template forceinline void diff --git a/gecode/kernel/memory/region.hpp b/gecode/kernel/memory/region.hpp index 77bbf19987..bbb83afdb7 100644 --- a/gecode/kernel/memory/region.hpp +++ b/gecode/kernel/memory/region.hpp @@ -441,7 +441,7 @@ namespace Gecode { free(b, n); return p; } else { - free(b + m, m - n); + free(b + m, n - m); return b; } } diff --git a/gecode/kernel/propagator/pattern.hpp b/gecode/kernel/propagator/pattern.hpp index 30d9773c4a..8ce419a242 100644 --- a/gecode/kernel/propagator/pattern.hpp +++ b/gecode/kernel/propagator/pattern.hpp @@ -309,7 +309,7 @@ namespace Gecode { template forceinline - UnaryPropagator::UnaryPropagator(Space& home, UnaryPropagator& p) + UnaryPropagator::UnaryPropagator(Space& home, UnaryPropagator& p) : Propagator(home, p) { x0.update(home, p.x0); } @@ -358,7 +358,7 @@ namespace Gecode { template forceinline - BinaryPropagator::BinaryPropagator(Space& home, BinaryPropagator& p) + BinaryPropagator::BinaryPropagator(Space& home, BinaryPropagator& p) : Propagator(home, p) { x0.update(home, p.x0); x1.update(home, p.x1); @@ -415,7 +415,7 @@ namespace Gecode { template forceinline - TernaryPropagator::TernaryPropagator(Space& home, TernaryPropagator& p) + TernaryPropagator::TernaryPropagator(Space& home, TernaryPropagator& p) : Propagator(home, p) { x0.update(home, p.x0); x1.update(home, p.x1); @@ -472,7 +472,7 @@ namespace Gecode { template forceinline - NaryPropagator::NaryPropagator(Space& home, NaryPropagator& p) + NaryPropagator::NaryPropagator(Space& home, NaryPropagator& p) : Propagator(home, p) { x.update(home, p.x); } @@ -522,7 +522,7 @@ namespace Gecode { template forceinline - NaryOnePropagator::NaryOnePropagator(Space& home, NaryOnePropagator& p) + NaryOnePropagator::NaryOnePropagator(Space& home, NaryOnePropagator& p) : Propagator(home, p) { x.update(home, p.x); y.update(home, p.y); diff --git a/gecode/kernel/trace/filter.cpp b/gecode/kernel/trace/filter.cpp index 6e62ab015c..a1d00c079c 100644 --- a/gecode/kernel/trace/filter.cpp +++ b/gecode/kernel/trace/filter.cpp @@ -181,7 +181,8 @@ namespace Gecode { } TraceFilter::TFO::~TFO(void) { - heap.free(f, n); + if (f != nullptr) + heap.free(f, n); } TraceFilter::TraceFilter(void) : SharedHandle(new TFO) {} diff --git a/gecode/minimodel/matrix.hpp b/gecode/minimodel/matrix.hpp index a0fdd4b236..b63ceff96f 100644 --- a/gecode/minimodel/matrix.hpp +++ b/gecode/minimodel/matrix.hpp @@ -68,22 +68,22 @@ namespace Gecode { template inline Slice:: - operator typename Slice::ArgsType(void) { + operator ArgsType(void) { return _r; } template inline Slice:: - operator Matrix::ArgsType>(void) { + operator Matrix(void) { return Matrix::ArgsType>(_r, _tc - _fc, _tr - _fr); } template inline Slice:: - operator typename Slice::ArgsType const(void) const { + operator const ArgsType(void) const { return _r; } template inline Slice:: - operator Matrix::ArgsType> const(void) const { + operator const Matrix(void) const { return Matrix::ArgsType>(_r, _tc - _fc, _tr - _fr); } diff --git a/gecode/search.hh b/gecode/search.hh index ce1b4cf11a..10a63add88 100644 --- a/gecode/search.hh +++ b/gecode/search.hh @@ -1723,7 +1723,7 @@ namespace Gecode { T* pbs(T* s, const Search::Options& o = Search::Options::def); /// Return a portfolio search engine builder - template + template class E> SEB pbs(const Search::Options& o = Search::Options::def); } // namespace Gecode diff --git a/gecode/set.hh b/gecode/set.hh index 224d0ad721..b248925bae 100644 --- a/gecode/set.hh +++ b/gecode/set.hh @@ -770,7 +770,10 @@ namespace Gecode { * */ //@{ - /// Post propagator for \f$\forall 0\leq i< |x|-1 : \max(x_i)<\min(x_{i+1})\f$ + /** \brief Post propagator for \f$\forall 0\leq i< |x|-1 : \max(x_i)<\min(x_{i+1})\f$ + * + * Throws an exception of type Set::TooFewArguments, if \a x is empty. + */ GECODE_SET_EXPORT void sequence(Home home, const SetVarArgs& x); /// Post propagator for \f$\forall 0\leq i< |x|-1 : \max(x_i)<\min(x_{i+1})\f$ and \f$ x = \bigcup_{i\in\{0,\dots,n-1\}} y_i \f$ GECODE_SET_EXPORT void sequence(Home home, const SetVarArgs& y, SetVar x); @@ -931,24 +934,38 @@ namespace Gecode { * \brief Post propagator for \f$ z=\langle x_0,\dots,x_{n-1}\rangle[y] \f$ * * The indices for \a y start at 0. + * + * Throws an exception of type Set::TooFewArguments, if \a x is empty. */ GECODE_SET_EXPORT void element(Home home, const SetVarArgs& x, IntVar y, SetVar z); /** * \brief Post propagator for \f$ z=\langle s_0,\dots,s_{n-1}\rangle[y] \f$ * * The indices for \a y start at 0. + * + * Throws an exception of type Set::TooFewArguments, if \a s is empty. + * + * Throws an exception of type Set::OutOfLimits, if a set in \a s + * exceeds the limits in Set::Limits. */ GECODE_SET_EXPORT void element(Home home, const IntSetArgs& s, IntVar y, SetVar z); /** \brief Post propagator for \f$ a_{x+w\cdot y}=z\f$ * - * Throws an exception of type Set::ArgumentSizeMismatch, if - * \f$ w\cdot h\neq|a|\f$. + * Throws an exception of type Set::TooFewArguments, if \a a is empty. + * + * Throws an exception of type Set::ArgumentSizeMismatch, if \a w or + * \a h is not positive or \f$ w\cdot h\neq|a|\f$. + * + * Throws an exception of type Set::OutOfLimits, if a set in \a a + * exceeds the limits in Set::Limits. */ GECODE_SET_EXPORT void element(Home home, const IntSetArgs& a, IntVar x, int w, IntVar y, int h, SetVar z); /** \brief Post propagator for \f$ a_{x+w\cdot y}=z\f$ * - * Throws an exception of type Set::ArgumentSizeMismatch, if - * \f$ w\cdot h\neq|a|\f$. + * Throws an exception of type Set::TooFewArguments, if \a a is empty. + * + * Throws an exception of type Set::ArgumentSizeMismatch, if \a w or + * \a h is not positive or \f$ w\cdot h\neq|a|\f$. */ GECODE_SET_EXPORT void element(Home home, const SetVarArgs& a, IntVar x, int w, IntVar y, int h, SetVar z); //@} @@ -1507,7 +1524,7 @@ namespace Gecode { * * \ingroup TaskModelSetBranch */ - GECODE_SET_EXPORT void assign(Home home, const SetVarArgs& x, const SetVarBranch& vars, const SetAssign& vals, + GECODE_SET_EXPORT void assign(Home home, const SetVarArgs& x, SetVarBranch vars, const SetAssign& vals, SetBranchFilter bf = nullptr, SetVarValPrint vvp = nullptr); /** * \brief Assign all \a x with tie-breaking variable selection \a vars and value selection \a vals diff --git a/gecode/set/branch.cpp b/gecode/set/branch.cpp index 11f5889d0f..ce908504f0 100644 --- a/gecode/set/branch.cpp +++ b/gecode/set/branch.cpp @@ -91,13 +91,14 @@ namespace Gecode { } void - assign(Home home, const SetVarArgs& x, const SetVarBranch& vars, const SetAssign& vals, SetBranchFilter bf, + assign(Home home, const SetVarArgs& x, SetVarBranch vars, const SetAssign& vals, SetBranchFilter bf, SetVarValPrint vvp) { using namespace Set; if (home.failed()) return; + vars.expand(home, x); ViewArray xv(home, x); - ViewSel* vs[1] = {new (home) ViewSelNone(home, vars)}; + ViewSel* vs[1] = {Branch::view_selection(home, vars)}; post_view_value_brancher(home, xv, vs, Branch::value_selection_commit(home, vals), std::move(bf), std::move(vvp)); } @@ -119,7 +120,7 @@ namespace Gecode { vars.d = SET_VAR_NONE(); vars.d.expand(home, x); if (vars.b.select() == SetVarBranch::SEL_NONE) { - assign(home, x, vars.a, vals, std::move(bf), std::move(vvp)); + assign(home, x, std::move(vars.a), vals, std::move(bf), std::move(vvp)); } else { ViewArray xv(home, x); ValSelCommitBase* vsc = Branch::value_selection_commit(home, vals); diff --git a/gecode/set/element.cpp b/gecode/set/element.cpp index 01a1408bbd..ef149860b3 100644 --- a/gecode/set/element.cpp +++ b/gecode/set/element.cpp @@ -172,6 +172,15 @@ namespace Gecode { } namespace { + /// Check that \a n elements form a non-empty matrix of width \a w and height \a h + void + check_matrix(int n, int w, int h) { + if (n == 0) + throw Set::TooFewArguments("Set::element"); + if ((w < 1) || (h < 1) || (static_cast(w) * h != n)) + throw Set::ArgumentSizeMismatch("Set::element"); + } + IntVar pair(Home home, IntVar x, int w, IntVar y, int h) { IntVar xy(home, 0, w * h - 1); @@ -183,20 +192,14 @@ namespace Gecode { void element(Home home, const IntSetArgs& a, IntVar x, int w, IntVar y, int h, SetVar z) { - if (a.size() == 0) - throw Set::TooFewArguments("Set::element"); - if (a.size() != w * h) - throw Set::ArgumentSizeMismatch("Set::element"); + check_matrix(a.size(), w, h); GECODE_POST; element(home, a, pair(home, x, w, y, h), z); } void element(Home home, const SetVarArgs& a, IntVar x, int w, IntVar y, int h, SetVar z) { - if (a.size() == 0) - throw Set::TooFewArguments("Set::element"); - if (a.size() != w * h) - throw Set::ArgumentSizeMismatch("Set::element"); + check_matrix(a.size(), w, h); GECODE_POST; element(home, a, pair(home, x, w, y, h), z); } diff --git a/gecode/set/element/inter.hpp b/gecode/set/element/inter.hpp index 70089aa4bd..1b508883aa 100644 --- a/gecode/set/element/inter.hpp +++ b/gecode/set/element/inter.hpp @@ -47,8 +47,7 @@ namespace Gecode { namespace Set { namespace Element { template forceinline - ElementIntersection::ElementIntersection(Space& home, - ElementIntersection& p) + ElementIntersection::ElementIntersection(Space& home, ElementIntersection& p) : Propagator(home, p), universe(p.universe) { x0.update(home, p.x0); x1.update(home, p.x1); diff --git a/gecode/set/element/union.hpp b/gecode/set/element/union.hpp index 7b105f1c3a..0dda31ab79 100644 --- a/gecode/set/element/union.hpp +++ b/gecode/set/element/union.hpp @@ -46,7 +46,7 @@ namespace Gecode { namespace Set { namespace Element { template forceinline - ElementUnion::ElementUnion(Space& home, ElementUnion& p) + ElementUnion::ElementUnion(Space& home, ElementUnion& p) : Propagator(home, p) { x0.update(home, p.x0); x1.update(home, p.x1); diff --git a/gecode/set/ldsb/brancher.hpp b/gecode/set/ldsb/brancher.hpp index 705199730d..ce7f5bd6af 100644 --- a/gecode/set/ldsb/brancher.hpp +++ b/gecode/set/ldsb/brancher.hpp @@ -33,10 +33,11 @@ namespace Gecode { namespace Set { namespace LDSB { template - LDSBSetBrancher::LDSBSetBrancher( - Home home, ViewArray& x, ViewSel* vs[n], ValSelCommitBase* vsc, SymmetryImp** syms, - int nsyms, BranchFilter::Var> bf, - VarValPrint::Var, Val> vvp) + LDSBSetBrancher::LDSBSetBrancher(Home home, ViewArray& x, + ViewSel* vs[n], + ValSelCommitBase* vsc, + SymmetryImp** syms, int nsyms, + BranchFilter bf, VarValPrint vvp) : LDSBBrancher(home, x, vs, vsc, syms, nsyms, std::move(bf), std::move(vvp)), _prev_pos(-1), _copied_syms(nullptr), _n_copied_syms(0), _stable(false) { // Put all the value symmetries at the end of the list. @@ -56,8 +57,7 @@ namespace Gecode { namespace Set { namespace LDSB { } template - LDSBSetBrancher::LDSBSetBrancher(Space& home, - LDSBSetBrancher& b) + LDSBSetBrancher::LDSBSetBrancher(Space& home, LDSBSetBrancher& b) : LDSBBrancher(home, b), _prev_pos(b._prev_pos), _n_non_value_symmetries(b._n_non_value_symmetries), _n_value_symmetries(b._n_value_symmetries), _n_copied_syms(b._n_copied_syms), _left_branch_values(b._left_branch_values), _stable(b._stable) { diff --git a/gecode/set/precede.hh b/gecode/set/precede.hh index 64e8f8db38..7a95dd4c42 100644 --- a/gecode/set/precede.hh +++ b/gecode/set/precede.hh @@ -85,7 +85,7 @@ namespace Gecode { namespace Set { namespace Precede { /// Constructor for posting Single(Home home, ViewArray& x, int s, int t, int beta, int gamma); /// Constructor for cloning \a p - Single(Space& home, Single& p); + Single(Space& home, Single& p); public: /// Copy propagator during cloning diff --git a/gecode/set/var/set.hpp b/gecode/set/var/set.hpp index 44c0e5659a..a1aaa31b20 100644 --- a/gecode/set/var/set.hpp +++ b/gecode/set/var/set.hpp @@ -198,6 +198,8 @@ namespace Gecode { return iter.width(); } + forceinline SetVarGlbValues::SetVarGlbValues(void) = default; + forceinline SetVarGlbValues::SetVarGlbValues(const SetVar& x) { SetVarGlbRanges ivr(x); @@ -219,6 +221,8 @@ namespace Gecode { return iter.val(); } + forceinline SetVarLubValues::SetVarLubValues(void) = default; + forceinline SetVarLubValues::SetVarLubValues(const SetVar& x) { SetVarLubRanges ivr(x); @@ -240,6 +244,8 @@ namespace Gecode { return iter.val(); } + forceinline SetVarUnknownValues::SetVarUnknownValues(void) = default; + forceinline SetVarUnknownValues::SetVarUnknownValues(const SetVar& x) { SetVarUnknownRanges ivr(x); diff --git a/test/assign/bool.cpp b/test/assign/bool.cpp index 3957fbea9b..2510b2e0c9 100644 --- a/test/assign/bool.cpp +++ b/test/assign/bool.cpp @@ -32,6 +32,10 @@ #include "test/assign.hh" +#include + +#include + namespace Test { namespace Assign { /// %Test branching with distinct propagator @@ -50,6 +54,109 @@ namespace Test { namespace Assign { Bool b_5("5", 5); Bool b_7("7", 7); + /// Merit that prefers the variable at position \a p + template + double + bool_merit_at(const Gecode::Space&, Gecode::BoolVar, int i) { + return (i == p) ? 1.0 : 0.0; + } + + /// Filter that accepts every variable + bool + bool_accept(const Gecode::Space&, Gecode::BoolVar, int) { + return true; + } + + /// Print function that prints nothing + void + bool_print_nothing(const Gecode::Space&, const Gecode::Brancher&, unsigned int, Gecode::BoolVar, int, const int&, + std::ostream&) {} + + /// Space with five Boolean variables of which exactly \a n are one + class BoolOrderSpace : public Gecode::Space { + public: + /// Variables to be assigned + Gecode::BoolVarArray x; + /// Initialize test space + BoolOrderSpace(int n) : x(*this, 5, 0, 1) { + Gecode::linear(*this, x, Gecode::IRT_EQ, n); + } + /// Constructor for cloning \a s + BoolOrderSpace(BoolOrderSpace& s) : Gecode::Space(s) { + x.update(*this, s.x); + } + /// Copy space during cloning + Gecode::Space* + copy(void) override { + return new BoolOrderSpace(*this); + } + }; + + /// Whether assigning one first in \a s sets exactly the last \a n variables + bool + assigned_last_first(BoolOrderSpace* s, int n) { + Gecode::DFS e(s); + delete s; + BoolOrderSpace* solution = e.next(); + bool ok = solution != nullptr; + for (int i = 0; ok && (i < solution->x.size()); i++) + ok = solution->x[i].val() == ((i >= solution->x.size() - n) ? 1 : 0); + delete solution; + return ok; + } + + /// %Test that assignment follows each of \a n tie-breaking selections + class BoolTieBreak : public Base { + protected: + /// Number of variable selections + int n; + + public: + /// Create and register test + BoolTieBreak(int n0) : Base("Bool::Assign::TieBreak::" + std::to_string(n0)), n(n0) {} + /// Perform test + bool + run(void) override { + using namespace Gecode; + TieBreak vars(BOOL_VAR_MERIT_MAX(&bool_merit_at<4>)); + if (n > 1) + vars.b = BOOL_VAR_MERIT_MAX(&bool_merit_at<3>); + if (n > 2) + vars.c = BOOL_VAR_MERIT_MAX(&bool_merit_at<2>); + if (n > 3) + vars.d = BOOL_VAR_MERIT_MAX(&bool_merit_at<1>); + BoolOrderSpace* s = new BoolOrderSpace(n); + assign(*s, s->x, vars, BOOL_ASSIGN_MAX(), &bool_accept, &bool_print_nothing); + return assigned_last_first(s, n); + } + }; + + namespace { + BoolTieBreak tb_1(1); + BoolTieBreak tb_2(2); + BoolTieBreak tb_3(3); + BoolTieBreak tb_4(4); + } // namespace + + /// %Test that assignment follows a single variable selection + class BoolVarSelection : public Base { + public: + /// Create and register test + BoolVarSelection(void) : Base("Bool::Assign::VarSelection") {} + /// Perform test + bool + run(void) override { + using namespace Gecode; + BoolOrderSpace* s = new BoolOrderSpace(1); + assign(*s, s->x, BOOL_VAR_MERIT_MAX(&bool_merit_at<4>), BOOL_ASSIGN_MAX()); + return assigned_last_first(s, 1); + } + }; + + namespace { + BoolVarSelection var_selection; + } // namespace + }} // namespace Test::Assign // STATISTICS: test-branch diff --git a/test/assign/float.cpp b/test/assign/float.cpp index 2d5113566c..206968804f 100644 --- a/test/assign/float.cpp +++ b/test/assign/float.cpp @@ -36,6 +36,8 @@ #ifdef GECODE_HAS_FLOAT_VARS +#include + namespace Test { namespace Assign { /// %Test assignment with distinct propagator @@ -61,6 +63,58 @@ namespace Test { namespace Assign { Float l_3("Large::3", d_large, 3); } // namespace + /// Merit that prefers the last of five variables + double + float_merit_last(const Gecode::Space&, Gecode::FloatVar, int i) { + return (i == 4) ? 1.0 : 0.0; + } + + /// Space with five variables in [0,1] whose sum is at most one + class FloatOrderSpace : public Gecode::Space { + public: + /// Variables to be assigned + Gecode::FloatVarArray x; + /// Initialize test space + FloatOrderSpace(void) : x(*this, 5, 0.0, 1.0) { + Gecode::linear(*this, x, Gecode::FRT_LQ, 1.0); + } + /// Constructor for cloning \a s + FloatOrderSpace(FloatOrderSpace& s) : Gecode::Space(s) { + x.update(*this, s.x); + } + /// Copy space during cloning + Gecode::Space* + copy(void) override { + return new FloatOrderSpace(*this); + } + }; + + /// %Test that assignment follows a single variable selection + class FloatVarSelection : public Base { + public: + /// Create and register test + FloatVarSelection(void) : Base("Float::Assign::VarSelection") {} + /// Perform test + bool + run(void) override { + using namespace Gecode; + FloatOrderSpace* s = new FloatOrderSpace; + assign(*s, s->x, FLOAT_VAR_MERIT_MAX(&float_merit_last), FLOAT_ASSIGN_MAX()); + DFS e(s); + delete s; + FloatOrderSpace* solution = e.next(); + bool ok = solution != nullptr; + for (int i = 0; ok && (i < solution->x.size()); i++) + ok = (i == 4) ? (solution->x[i].min() > 0.5) : (solution->x[i].max() < 0.5); + delete solution; + return ok; + } + }; + + namespace { + FloatVarSelection var_selection; + } // namespace + }} // namespace Test::Assign #endif diff --git a/test/assign/int.cpp b/test/assign/int.cpp index 7a5893ff14..675f0a4620 100644 --- a/test/assign/int.cpp +++ b/test/assign/int.cpp @@ -32,6 +32,10 @@ #include "test/assign.hh" +#include + +#include + namespace Test { namespace Assign { /// %Test assignment with distinct propagator @@ -59,6 +63,98 @@ namespace Test { namespace Assign { Int l_2("Large::2", d_large, 2); Int l_3("Large::3", d_large, 3); + /// Merit that prefers the variable at position \a p + template + double + int_merit_at(const Gecode::Space&, Gecode::IntVar, int i) { + return (i == p) ? 1.0 : 0.0; + } + + /// Space with five 0/1 variables of which exactly \a n are one + class IntOrderSpace : public Gecode::Space { + public: + /// Variables to be assigned + Gecode::IntVarArray x; + /// Initialize test space + IntOrderSpace(int n) : x(*this, 5, 0, 1) { + Gecode::linear(*this, x, Gecode::IRT_EQ, n); + } + /// Constructor for cloning \a s + IntOrderSpace(IntOrderSpace& s) : Gecode::Space(s) { + x.update(*this, s.x); + } + /// Copy space during cloning + Gecode::Space* + copy(void) override { + return new IntOrderSpace(*this); + } + }; + + /// Whether assigning one first in \a s sets exactly the last \a n variables + bool + assigned_last_first(IntOrderSpace* s, int n) { + Gecode::DFS e(s); + delete s; + IntOrderSpace* solution = e.next(); + bool ok = solution != nullptr; + for (int i = 0; ok && (i < solution->x.size()); i++) + ok = solution->x[i].val() == ((i >= solution->x.size() - n) ? 1 : 0); + delete solution; + return ok; + } + + /// %Test that assignment follows each of \a n tie-breaking selections + class IntTieBreak : public Base { + protected: + /// Number of variable selections + int n; + + public: + /// Create and register test + IntTieBreak(int n0) : Base("Int::Assign::TieBreak::" + std::to_string(n0)), n(n0) {} + /// Perform test + bool + run(void) override { + using namespace Gecode; + TieBreak vars(INT_VAR_MERIT_MAX(&int_merit_at<4>)); + if (n > 1) + vars.b = INT_VAR_MERIT_MAX(&int_merit_at<3>); + if (n > 2) + vars.c = INT_VAR_MERIT_MAX(&int_merit_at<2>); + if (n > 3) + vars.d = INT_VAR_MERIT_MAX(&int_merit_at<1>); + IntOrderSpace* s = new IntOrderSpace(n); + assign(*s, s->x, vars, INT_ASSIGN_MAX()); + return assigned_last_first(s, n); + } + }; + + namespace { + IntTieBreak tb_1(1); + IntTieBreak tb_2(2); + IntTieBreak tb_3(3); + IntTieBreak tb_4(4); + } // namespace + + /// %Test that assignment follows a single variable selection + class IntVarSelection : public Base { + public: + /// Create and register test + IntVarSelection(void) : Base("Int::Assign::VarSelection") {} + /// Perform test + bool + run(void) override { + using namespace Gecode; + IntOrderSpace* s = new IntOrderSpace(1); + assign(*s, s->x, INT_VAR_MERIT_MAX(&int_merit_at<4>), INT_ASSIGN_MAX()); + return assigned_last_first(s, 1); + } + }; + + namespace { + IntVarSelection var_selection; + } // namespace + }} // namespace Test::Assign // STATISTICS: test-branch diff --git a/test/assign/set.cpp b/test/assign/set.cpp index e3b7447e20..c00532d6f0 100644 --- a/test/assign/set.cpp +++ b/test/assign/set.cpp @@ -34,6 +34,8 @@ #ifdef GECODE_HAS_SET_VARS +#include + namespace Test { namespace Assign { /// %Test assignment with disjoint union propagator @@ -59,6 +61,59 @@ namespace Test { namespace Assign { Set s_4("Sparse::4", Gecode::IntSet(s), 4); } // namespace + /// Merit that prefers the last of five variables + double + set_merit_last(const Gecode::Space&, Gecode::SetVar, int i) { + return (i == 4) ? 1.0 : 0.0; + } + + /// Space with five sets of which exactly one contains zero + class SetOrderSpace : public Gecode::Space { + public: + /// Variables to be assigned + Gecode::SetVarArray x; + /// Initialize test space + SetOrderSpace(void) : x(*this, 5, Gecode::IntSet::empty, Gecode::IntSet(0, 0)) { + Gecode::SetVar zero(*this, Gecode::IntSet(0, 0), Gecode::IntSet(0, 0)); + Gecode::rel(*this, Gecode::SOT_DUNION, x, zero); + } + /// Constructor for cloning \a s + SetOrderSpace(SetOrderSpace& s) : Gecode::Space(s) { + x.update(*this, s.x); + } + /// Copy space during cloning + Gecode::Space* + copy(void) override { + return new SetOrderSpace(*this); + } + }; + + /// %Test that assignment follows a single variable selection + class SetVarSelection : public Base { + public: + /// Create and register test + SetVarSelection(void) : Base("Set::Assign::VarSelection") {} + /// Perform test + bool + run(void) override { + using namespace Gecode; + SetOrderSpace* s = new SetOrderSpace; + assign(*s, s->x, SET_VAR_MERIT_MAX(&set_merit_last), SET_ASSIGN_MIN_INC()); + DFS e(s); + delete s; + SetOrderSpace* solution = e.next(); + bool ok = solution != nullptr; + for (int i = 0; ok && (i < solution->x.size()); i++) + ok = solution->x[i].glb_size() == ((i == 4) ? 1U : 0U); + delete solution; + return ok; + } + }; + + namespace { + SetVarSelection var_selection; + } // namespace + }} // namespace Test::Assign #endif diff --git a/test/flatzinc/branching.cpp b/test/flatzinc/branching.cpp new file mode 100644 index 0000000000..e348a05ea2 --- /dev/null +++ b/test/flatzinc/branching.cpp @@ -0,0 +1,197 @@ +/* + * Main authors: + * Mikael Zayenz Lagerkvist + * + * 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 "test/flatzinc.hh" + +#include + +#include +#include +#include + +namespace Test { namespace FlatZinc { namespace { + typedef std::unique_ptr FlatZincSpacePtr; + + /// Parse \a source and post its branchers with options \a args + FlatZincSpacePtr + post_branchers(const std::string& source, std::vector args = {}) { + Gecode::FlatZinc::FlatZincOptions fznopt("Gecode/FlatZinc"); + std::string cmd("fzn-gecode"); + int argc = static_cast(args.size()) + 1; + std::vector argv(argc); + argv[0] = cmd.data(); + for (int i = 1; i < argc; i++) + argv[i] = args[i - 1].data(); + fznopt.parse(argc, argv.data()); + + Gecode::FlatZinc::Printer p; + std::stringstream ss(source); + std::ostringstream err; + FlatZincSpacePtr fg(Gecode::FlatZinc::parse(ss, p, err)); + if (fg) + fg->create_branchers(p, fg->solve_annotations(), fznopt, false, err); + return fg; + } + + /// Return how the first choice of \a source prints for alternative \a a + std::string + first_choice(const std::string& source, unsigned int a) { + FlatZincSpacePtr fg = post_branchers(source); + if (!fg || (fg->status() != Gecode::SS_BRANCH)) + return ""; + std::unique_ptr c(fg->choice()); + std::ostringstream os; + fg->Gecode::Space::print(*c, a, os); + return os.str(); + } + + /// Verify that the -decay option reaches the default branchers. + class DefaultSearchDecay : public Base { + private: + static bool + uses_option(const std::string& source) { + FlatZincSpacePtr fg = post_branchers(source, {"-decay", "0.5"}); + return fg && (fg->afc_decay() == 0.5); + } + + public: + DefaultSearchDecay(void) : Base("FlatZinc::Branching::DefaultSearchDecay") {} + + bool + run(void) override { + return uses_option("var 0..1: x :: output_var;\n" + "var bool: b :: output_var;\n" + "solve satisfy;\n") && + uses_option("var 0..1: x :: output_var;\nsolve satisfy;\n") && + uses_option("var bool: b :: output_var;\nsolve satisfy;\n") +#ifdef GECODE_HAS_SET_VARS + && uses_option("var set of 1..2: s :: output_var;\nsolve satisfy;\n") +#endif + ; + } + }; + + DefaultSearchDecay default_search_decay; + + /// Verify that the combined variable selections keep their decay. + class IntBoolDecay : public Base { + private: + static bool + keeps_decay(const Gecode::FlatZinc::IntBoolVarBranch& b) { + return b.decay() == 0.5; + } + + public: + IntBoolDecay(void) : Base("FlatZinc::Branching::IntBoolDecay") {} + + bool + run(void) override { + using namespace Gecode::FlatZinc; + return keeps_decay(int_bool_var_afc_max(0.5)) && keeps_decay(int_bool_var_afc_size_max(0.5)) && + keeps_decay(int_bool_var_action_max(0.5)) && keeps_decay(int_bool_var_action_size_max(0.5)); + } + }; + + IntBoolDecay int_bool_decay; + +#ifdef GECODE_HAS_SET_VARS + /// Verify that set choices print the relations of their value selection. + class SetRelationNames : public Base { + private: + static bool + prints(const std::string& annotation, const std::string& left, const std::string& right) { + const std::string source = "var set of 1..3: s :: output_var;\nsolve :: " + annotation + " satisfy;\n"; + return (first_choice(source, 0) == left) && (first_choice(source, 1) == right); + } + + public: + SetRelationNames(void) : Base("FlatZinc::Branching::SetRelationNames") {} + + bool + run(void) override { + return prints("set_search([s], input_order, indomain_min, complete)", "s in 1", "s not in 1") && + prints("set_search([s], input_order, outdomain_min, complete)", "s not in 1", "s in 1") && + prints("set_default_search(input_order, outdomain_min)", "s not in 1", "s in 1"); + } + }; + + SetRelationNames set_relation_names; +#endif + + /// Tracer remembering the first value a variable is assigned to + class FirstAssignment : public Gecode::IntTracer { + public: + std::optional value; + + void + init(const Gecode::Space&, const Gecode::IntTraceRecorder&) override {} + void + prune(const Gecode::Space&, const Gecode::IntTraceRecorder& t, const Gecode::ViewTraceInfo&, int i, + Gecode::IntTraceDelta&) override { + if (!value && t[i].assigned()) + value = t[i].val(); + } + void + fail(const Gecode::Space&, const Gecode::IntTraceRecorder&) override {} + void + fix(const Gecode::Space&, const Gecode::IntTraceRecorder&) override {} + void + done(const Gecode::Space&, const Gecode::IntTraceRecorder&) override {} + }; + + /// Verify that a cloned auxiliary brancher keeps the default search. + class AuxVarClone : public Base { + public: + AuxVarClone(void) : Base("FlatZinc::Branching::AuxVarClone") {} + + bool + run(void) override { + FlatZincSpacePtr fg = post_branchers("var 0..3: a :: var_is_introduced;\n" + "solve :: int_default_search(input_order, indomain_max) satisfy;\n"); + if (!fg) + return false; + FirstAssignment tracer; + Gecode::trace(*fg, fg->iv_aux, Gecode::TE_PRUNE, tracer); + if (fg->status() != Gecode::SS_BRANCH) + return false; + std::unique_ptr clone(fg->clone()); + if (clone->status() != Gecode::SS_BRANCH) + return false; + std::unique_ptr c(clone->choice()); + return tracer.value == 3; + } + }; + + AuxVarClone aux_var_clone; +}}} // namespace Test::FlatZinc + +// STATISTICS: test-flatzinc diff --git a/test/float.cpp b/test/float.cpp index e53517be2f..5c896a34af 100644 --- a/test/float.cpp +++ b/test/float.cpp @@ -719,7 +719,7 @@ namespace Test { namespace Float { CHECK_TEST(subsumed(*s), "No subsumption"); if (sol == MT_TRUE) { CHECK_TEST(!s->r.var().assigned(), "Control variable assigned"); - } else if ((sol = MT_FALSE) && s->r.var().assigned()) { + } else if ((sol == MT_FALSE) && s->r.var().assigned()) { CHECK_TEST(s->r.var().val() == 0, "One on non-solution"); } delete s; diff --git a/test/float.hh b/test/float.hh index 9f1e0d9225..423924d950 100644 --- a/test/float.hh +++ b/test/float.hh @@ -61,9 +61,9 @@ namespace Test { /// Type for comparisons and solutions enum MaybeType { - MT_FALSE = 0, //< Does hold - MT_TRUE, //< Does not hold - MT_MAYBE //< Might or might not hold + MT_FALSE = 0, ///< Does not hold + MT_TRUE, ///< Does hold + MT_MAYBE ///< Might or might not hold }; /// Three-valued conjunction of MaybeType diff --git a/test/float/linear.cpp b/test/float/linear.cpp index 723c845245..77b48521b5 100644 --- a/test/float/linear.cpp +++ b/test/float/linear.cpp @@ -238,6 +238,21 @@ namespace Test { namespace Float { }; Empty empty; + /// %Test coefficients given by an initializer list + class InitializerList : public Base { + public: + /// Create and register test + InitializerList(void) : Base("Float::Linear::InitializerList") {} + /// Perform test + bool + run(void) override { + using namespace Gecode; + FloatValArgs a({2.0, -3.0}); + return (a.size() == 2) && (a[0].min() == 2.0) && (a[1].max() == -3.0); + } + }; + InitializerList initializer_list; + /// Help class to create and register tests class Create { public: diff --git a/test/int/bin-packing.cpp b/test/int/bin-packing.cpp index dbad6d8373..7da8eb1814 100644 --- a/test/int/bin-packing.cpp +++ b/test/int/bin-packing.cpp @@ -361,21 +361,20 @@ namespace Test { namespace Int { } }; + /// Space without variables + class Fixture : public Gecode::Space { + public: + Fixture(void) = default; + // NOLINTNEXTLINE(modernize-use-equals-default) + Fixture(Fixture& fixture) : Gecode::Space(fixture) {} + Gecode::Space* + copy(void) override { + return new Fixture(*this); + } + }; + /// %Test that both bin-packing overloads post nothing for zero items class Empty : public Base { - private: - /// Space without variables - class Fixture : public Gecode::Space { - public: - Fixture(void) = default; - // NOLINTNEXTLINE(modernize-use-equals-default) - Fixture(Fixture& fixture) : Gecode::Space(fixture) {} - Gecode::Space* - copy(void) override { - return new Fixture(*this); - } - }; - public: Empty(void) : Base("Int::BinPacking::Empty") {} bool @@ -403,6 +402,49 @@ namespace Test { namespace Int { Empty empty; + /// %Test that multi-dimensional bin packing needs at least one dimension + class NoDimension : public Base { + private: + /// Test whether posting with \a d dimensions throws Int::OutOfLimits + static bool + is_rejected(int d) { + using namespace Gecode; + Fixture home; + IntVarArgs l; + IntVarArgs b(home, 1, 0, 0); + IntArgs none; + try { + bin_packing(home, d, l, b, none, none); + } catch (const Gecode::Int::OutOfLimits&) { + return true; + } + return false; + } + /// Test whether shared variables are reported before the dimension + static bool + reports_same_first(void) { + using namespace Gecode; + Fixture home; + IntVarArgs x(home, 1, 0, 1); + IntArgs none; + try { + bin_packing(home, 0, x, x, none, none); + } catch (const Gecode::Int::ArgumentSame&) { + return true; + } + return false; + } + + public: + NoDimension(void) : Base("Int::BinPacking::NoDimension") {} + bool + run(void) override { + return is_rejected(0) && is_rejected(-1) && reports_same_first(); + } + }; + + NoDimension no_dimension; + /// %Test for comparing bin-packing items class ItemCompare : public Base { private: diff --git a/test/int/element.cpp b/test/int/element.cpp index 1093659e83..7393973df6 100644 --- a/test/int/element.cpp +++ b/test/int/element.cpp @@ -646,6 +646,90 @@ namespace Test { namespace Int { }; Create c; + + /// Space with the variables for posting two-dimensional element + class MatrixFixture : public Gecode::Space { + public: + /// Column + Gecode::IntVar x; + /// Row + Gecode::IntVar y; + /// Integer result + Gecode::IntVar z; + /// Boolean result + Gecode::BoolVar b; + /// Create fixture + MatrixFixture(void) : x(*this, 0, 1), y(*this, 0, 1), z(*this, 0, 1), b(*this, 0, 1) {} + /// Constructor for cloning \a fixture + MatrixFixture(MatrixFixture& fixture) : Gecode::Space(fixture) { + x.update(*this, fixture.x); + y.update(*this, fixture.y); + z.update(*this, fixture.z); + b.update(*this, fixture.b); + } + /// Copy during cloning + Gecode::Space* + copy(void) override { + return new MatrixFixture(*this); + } + }; + + /// Test whether \a post throws an exception of type \a E on a new space + template + bool + is_rejected(Post post) { + MatrixFixture home; + try { + post(home); + } catch (const E&) { + return true; + } + return false; + } + + /// Test whether every overload throws \a E for an array of size \a n, width \a w, and height \a h + template + bool + is_rejected_by_all(int n, int w, int h) { + using namespace Gecode; + IntSharedArray c(IntArgs::create(n, 0, 0)); + return is_rejected([&](MatrixFixture& s) { element(s, c, s.x, w, s.y, h, s.z); }) && + is_rejected([&](MatrixFixture& s) { element(s, c, s.x, 0, w, s.y, 0, h, s.z); }) && + is_rejected([&](MatrixFixture& s) { element(s, c, s.x, w, s.y, h, s.b); }) && + is_rejected([&](MatrixFixture& s) { element(s, c, s.x, 0, w, s.y, 0, h, s.b); }) && + is_rejected([&](MatrixFixture& s) { element(s, IntVarArgs(s, n, 0, 1), s.x, w, s.y, h, s.z); }) && + is_rejected( + [&](MatrixFixture& s) { element(s, IntVarArgs(s, n, 0, 1), s.x, 0, w, s.y, 0, h, s.z); }) && + is_rejected( + [&](MatrixFixture& s) { element(s, BoolVarArgs(s, n, 0, 1), s.x, w, s.y, h, s.b); }) && + is_rejected( + [&](MatrixFixture& s) { element(s, BoolVarArgs(s, n, 0, 1), s.x, 0, w, s.y, 0, h, s.b); }); + } + + /// %Test that two-dimensional element rejects invalid matrices + class MatrixInvalid : public Base { + public: + /// Create and register test + MatrixInvalid(void) : Base("Int::Element::Matrix::Invalid") {} + /// Perform test + bool + run(void) override { + using Gecode::Int::ArgumentSizeMismatch; + using Gecode::Int::TooFewArguments; + return is_rejected_by_all(0, 0, 0) && is_rejected_by_all(0, 0, 5) && + is_rejected_by_all(0, 5, 0) && is_rejected_by_all(0, 1, 1) && + // The product is a multiple of 2^32 + is_rejected_by_all(0, 65536, 65536) && + is_rejected_by_all(3, 0, 5) && + is_rejected_by_all(6, 2, -3) && + is_rejected_by_all(1, -1, -1) && + is_rejected_by_all(6, -2, -3) && + // The product is 2 * 2^32 + 1 + is_rejected_by_all(1, 9, 954437177); + } + }; + + MatrixInvalid matrix_invalid; //@} } // namespace Element diff --git a/test/ldsb.cpp b/test/ldsb.cpp index 29feaaf09f..f2d7464955 100644 --- a/test/ldsb.cpp +++ b/test/ldsb.cpp @@ -899,6 +899,31 @@ namespace Test { namespace LDSB { } }; + /// %Test for value sequence symmetry over the domain of a variable + class SimIntValSym4 { + public: + /// Number of variables + static const int n = 2; + /// Lower bound of values + static const int l = 0; + /// Upper bound of values + static const int u = 6; + /// Setup problem constraints and symmetries + static void + setup(Home home, IntVarArray& xs) { + Symmetries s; + // Values 0,1,2 are symmetric with 6,5,4. + s << values_reflect(xs[0]); + rel(home, xs[0] + xs[1] == 6); + branch(home, xs, INT_VAR_NONE(), INT_VAL_MED(), s); + } + /// Compute list of expected solutions + static std::vector + expected_solutions(void) { + return SimIntValSym3::expected_solutions(); + } + }; + /// %Test for value symmetry class ValSym1 { public: @@ -1927,6 +1952,7 @@ namespace Test { namespace LDSB { LDSB simintvalsym1("SimIntValSym1"); LDSB simintvalsym2("SimIntValSym2"); LDSB simintvalsym3("SimIntValSym3"); + LDSB simintvalsym4("SimIntValSym4"); LDSB valsym1("ValSym1"); LDSB valsym1b("ValSym1b"); LDSB valsym1c("ValSym1c"); diff --git a/test/region.cpp b/test/region.cpp index 13b168dc13..305a10d001 100644 --- a/test/region.cpp +++ b/test/region.cpp @@ -99,6 +99,89 @@ namespace Test { SpaceReallocEmpty space_realloc_empty; + /// %Test for growing and shrinking a block of pointers in a space + class SpaceReallocPointers : public Test::Base { + public: + /// Initialize test + SpaceReallocPointers(void) : Test::Base("Space::Realloc::Pointers") {} + /// Perform actual tests + bool + run(void) override { + EmptySpace home; + int values[2] = {0, 1}; + int** p = home.alloc(2); + p[0] = &values[0]; + p[1] = &values[1]; + // Unsigned long sizes select the overload for pointers + p = home.realloc(p, 2UL, 4UL); + const bool grown = (p[0] == &values[0]) && (p[1] == &values[1]); + p = home.realloc(p, 4UL, 2UL); + const bool reused = (home.fl_alloc<2 * sizeof(int*)>() == p + 2); + return grown && reused && (p[1] == &values[1]); + } + }; + + SpaceReallocPointers space_realloc_pointers; + + /// Object that counts its destructions + class CountedObject { + public: + /// Where to count destructions + int* destroyed = nullptr; + /// Count destruction + ~CountedObject(void) { + if (destroyed != nullptr) + (*destroyed)++; + } + }; + + /// Test whether shrinking in \a a destroys exactly the removed objects + template + bool + shrink_destroys_tail(Allocator& a) { + int destroyed = 0; + CountedObject* b = a.template alloc(4); + for (int i = 0; i < 4; i++) + b[i].destroyed = &destroyed; + b = a.template realloc(b, 4, 1); + const bool shrunk = (destroyed == 3); + a.template free(b, 1); + return shrunk && (destroyed == 4); + } + + /// %Test for shrinking blocks in a space + class SpaceReallocShrink : public Test::Base { + public: + /// Initialize test + SpaceReallocShrink(void) : Test::Base("Space::Realloc::Shrink") {} + /// Perform actual tests + bool + run(void) override { + EmptySpace home; + int* p = home.alloc(8); + int* tail = p + 4; + p = home.realloc(p, 8, 4); + return (home.fl_alloc<4 * sizeof(int)>() == tail) && shrink_destroys_tail(home); + } + }; + + SpaceReallocShrink space_realloc_shrink; + + /// %Test for shrinking blocks in a region + class RegionReallocShrink : public Test::Base { + public: + /// Initialize test + RegionReallocShrink(void) : Test::Base("Region::Realloc::Shrink") {} + /// Perform actual tests + bool + run(void) override { + Gecode::Region r; + return shrink_destroys_tail(r); + } + }; + + RegionReallocShrink region_realloc_shrink; + /// %Test for comparing space and region allocators class AllocatorCompare : public Test::Base { public: diff --git a/test/search.cpp b/test/search.cpp index e9db08025b..8717de9c43 100644 --- a/test/search.cpp +++ b/test/search.cpp @@ -2657,31 +2657,33 @@ namespace Test { return true; } }; + + /// Space for relaxing + class RelaxSpace : public Gecode::Space { + public: + RelaxSpace(void) = default; + // NOLINTNEXTLINE(modernize-use-equals-default) + RelaxSpace(RelaxSpace& space) : Gecode::Space(space) {} + Gecode::Space* + copy(void) override { + return new RelaxSpace(*this); + } + }; + /// Relaxing empty variable arrays posts nothing class RelaxEmpty : public Base { private: - /// Space without variables - class Fixture : public Gecode::Space { - public: - Fixture(void) = default; - // NOLINTNEXTLINE(modernize-use-equals-default) - Fixture(Fixture& fixture) : Gecode::Space(fixture) {} - Gecode::Space* - copy(void) override { - return new Fixture(*this); - } - }; /// Test whether relaxing empty \a VarArgs leaves a space with exactly one solution template static bool relaxes_empty(void) { - Fixture* s = new Fixture; + RelaxSpace* s = new RelaxSpace; Gecode::relax(*s, VarArgs(), VarArgs(), Gecode::Rnd(1U), 0.5); bool solved = s->status() == Gecode::SS_SOLVED; - Gecode::DFS e(s); + Gecode::DFS e(s); delete s; int n = 0; - while (Fixture* t = e.next()) { + while (RelaxSpace* t = e.next()) { n++; delete t; } @@ -2690,7 +2692,7 @@ namespace Test { /// Test whether relaxing empty arrays still checks the arguments static bool checks_arguments(void) { - Fixture s; + RelaxSpace s; bool mismatch = false; try { Gecode::relax(s, Gecode::IntVarArgs(), Gecode::IntVarArgs(s, 1, 0, 0), Gecode::Rnd(1U), 0.5); @@ -2723,6 +2725,22 @@ namespace Test { RelaxEmpty relax_empty; + /// Relaxing fails the space when a value cannot be kept + class RelaxFailed : public Base { + public: + RelaxFailed(void) : Base("Search::Relax::Failed") {} + bool + run(void) override { + RelaxSpace s; + Gecode::IntVarArgs x(s, 2, 0, 0); + Gecode::IntVarArgs sx(s, 2, 1, 1); + Gecode::relax(s, x, sx, Gecode::Rnd(1U), 0.0); + return s.failed(); + } + }; + + RelaxFailed relax_failed; + /// %Test for depth-first search template class DFS : public Test { @@ -3501,36 +3519,6 @@ namespace Test { RBSIncompleteDefault rbs_incomplete_default; - /// Space for relaxing - class RelaxSpace : public Gecode::Space { - public: - RelaxSpace(void) = default; - // NOLINTNEXTLINE(modernize-use-equals-default) - RelaxSpace(RelaxSpace& s) : Gecode::Space(s) {} - Gecode::Space* - copy(void) override { - return new RelaxSpace(*this); - } - }; - - /// Relaxing fails the space when a value cannot be kept - class RelaxFailed : public Base { - public: - RelaxFailed(void) : Base("Search::Relax::Failed") {} - bool - run(void) override { - RelaxSpace s; - // The kept value lies in a hole of the domain - Gecode::IntVarArgs x(s, 2, Gecode::IntSet({0, 2})); - Gecode::IntVarArgs sx(s, 2, 1, 1); - // Probability zero keeps one of the two values - Gecode::relax(s, x, sx, Gecode::Rnd(1U), 0.0); - return s.failed(); - } - }; - - RelaxFailed relax_failed; - /// %Test for portfolio-based search template class Engine> class PBS : public Test { diff --git a/test/set/construct.cpp b/test/set/construct.cpp index 2debeb20d6..6f26d3fd19 100644 --- a/test/set/construct.cpp +++ b/test/set/construct.cpp @@ -249,6 +249,42 @@ namespace Test { namespace Set { ViewCompare view_compare; + /// %Test default construction of value iterators + class DefaultValues : public ::Test::Base { + private: + /// Space for the variable behind the iterators + class Fixture : public Gecode::Space { + public: + Fixture(void) = default; + // NOLINTNEXTLINE(modernize-use-equals-default) + Fixture(Fixture& fixture) : Gecode::Space(fixture) {} + Gecode::Space* + copy(void) override { + return new Fixture(*this); + } + }; + + public: + /// Create and register test + DefaultValues(void) : ::Test::Base("Set::Var::DefaultValues") {} + /// Perform test + bool + run(void) override { + using namespace Gecode; + Fixture home; + SetVar x(home, IntSet(1, 1), IntSet(1, 2)); + SetVarGlbValues glb; + SetVarLubValues lub; + SetVarUnknownValues unknown; + glb = SetVarGlbValues(x); + lub = SetVarLubValues(x); + unknown = SetVarUnknownValues(x); + return glb() && (glb.val() == 1) && lub() && (lub.val() == 1) && unknown() && (unknown.val() == 2); + } + }; + + DefaultValues default_values; + } // namespace Var }} // namespace Test::Set diff --git a/test/set/element.cpp b/test/set/element.cpp index 8b2e411b0b..5663c2b2c4 100644 --- a/test/set/element.cpp +++ b/test/set/element.cpp @@ -431,6 +431,85 @@ namespace Test { namespace Set { }; ElementVarEmpty _element_var_empty; + /// Space with the variables for posting element with an integer index + class IndexFixture : public Gecode::Space { + public: + /// Index or column + IntVar x; + /// Row + IntVar y; + /// Result set + SetVar z; + /// Create fixture + IndexFixture(void) : x(*this, 0, 1), y(*this, 0, 1), z(*this, IntSet::empty, IntSet(0, 3)) {} + /// Constructor for cloning \a fixture + IndexFixture(IndexFixture& fixture) : Gecode::Space(fixture) { + x.update(*this, fixture.x); + y.update(*this, fixture.y); + z.update(*this, fixture.z); + } + /// Copy during cloning + Gecode::Space* + copy(void) override { + return new IndexFixture(*this); + } + }; + + /// Test whether posting a matrix of \a n sets throws \a E for both array types + template + bool + is_matrix_rejected(int n, int w, int h) { + IndexFixture constant, variable; + bool constant_rejected = false; + bool variable_rejected = false; + try { + element(constant, IntSetArgs(n), constant.x, w, constant.y, h, constant.z); + } catch (const E&) { + constant_rejected = true; + } + try { + element(variable, SetVarArgs(variable, n, IntSet::empty, 0, 3), variable.x, w, variable.y, h, + variable.z); + } catch (const E&) { + variable_rejected = true; + } + return constant_rejected && variable_rejected; + } + + /// Test whether posting over no sets throws Set::TooFewArguments for array type \a Args + template + bool + is_array_rejected(void) { + IndexFixture home; + try { + element(home, Args(), home.x, home.z); + } catch (const Gecode::Set::TooFewArguments&) { + return true; + } + return false; + } + + /// %Test that element with an integer index rejects invalid arrays and matrices + class ElementIndexInvalid : public Base { + public: + /// Create and register test + ElementIndexInvalid(void) : Base("Set::Element::Index::Invalid") {} + /// Perform test + bool + run(void) override { + using Gecode::Set::ArgumentSizeMismatch; + using Gecode::Set::TooFewArguments; + return is_array_rejected() && is_array_rejected() && + is_matrix_rejected(0, 0, 0) && is_matrix_rejected(0, 1, 1) && + is_matrix_rejected(3, 0, 5) && + is_matrix_rejected(1, -1, -1) && + is_matrix_rejected(6, -2, -3) && + // The product is 2 * 2^32 + 1 + is_matrix_rejected(1, 9, 954437177); + } + }; + ElementIndexInvalid _element_index_invalid; + /// %Test for matrix element with integer set array and set variable class MatrixIntSet : public SetTest { protected: diff --git a/test/set/mm-set.cpp b/test/set/mm-set.cpp index df4466cfc6..dc3ef72756 100644 --- a/test/set/mm-set.cpp +++ b/test/set/mm-set.cpp @@ -31,6 +31,7 @@ */ #include "test/int.hh" +#include "test/set.hh" #include @@ -148,8 +149,8 @@ namespace Test { namespace Int { public: /// Create and register test SetExprConst(TestTags tags, const SetInstr* bis0, const std::string& s, Gecode::SetRelType srt0, int c0) - : Test(tags, "MiniModel::SetExpr::Const::" + s + "::" + str(srt0) + "::" + str(c0), 4, 0, 1, - simple_reified_semantics(bis0)), + : Test(tags, "MiniModel::SetExpr::Const::" + s + "::" + Set::SetTest::str(srt0) + "::" + str(c0), 4, 0, + 1, simple_reified_semantics(bis0)), bis(bis0), c(c0), srt(srt0) {} /// %Test whether \a x is solution bool @@ -275,7 +276,7 @@ namespace Test { namespace Int { /// Create and register test SetExprExpr(TestTags tags, const SetInstr* bis00, const SetInstr* bis10, const std::string& s, Gecode::SetRelType srt0) - : Test(tags, "MiniModel::SetExpr::Expr::" + s + "::" + str(srt0), 8, 0, 1, + : Test(tags, "MiniModel::SetExpr::Expr::" + s + "::" + Set::SetTest::str(srt0), 8, 0, 1, simple_reified_semantics(bis00) && simple_reified_semantics(bis10)), bis0(bis00), bis1(bis10), srt(srt0) {} /// %Test whether \a x is solution diff --git a/test/set/sequence.cpp b/test/set/sequence.cpp index 61bf2705b9..0b2b6ed956 100644 --- a/test/set/sequence.cpp +++ b/test/set/sequence.cpp @@ -127,6 +127,38 @@ namespace Test { namespace Set { SeqU _sequ1(1); SeqU _sequ3(3); + /// %Test that sequence without a union rejects an empty array + class SeqEmpty : public Base { + private: + /// Space without variables + class Fixture : public Space { + public: + Fixture(void) = default; + // NOLINTNEXTLINE(modernize-use-equals-default) + Fixture(Fixture& fixture) : Space(fixture) {} + Space* + copy(void) override { + return new Fixture(*this); + } + }; + + public: + /// Create and register test + SeqEmpty(void) : Base("Set::Sequence::Empty") {} + /// Perform test + bool + run(void) override { + Fixture home; + try { + Gecode::sequence(home, SetVarArgs()); + } catch (const Gecode::Set::TooFewArguments&) { + return true; + } + return false; + } + }; + SeqEmpty _seq_empty; + } // namespace Sequence }} // namespace Test::Set