From a268843054e69ef4c7ac25540f8a7291e757d22e Mon Sep 17 00:00:00 2001 From: Mikael Zayenz Lagerkvist Date: Mon, 2 Nov 2026 01:51:37 +0100 Subject: [PATCH 1/6] Pass branch configuration handles by const& and move stored callbacks Zdev-Change-Id: Zcab7b04117e00a1fae0ceb57e7f08b8ef521927647e15241606b165f7a4eb00e --- gecode/float.hh | 50 ++++----- gecode/float/branch/action.cpp | 4 +- gecode/float/branch/assign.hpp | 8 +- gecode/float/branch/chb.cpp | 4 +- gecode/float/branch/val.hpp | 8 +- gecode/float/branch/var.hpp | 106 +++++++++---------- gecode/int.hh | 88 ++++++++-------- gecode/int/branch/action.cpp | 8 +- gecode/int/branch/assign.hpp | 16 +-- gecode/int/branch/chb.cpp | 8 +- gecode/int/branch/val.hpp | 16 +-- gecode/int/branch/var.hpp | 168 +++++++++++++++--------------- gecode/kernel/branch/action.hpp | 13 +-- gecode/kernel/branch/chb.hpp | 12 +-- gecode/kernel/branch/tiebreak.hpp | 11 +- gecode/kernel/branch/val.hpp | 6 +- gecode/kernel/branch/var.hpp | 28 ++--- gecode/set.hh | 54 +++++----- gecode/set/branch/action.cpp | 4 +- gecode/set/branch/assign.hpp | 10 +- gecode/set/branch/chb.cpp | 4 +- gecode/set/branch/val.hpp | 10 +- gecode/set/branch/var.hpp | 106 +++++++++---------- 23 files changed, 370 insertions(+), 372 deletions(-) diff --git a/gecode/float.hh b/gecode/float.hh index 3d75310029..2f6c591886 100644 --- a/gecode/float.hh +++ b/gecode/float.hh @@ -1514,7 +1514,7 @@ namespace Gecode { */ GECODE_FLOAT_EXPORT FloatAction(Home home, const FloatVarArgs& x, double d = 1.0, bool p = true, bool f = true, - FloatBranchMerit bm = nullptr); + const FloatBranchMerit& bm = nullptr); /** * \brief Initialize for float variables \a x with decay factor \a d * @@ -1529,7 +1529,7 @@ namespace Gecode { * */ GECODE_FLOAT_EXPORT void init(Home home, const FloatVarArgs& x, double d = 1.0, bool p = true, bool f = true, - FloatBranchMerit bm = nullptr); + const FloatBranchMerit& bm = nullptr); }; } // namespace Gecode @@ -1566,7 +1566,7 @@ namespace Gecode { * */ GECODE_FLOAT_EXPORT - FloatCHB(Home home, const FloatVarArgs& x, FloatBranchMerit bm = nullptr); + FloatCHB(Home home, const FloatVarArgs& x, const FloatBranchMerit& bm = nullptr); /** * \brief Initialize for float variables \a x * @@ -1578,7 +1578,7 @@ namespace Gecode { * action storage has been constructed with the default constructor. * */ - GECODE_FLOAT_EXPORT void init(Home home, const FloatVarArgs& x, FloatBranchMerit bm = nullptr); + GECODE_FLOAT_EXPORT void init(Home home, const FloatVarArgs& x, const FloatBranchMerit& bm = nullptr); }; } // namespace Gecode @@ -1641,17 +1641,17 @@ namespace Gecode { /// Initialize with strategy SEL_NONE FloatVarBranch(void); /// Initialize with random number generator \a r - FloatVarBranch(Rnd r); + FloatVarBranch(const Rnd& r); /// Initialize with selection strategy \a s and tie-break limit function \a t FloatVarBranch(Select s, BranchTbl t); /// Initialize with selection strategy \a s, decay factor \a d, and tie-break limit function \a t FloatVarBranch(Select s, double, BranchTbl t); /// Initialize with selection strategy \a s, AFC \a a, and tie-break limit function \a t - FloatVarBranch(Select s, FloatAFC a, BranchTbl t); + FloatVarBranch(Select s, const FloatAFC& a, BranchTbl t); /// Initialize with selection strategy \a s, action \a a, and tie-break limit function \a t - FloatVarBranch(Select s, FloatAction a, BranchTbl t); + FloatVarBranch(Select s, const FloatAction& a, BranchTbl t); /// Initialize with selection strategy \a s, CHB \a c, and tie-break limit function \a t - FloatVarBranch(Select s, FloatCHB c, BranchTbl t); + FloatVarBranch(Select s, const FloatCHB& c, BranchTbl t); /// Initialize with selection strategy \a s, branch merit function \a mf, and tie-break limit function \a t FloatVarBranch(Select s, FloatBranchMerit mf, BranchTbl t); /// Return selection strategy @@ -1668,7 +1668,7 @@ namespace Gecode { /// Select first unassigned variable FloatVarBranch FLOAT_VAR_NONE(void); /// Select random variable (uniform distribution, for tie breaking) - FloatVarBranch FLOAT_VAR_RND(Rnd r); + FloatVarBranch FLOAT_VAR_RND(const Rnd& r); /// Select variable with least merit according to branch merit function \a bm FloatVarBranch FLOAT_VAR_MERIT_MIN(FloatBranchMerit bm, BranchTbl tbl = nullptr); /// Select variable with highest merit according to branch merit function \a bm @@ -1680,27 +1680,27 @@ namespace Gecode { /// Select variable with smallest accumulated failure count with decay factor \a d FloatVarBranch FLOAT_VAR_AFC_MIN(double d = 1.0, BranchTbl tbl = nullptr); /// Select variable with smallest accumulated failure count - FloatVarBranch FLOAT_VAR_AFC_MIN(FloatAFC a, BranchTbl tbl = nullptr); + FloatVarBranch FLOAT_VAR_AFC_MIN(const FloatAFC& a, BranchTbl tbl = nullptr); /// Select variable with largest accumulated failure count with decay factor \a d FloatVarBranch FLOAT_VAR_AFC_MAX(double d = 1.0, BranchTbl tbl = nullptr); /// Select variable with largest accumulated failure count - FloatVarBranch FLOAT_VAR_AFC_MAX(FloatAFC a, BranchTbl tbl = nullptr); + FloatVarBranch FLOAT_VAR_AFC_MAX(const FloatAFC& a, BranchTbl tbl = nullptr); /// Select variable with lowest action with decay factor \a d FloatVarBranch FLOAT_VAR_ACTION_MIN(double d = 1.0, BranchTbl tbl = nullptr); /// Select variable with lowest action - FloatVarBranch FLOAT_VAR_ACTION_MIN(FloatAction a, BranchTbl tbl = nullptr); + FloatVarBranch FLOAT_VAR_ACTION_MIN(const FloatAction& a, BranchTbl tbl = nullptr); /// Select variable with highest action with decay factor \a d FloatVarBranch FLOAT_VAR_ACTION_MAX(double d = 1.0, BranchTbl tbl = nullptr); /// Select variable with highest action - FloatVarBranch FLOAT_VAR_ACTION_MAX(FloatAction a, BranchTbl tbl = nullptr); + FloatVarBranch FLOAT_VAR_ACTION_MAX(const FloatAction& a, BranchTbl tbl = nullptr); /// Select variable with lowest CHB Q-score FloatVarBranch FLOAT_VAR_CHB_MIN(BranchTbl tbl = nullptr); /// Select variable with lowest CHB Q-score - FloatVarBranch FLOAT_VAR_CHB_MIN(FloatCHB a, BranchTbl tbl = nullptr); + FloatVarBranch FLOAT_VAR_CHB_MIN(const FloatCHB& a, BranchTbl tbl = nullptr); /// Select variable with highest CHB Q-score FloatVarBranch FLOAT_VAR_CHB_MAX(BranchTbl tbl = nullptr); /// Select variable with highest CHB Q-score - FloatVarBranch FLOAT_VAR_CHB_MAX(FloatCHB a, BranchTbl tbl = nullptr); + FloatVarBranch FLOAT_VAR_CHB_MAX(const FloatCHB& a, BranchTbl tbl = nullptr); /// Select variable with smallest min FloatVarBranch FLOAT_VAR_MIN_MIN(BranchTbl tbl = nullptr); /// Select variable with largest min @@ -1720,27 +1720,27 @@ namespace Gecode { /// Select variable with smalllest accumulated failure count divided by domain size with decay factor \a d FloatVarBranch FLOAT_VAR_AFC_SIZE_MIN(double d = 1.0, BranchTbl tbl = nullptr); /// Select variable with smallest accumulated failure count divided by domain size - FloatVarBranch FLOAT_VAR_AFC_SIZE_MIN(FloatAFC a, BranchTbl tbl = nullptr); + FloatVarBranch FLOAT_VAR_AFC_SIZE_MIN(const FloatAFC& a, BranchTbl tbl = nullptr); /// Select variable with largest accumulated failure count divided by domain size with decay factor \a d FloatVarBranch FLOAT_VAR_AFC_SIZE_MAX(double d = 1.0, BranchTbl tbl = nullptr); /// Select variable with largest accumulated failure count divided by domain size - FloatVarBranch FLOAT_VAR_AFC_SIZE_MAX(FloatAFC a, BranchTbl tbl = nullptr); + FloatVarBranch FLOAT_VAR_AFC_SIZE_MAX(const FloatAFC& a, BranchTbl tbl = nullptr); /// Select variable with smallest action divided by domain size with decay factor \a d FloatVarBranch FLOAT_VAR_ACTION_SIZE_MIN(double d = 1.0, BranchTbl tbl = nullptr); /// Select variable with smallest action divided by domain size - FloatVarBranch FLOAT_VAR_ACTION_SIZE_MIN(FloatAction a, BranchTbl tbl = nullptr); + FloatVarBranch FLOAT_VAR_ACTION_SIZE_MIN(const FloatAction& a, BranchTbl tbl = nullptr); /// Select variable with largest action divided by domain size with decay factor \a d FloatVarBranch FLOAT_VAR_ACTION_SIZE_MAX(double d = 1.0, BranchTbl tbl = nullptr); /// Select variable with largest action divided by domain size - FloatVarBranch FLOAT_VAR_ACTION_SIZE_MAX(FloatAction a, BranchTbl tbl = nullptr); + FloatVarBranch FLOAT_VAR_ACTION_SIZE_MAX(const FloatAction& a, BranchTbl tbl = nullptr); /// Select variable with smallest CHB Q-score divided by domain size FloatVarBranch FLOAT_VAR_CHB_SIZE_MIN(BranchTbl tbl = nullptr); /// Select variable with smallest CHB Q-score divided by domain size - FloatVarBranch FLOAT_VAR_CHB_SIZE_MIN(FloatCHB c, BranchTbl tbl = nullptr); + FloatVarBranch FLOAT_VAR_CHB_SIZE_MIN(const FloatCHB& c, BranchTbl tbl = nullptr); /// Select variable with largest CHB Q-score divided by domain size FloatVarBranch FLOAT_VAR_CHB_SIZE_MAX(BranchTbl tbl = nullptr); /// Select variable with largest CHB Q-score divided by domain size - FloatVarBranch FLOAT_VAR_CHB_SIZE_MAX(FloatCHB a, BranchTbl tbl = nullptr); + FloatVarBranch FLOAT_VAR_CHB_SIZE_MAX(const FloatCHB& a, BranchTbl tbl = nullptr); //@} } // namespace Gecode @@ -1772,7 +1772,7 @@ namespace Gecode { /// Initialize with selection strategy \a s FloatValBranch(Select s = SEL_SPLIT_MIN); /// Initialize with random number generator \a r - FloatValBranch(Rnd r); + FloatValBranch(const Rnd& r); /// Initialize with value function \a f and commit function \a c FloatValBranch(FloatBranchVal v, FloatBranchCommit c); /// Return selection strategy @@ -1789,7 +1789,7 @@ namespace Gecode { /// Select values greater than mean of smallest and largest value FloatValBranch FLOAT_VAL_SPLIT_MAX(void); /// Select values randomly which are not greater or not smaller than mean of largest and smallest value - FloatValBranch FLOAT_VAL_SPLIT_RND(Rnd r); + FloatValBranch FLOAT_VAL_SPLIT_RND(const Rnd& r); /** * Select value as defined by the value function \a v and commit function \a c * The default commit function posts the constraint that the float variable @@ -1828,7 +1828,7 @@ namespace Gecode { /// Initialize with selection strategy \a s FloatAssign(Select s = SEL_MIN); /// Initialize with random number generator \a r - FloatAssign(Rnd r); + FloatAssign(const Rnd& r); /// Initialize with value function \a f and commit function \a c FloatAssign(FloatBranchVal v, FloatBranchCommit c); /// Return selection strategy @@ -1845,7 +1845,7 @@ namespace Gecode { /// Select median value of the upper part FloatAssign FLOAT_ASSIGN_MAX(void); /// Select median value of a randomly chosen part - FloatAssign FLOAT_ASSIGN_RND(Rnd r); + FloatAssign FLOAT_ASSIGN_RND(const Rnd& r); /** * Select value as defined by the value function \a v and commit function \a c * The default commit function posts the constraint that the float variable diff --git a/gecode/float/branch/action.cpp b/gecode/float/branch/action.cpp index 1ce0356a5e..00b0acb64c 100644 --- a/gecode/float/branch/action.cpp +++ b/gecode/float/branch/action.cpp @@ -34,13 +34,13 @@ namespace Gecode { - FloatAction::FloatAction(Home home, const FloatVarArgs& x, double d, bool p, bool f, FloatBranchMerit bm) { + FloatAction::FloatAction(Home home, const FloatVarArgs& x, double d, bool p, bool f, const FloatBranchMerit& bm) { ViewArray y(home, x); Action::init(home, y, d, p, f, bm); } void - FloatAction::init(Home home, const FloatVarArgs& x, double d, bool p, bool f, FloatBranchMerit bm) { + FloatAction::init(Home home, const FloatVarArgs& x, double d, bool p, bool f, const FloatBranchMerit& bm) { ViewArray y(home, x); Action::init(home, y, d, p, f, bm); } diff --git a/gecode/float/branch/assign.hpp b/gecode/float/branch/assign.hpp index d63635a7cd..e38cfa3bc8 100644 --- a/gecode/float/branch/assign.hpp +++ b/gecode/float/branch/assign.hpp @@ -37,12 +37,12 @@ namespace Gecode { : s(s0) {} forceinline - FloatAssign::FloatAssign(Rnd r) + FloatAssign::FloatAssign(const Rnd& r) : ValBranch(r), s(SEL_RND) {} forceinline FloatAssign::FloatAssign(FloatBranchVal v, FloatBranchCommit c) - : ValBranch(v, c), s(SEL_VAL_COMMIT) {} + : ValBranch(std::move(v), std::move(c)), s(SEL_VAL_COMMIT) {} forceinline FloatAssign::Select FloatAssign::select(void) const { @@ -60,13 +60,13 @@ namespace Gecode { } inline FloatAssign - FLOAT_ASSIGN_RND(Rnd r) { + FLOAT_ASSIGN_RND(const Rnd& r) { return FloatAssign(r); } inline FloatAssign FLOAT_ASSIGN(FloatBranchVal v, FloatBranchCommit c) { - return FloatAssign(v, c); + return FloatAssign(std::move(v), std::move(c)); } } // namespace Gecode diff --git a/gecode/float/branch/chb.cpp b/gecode/float/branch/chb.cpp index 4d5ec9e97c..b107395594 100644 --- a/gecode/float/branch/chb.cpp +++ b/gecode/float/branch/chb.cpp @@ -34,13 +34,13 @@ namespace Gecode { - FloatCHB::FloatCHB(Home home, const FloatVarArgs& x, FloatBranchMerit bm) { + FloatCHB::FloatCHB(Home home, const FloatVarArgs& x, const FloatBranchMerit& bm) { ViewArray y(home, x); CHB::init(home, y, bm); } void - FloatCHB::init(Home home, const FloatVarArgs& x, FloatBranchMerit bm) { + FloatCHB::init(Home home, const FloatVarArgs& x, const FloatBranchMerit& bm) { ViewArray y(home, x); CHB::init(home, y, bm); } diff --git a/gecode/float/branch/val.hpp b/gecode/float/branch/val.hpp index 2777e6b268..61d98505a5 100644 --- a/gecode/float/branch/val.hpp +++ b/gecode/float/branch/val.hpp @@ -37,12 +37,12 @@ namespace Gecode { : s(s0) {} forceinline - FloatValBranch::FloatValBranch(Rnd r) + FloatValBranch::FloatValBranch(const Rnd& r) : ValBranch(r), s(SEL_SPLIT_RND) {} forceinline FloatValBranch::FloatValBranch(FloatBranchVal v, FloatBranchCommit c) - : ValBranch(v, c), s(SEL_VAL_COMMIT) {} + : ValBranch(std::move(v), std::move(c)), s(SEL_VAL_COMMIT) {} forceinline FloatValBranch::Select FloatValBranch::select(void) const { @@ -60,13 +60,13 @@ namespace Gecode { } inline FloatValBranch - FLOAT_VAL_SPLIT_RND(Rnd r) { + FLOAT_VAL_SPLIT_RND(const Rnd& r) { return FloatValBranch(r); } inline FloatValBranch FLOAT_VAL(FloatBranchVal v, FloatBranchCommit c) { - return FloatValBranch(v, c); + return FloatValBranch(std::move(v), std::move(c)); } } // namespace Gecode diff --git a/gecode/float/branch/var.hpp b/gecode/float/branch/var.hpp index cacee2f701..bce2be4d63 100644 --- a/gecode/float/branch/var.hpp +++ b/gecode/float/branch/var.hpp @@ -43,7 +43,7 @@ namespace Gecode { : VarBranch(std::move(t)), s(s0) {} forceinline - FloatVarBranch::FloatVarBranch(Rnd r) + FloatVarBranch::FloatVarBranch(const Rnd& r) : VarBranch(r), s(SEL_RND) {} forceinline @@ -51,15 +51,15 @@ namespace Gecode { : VarBranch(d, std::move(t)), s(s0) {} forceinline - FloatVarBranch::FloatVarBranch(Select s0, FloatAFC a, BranchTbl t) + FloatVarBranch::FloatVarBranch(Select s0, const FloatAFC& a, BranchTbl t) : VarBranch(a, std::move(t)), s(s0) {} forceinline - FloatVarBranch::FloatVarBranch(Select s0, FloatAction a, BranchTbl t) + FloatVarBranch::FloatVarBranch(Select s0, const FloatAction& a, BranchTbl t) : VarBranch(a, std::move(t)), s(s0) {} forceinline - FloatVarBranch::FloatVarBranch(Select s0, FloatCHB c, BranchTbl t) + FloatVarBranch::FloatVarBranch(Select s0, const FloatCHB& c, BranchTbl t) : VarBranch(c, std::move(t)), s(s0) {} forceinline @@ -106,187 +106,187 @@ namespace Gecode { inline FloatVarBranch FLOAT_VAR_MERIT_MIN(FloatBranchMerit bm, BranchTbl tbl) { - return FloatVarBranch(FloatVarBranch::SEL_MERIT_MIN, bm, tbl); + return FloatVarBranch(FloatVarBranch::SEL_MERIT_MIN, std::move(bm), std::move(tbl)); } inline FloatVarBranch FLOAT_VAR_MERIT_MAX(FloatBranchMerit bm, BranchTbl tbl) { - return FloatVarBranch(FloatVarBranch::SEL_MERIT_MAX, bm, tbl); + return FloatVarBranch(FloatVarBranch::SEL_MERIT_MAX, std::move(bm), std::move(tbl)); } inline FloatVarBranch - FLOAT_VAR_RND(Rnd r) { + FLOAT_VAR_RND(const Rnd& r) { return FloatVarBranch(r); } inline FloatVarBranch FLOAT_VAR_DEGREE_MIN(BranchTbl tbl) { - return FloatVarBranch(FloatVarBranch::SEL_DEGREE_MIN, tbl); + return FloatVarBranch(FloatVarBranch::SEL_DEGREE_MIN, std::move(tbl)); } inline FloatVarBranch FLOAT_VAR_DEGREE_MAX(BranchTbl tbl) { - return FloatVarBranch(FloatVarBranch::SEL_DEGREE_MAX, tbl); + return FloatVarBranch(FloatVarBranch::SEL_DEGREE_MAX, std::move(tbl)); } inline FloatVarBranch FLOAT_VAR_AFC_MIN(double d, BranchTbl tbl) { - return FloatVarBranch(FloatVarBranch::SEL_AFC_MIN, d, tbl); + return FloatVarBranch(FloatVarBranch::SEL_AFC_MIN, d, std::move(tbl)); } inline FloatVarBranch - FLOAT_VAR_AFC_MIN(FloatAFC a, BranchTbl tbl) { - return FloatVarBranch(FloatVarBranch::SEL_AFC_MIN, a, tbl); + FLOAT_VAR_AFC_MIN(const FloatAFC& a, BranchTbl tbl) { + return FloatVarBranch(FloatVarBranch::SEL_AFC_MIN, a, std::move(tbl)); } inline FloatVarBranch FLOAT_VAR_AFC_MAX(double d, BranchTbl tbl) { - return FloatVarBranch(FloatVarBranch::SEL_AFC_MAX, d, tbl); + return FloatVarBranch(FloatVarBranch::SEL_AFC_MAX, d, std::move(tbl)); } inline FloatVarBranch - FLOAT_VAR_AFC_MAX(FloatAFC a, BranchTbl tbl) { - return FloatVarBranch(FloatVarBranch::SEL_AFC_MAX, a, tbl); + FLOAT_VAR_AFC_MAX(const FloatAFC& a, BranchTbl tbl) { + return FloatVarBranch(FloatVarBranch::SEL_AFC_MAX, a, std::move(tbl)); } inline FloatVarBranch FLOAT_VAR_ACTION_MIN(double d, BranchTbl tbl) { - return FloatVarBranch(FloatVarBranch::SEL_ACTION_MIN, d, tbl); + return FloatVarBranch(FloatVarBranch::SEL_ACTION_MIN, d, std::move(tbl)); } inline FloatVarBranch - FLOAT_VAR_ACTION_MIN(FloatAction a, BranchTbl tbl) { - return FloatVarBranch(FloatVarBranch::SEL_ACTION_MIN, a, tbl); + FLOAT_VAR_ACTION_MIN(const FloatAction& a, BranchTbl tbl) { + return FloatVarBranch(FloatVarBranch::SEL_ACTION_MIN, a, std::move(tbl)); } inline FloatVarBranch FLOAT_VAR_ACTION_MAX(double d, BranchTbl tbl) { - return FloatVarBranch(FloatVarBranch::SEL_ACTION_MAX, d, tbl); + return FloatVarBranch(FloatVarBranch::SEL_ACTION_MAX, d, std::move(tbl)); } inline FloatVarBranch - FLOAT_VAR_ACTION_MAX(FloatAction a, BranchTbl tbl) { - return FloatVarBranch(FloatVarBranch::SEL_ACTION_MAX, a, tbl); + FLOAT_VAR_ACTION_MAX(const FloatAction& a, BranchTbl tbl) { + return FloatVarBranch(FloatVarBranch::SEL_ACTION_MAX, a, std::move(tbl)); } inline FloatVarBranch FLOAT_VAR_CHB_MIN(BranchTbl tbl) { - return FloatVarBranch(FloatVarBranch::SEL_CHB_MIN, tbl); + return FloatVarBranch(FloatVarBranch::SEL_CHB_MIN, std::move(tbl)); } inline FloatVarBranch - FLOAT_VAR_CHB_MIN(FloatCHB c, BranchTbl tbl) { - return FloatVarBranch(FloatVarBranch::SEL_CHB_MIN, c, tbl); + FLOAT_VAR_CHB_MIN(const FloatCHB& c, BranchTbl tbl) { + return FloatVarBranch(FloatVarBranch::SEL_CHB_MIN, c, std::move(tbl)); } inline FloatVarBranch FLOAT_VAR_CHB_MAX(BranchTbl tbl) { - return FloatVarBranch(FloatVarBranch::SEL_CHB_MAX, tbl); + return FloatVarBranch(FloatVarBranch::SEL_CHB_MAX, std::move(tbl)); } inline FloatVarBranch - FLOAT_VAR_CHB_MAX(FloatCHB c, BranchTbl tbl) { - return FloatVarBranch(FloatVarBranch::SEL_CHB_MAX, c, tbl); + FLOAT_VAR_CHB_MAX(const FloatCHB& c, BranchTbl tbl) { + return FloatVarBranch(FloatVarBranch::SEL_CHB_MAX, c, std::move(tbl)); } inline FloatVarBranch FLOAT_VAR_MIN_MIN(BranchTbl tbl) { - return FloatVarBranch(FloatVarBranch::SEL_MIN_MIN, tbl); + return FloatVarBranch(FloatVarBranch::SEL_MIN_MIN, std::move(tbl)); } inline FloatVarBranch FLOAT_VAR_MIN_MAX(BranchTbl tbl) { - return FloatVarBranch(FloatVarBranch::SEL_MIN_MAX, tbl); + return FloatVarBranch(FloatVarBranch::SEL_MIN_MAX, std::move(tbl)); } inline FloatVarBranch FLOAT_VAR_MAX_MIN(BranchTbl tbl) { - return FloatVarBranch(FloatVarBranch::SEL_MAX_MIN, tbl); + return FloatVarBranch(FloatVarBranch::SEL_MAX_MIN, std::move(tbl)); } inline FloatVarBranch FLOAT_VAR_MAX_MAX(BranchTbl tbl) { - return FloatVarBranch(FloatVarBranch::SEL_MAX_MAX, tbl); + return FloatVarBranch(FloatVarBranch::SEL_MAX_MAX, std::move(tbl)); } inline FloatVarBranch FLOAT_VAR_SIZE_MIN(BranchTbl tbl) { - return FloatVarBranch(FloatVarBranch::SEL_SIZE_MIN, tbl); + return FloatVarBranch(FloatVarBranch::SEL_SIZE_MIN, std::move(tbl)); } inline FloatVarBranch FLOAT_VAR_SIZE_MAX(BranchTbl tbl) { - return FloatVarBranch(FloatVarBranch::SEL_SIZE_MAX, tbl); + return FloatVarBranch(FloatVarBranch::SEL_SIZE_MAX, std::move(tbl)); } inline FloatVarBranch FLOAT_VAR_DEGREE_SIZE_MIN(BranchTbl tbl) { - return FloatVarBranch(FloatVarBranch::SEL_DEGREE_SIZE_MIN, tbl); + return FloatVarBranch(FloatVarBranch::SEL_DEGREE_SIZE_MIN, std::move(tbl)); } inline FloatVarBranch FLOAT_VAR_DEGREE_SIZE_MAX(BranchTbl tbl) { - return FloatVarBranch(FloatVarBranch::SEL_DEGREE_SIZE_MAX, tbl); + return FloatVarBranch(FloatVarBranch::SEL_DEGREE_SIZE_MAX, std::move(tbl)); } inline FloatVarBranch FLOAT_VAR_AFC_SIZE_MIN(double d, BranchTbl tbl) { - return FloatVarBranch(FloatVarBranch::SEL_AFC_SIZE_MIN, d, tbl); + return FloatVarBranch(FloatVarBranch::SEL_AFC_SIZE_MIN, d, std::move(tbl)); } inline FloatVarBranch - FLOAT_VAR_AFC_SIZE_MIN(FloatAFC a, BranchTbl tbl) { - return FloatVarBranch(FloatVarBranch::SEL_AFC_SIZE_MIN, a, tbl); + FLOAT_VAR_AFC_SIZE_MIN(const FloatAFC& a, BranchTbl tbl) { + return FloatVarBranch(FloatVarBranch::SEL_AFC_SIZE_MIN, a, std::move(tbl)); } inline FloatVarBranch FLOAT_VAR_AFC_SIZE_MAX(double d, BranchTbl tbl) { - return FloatVarBranch(FloatVarBranch::SEL_AFC_SIZE_MAX, d, tbl); + return FloatVarBranch(FloatVarBranch::SEL_AFC_SIZE_MAX, d, std::move(tbl)); } inline FloatVarBranch - FLOAT_VAR_AFC_SIZE_MAX(FloatAFC a, BranchTbl tbl) { - return FloatVarBranch(FloatVarBranch::SEL_AFC_SIZE_MAX, a, tbl); + FLOAT_VAR_AFC_SIZE_MAX(const FloatAFC& a, BranchTbl tbl) { + return FloatVarBranch(FloatVarBranch::SEL_AFC_SIZE_MAX, a, std::move(tbl)); } inline FloatVarBranch FLOAT_VAR_ACTION_SIZE_MIN(double d, BranchTbl tbl) { - return FloatVarBranch(FloatVarBranch::SEL_ACTION_SIZE_MIN, d, tbl); + return FloatVarBranch(FloatVarBranch::SEL_ACTION_SIZE_MIN, d, std::move(tbl)); } inline FloatVarBranch - FLOAT_VAR_ACTION_SIZE_MIN(FloatAction a, BranchTbl tbl) { - return FloatVarBranch(FloatVarBranch::SEL_ACTION_SIZE_MIN, a, tbl); + FLOAT_VAR_ACTION_SIZE_MIN(const FloatAction& a, BranchTbl tbl) { + return FloatVarBranch(FloatVarBranch::SEL_ACTION_SIZE_MIN, a, std::move(tbl)); } inline FloatVarBranch FLOAT_VAR_ACTION_SIZE_MAX(double d, BranchTbl tbl) { - return FloatVarBranch(FloatVarBranch::SEL_ACTION_SIZE_MAX, d, tbl); + return FloatVarBranch(FloatVarBranch::SEL_ACTION_SIZE_MAX, d, std::move(tbl)); } inline FloatVarBranch - FLOAT_VAR_ACTION_SIZE_MAX(FloatAction a, BranchTbl tbl) { - return FloatVarBranch(FloatVarBranch::SEL_ACTION_SIZE_MAX, a, tbl); + FLOAT_VAR_ACTION_SIZE_MAX(const FloatAction& a, BranchTbl tbl) { + return FloatVarBranch(FloatVarBranch::SEL_ACTION_SIZE_MAX, a, std::move(tbl)); } inline FloatVarBranch FLOAT_VAR_CHB_SIZE_MIN(BranchTbl tbl) { - return FloatVarBranch(FloatVarBranch::SEL_CHB_SIZE_MIN, tbl); + return FloatVarBranch(FloatVarBranch::SEL_CHB_SIZE_MIN, std::move(tbl)); } inline FloatVarBranch - FLOAT_VAR_CHB_SIZE_MIN(FloatCHB c, BranchTbl tbl) { - return FloatVarBranch(FloatVarBranch::SEL_CHB_SIZE_MIN, c, tbl); + FLOAT_VAR_CHB_SIZE_MIN(const FloatCHB& c, BranchTbl tbl) { + return FloatVarBranch(FloatVarBranch::SEL_CHB_SIZE_MIN, c, std::move(tbl)); } inline FloatVarBranch FLOAT_VAR_CHB_SIZE_MAX(BranchTbl tbl) { - return FloatVarBranch(FloatVarBranch::SEL_CHB_SIZE_MAX, tbl); + return FloatVarBranch(FloatVarBranch::SEL_CHB_SIZE_MAX, std::move(tbl)); } inline FloatVarBranch - FLOAT_VAR_CHB_SIZE_MAX(FloatCHB c, BranchTbl tbl) { - return FloatVarBranch(FloatVarBranch::SEL_CHB_SIZE_MAX, c, tbl); + FLOAT_VAR_CHB_SIZE_MAX(const FloatCHB& c, BranchTbl tbl) { + return FloatVarBranch(FloatVarBranch::SEL_CHB_SIZE_MAX, c, std::move(tbl)); } } // namespace Gecode diff --git a/gecode/int.hh b/gecode/int.hh index ad548107d8..26ffe6aea9 100644 --- a/gecode/int.hh +++ b/gecode/int.hh @@ -5026,7 +5026,7 @@ namespace Gecode { */ GECODE_INT_EXPORT IntAction(Home home, const IntVarArgs& x, double d = 1.0, bool p = true, bool f = true, - IntBranchMerit bm = nullptr); + const IntBranchMerit& bm = nullptr); /** * \brief Initialize for integer variables \a x with decay factor \a d * @@ -5041,7 +5041,7 @@ namespace Gecode { * */ GECODE_INT_EXPORT void init(Home home, const IntVarArgs& x, double d = 1.0, bool p = true, bool f = true, - IntBranchMerit bm = nullptr); + const IntBranchMerit& bm = nullptr); }; /** @@ -5074,7 +5074,7 @@ namespace Gecode { */ GECODE_INT_EXPORT BoolAction(Home home, const BoolVarArgs& x, double d = 1.0, bool p = true, bool f = true, - BoolBranchMerit bm = nullptr); + const BoolBranchMerit& bm = nullptr); /** * \brief Initialize for Boolean variables \a x with decay factor \a d * @@ -5089,7 +5089,7 @@ namespace Gecode { * */ GECODE_INT_EXPORT void init(Home home, const BoolVarArgs& x, double d = 1.0, bool p = true, bool f = true, - BoolBranchMerit bm = nullptr); + const BoolBranchMerit& bm = nullptr); }; } // namespace Gecode @@ -5126,7 +5126,7 @@ namespace Gecode { * */ GECODE_INT_EXPORT - IntCHB(Home home, const IntVarArgs& x, IntBranchMerit bm = nullptr); + IntCHB(Home home, const IntVarArgs& x, const IntBranchMerit& bm = nullptr); /** * \brief Initialize for integer variables \a x * @@ -5138,7 +5138,7 @@ namespace Gecode { * action storage has been constructed with the default constructor. * */ - GECODE_INT_EXPORT void init(Home home, const IntVarArgs& x, IntBranchMerit bm = nullptr); + GECODE_INT_EXPORT void init(Home home, const IntVarArgs& x, const IntBranchMerit& bm = nullptr); }; /** @@ -5169,7 +5169,7 @@ namespace Gecode { * */ GECODE_INT_EXPORT - BoolCHB(Home home, const BoolVarArgs& x, BoolBranchMerit bm = nullptr); + BoolCHB(Home home, const BoolVarArgs& x, const BoolBranchMerit& bm = nullptr); /** * \brief Initialize for Boolean variables \a x * @@ -5181,7 +5181,7 @@ namespace Gecode { * action storage has been constructed with the default constructor. * */ - GECODE_INT_EXPORT void init(Home home, const BoolVarArgs& x, BoolBranchMerit bm = nullptr); + GECODE_INT_EXPORT void init(Home home, const BoolVarArgs& x, const BoolBranchMerit& bm = nullptr); }; } // namespace Gecode @@ -5273,17 +5273,17 @@ namespace Gecode { /// Initialize with strategy SEL_NONE IntVarBranch(void); /// Initialize with random number generator \a r - IntVarBranch(Rnd r); + IntVarBranch(const Rnd& r); /// Initialize with selection strategy \a s and tie-break limit function \a t IntVarBranch(Select s, BranchTbl t); /// Initialize with selection strategy \a s, decay factor \a d, and tie-break limit function \a t IntVarBranch(Select s, double d, BranchTbl t); /// Initialize with selection strategy \a s, AFC \a a, and tie-break limit function \a t - IntVarBranch(Select s, IntAFC a, BranchTbl t); + IntVarBranch(Select s, const IntAFC& a, BranchTbl t); /// Initialize with selection strategy \a s, action \a a, and tie-break limit function \a t - IntVarBranch(Select s, IntAction a, BranchTbl t); + IntVarBranch(Select s, const IntAction& a, BranchTbl t); /// Initialize with selection strategy \a s, CHB \a c, and tie-break limit function \a t - IntVarBranch(Select s, IntCHB c, BranchTbl t); + IntVarBranch(Select s, const IntCHB& c, BranchTbl t); /// Initialize with selection strategy \a s, branch merit function \a mf, and tie-break limit function \a t IntVarBranch(Select s, IntBranchMerit mf, BranchTbl t); /// Return selection strategy @@ -5323,17 +5323,17 @@ namespace Gecode { /// Initialize with strategy SEL_NONE BoolVarBranch(void); /// Initialize with random number generator \a r - BoolVarBranch(Rnd r); + BoolVarBranch(const Rnd& r); /// Initialize with selection strategy \a s and tie-break limit function \a t BoolVarBranch(Select s, BranchTbl t); /// Initialize with selection strategy \a s, decay factor \a d, and tie-break limit function \a t BoolVarBranch(Select s, double d, BranchTbl t); /// Initialize with selection strategy \a s, AFC \a a, and tie-break limit function \a t - BoolVarBranch(Select s, BoolAFC a, BranchTbl t); + BoolVarBranch(Select s, const BoolAFC& a, BranchTbl t); /// Initialize with selection strategy \a s, action \a a, and tie-break limit function \a t - BoolVarBranch(Select s, BoolAction a, BranchTbl t); + BoolVarBranch(Select s, const BoolAction& a, BranchTbl t); /// Initialize with selection strategy \a s, CHB \a c, and tie-break limit function \a t - BoolVarBranch(Select s, BoolCHB c, BranchTbl t); + BoolVarBranch(Select s, const BoolCHB& c, BranchTbl t); /// Initialize with selection strategy \a s, branch merit function \a mf, and tie-break limit function \a t BoolVarBranch(Select s, BoolBranchMerit mf, BranchTbl t); /// Return selection strategy @@ -5350,7 +5350,7 @@ namespace Gecode { /// Select first unassigned variable IntVarBranch INT_VAR_NONE(void); /// Select random variable (uniform distribution, for tie breaking) - IntVarBranch INT_VAR_RND(Rnd r); + IntVarBranch INT_VAR_RND(const Rnd& r); /// Select variable with least merit according to branch merit function \a bm IntVarBranch INT_VAR_MERIT_MIN(IntBranchMerit bm, BranchTbl tbl = nullptr); /// Select variable with highest merit according to branch merit function \a bm @@ -5362,25 +5362,25 @@ namespace Gecode { /// Select variable with smallest accumulated failure count with decay factor \a d IntVarBranch INT_VAR_AFC_MIN(double d = 1.0, BranchTbl tbl = nullptr); /// Select variable with smallest accumulated failure count - IntVarBranch INT_VAR_AFC_MIN(IntAFC a, BranchTbl tbl = nullptr); + IntVarBranch INT_VAR_AFC_MIN(const IntAFC& a, BranchTbl tbl = nullptr); /// Select variable with largest accumulated failure count with decay factor \a d IntVarBranch INT_VAR_AFC_MAX(double d = 1.0, BranchTbl tbl = nullptr); /// Select variable with largest accumulated failure count - IntVarBranch INT_VAR_AFC_MAX(IntAFC a, BranchTbl tbl = nullptr); + IntVarBranch INT_VAR_AFC_MAX(const IntAFC& a, BranchTbl tbl = nullptr); /// Select variable with lowest action with decay factor \a d IntVarBranch INT_VAR_ACTION_MIN(double d = 1.0, BranchTbl tbl = nullptr); /// Select variable with lowest action - IntVarBranch INT_VAR_ACTION_MIN(IntAction a, BranchTbl tbl = nullptr); + IntVarBranch INT_VAR_ACTION_MIN(const IntAction& a, BranchTbl tbl = nullptr); /// Select variable with highest action with decay factor \a d IntVarBranch INT_VAR_ACTION_MAX(double d = 1.0, BranchTbl tbl = nullptr); /// Select variable with highest action - IntVarBranch INT_VAR_ACTION_MAX(IntAction a, BranchTbl tbl = nullptr); + IntVarBranch INT_VAR_ACTION_MAX(const IntAction& a, BranchTbl tbl = nullptr); /// Select variable with lowest CHB Q-score - IntVarBranch INT_VAR_CHB_MIN(IntCHB c, BranchTbl tbl = nullptr); + IntVarBranch INT_VAR_CHB_MIN(const IntCHB& c, BranchTbl tbl = nullptr); /// Select variable with lowest CHB Q-score IntVarBranch INT_VAR_CHB_MIN(BranchTbl tbl = nullptr); /// Select variable with largest CHB Q-score - IntVarBranch INT_VAR_CHB_MAX(IntCHB c, BranchTbl tbl = nullptr); + IntVarBranch INT_VAR_CHB_MAX(const IntCHB& c, BranchTbl tbl = nullptr); /// Select variable with largest CHB Q-score IntVarBranch INT_VAR_CHB_MAX(BranchTbl tbl = nullptr); /// Select variable with smallest min @@ -5402,25 +5402,25 @@ namespace Gecode { /// Select variable with smallest accumulated failure count divided by domain size with decay factor \a d IntVarBranch INT_VAR_AFC_SIZE_MIN(double d = 1.0, BranchTbl tbl = nullptr); /// Select variable with smallest accumulated failure count divided by domain size - IntVarBranch INT_VAR_AFC_SIZE_MIN(IntAFC a, BranchTbl tbl = nullptr); + IntVarBranch INT_VAR_AFC_SIZE_MIN(const IntAFC& a, BranchTbl tbl = nullptr); /// Select variable with largest accumulated failure count divided by domain size with decay factor \a d IntVarBranch INT_VAR_AFC_SIZE_MAX(double d = 1.0, BranchTbl tbl = nullptr); /// Select variable with largest accumulated failure count divided by domain size - IntVarBranch INT_VAR_AFC_SIZE_MAX(IntAFC a, BranchTbl tbl = nullptr); + IntVarBranch INT_VAR_AFC_SIZE_MAX(const IntAFC& a, BranchTbl tbl = nullptr); /// Select variable with smallest action divided by domain size with decay factor \a d IntVarBranch INT_VAR_ACTION_SIZE_MIN(double d = 1.0, BranchTbl tbl = nullptr); /// Select variable with smallest action divided by domain size - IntVarBranch INT_VAR_ACTION_SIZE_MIN(IntAction a, BranchTbl tbl = nullptr); + IntVarBranch INT_VAR_ACTION_SIZE_MIN(const IntAction& a, BranchTbl tbl = nullptr); /// Select variable with largest action divided by domain size with decay factor \a d IntVarBranch INT_VAR_ACTION_SIZE_MAX(double d = 1.0, BranchTbl tbl = nullptr); /// Select variable with largest action divided by domain size - IntVarBranch INT_VAR_ACTION_SIZE_MAX(IntAction a, BranchTbl tbl = nullptr); + IntVarBranch INT_VAR_ACTION_SIZE_MAX(const IntAction& a, BranchTbl tbl = nullptr); /// Select variable with smallest CHB Q-score divided by domain size - IntVarBranch INT_VAR_CHB_SIZE_MIN(IntCHB c, BranchTbl tbl = nullptr); + IntVarBranch INT_VAR_CHB_SIZE_MIN(const IntCHB& c, BranchTbl tbl = nullptr); /// Select variable with smallest CHB Q-score divided by domain size IntVarBranch INT_VAR_CHB_SIZE_MIN(BranchTbl tbl = nullptr); /// Select variable with largest CHB Q-score divided by domain size - IntVarBranch INT_VAR_CHB_SIZE_MAX(IntCHB c, BranchTbl tbl = nullptr); + IntVarBranch INT_VAR_CHB_SIZE_MAX(const IntCHB& c, BranchTbl tbl = nullptr); /// Select variable with largest CHB Q-score divided by domain size IntVarBranch INT_VAR_CHB_SIZE_MAX(BranchTbl tbl = nullptr); /** \brief Select variable with smallest min-regret @@ -5451,7 +5451,7 @@ namespace Gecode { /// Select first unassigned variable BoolVarBranch BOOL_VAR_NONE(void); /// Select random variable (uniform distribution, for tie breaking) - BoolVarBranch BOOL_VAR_RND(Rnd r); + BoolVarBranch BOOL_VAR_RND(const Rnd& r); /// Select variable with least merit according to branch merit function \a bm BoolVarBranch BOOL_VAR_MERIT_MIN(BoolBranchMerit bm, BranchTbl tbl = nullptr); /// Select variable with highest merit according to branch merit function \a bm @@ -5463,25 +5463,25 @@ namespace Gecode { /// Select variable with smallest accumulated failure count with decay factor \a d BoolVarBranch BOOL_VAR_AFC_MIN(double d = 1.0, BranchTbl tbl = nullptr); /// Select variable with smallest accumulated failure count - BoolVarBranch BOOL_VAR_AFC_MIN(BoolAFC a, BranchTbl tbl = nullptr); + BoolVarBranch BOOL_VAR_AFC_MIN(const BoolAFC& a, BranchTbl tbl = nullptr); /// Select variable with largest accumulated failure count with decay factor \a d BoolVarBranch BOOL_VAR_AFC_MAX(double d = 1.0, BranchTbl tbl = nullptr); /// Select variable with largest accumulated failure count - BoolVarBranch BOOL_VAR_AFC_MAX(BoolAFC a, BranchTbl tbl = nullptr); + BoolVarBranch BOOL_VAR_AFC_MAX(const BoolAFC& a, BranchTbl tbl = nullptr); /// Select variable with lowest action with decay factor \a d BoolVarBranch BOOL_VAR_ACTION_MIN(double d = 1.0, BranchTbl tbl = nullptr); /// Select variable with lowest action - BoolVarBranch BOOL_VAR_ACTION_MIN(BoolAction a, BranchTbl tbl = nullptr); + BoolVarBranch BOOL_VAR_ACTION_MIN(const BoolAction& a, BranchTbl tbl = nullptr); /// Select variable with highest action with decay factor \a d BoolVarBranch BOOL_VAR_ACTION_MAX(double d = 1.0, BranchTbl tbl = nullptr); /// Select variable with highest action - BoolVarBranch BOOL_VAR_ACTION_MAX(BoolAction a, BranchTbl tbl = nullptr); + BoolVarBranch BOOL_VAR_ACTION_MAX(const BoolAction& a, BranchTbl tbl = nullptr); /// Select variable with lowest CHB Q-score - BoolVarBranch BOOL_VAR_CHB_MIN(BoolCHB c, BranchTbl tbl = nullptr); + BoolVarBranch BOOL_VAR_CHB_MIN(const BoolCHB& c, BranchTbl tbl = nullptr); /// Select variable with lowest CHB Q-score BoolVarBranch BOOL_VAR_CHB_MIN(BranchTbl tbl = nullptr); /// Select variable with largest CHB Q-score - BoolVarBranch BOOL_VAR_CHB_MAX(BoolCHB c, BranchTbl tbl = nullptr); + BoolVarBranch BOOL_VAR_CHB_MAX(const BoolCHB& c, BranchTbl tbl = nullptr); /// Select variable with largest CHB Q-score BoolVarBranch BOOL_VAR_CHB_MAX(BranchTbl tbl = nullptr); //@} @@ -5522,7 +5522,7 @@ namespace Gecode { /// Initialize with selection strategy \a s IntValBranch(Select s = SEL_MIN); /// Initialize with random number generator \a r - IntValBranch(Rnd r); + IntValBranch(const Rnd& r); /// Initialize with value function \a f and commit function \a c IntValBranch(IntBranchVal v, IntBranchCommit c); /// Return selection strategy @@ -5552,7 +5552,7 @@ namespace Gecode { /// Initialize with selection strategy \a s BoolValBranch(Select s = SEL_MIN); /// Initialize with random number generator \a r - BoolValBranch(Rnd r); + BoolValBranch(const Rnd& r); /// Initialize with value function \a f and commit function \a c BoolValBranch(BoolBranchVal v, BoolBranchCommit c); /// Return selection strategy @@ -5571,7 +5571,7 @@ namespace Gecode { /// Select largest value IntValBranch INT_VAL_MAX(void); /// Select random value - IntValBranch INT_VAL_RND(Rnd r); + IntValBranch INT_VAL_RND(const Rnd& r); /// Select values not greater than mean of smallest and largest value IntValBranch INT_VAL_SPLIT_MIN(void); /// Select values greater than mean of smallest and largest value @@ -5597,7 +5597,7 @@ namespace Gecode { /// Select largest value BoolValBranch BOOL_VAL_MAX(void); /// Select random value - BoolValBranch BOOL_VAL_RND(Rnd r); + BoolValBranch BOOL_VAL_RND(const Rnd& r); /** * \brief Select value as defined by the value function \a v and commit function \a c * Uses a commit function as default that posts the constraints that @@ -5637,7 +5637,7 @@ namespace Gecode { /// Initialize with selection strategy \a s IntAssign(Select s = SEL_MIN); /// Initialize with random number generator \a r - IntAssign(Rnd r); + IntAssign(const Rnd& r); /// Initialize with value function \a f and commit function \a c IntAssign(IntBranchVal v, IntBranchCommit c); /// Return selection strategy @@ -5667,7 +5667,7 @@ namespace Gecode { /// Initialize with selection strategy \a s BoolAssign(Select s = SEL_MIN); /// Initialize with random number generator \a r - BoolAssign(Rnd r); + BoolAssign(const Rnd& r); /// Initialize with value function \a f and commit function \a c BoolAssign(BoolBranchVal v, BoolBranchCommit c); /// Return selection strategy @@ -5686,7 +5686,7 @@ namespace Gecode { /// Select largest value IntAssign INT_ASSIGN_MAX(void); /// Select random value - IntAssign INT_ASSIGN_RND(Rnd r); + IntAssign INT_ASSIGN_RND(const Rnd& r); /** * \brief Select value as defined by the value function \a v and commit function \a c * @@ -5700,7 +5700,7 @@ namespace Gecode { /// Select largest value BoolAssign BOOL_ASSIGN_MAX(void); /// Select random value - BoolAssign BOOL_ASSIGN_RND(Rnd r); + BoolAssign BOOL_ASSIGN_RND(const Rnd& r); /** * \brief Select value as defined by the value function \a v and commit function \a c * diff --git a/gecode/int/branch/action.cpp b/gecode/int/branch/action.cpp index 3b6e259b3c..f74de303b4 100644 --- a/gecode/int/branch/action.cpp +++ b/gecode/int/branch/action.cpp @@ -34,24 +34,24 @@ namespace Gecode { - IntAction::IntAction(Home home, const IntVarArgs& x, double d, bool p, bool f, IntBranchMerit bm) { + IntAction::IntAction(Home home, const IntVarArgs& x, double d, bool p, bool f, const IntBranchMerit& bm) { ViewArray y(home, x); Action::init(home, y, d, p, f, bm); } void - IntAction::init(Home home, const IntVarArgs& x, double d, bool p, bool f, IntBranchMerit bm) { + IntAction::init(Home home, const IntVarArgs& x, double d, bool p, bool f, const IntBranchMerit& bm) { ViewArray y(home, x); Action::init(home, y, d, p, f, bm); } - BoolAction::BoolAction(Home home, const BoolVarArgs& x, double d, bool p, bool f, BoolBranchMerit bm) { + BoolAction::BoolAction(Home home, const BoolVarArgs& x, double d, bool p, bool f, const BoolBranchMerit& bm) { ViewArray y(home, x); Action::init(home, y, d, p, f, bm); } void - BoolAction::init(Home home, const BoolVarArgs& x, double d, bool p, bool f, BoolBranchMerit bm) { + BoolAction::init(Home home, const BoolVarArgs& x, double d, bool p, bool f, const BoolBranchMerit& bm) { ViewArray y(home, x); Action::init(home, y, d, p, f, bm); } diff --git a/gecode/int/branch/assign.hpp b/gecode/int/branch/assign.hpp index 29965cd34a..e39d895e66 100644 --- a/gecode/int/branch/assign.hpp +++ b/gecode/int/branch/assign.hpp @@ -37,12 +37,12 @@ namespace Gecode { : s(s0) {} forceinline - IntAssign::IntAssign(Rnd r) + IntAssign::IntAssign(const Rnd& r) : ValBranch(r), s(SEL_RND) {} forceinline IntAssign::IntAssign(IntBranchVal v, IntBranchCommit c) - : ValBranch(v, c), s(SEL_VAL_COMMIT) {} + : ValBranch(std::move(v), std::move(c)), s(SEL_VAL_COMMIT) {} forceinline IntAssign::Select IntAssign::select(void) const { @@ -65,13 +65,13 @@ namespace Gecode { } inline IntAssign - INT_ASSIGN_RND(Rnd r) { + INT_ASSIGN_RND(const Rnd& r) { return IntAssign(r); } inline IntAssign INT_ASSIGN(IntBranchVal v, IntBranchCommit c) { - return IntAssign(v, c); + return IntAssign(std::move(v), std::move(c)); } forceinline @@ -79,12 +79,12 @@ namespace Gecode { : s(s0) {} forceinline - BoolAssign::BoolAssign(Rnd r) + BoolAssign::BoolAssign(const Rnd& r) : ValBranch(r), s(SEL_RND) {} forceinline BoolAssign::BoolAssign(BoolBranchVal v, BoolBranchCommit c) - : ValBranch(v, c), s(SEL_VAL_COMMIT) {} + : ValBranch(std::move(v), std::move(c)), s(SEL_VAL_COMMIT) {} forceinline BoolAssign::Select BoolAssign::select(void) const { @@ -102,13 +102,13 @@ namespace Gecode { } inline BoolAssign - BOOL_ASSIGN_RND(Rnd r) { + BOOL_ASSIGN_RND(const Rnd& r) { return BoolAssign(r); } inline BoolAssign BOOL_ASSIGN(BoolBranchVal v, BoolBranchCommit c) { - return BoolAssign(v, c); + return BoolAssign(std::move(v), std::move(c)); } } // namespace Gecode diff --git a/gecode/int/branch/chb.cpp b/gecode/int/branch/chb.cpp index c7dceb9d96..732f0dd9ef 100644 --- a/gecode/int/branch/chb.cpp +++ b/gecode/int/branch/chb.cpp @@ -34,24 +34,24 @@ namespace Gecode { - IntCHB::IntCHB(Home home, const IntVarArgs& x, IntBranchMerit bm) { + IntCHB::IntCHB(Home home, const IntVarArgs& x, const IntBranchMerit& bm) { ViewArray y(home, x); CHB::init(home, y, bm); } void - IntCHB::init(Home home, const IntVarArgs& x, IntBranchMerit bm) { + IntCHB::init(Home home, const IntVarArgs& x, const IntBranchMerit& bm) { ViewArray y(home, x); CHB::init(home, y, bm); } - BoolCHB::BoolCHB(Home home, const BoolVarArgs& x, BoolBranchMerit bm) { + BoolCHB::BoolCHB(Home home, const BoolVarArgs& x, const BoolBranchMerit& bm) { ViewArray y(home, x); CHB::init(home, y, bm); } void - BoolCHB::init(Home home, const BoolVarArgs& x, BoolBranchMerit bm) { + BoolCHB::init(Home home, const BoolVarArgs& x, const BoolBranchMerit& bm) { ViewArray y(home, x); CHB::init(home, y, bm); } diff --git a/gecode/int/branch/val.hpp b/gecode/int/branch/val.hpp index 60fec49b47..2423fdcd18 100644 --- a/gecode/int/branch/val.hpp +++ b/gecode/int/branch/val.hpp @@ -37,12 +37,12 @@ namespace Gecode { : s(s0) {} forceinline - IntValBranch::IntValBranch(Rnd r) + IntValBranch::IntValBranch(const Rnd& r) : ValBranch(r), s(SEL_RND) {} forceinline IntValBranch::IntValBranch(IntBranchVal v, IntBranchCommit c) - : ValBranch(v, c), s(SEL_VAL_COMMIT) {} + : ValBranch(std::move(v), std::move(c)), s(SEL_VAL_COMMIT) {} forceinline IntValBranch::Select IntValBranch::select(void) const { @@ -65,7 +65,7 @@ namespace Gecode { } inline IntValBranch - INT_VAL_RND(Rnd r) { + INT_VAL_RND(const Rnd& r) { return IntValBranch(r); } @@ -91,7 +91,7 @@ namespace Gecode { inline IntValBranch INT_VAL(IntBranchVal v, IntBranchCommit c) { - return IntValBranch(v, c); + return IntValBranch(std::move(v), std::move(c)); } inline IntValBranch @@ -109,12 +109,12 @@ namespace Gecode { : s(s0) {} forceinline - BoolValBranch::BoolValBranch(Rnd r) + BoolValBranch::BoolValBranch(const Rnd& r) : ValBranch(r), s(SEL_RND) {} forceinline BoolValBranch::BoolValBranch(BoolBranchVal v, BoolBranchCommit c) - : ValBranch(v, c), s(SEL_VAL_COMMIT) {} + : ValBranch(std::move(v), std::move(c)), s(SEL_VAL_COMMIT) {} forceinline BoolValBranch::Select BoolValBranch::select(void) const { @@ -132,13 +132,13 @@ namespace Gecode { } inline BoolValBranch - BOOL_VAL_RND(Rnd r) { + BOOL_VAL_RND(const Rnd& r) { return BoolValBranch(r); } inline BoolValBranch BOOL_VAL(BoolBranchVal v, BoolBranchCommit c) { - return BoolValBranch(v, c); + return BoolValBranch(std::move(v), std::move(c)); } } // namespace Gecode diff --git a/gecode/int/branch/var.hpp b/gecode/int/branch/var.hpp index 7a5126328d..ac0ddb5125 100644 --- a/gecode/int/branch/var.hpp +++ b/gecode/int/branch/var.hpp @@ -43,7 +43,7 @@ namespace Gecode { : VarBranch(std::move(t)), s(s0) {} forceinline - IntVarBranch::IntVarBranch(Rnd r) + IntVarBranch::IntVarBranch(const Rnd& r) : VarBranch(r), s(SEL_RND) {} forceinline @@ -51,15 +51,15 @@ namespace Gecode { : VarBranch(d, std::move(t)), s(s0) {} forceinline - IntVarBranch::IntVarBranch(Select s0, IntAFC a, BranchTbl t) + IntVarBranch::IntVarBranch(Select s0, const IntAFC& a, BranchTbl t) : VarBranch(a, std::move(t)), s(s0) {} forceinline - IntVarBranch::IntVarBranch(Select s0, IntAction a, BranchTbl t) + IntVarBranch::IntVarBranch(Select s0, const IntAction& a, BranchTbl t) : VarBranch(a, std::move(t)), s(s0) {} forceinline - IntVarBranch::IntVarBranch(Select s0, IntCHB c, BranchTbl t) + IntVarBranch::IntVarBranch(Select s0, const IntCHB& c, BranchTbl t) : VarBranch(c, std::move(t)), s(s0) {} forceinline @@ -105,208 +105,208 @@ namespace Gecode { } inline IntVarBranch - INT_VAR_RND(Rnd r) { + INT_VAR_RND(const Rnd& r) { return IntVarBranch(r); } inline IntVarBranch INT_VAR_MERIT_MIN(IntBranchMerit bm, BranchTbl tbl) { - return IntVarBranch(IntVarBranch::SEL_MERIT_MIN, bm, tbl); + return IntVarBranch(IntVarBranch::SEL_MERIT_MIN, std::move(bm), std::move(tbl)); } inline IntVarBranch INT_VAR_MERIT_MAX(IntBranchMerit bm, BranchTbl tbl) { - return IntVarBranch(IntVarBranch::SEL_MERIT_MAX, bm, tbl); + return IntVarBranch(IntVarBranch::SEL_MERIT_MAX, std::move(bm), std::move(tbl)); } inline IntVarBranch INT_VAR_DEGREE_MIN(BranchTbl tbl) { - return IntVarBranch(IntVarBranch::SEL_DEGREE_MIN, tbl); + return IntVarBranch(IntVarBranch::SEL_DEGREE_MIN, std::move(tbl)); } inline IntVarBranch INT_VAR_DEGREE_MAX(BranchTbl tbl) { - return IntVarBranch(IntVarBranch::SEL_DEGREE_MAX, tbl); + return IntVarBranch(IntVarBranch::SEL_DEGREE_MAX, std::move(tbl)); } inline IntVarBranch INT_VAR_AFC_MIN(double d, BranchTbl tbl) { - return IntVarBranch(IntVarBranch::SEL_AFC_MIN, d, tbl); + return IntVarBranch(IntVarBranch::SEL_AFC_MIN, d, std::move(tbl)); } inline IntVarBranch - INT_VAR_AFC_MIN(IntAFC a, BranchTbl tbl) { - return IntVarBranch(IntVarBranch::SEL_AFC_MIN, a, tbl); + INT_VAR_AFC_MIN(const IntAFC& a, BranchTbl tbl) { + return IntVarBranch(IntVarBranch::SEL_AFC_MIN, a, std::move(tbl)); } inline IntVarBranch INT_VAR_AFC_MAX(double d, BranchTbl tbl) { - return IntVarBranch(IntVarBranch::SEL_AFC_MAX, d, tbl); + return IntVarBranch(IntVarBranch::SEL_AFC_MAX, d, std::move(tbl)); } inline IntVarBranch - INT_VAR_AFC_MAX(IntAFC a, BranchTbl tbl) { - return IntVarBranch(IntVarBranch::SEL_AFC_MAX, a, tbl); + INT_VAR_AFC_MAX(const IntAFC& a, BranchTbl tbl) { + return IntVarBranch(IntVarBranch::SEL_AFC_MAX, a, std::move(tbl)); } inline IntVarBranch INT_VAR_ACTION_MIN(double d, BranchTbl tbl) { - return IntVarBranch(IntVarBranch::SEL_ACTION_MIN, d, tbl); + return IntVarBranch(IntVarBranch::SEL_ACTION_MIN, d, std::move(tbl)); } inline IntVarBranch - INT_VAR_ACTION_MIN(IntAction a, BranchTbl tbl) { - return IntVarBranch(IntVarBranch::SEL_ACTION_MIN, a, tbl); + INT_VAR_ACTION_MIN(const IntAction& a, BranchTbl tbl) { + return IntVarBranch(IntVarBranch::SEL_ACTION_MIN, a, std::move(tbl)); } inline IntVarBranch INT_VAR_ACTION_MAX(double d, BranchTbl tbl) { - return IntVarBranch(IntVarBranch::SEL_ACTION_MAX, d, tbl); + return IntVarBranch(IntVarBranch::SEL_ACTION_MAX, d, std::move(tbl)); } inline IntVarBranch - INT_VAR_ACTION_MAX(IntAction a, BranchTbl tbl) { - return IntVarBranch(IntVarBranch::SEL_ACTION_MAX, a, tbl); + INT_VAR_ACTION_MAX(const IntAction& a, BranchTbl tbl) { + return IntVarBranch(IntVarBranch::SEL_ACTION_MAX, a, std::move(tbl)); } inline IntVarBranch - INT_VAR_CHB_MIN(IntCHB c, BranchTbl tbl) { - return IntVarBranch(IntVarBranch::SEL_CHB_MIN, c, tbl); + INT_VAR_CHB_MIN(const IntCHB& c, BranchTbl tbl) { + return IntVarBranch(IntVarBranch::SEL_CHB_MIN, c, std::move(tbl)); } inline IntVarBranch INT_VAR_CHB_MIN(BranchTbl tbl) { - return IntVarBranch(IntVarBranch::SEL_CHB_MIN, tbl); + return IntVarBranch(IntVarBranch::SEL_CHB_MIN, std::move(tbl)); } inline IntVarBranch - INT_VAR_CHB_MAX(IntCHB c, BranchTbl tbl) { - return IntVarBranch(IntVarBranch::SEL_CHB_MAX, c, tbl); + INT_VAR_CHB_MAX(const IntCHB& c, BranchTbl tbl) { + return IntVarBranch(IntVarBranch::SEL_CHB_MAX, c, std::move(tbl)); } inline IntVarBranch INT_VAR_CHB_MAX(BranchTbl tbl) { - return IntVarBranch(IntVarBranch::SEL_CHB_MAX, tbl); + return IntVarBranch(IntVarBranch::SEL_CHB_MAX, std::move(tbl)); } inline IntVarBranch INT_VAR_MIN_MIN(BranchTbl tbl) { - return IntVarBranch(IntVarBranch::SEL_MIN_MIN, tbl); + return IntVarBranch(IntVarBranch::SEL_MIN_MIN, std::move(tbl)); } inline IntVarBranch INT_VAR_MIN_MAX(BranchTbl tbl) { - return IntVarBranch(IntVarBranch::SEL_MIN_MAX, tbl); + return IntVarBranch(IntVarBranch::SEL_MIN_MAX, std::move(tbl)); } inline IntVarBranch INT_VAR_MAX_MIN(BranchTbl tbl) { - return IntVarBranch(IntVarBranch::SEL_MAX_MIN, tbl); + return IntVarBranch(IntVarBranch::SEL_MAX_MIN, std::move(tbl)); } inline IntVarBranch INT_VAR_MAX_MAX(BranchTbl tbl) { - return IntVarBranch(IntVarBranch::SEL_MAX_MAX, tbl); + return IntVarBranch(IntVarBranch::SEL_MAX_MAX, std::move(tbl)); } inline IntVarBranch INT_VAR_SIZE_MIN(BranchTbl tbl) { - return IntVarBranch(IntVarBranch::SEL_SIZE_MIN, tbl); + return IntVarBranch(IntVarBranch::SEL_SIZE_MIN, std::move(tbl)); } inline IntVarBranch INT_VAR_SIZE_MAX(BranchTbl tbl) { - return IntVarBranch(IntVarBranch::SEL_SIZE_MAX, tbl); + return IntVarBranch(IntVarBranch::SEL_SIZE_MAX, std::move(tbl)); } inline IntVarBranch INT_VAR_DEGREE_SIZE_MIN(BranchTbl tbl) { - return IntVarBranch(IntVarBranch::SEL_DEGREE_SIZE_MIN, tbl); + return IntVarBranch(IntVarBranch::SEL_DEGREE_SIZE_MIN, std::move(tbl)); } inline IntVarBranch INT_VAR_DEGREE_SIZE_MAX(BranchTbl tbl) { - return IntVarBranch(IntVarBranch::SEL_DEGREE_SIZE_MAX, tbl); + return IntVarBranch(IntVarBranch::SEL_DEGREE_SIZE_MAX, std::move(tbl)); } inline IntVarBranch INT_VAR_AFC_SIZE_MIN(double d, BranchTbl tbl) { - return IntVarBranch(IntVarBranch::SEL_AFC_SIZE_MIN, d, tbl); + return IntVarBranch(IntVarBranch::SEL_AFC_SIZE_MIN, d, std::move(tbl)); } inline IntVarBranch - INT_VAR_AFC_SIZE_MIN(IntAFC a, BranchTbl tbl) { - return IntVarBranch(IntVarBranch::SEL_AFC_SIZE_MIN, a, tbl); + INT_VAR_AFC_SIZE_MIN(const IntAFC& a, BranchTbl tbl) { + return IntVarBranch(IntVarBranch::SEL_AFC_SIZE_MIN, a, std::move(tbl)); } inline IntVarBranch INT_VAR_AFC_SIZE_MAX(double d, BranchTbl tbl) { - return IntVarBranch(IntVarBranch::SEL_AFC_SIZE_MAX, d, tbl); + return IntVarBranch(IntVarBranch::SEL_AFC_SIZE_MAX, d, std::move(tbl)); } inline IntVarBranch - INT_VAR_AFC_SIZE_MAX(IntAFC a, BranchTbl tbl) { - return IntVarBranch(IntVarBranch::SEL_AFC_SIZE_MAX, a, tbl); + INT_VAR_AFC_SIZE_MAX(const IntAFC& a, BranchTbl tbl) { + return IntVarBranch(IntVarBranch::SEL_AFC_SIZE_MAX, a, std::move(tbl)); } inline IntVarBranch INT_VAR_ACTION_SIZE_MIN(double d, BranchTbl tbl) { - return IntVarBranch(IntVarBranch::SEL_ACTION_SIZE_MIN, d, tbl); + return IntVarBranch(IntVarBranch::SEL_ACTION_SIZE_MIN, d, std::move(tbl)); } inline IntVarBranch - INT_VAR_ACTION_SIZE_MIN(IntAction a, BranchTbl tbl) { - return IntVarBranch(IntVarBranch::SEL_ACTION_SIZE_MIN, a, tbl); + INT_VAR_ACTION_SIZE_MIN(const IntAction& a, BranchTbl tbl) { + return IntVarBranch(IntVarBranch::SEL_ACTION_SIZE_MIN, a, std::move(tbl)); } inline IntVarBranch INT_VAR_ACTION_SIZE_MAX(double d, BranchTbl tbl) { - return IntVarBranch(IntVarBranch::SEL_ACTION_SIZE_MAX, d, tbl); + return IntVarBranch(IntVarBranch::SEL_ACTION_SIZE_MAX, d, std::move(tbl)); } inline IntVarBranch - INT_VAR_ACTION_SIZE_MAX(IntAction a, BranchTbl tbl) { - return IntVarBranch(IntVarBranch::SEL_ACTION_SIZE_MAX, a, tbl); + INT_VAR_ACTION_SIZE_MAX(const IntAction& a, BranchTbl tbl) { + return IntVarBranch(IntVarBranch::SEL_ACTION_SIZE_MAX, a, std::move(tbl)); } inline IntVarBranch - INT_VAR_CHB_SIZE_MIN(IntCHB c, BranchTbl tbl) { - return IntVarBranch(IntVarBranch::SEL_CHB_SIZE_MIN, c, tbl); + INT_VAR_CHB_SIZE_MIN(const IntCHB& c, BranchTbl tbl) { + return IntVarBranch(IntVarBranch::SEL_CHB_SIZE_MIN, c, std::move(tbl)); } inline IntVarBranch INT_VAR_CHB_SIZE_MIN(BranchTbl tbl) { - return IntVarBranch(IntVarBranch::SEL_CHB_SIZE_MIN, tbl); + return IntVarBranch(IntVarBranch::SEL_CHB_SIZE_MIN, std::move(tbl)); } inline IntVarBranch - INT_VAR_CHB_SIZE_MAX(IntCHB c, BranchTbl tbl) { - return IntVarBranch(IntVarBranch::SEL_CHB_SIZE_MAX, c, tbl); + INT_VAR_CHB_SIZE_MAX(const IntCHB& c, BranchTbl tbl) { + return IntVarBranch(IntVarBranch::SEL_CHB_SIZE_MAX, c, std::move(tbl)); } inline IntVarBranch INT_VAR_CHB_SIZE_MAX(BranchTbl tbl) { - return IntVarBranch(IntVarBranch::SEL_CHB_SIZE_MAX, tbl); + return IntVarBranch(IntVarBranch::SEL_CHB_SIZE_MAX, std::move(tbl)); } inline IntVarBranch INT_VAR_REGRET_MIN_MIN(BranchTbl tbl) { - return IntVarBranch(IntVarBranch::SEL_REGRET_MIN_MIN, tbl); + return IntVarBranch(IntVarBranch::SEL_REGRET_MIN_MIN, std::move(tbl)); } inline IntVarBranch INT_VAR_REGRET_MIN_MAX(BranchTbl tbl) { - return IntVarBranch(IntVarBranch::SEL_REGRET_MIN_MAX, tbl); + return IntVarBranch(IntVarBranch::SEL_REGRET_MIN_MAX, std::move(tbl)); } inline IntVarBranch INT_VAR_REGRET_MAX_MIN(BranchTbl tbl) { - return IntVarBranch(IntVarBranch::SEL_REGRET_MAX_MIN, tbl); + return IntVarBranch(IntVarBranch::SEL_REGRET_MAX_MIN, std::move(tbl)); } inline IntVarBranch INT_VAR_REGRET_MAX_MAX(BranchTbl tbl) { - return IntVarBranch(IntVarBranch::SEL_REGRET_MAX_MAX, tbl); + return IntVarBranch(IntVarBranch::SEL_REGRET_MAX_MAX, std::move(tbl)); } forceinline @@ -318,7 +318,7 @@ namespace Gecode { : VarBranch(std::move(t)), s(s0) {} forceinline - BoolVarBranch::BoolVarBranch(Rnd r) + BoolVarBranch::BoolVarBranch(const Rnd& r) : VarBranch(r), s(SEL_RND) {} forceinline @@ -326,15 +326,15 @@ namespace Gecode { : VarBranch(d, std::move(t)), s(s0) {} forceinline - BoolVarBranch::BoolVarBranch(Select s0, BoolAFC a, BranchTbl t) + BoolVarBranch::BoolVarBranch(Select s0, const BoolAFC& a, BranchTbl t) : VarBranch(a, std::move(t)), s(s0) {} forceinline - BoolVarBranch::BoolVarBranch(Select s0, BoolAction a, BranchTbl t) + BoolVarBranch::BoolVarBranch(Select s0, const BoolAction& a, BranchTbl t) : VarBranch(a, std::move(t)), s(s0) {} forceinline - BoolVarBranch::BoolVarBranch(Select s0, BoolCHB c, BranchTbl t) + BoolVarBranch::BoolVarBranch(Select s0, const BoolCHB& c, BranchTbl t) : VarBranch(c, std::move(t)), s(s0) {} forceinline @@ -374,88 +374,88 @@ namespace Gecode { } inline BoolVarBranch - BOOL_VAR_RND(Rnd r) { + BOOL_VAR_RND(const Rnd& r) { return BoolVarBranch(r); } inline BoolVarBranch BOOL_VAR_MERIT_MIN(BoolBranchMerit bm, BranchTbl tbl) { - return BoolVarBranch(BoolVarBranch::SEL_MERIT_MIN, bm, tbl); + return BoolVarBranch(BoolVarBranch::SEL_MERIT_MIN, std::move(bm), std::move(tbl)); } inline BoolVarBranch BOOL_VAR_MERIT_MAX(BoolBranchMerit bm, BranchTbl tbl) { - return BoolVarBranch(BoolVarBranch::SEL_MERIT_MAX, bm, tbl); + return BoolVarBranch(BoolVarBranch::SEL_MERIT_MAX, std::move(bm), std::move(tbl)); } inline BoolVarBranch BOOL_VAR_DEGREE_MIN(BranchTbl tbl) { - return BoolVarBranch(BoolVarBranch::SEL_DEGREE_MIN, tbl); + return BoolVarBranch(BoolVarBranch::SEL_DEGREE_MIN, std::move(tbl)); } inline BoolVarBranch BOOL_VAR_DEGREE_MAX(BranchTbl tbl) { - return BoolVarBranch(BoolVarBranch::SEL_DEGREE_MAX, tbl); + return BoolVarBranch(BoolVarBranch::SEL_DEGREE_MAX, std::move(tbl)); } inline BoolVarBranch BOOL_VAR_AFC_MIN(double d, BranchTbl tbl) { - return BoolVarBranch(BoolVarBranch::SEL_AFC_MIN, d, tbl); + return BoolVarBranch(BoolVarBranch::SEL_AFC_MIN, d, std::move(tbl)); } inline BoolVarBranch - BOOL_VAR_AFC_MIN(BoolAFC a, BranchTbl tbl) { - return BoolVarBranch(BoolVarBranch::SEL_AFC_MIN, a, tbl); + BOOL_VAR_AFC_MIN(const BoolAFC& a, BranchTbl tbl) { + return BoolVarBranch(BoolVarBranch::SEL_AFC_MIN, a, std::move(tbl)); } inline BoolVarBranch BOOL_VAR_AFC_MAX(double d, BranchTbl tbl) { - return BoolVarBranch(BoolVarBranch::SEL_AFC_MAX, d, tbl); + return BoolVarBranch(BoolVarBranch::SEL_AFC_MAX, d, std::move(tbl)); } inline BoolVarBranch - BOOL_VAR_AFC_MAX(BoolAFC a, BranchTbl tbl) { - return BoolVarBranch(BoolVarBranch::SEL_AFC_MAX, a, tbl); + BOOL_VAR_AFC_MAX(const BoolAFC& a, BranchTbl tbl) { + return BoolVarBranch(BoolVarBranch::SEL_AFC_MAX, a, std::move(tbl)); } inline BoolVarBranch BOOL_VAR_ACTION_MIN(double d, BranchTbl tbl) { - return BoolVarBranch(BoolVarBranch::SEL_ACTION_MIN, d, tbl); + return BoolVarBranch(BoolVarBranch::SEL_ACTION_MIN, d, std::move(tbl)); } inline BoolVarBranch - BOOL_VAR_ACTION_MIN(BoolAction a, BranchTbl tbl) { - return BoolVarBranch(BoolVarBranch::SEL_ACTION_MIN, a, tbl); + BOOL_VAR_ACTION_MIN(const BoolAction& a, BranchTbl tbl) { + return BoolVarBranch(BoolVarBranch::SEL_ACTION_MIN, a, std::move(tbl)); } inline BoolVarBranch BOOL_VAR_ACTION_MAX(double d, BranchTbl tbl) { - return BoolVarBranch(BoolVarBranch::SEL_ACTION_MAX, d, tbl); + return BoolVarBranch(BoolVarBranch::SEL_ACTION_MAX, d, std::move(tbl)); } inline BoolVarBranch - BOOL_VAR_ACTION_MAX(BoolAction a, BranchTbl tbl) { - return BoolVarBranch(BoolVarBranch::SEL_ACTION_MAX, a, tbl); + BOOL_VAR_ACTION_MAX(const BoolAction& a, BranchTbl tbl) { + return BoolVarBranch(BoolVarBranch::SEL_ACTION_MAX, a, std::move(tbl)); } inline BoolVarBranch - BOOL_VAR_CHB_MIN(BoolCHB c, BranchTbl tbl) { - return BoolVarBranch(BoolVarBranch::SEL_CHB_MIN, c, tbl); + BOOL_VAR_CHB_MIN(const BoolCHB& c, BranchTbl tbl) { + return BoolVarBranch(BoolVarBranch::SEL_CHB_MIN, c, std::move(tbl)); } inline BoolVarBranch BOOL_VAR_CHB_MIN(BranchTbl tbl) { - return BoolVarBranch(BoolVarBranch::SEL_CHB_MIN, tbl); + return BoolVarBranch(BoolVarBranch::SEL_CHB_MIN, std::move(tbl)); } inline BoolVarBranch - BOOL_VAR_CHB_MAX(BoolCHB c, BranchTbl tbl) { - return BoolVarBranch(BoolVarBranch::SEL_CHB_MAX, c, tbl); + BOOL_VAR_CHB_MAX(const BoolCHB& c, BranchTbl tbl) { + return BoolVarBranch(BoolVarBranch::SEL_CHB_MAX, c, std::move(tbl)); } inline BoolVarBranch BOOL_VAR_CHB_MAX(BranchTbl tbl) { - return BoolVarBranch(BoolVarBranch::SEL_CHB_MAX, tbl); + return BoolVarBranch(BoolVarBranch::SEL_CHB_MAX, std::move(tbl)); } } // namespace Gecode diff --git a/gecode/kernel/branch/action.hpp b/gecode/kernel/branch/action.hpp index e101e546ed..b2c1223c37 100644 --- a/gecode/kernel/branch/action.hpp +++ b/gecode/kernel/branch/action.hpp @@ -55,7 +55,8 @@ namespace Gecode { double* a; /// Initialize action values template - Storage(Home home, ViewArray& x, double d, typename BranchTraits::Merit bm); + Storage(Home home, ViewArray& x, double d, + const typename BranchTraits::Merit& bm); /// Update action value at position \a i void update(int i); /// Delete object @@ -97,7 +98,7 @@ namespace Gecode { */ template Action(Home home, ViewArray& x, double d, bool p, bool f, - typename BranchTraits::Merit bm); + const typename BranchTraits::Merit& bm); /** * \brief Initialize for views \a x and decay factor \a d and action as defined by \a bm * @@ -105,7 +106,7 @@ namespace Gecode { */ template void init(Home home, ViewArray& x, double d, bool p, bool f, - typename BranchTraits::Merit bm); + const typename BranchTraits::Merit& bm); /// Default (empty) action information GECODE_KERNEL_EXPORT static const Action def; //@} @@ -269,7 +270,7 @@ namespace Gecode { template forceinline Action::Storage::Storage(Home home, ViewArray& x, double d, - typename BranchTraits::Merit bm) + const typename BranchTraits::Merit& bm) : n(x.size()), invd(1.0 / d), a(heap.alloc(x.size())) { if (bm) for (int i = 0; i < n; i++) { @@ -336,7 +337,7 @@ namespace Gecode { template forceinline Action::Action(Home home, ViewArray& x, double d, bool p, bool f, - typename BranchTraits::Merit bm) { + const typename BranchTraits::Merit& bm) { assert(!*this); if (!p && !f) return; @@ -351,7 +352,7 @@ namespace Gecode { template forceinline void Action::init(Home home, ViewArray& x, double d, bool p, bool f, - typename BranchTraits::Merit bm) { + const typename BranchTraits::Merit& bm) { assert(!*this); if (!p && !f) return; diff --git a/gecode/kernel/branch/chb.hpp b/gecode/kernel/branch/chb.hpp index 6f1cbeb01a..7c625cb101 100644 --- a/gecode/kernel/branch/chb.hpp +++ b/gecode/kernel/branch/chb.hpp @@ -69,7 +69,7 @@ namespace Gecode { Info* chb; /// Initialize CHB info template - Storage(Home home, ViewArray& x, typename BranchTraits::Merit bm); + Storage(Home home, ViewArray& x, const typename BranchTraits::Merit& bm); /// Delete object GECODE_KERNEL_EXPORT ~Storage(void) override; @@ -112,10 +112,10 @@ namespace Gecode { CHB& operator=(const CHB& a); /// Initialize for views \a x and Q-score as defined by \a bm template - CHB(Home home, ViewArray& x, typename BranchTraits::Merit bm); + CHB(Home home, ViewArray& x, const typename BranchTraits::Merit& bm); /// Initialize for views \a x and Q-score as defined by \a bm template - void init(Home home, ViewArray& x, typename BranchTraits::Merit bm); + void init(Home home, ViewArray& x, const typename BranchTraits::Merit& bm); /// Default (empty) chb information GECODE_KERNEL_EXPORT static const CHB def; //@} @@ -254,7 +254,7 @@ namespace Gecode { */ template forceinline - CHB::Storage::Storage(Home home, ViewArray& x, typename BranchTraits::Merit bm) + CHB::Storage::Storage(Home home, ViewArray& x, const typename BranchTraits::Merit& bm) : n(x.size()), nf(0U), alpha(Kernel::Config::chb_alpha_init), chb(heap.alloc(x.size())) { if (bm) { for (int i = 0; i < n; i++) { @@ -334,14 +334,14 @@ namespace Gecode { template forceinline - CHB::CHB(Home home, ViewArray& x, typename BranchTraits::Merit bm) { + CHB::CHB(Home home, ViewArray& x, const typename BranchTraits::Merit& bm) { assert(!*this); object(*new Storage(home, x, bm)); (void)Recorder::post(home, x, *this); } template forceinline void - CHB::init(Home home, ViewArray& x, typename BranchTraits::Merit bm) { + CHB::init(Home home, ViewArray& x, const typename BranchTraits::Merit& bm) { assert(!*this); object(*new Storage(home, x, bm)); (void)Recorder::post(home, x, *this); diff --git a/gecode/kernel/branch/tiebreak.hpp b/gecode/kernel/branch/tiebreak.hpp index aa93d86431..cf2da2f121 100644 --- a/gecode/kernel/branch/tiebreak.hpp +++ b/gecode/kernel/branch/tiebreak.hpp @@ -63,27 +63,24 @@ namespace Gecode { template forceinline TieBreak::TieBreak(VarBranch a0, VarBranch b0, VarBranch c0, VarBranch d0) - : a(a0), b(b0), c(c0), d(d0) {} + : a(std::move(a0)), b(std::move(b0)), c(std::move(c0)), d(std::move(d0)) {} template TieBreak tie_break(VarBranch a, VarBranch b) { - TieBreak ab(a, b); - return ab; + return TieBreak(std::move(a), std::move(b)); } template TieBreak tie_break(VarBranch a, VarBranch b, VarBranch c) { - TieBreak abc(a, b, c); - return abc; + return TieBreak(std::move(a), std::move(b), std::move(c)); } template TieBreak tie_break(VarBranch a, VarBranch b, VarBranch c, VarBranch d) { - TieBreak abcd(a, b, c, d); - return abcd; + return TieBreak(std::move(a), std::move(b), std::move(c), std::move(d)); } } // namespace Gecode diff --git a/gecode/kernel/branch/val.hpp b/gecode/kernel/branch/val.hpp index 96378f8e12..d1426ce9ae 100644 --- a/gecode/kernel/branch/val.hpp +++ b/gecode/kernel/branch/val.hpp @@ -56,7 +56,7 @@ namespace Gecode { /// Initialize ValBranch(void); /// Initialize with random number generator \a r - ValBranch(Rnd r); + ValBranch(const Rnd& r); /// Initialize with value function \a v and commit function \a c ValBranch(BranchVal v, BranchCommit c); /// Return random number generator @@ -71,10 +71,10 @@ namespace Gecode { inline ValBranch::ValBranch(void) : vf(nullptr), cf(nullptr) {} template - inline ValBranch::ValBranch(Rnd r0) : r(r0), vf(nullptr), cf(nullptr) {} + inline ValBranch::ValBranch(const Rnd& r0) : r(r0), vf(nullptr), cf(nullptr) {} template - inline ValBranch::ValBranch(BranchVal v, BranchCommit c) : vf(v), cf(c) {} + inline ValBranch::ValBranch(BranchVal v, BranchCommit c) : vf(std::move(v)), cf(std::move(c)) {} template inline Rnd diff --git a/gecode/kernel/branch/var.hpp b/gecode/kernel/branch/var.hpp index 6ff86c1ef4..af2360433a 100644 --- a/gecode/kernel/branch/var.hpp +++ b/gecode/kernel/branch/var.hpp @@ -78,15 +78,15 @@ namespace Gecode { /// Initialize with tie-break limit function \a t VarBranch(BranchTbl t); /// Initialize with random number generator \a r - VarBranch(Rnd r); + VarBranch(const Rnd& r); /// Initialize with decay factor \a d and tie-break limit function \a t VarBranch(double d, BranchTbl t); /// Initialize with AFC \a a and tie-break limit function \a t - VarBranch(AFC a, BranchTbl t); + VarBranch(const AFC& a, BranchTbl t); /// Initialize with action \a a and tie-break limit function \a t - VarBranch(Action a, BranchTbl t); + VarBranch(const Action& a, BranchTbl t); /// Initialize with CHB \a c and tie-break limit function \a t - VarBranch(CHB c, BranchTbl t); + VarBranch(const CHB& c, BranchTbl t); /// Initialize with merit function \a f and tie-break limit function \a t VarBranch(MeritFunction f, BranchTbl t); /// Return tie-break limit function @@ -98,15 +98,15 @@ namespace Gecode { /// Return AFC AFC afc(void) const; /// Set AFC to \a a - void afc(AFC a); + void afc(const AFC& a); /// Return action Action action(void) const; /// Set action to \a a - void action(Action a); + void action(const Action& a); /// Return CHB CHB chb(void) const; /// Set CHB to \a chb - void chb(CHB chb); + void chb(const CHB& chb); /// Return merit function MeritFunction merit(void) const; }; @@ -122,25 +122,25 @@ namespace Gecode { inline VarBranch::VarBranch(double d, BranchTbl t) : _tbl(std::move(t)), _decay(d) {} template - inline VarBranch::VarBranch(AFC a, BranchTbl t) : _tbl(std::move(t)), _decay(1.0), _afc(a) { + inline VarBranch::VarBranch(const AFC& a, BranchTbl t) : _tbl(std::move(t)), _decay(1.0), _afc(a) { if (!_afc) throw UninitializedAFC("VarBranch::VarBranch"); } template - inline VarBranch::VarBranch(Action a, BranchTbl t) : _tbl(std::move(t)), _decay(1.0), _act(a) { + inline VarBranch::VarBranch(const Action& a, BranchTbl t) : _tbl(std::move(t)), _decay(1.0), _act(a) { if (!_act) throw UninitializedAction("VarBranch::VarBranch"); } template - inline VarBranch::VarBranch(CHB c, BranchTbl t) : _tbl(std::move(t)), _decay(1.0), _chb(c) { + inline VarBranch::VarBranch(const CHB& c, BranchTbl t) : _tbl(std::move(t)), _decay(1.0), _chb(c) { if (!_chb) throw UninitializedCHB("VarBranch::VarBranch"); } template - inline VarBranch::VarBranch(Rnd r) : _tbl(nullptr), _rnd(r), _decay(1.0) {} + inline VarBranch::VarBranch(const Rnd& r) : _tbl(nullptr), _rnd(r), _decay(1.0) {} template inline VarBranch::VarBranch(MeritFunction f, BranchTbl t) @@ -172,7 +172,7 @@ namespace Gecode { template inline void - VarBranch::afc(AFC a) { + VarBranch::afc(const AFC& a) { _afc = a; } @@ -184,7 +184,7 @@ namespace Gecode { template inline void - VarBranch::action(Action a) { + VarBranch::action(const Action& a) { _act = a; } @@ -196,7 +196,7 @@ namespace Gecode { template inline void - VarBranch::chb(CHB chb) { + VarBranch::chb(const CHB& chb) { _chb = chb; } diff --git a/gecode/set.hh b/gecode/set.hh index 83b21ffbb1..61689fb0a9 100644 --- a/gecode/set.hh +++ b/gecode/set.hh @@ -1106,7 +1106,7 @@ namespace Gecode { */ GECODE_SET_EXPORT SetAction(Home home, const SetVarArgs& x, double d = 1.0, bool p = true, bool f = true, - SetBranchMerit bm = nullptr); + const SetBranchMerit& bm = nullptr); /** * \brief Initialize for set variables \a x with decay factor \a d * @@ -1121,7 +1121,7 @@ namespace Gecode { * */ GECODE_SET_EXPORT void init(Home home, const SetVarArgs& x, double d = 1.0, bool p = true, bool f = true, - SetBranchMerit bm = nullptr); + const SetBranchMerit& bm = nullptr); }; } // namespace Gecode @@ -1158,7 +1158,7 @@ namespace Gecode { * */ GECODE_SET_EXPORT - SetCHB(Home home, const SetVarArgs& x, SetBranchMerit bm = nullptr); + SetCHB(Home home, const SetVarArgs& x, const SetBranchMerit& bm = nullptr); /** * \brief Initialize for set variables \a x * @@ -1170,7 +1170,7 @@ namespace Gecode { * action storage has been constructed with the default constructor. * */ - GECODE_SET_EXPORT void init(Home home, const SetVarArgs& x, SetBranchMerit bm = nullptr); + GECODE_SET_EXPORT void init(Home home, const SetVarArgs& x, const SetBranchMerit& bm = nullptr); }; } // namespace Gecode @@ -1233,17 +1233,17 @@ namespace Gecode { /// Initialize with strategy SEL_NONE SetVarBranch(void); /// Initialize with random number generator \a r - SetVarBranch(Rnd r); + SetVarBranch(const Rnd& r); /// Initialize with selection strategy \a s and tie-break limit function \a t SetVarBranch(Select s, BranchTbl t); /// Initialize with selection strategy \a s, decay factor \a d, and tie-break limit function \a t SetVarBranch(Select s, double d, BranchTbl t); /// Initialize with selection strategy \a s, afc \a a, and tie-break limit function \a t - SetVarBranch(Select s, SetAFC a, BranchTbl t); + SetVarBranch(Select s, const SetAFC& a, BranchTbl t); /// Initialize with selection strategy \a s, action \a a, and tie-break limit function \a t - SetVarBranch(Select s, SetAction a, BranchTbl t); + SetVarBranch(Select s, const SetAction& a, BranchTbl t); /// Initialize with selection strategy \a s, CHB \a c, and tie-break limit function \a t - SetVarBranch(Select s, SetCHB c, BranchTbl t); + SetVarBranch(Select s, const SetCHB& c, BranchTbl t); /// Initialize with selection strategy \a s, branch merit function \a mf, and tie-break limit function \a t SetVarBranch(Select s, SetBranchMerit mf, BranchTbl t); /// Return selection strategy @@ -1260,7 +1260,7 @@ namespace Gecode { /// Select first unassigned variable SetVarBranch SET_VAR_NONE(void); /// Select random variable (uniform distribution, for tie breaking) - SetVarBranch SET_VAR_RND(Rnd r); + SetVarBranch SET_VAR_RND(const Rnd& r); /// Select variable with least merit according to branch merit function \a bm SetVarBranch SET_VAR_MERIT_MIN(SetBranchMerit bm, BranchTbl tbl = nullptr); /// Select variable with highest merit according to branch merit function \a bm @@ -1272,27 +1272,27 @@ namespace Gecode { /// Select variable with smallest accumulated failure count with decay factor \a d SetVarBranch SET_VAR_AFC_MIN(double d = 1.0, BranchTbl tbl = nullptr); /// Select variable with smallest accumulated failure count - SetVarBranch SET_VAR_AFC_MIN(SetAFC a, BranchTbl tbl = nullptr); + SetVarBranch SET_VAR_AFC_MIN(const SetAFC& a, BranchTbl tbl = nullptr); /// Select variable with largest accumulated failure count with decay factor \a d SetVarBranch SET_VAR_AFC_MAX(double d = 1.0, BranchTbl tbl = nullptr); /// Select variable with largest accumulated failure count - SetVarBranch SET_VAR_AFC_MAX(SetAFC a, BranchTbl tbl = nullptr); + SetVarBranch SET_VAR_AFC_MAX(const SetAFC& a, BranchTbl tbl = nullptr); /// Select variable with lowest action with decay factor \a d SetVarBranch SET_VAR_ACTION_MIN(double d = 1.0, BranchTbl tbl = nullptr); /// Select variable with lowest action - SetVarBranch SET_VAR_ACTION_MIN(SetAction a, BranchTbl tbl = nullptr); + SetVarBranch SET_VAR_ACTION_MIN(const SetAction& a, BranchTbl tbl = nullptr); /// Select variable with highest action with decay factor \a d SetVarBranch SET_VAR_ACTION_MAX(double d = 1.0, BranchTbl tbl = nullptr); /// Select variable with highest action - SetVarBranch SET_VAR_ACTION_MAX(SetAction a, BranchTbl tbl = nullptr); + SetVarBranch SET_VAR_ACTION_MAX(const SetAction& a, BranchTbl tbl = nullptr); /// Select variable with lowest CHB Q-score SetVarBranch SET_VAR_CHB_MIN(BranchTbl tbl = nullptr); /// Select variable with lowest CHB Q-score - SetVarBranch SET_VAR_CHB_MIN(SetCHB c, BranchTbl tbl = nullptr); + SetVarBranch SET_VAR_CHB_MIN(const SetCHB& c, BranchTbl tbl = nullptr); /// Select variable with highest CHB Q-score SetVarBranch SET_VAR_CHB_MAX(BranchTbl tbl = nullptr); /// Select variable with highest CHB Q-score - SetVarBranch SET_VAR_CHB_MAX(SetCHB c, BranchTbl tbl = nullptr); + SetVarBranch SET_VAR_CHB_MAX(const SetCHB& c, BranchTbl tbl = nullptr); /// Select variable with smallest minimum unknown element SetVarBranch SET_VAR_MIN_MIN(BranchTbl tbl = nullptr); /// Select variable with largest minimum unknown element @@ -1312,27 +1312,27 @@ namespace Gecode { /// Select variable with smallest accumulated failure count divided by domain size with decay factor \a d SetVarBranch SET_VAR_AFC_SIZE_MIN(double d = 1.0, BranchTbl tbl = nullptr); /// Select variable with smallest accumulated failure count divided by domain size - SetVarBranch SET_VAR_AFC_SIZE_MIN(SetAFC a, BranchTbl tbl = nullptr); + SetVarBranch SET_VAR_AFC_SIZE_MIN(const SetAFC& a, BranchTbl tbl = nullptr); /// Select variable with largest accumulated failure count divided by domain size with decay factor \a d SetVarBranch SET_VAR_AFC_SIZE_MAX(double d = 1.0, BranchTbl tbl = nullptr); /// Select variable with largest accumulated failure count divided by domain size - SetVarBranch SET_VAR_AFC_SIZE_MAX(SetAFC a, BranchTbl tbl = nullptr); + SetVarBranch SET_VAR_AFC_SIZE_MAX(const SetAFC& a, BranchTbl tbl = nullptr); /// Select variable with smallest action divided by domain size with decay factor \a d SetVarBranch SET_VAR_ACTION_SIZE_MIN(double d = 1.0, BranchTbl tbl = nullptr); /// Select variable with smallest action divided by domain size - SetVarBranch SET_VAR_ACTION_SIZE_MIN(SetAction a, BranchTbl tbl = nullptr); + SetVarBranch SET_VAR_ACTION_SIZE_MIN(const SetAction& a, BranchTbl tbl = nullptr); /// Select variable with largest action divided by domain size with decay factor \a d SetVarBranch SET_VAR_ACTION_SIZE_MAX(double d = 1.0, BranchTbl tbl = nullptr); /// Select variable with largest action divided by domain size - SetVarBranch SET_VAR_ACTION_SIZE_MAX(SetAction a, BranchTbl tbl = nullptr); + SetVarBranch SET_VAR_ACTION_SIZE_MAX(const SetAction& a, BranchTbl tbl = nullptr); /// Select variable with smallest CHB Q-score divided by domain size SetVarBranch SET_VAR_CHB_SIZE_MIN(BranchTbl tbl = nullptr); /// Select variable with smallest CHB Q-score divided by domain size - SetVarBranch SET_VAR_CHB_SIZE_MIN(SetCHB c, BranchTbl tbl = nullptr); + SetVarBranch SET_VAR_CHB_SIZE_MIN(const SetCHB& c, BranchTbl tbl = nullptr); /// Select variable with largest CHB Q-score divided by domain size SetVarBranch SET_VAR_CHB_SIZE_MAX(BranchTbl tbl = nullptr); /// Select variable with largest CHB Q-score divided by domain size - SetVarBranch SET_VAR_CHB_SIZE_MAX(SetCHB c, BranchTbl tbl = nullptr); + SetVarBranch SET_VAR_CHB_SIZE_MAX(const SetCHB& c, BranchTbl tbl = nullptr); //@} } // namespace Gecode @@ -1369,7 +1369,7 @@ namespace Gecode { /// Initialize with selection strategy \a s SetValBranch(Select s = SEL_MIN_INC); /// Initialize with random number generator \a r - SetValBranch(Select s, Rnd r); + SetValBranch(Select s, const Rnd& r); /// Initialize with value function \a f and commit function \a c SetValBranch(SetBranchVal v, SetBranchCommit c); /// Return selection strategy @@ -1394,9 +1394,9 @@ namespace Gecode { /// Exclude largest element SetValBranch SET_VAL_MAX_EXC(void); /// Include random element - SetValBranch SET_VAL_RND_INC(Rnd r); + SetValBranch SET_VAL_RND_INC(const Rnd& r); /// Exclude random element - SetValBranch SET_VAL_RND_EXC(Rnd r); + SetValBranch SET_VAL_RND_EXC(const Rnd& r); /** * \brief Select value as defined by the value function \a v and commit function \a c * @@ -1441,7 +1441,7 @@ namespace Gecode { /// Initialize with selection strategy \a s SetAssign(Select s = SEL_MIN_INC); /// Initialize with random number generator \a r - SetAssign(Select s, Rnd r); + SetAssign(Select s, const Rnd& r); /// Initialize with value function \a f and commit function \a c SetAssign(SetBranchVal v, SetBranchCommit c); /// Return selection strategy @@ -1466,9 +1466,9 @@ namespace Gecode { /// Exclude largest element SetAssign SET_ASSIGN_MAX_EXC(void); /// Include random element - SetAssign SET_ASSIGN_RND_INC(Rnd r); + SetAssign SET_ASSIGN_RND_INC(const Rnd& r); /// Exclude random element - SetAssign SET_ASSIGN_RND_EXC(Rnd r); + SetAssign SET_ASSIGN_RND_EXC(const Rnd& r); /** * \brief Select value as defined by the value function \a v and commit function \a c * diff --git a/gecode/set/branch/action.cpp b/gecode/set/branch/action.cpp index 6a8c68037f..65d6a20d81 100644 --- a/gecode/set/branch/action.cpp +++ b/gecode/set/branch/action.cpp @@ -34,13 +34,13 @@ namespace Gecode { - SetAction::SetAction(Home home, const SetVarArgs& x, double d, bool p, bool f, SetBranchMerit bm) { + SetAction::SetAction(Home home, const SetVarArgs& x, double d, bool p, bool f, const SetBranchMerit& bm) { ViewArray y(home, x); Action::init(home, y, d, p, f, bm); } void - SetAction::init(Home home, const SetVarArgs& x, double d, bool p, bool f, SetBranchMerit bm) { + SetAction::init(Home home, const SetVarArgs& x, double d, bool p, bool f, const SetBranchMerit& bm) { ViewArray y(home, x); Action::init(home, y, d, p, f, bm); } diff --git a/gecode/set/branch/assign.hpp b/gecode/set/branch/assign.hpp index f857f0307e..ba9d300530 100644 --- a/gecode/set/branch/assign.hpp +++ b/gecode/set/branch/assign.hpp @@ -37,12 +37,12 @@ namespace Gecode { : s(s0) {} forceinline - SetAssign::SetAssign(Select s0, Rnd r) + SetAssign::SetAssign(Select s0, const Rnd& r) : ValBranch(r), s(s0) {} forceinline SetAssign::SetAssign(SetBranchVal v, SetBranchCommit c) - : ValBranch(v, c), s(SEL_VAL_COMMIT) {} + : ValBranch(std::move(v), std::move(c)), s(SEL_VAL_COMMIT) {} forceinline SetAssign::Select SetAssign::select(void) const { @@ -80,18 +80,18 @@ namespace Gecode { } inline SetAssign - SET_ASSIGN_RND_INC(Rnd r) { + SET_ASSIGN_RND_INC(const Rnd& r) { return SetAssign(SetAssign::SEL_RND_INC, r); } inline SetAssign - SET_ASSIGN_RND_EXC(Rnd r) { + SET_ASSIGN_RND_EXC(const Rnd& r) { return SetAssign(SetAssign::SEL_RND_EXC, r); } inline SetAssign SET_ASSIGN(SetBranchVal v, SetBranchCommit c) { - return SetAssign(v, c); + return SetAssign(std::move(v), std::move(c)); } } // namespace Gecode diff --git a/gecode/set/branch/chb.cpp b/gecode/set/branch/chb.cpp index 99ec2e3a23..cc4210d41e 100644 --- a/gecode/set/branch/chb.cpp +++ b/gecode/set/branch/chb.cpp @@ -34,13 +34,13 @@ namespace Gecode { - SetCHB::SetCHB(Home home, const SetVarArgs& x, SetBranchMerit bm) { + SetCHB::SetCHB(Home home, const SetVarArgs& x, const SetBranchMerit& bm) { ViewArray y(home, x); CHB::init(home, y, bm); } void - SetCHB::init(Home home, const SetVarArgs& x, SetBranchMerit bm) { + SetCHB::init(Home home, const SetVarArgs& x, const SetBranchMerit& bm) { ViewArray y(home, x); CHB::init(home, y, bm); } diff --git a/gecode/set/branch/val.hpp b/gecode/set/branch/val.hpp index 8948cc2c8e..0fe691ea36 100644 --- a/gecode/set/branch/val.hpp +++ b/gecode/set/branch/val.hpp @@ -37,12 +37,12 @@ namespace Gecode { : s(s0) {} forceinline - SetValBranch::SetValBranch(Select s0, Rnd r) + SetValBranch::SetValBranch(Select s0, const Rnd& r) : ValBranch(r), s(s0) {} forceinline SetValBranch::SetValBranch(SetBranchVal v, SetBranchCommit c) - : ValBranch(v, c), s(SEL_VAL_COMMIT) {} + : ValBranch(std::move(v), std::move(c)), s(SEL_VAL_COMMIT) {} forceinline SetValBranch::Select SetValBranch::select(void) const { @@ -80,18 +80,18 @@ namespace Gecode { } inline SetValBranch - SET_VAL_RND_INC(Rnd r) { + SET_VAL_RND_INC(const Rnd& r) { return SetValBranch(SetValBranch::SEL_RND_INC, r); } inline SetValBranch - SET_VAL_RND_EXC(Rnd r) { + SET_VAL_RND_EXC(const Rnd& r) { return SetValBranch(SetValBranch::SEL_RND_EXC, r); } inline SetValBranch SET_VAL(SetBranchVal v, SetBranchCommit c) { - return SetValBranch(v, c); + return SetValBranch(std::move(v), std::move(c)); } } // namespace Gecode diff --git a/gecode/set/branch/var.hpp b/gecode/set/branch/var.hpp index d0cd8fabe4..4ba843caf4 100644 --- a/gecode/set/branch/var.hpp +++ b/gecode/set/branch/var.hpp @@ -43,7 +43,7 @@ namespace Gecode { : VarBranch(std::move(t)), s(s0) {} forceinline - SetVarBranch::SetVarBranch(Rnd r) + SetVarBranch::SetVarBranch(const Rnd& r) : VarBranch(r), s(SEL_RND) {} forceinline @@ -51,15 +51,15 @@ namespace Gecode { : VarBranch(d, std::move(t)), s(s0) {} forceinline - SetVarBranch::SetVarBranch(Select s0, SetAFC a, BranchTbl t) + SetVarBranch::SetVarBranch(Select s0, const SetAFC& a, BranchTbl t) : VarBranch(a, std::move(t)), s(s0) {} forceinline - SetVarBranch::SetVarBranch(Select s0, SetAction a, BranchTbl t) + SetVarBranch::SetVarBranch(Select s0, const SetAction& a, BranchTbl t) : VarBranch(a, std::move(t)), s(s0) {} forceinline - SetVarBranch::SetVarBranch(Select s0, SetCHB c, BranchTbl t) + SetVarBranch::SetVarBranch(Select s0, const SetCHB& c, BranchTbl t) : VarBranch(c, std::move(t)), s(s0) {} forceinline @@ -105,188 +105,188 @@ namespace Gecode { } inline SetVarBranch - SET_VAR_RND(Rnd r) { + SET_VAR_RND(const Rnd& r) { return SetVarBranch(r); } inline SetVarBranch SET_VAR_MERIT_MIN(SetBranchMerit bm, BranchTbl tbl) { - return SetVarBranch(SetVarBranch::SEL_MERIT_MIN, bm, tbl); + return SetVarBranch(SetVarBranch::SEL_MERIT_MIN, std::move(bm), std::move(tbl)); } inline SetVarBranch SET_VAR_MERIT_MAX(SetBranchMerit bm, BranchTbl tbl) { - return SetVarBranch(SetVarBranch::SEL_MERIT_MAX, bm, tbl); + return SetVarBranch(SetVarBranch::SEL_MERIT_MAX, std::move(bm), std::move(tbl)); } inline SetVarBranch SET_VAR_DEGREE_MIN(BranchTbl tbl) { - return SetVarBranch(SetVarBranch::SEL_DEGREE_MIN, tbl); + return SetVarBranch(SetVarBranch::SEL_DEGREE_MIN, std::move(tbl)); } inline SetVarBranch SET_VAR_DEGREE_MAX(BranchTbl tbl) { - return SetVarBranch(SetVarBranch::SEL_DEGREE_MAX, tbl); + return SetVarBranch(SetVarBranch::SEL_DEGREE_MAX, std::move(tbl)); } inline SetVarBranch SET_VAR_AFC_MIN(double d, BranchTbl tbl) { - return SetVarBranch(SetVarBranch::SEL_AFC_MIN, d, tbl); + return SetVarBranch(SetVarBranch::SEL_AFC_MIN, d, std::move(tbl)); } inline SetVarBranch - SET_VAR_AFC_MIN(SetAFC a, BranchTbl tbl) { - return SetVarBranch(SetVarBranch::SEL_AFC_MIN, a, tbl); + SET_VAR_AFC_MIN(const SetAFC& a, BranchTbl tbl) { + return SetVarBranch(SetVarBranch::SEL_AFC_MIN, a, std::move(tbl)); } inline SetVarBranch SET_VAR_AFC_MAX(double d, BranchTbl tbl) { - return SetVarBranch(SetVarBranch::SEL_AFC_MAX, d, tbl); + return SetVarBranch(SetVarBranch::SEL_AFC_MAX, d, std::move(tbl)); } inline SetVarBranch - SET_VAR_AFC_MAX(SetAFC a, BranchTbl tbl) { - return SetVarBranch(SetVarBranch::SEL_AFC_MAX, a, tbl); + SET_VAR_AFC_MAX(const SetAFC& a, BranchTbl tbl) { + return SetVarBranch(SetVarBranch::SEL_AFC_MAX, a, std::move(tbl)); } inline SetVarBranch SET_VAR_ACTION_MIN(double d, BranchTbl tbl) { - return SetVarBranch(SetVarBranch::SEL_ACTION_MIN, d, tbl); + return SetVarBranch(SetVarBranch::SEL_ACTION_MIN, d, std::move(tbl)); } inline SetVarBranch - SET_VAR_ACTION_MIN(SetAction a, BranchTbl tbl) { - return SetVarBranch(SetVarBranch::SEL_ACTION_MIN, a, tbl); + SET_VAR_ACTION_MIN(const SetAction& a, BranchTbl tbl) { + return SetVarBranch(SetVarBranch::SEL_ACTION_MIN, a, std::move(tbl)); } inline SetVarBranch SET_VAR_ACTION_MAX(double d, BranchTbl tbl) { - return SetVarBranch(SetVarBranch::SEL_ACTION_MAX, d, tbl); + return SetVarBranch(SetVarBranch::SEL_ACTION_MAX, d, std::move(tbl)); } inline SetVarBranch - SET_VAR_ACTION_MAX(SetAction a, BranchTbl tbl) { - return SetVarBranch(SetVarBranch::SEL_ACTION_MAX, a, tbl); + SET_VAR_ACTION_MAX(const SetAction& a, BranchTbl tbl) { + return SetVarBranch(SetVarBranch::SEL_ACTION_MAX, a, std::move(tbl)); } inline SetVarBranch SET_VAR_CHB_MIN(BranchTbl tbl) { - return SetVarBranch(SetVarBranch::SEL_CHB_MIN, tbl); + return SetVarBranch(SetVarBranch::SEL_CHB_MIN, std::move(tbl)); } inline SetVarBranch - SET_VAR_CHB_MIN(SetCHB c, BranchTbl tbl) { - return SetVarBranch(SetVarBranch::SEL_CHB_MIN, c, tbl); + SET_VAR_CHB_MIN(const SetCHB& c, BranchTbl tbl) { + return SetVarBranch(SetVarBranch::SEL_CHB_MIN, c, std::move(tbl)); } inline SetVarBranch SET_VAR_CHB_MAX(BranchTbl tbl) { - return SetVarBranch(SetVarBranch::SEL_CHB_MAX, tbl); + return SetVarBranch(SetVarBranch::SEL_CHB_MAX, std::move(tbl)); } inline SetVarBranch - SET_VAR_CHB_MAX(SetCHB c, BranchTbl tbl) { - return SetVarBranch(SetVarBranch::SEL_CHB_MAX, c, tbl); + SET_VAR_CHB_MAX(const SetCHB& c, BranchTbl tbl) { + return SetVarBranch(SetVarBranch::SEL_CHB_MAX, c, std::move(tbl)); } inline SetVarBranch SET_VAR_MIN_MIN(BranchTbl tbl) { - return SetVarBranch(SetVarBranch::SEL_MIN_MIN, tbl); + return SetVarBranch(SetVarBranch::SEL_MIN_MIN, std::move(tbl)); } inline SetVarBranch SET_VAR_MIN_MAX(BranchTbl tbl) { - return SetVarBranch(SetVarBranch::SEL_MIN_MAX, tbl); + return SetVarBranch(SetVarBranch::SEL_MIN_MAX, std::move(tbl)); } inline SetVarBranch SET_VAR_MAX_MIN(BranchTbl tbl) { - return SetVarBranch(SetVarBranch::SEL_MAX_MIN, tbl); + return SetVarBranch(SetVarBranch::SEL_MAX_MIN, std::move(tbl)); } inline SetVarBranch SET_VAR_MAX_MAX(BranchTbl tbl) { - return SetVarBranch(SetVarBranch::SEL_MAX_MAX, tbl); + return SetVarBranch(SetVarBranch::SEL_MAX_MAX, std::move(tbl)); } inline SetVarBranch SET_VAR_SIZE_MIN(BranchTbl tbl) { - return SetVarBranch(SetVarBranch::SEL_SIZE_MIN, tbl); + return SetVarBranch(SetVarBranch::SEL_SIZE_MIN, std::move(tbl)); } inline SetVarBranch SET_VAR_SIZE_MAX(BranchTbl tbl) { - return SetVarBranch(SetVarBranch::SEL_SIZE_MAX, tbl); + return SetVarBranch(SetVarBranch::SEL_SIZE_MAX, std::move(tbl)); } inline SetVarBranch SET_VAR_DEGREE_SIZE_MIN(BranchTbl tbl) { - return SetVarBranch(SetVarBranch::SEL_DEGREE_SIZE_MIN, tbl); + return SetVarBranch(SetVarBranch::SEL_DEGREE_SIZE_MIN, std::move(tbl)); } inline SetVarBranch SET_VAR_DEGREE_SIZE_MAX(BranchTbl tbl) { - return SetVarBranch(SetVarBranch::SEL_DEGREE_SIZE_MAX, tbl); + return SetVarBranch(SetVarBranch::SEL_DEGREE_SIZE_MAX, std::move(tbl)); } inline SetVarBranch SET_VAR_AFC_SIZE_MIN(double d, BranchTbl tbl) { - return SetVarBranch(SetVarBranch::SEL_AFC_SIZE_MIN, d, tbl); + return SetVarBranch(SetVarBranch::SEL_AFC_SIZE_MIN, d, std::move(tbl)); } inline SetVarBranch - SET_VAR_AFC_SIZE_MIN(SetAFC a, BranchTbl tbl) { - return SetVarBranch(SetVarBranch::SEL_AFC_SIZE_MIN, a, tbl); + SET_VAR_AFC_SIZE_MIN(const SetAFC& a, BranchTbl tbl) { + return SetVarBranch(SetVarBranch::SEL_AFC_SIZE_MIN, a, std::move(tbl)); } inline SetVarBranch SET_VAR_AFC_SIZE_MAX(double d, BranchTbl tbl) { - return SetVarBranch(SetVarBranch::SEL_AFC_SIZE_MAX, d, tbl); + return SetVarBranch(SetVarBranch::SEL_AFC_SIZE_MAX, d, std::move(tbl)); } inline SetVarBranch - SET_VAR_AFC_SIZE_MAX(SetAFC a, BranchTbl tbl) { - return SetVarBranch(SetVarBranch::SEL_AFC_SIZE_MAX, a, tbl); + SET_VAR_AFC_SIZE_MAX(const SetAFC& a, BranchTbl tbl) { + return SetVarBranch(SetVarBranch::SEL_AFC_SIZE_MAX, a, std::move(tbl)); } inline SetVarBranch SET_VAR_ACTION_SIZE_MIN(double d, BranchTbl tbl) { - return SetVarBranch(SetVarBranch::SEL_ACTION_SIZE_MIN, d, tbl); + return SetVarBranch(SetVarBranch::SEL_ACTION_SIZE_MIN, d, std::move(tbl)); } inline SetVarBranch - SET_VAR_ACTION_SIZE_MIN(SetAction a, BranchTbl tbl) { - return SetVarBranch(SetVarBranch::SEL_ACTION_SIZE_MIN, a, tbl); + SET_VAR_ACTION_SIZE_MIN(const SetAction& a, BranchTbl tbl) { + return SetVarBranch(SetVarBranch::SEL_ACTION_SIZE_MIN, a, std::move(tbl)); } inline SetVarBranch SET_VAR_ACTION_SIZE_MAX(double d, BranchTbl tbl) { - return SetVarBranch(SetVarBranch::SEL_ACTION_SIZE_MAX, d, tbl); + return SetVarBranch(SetVarBranch::SEL_ACTION_SIZE_MAX, d, std::move(tbl)); } inline SetVarBranch - SET_VAR_ACTION_SIZE_MAX(SetAction a, BranchTbl tbl) { - return SetVarBranch(SetVarBranch::SEL_ACTION_SIZE_MAX, a, tbl); + SET_VAR_ACTION_SIZE_MAX(const SetAction& a, BranchTbl tbl) { + return SetVarBranch(SetVarBranch::SEL_ACTION_SIZE_MAX, a, std::move(tbl)); } inline SetVarBranch SET_VAR_CHB_SIZE_MIN(BranchTbl tbl) { - return SetVarBranch(SetVarBranch::SEL_CHB_SIZE_MIN, tbl); + return SetVarBranch(SetVarBranch::SEL_CHB_SIZE_MIN, std::move(tbl)); } inline SetVarBranch - SET_VAR_CHB_SIZE_MIN(SetCHB c, BranchTbl tbl) { - return SetVarBranch(SetVarBranch::SEL_CHB_SIZE_MIN, c, tbl); + SET_VAR_CHB_SIZE_MIN(const SetCHB& c, BranchTbl tbl) { + return SetVarBranch(SetVarBranch::SEL_CHB_SIZE_MIN, c, std::move(tbl)); } inline SetVarBranch SET_VAR_CHB_SIZE_MAX(BranchTbl tbl) { - return SetVarBranch(SetVarBranch::SEL_CHB_SIZE_MAX, tbl); + return SetVarBranch(SetVarBranch::SEL_CHB_SIZE_MAX, std::move(tbl)); } inline SetVarBranch - SET_VAR_CHB_SIZE_MAX(SetCHB c, BranchTbl tbl) { - return SetVarBranch(SetVarBranch::SEL_CHB_SIZE_MAX, c, tbl); + SET_VAR_CHB_SIZE_MAX(const SetCHB& c, BranchTbl tbl) { + return SetVarBranch(SetVarBranch::SEL_CHB_SIZE_MAX, c, std::move(tbl)); } } // namespace Gecode From 23640cf511e41b2b69f1798b1eb4ab41e0651e2d Mon Sep 17 00:00:00 2001 From: Mikael Zayenz Lagerkvist Date: Mon, 2 Nov 2026 03:29:28 +0100 Subject: [PATCH 2/6] Move brancher filter and print callbacks into SharedData storage Zdev-Change-Id: Z757c255838d9ab5582918cb98071b2660dbb370a68149ff589c16d34f4410986 --- gecode/float.hh | 22 ++--- gecode/float/branch.cpp | 50 +++++++----- gecode/float/branch.hpp | 8 +- gecode/int.hh | 59 +++++++------- gecode/int/branch.cpp | 126 +++++++++++++++-------------- gecode/int/branch.hpp | 16 ++-- gecode/int/branch/open.hpp | 32 ++++---- gecode/int/branch/view-values.hpp | 20 ++--- gecode/int/ldsb.cpp | 32 ++++---- gecode/int/ldsb/brancher.hpp | 15 ++-- gecode/kernel/branch/filter.hpp | 19 +++-- gecode/kernel/branch/print.hpp | 19 +++-- gecode/kernel/branch/view-val.hpp | 19 ++--- gecode/kernel/branch/view.hpp | 2 +- gecode/kernel/data/shared-data.hpp | 14 ++++ gecode/set.hh | 20 ++--- gecode/set/branch.cpp | 39 ++++----- gecode/set/branch.hpp | 8 +- gecode/set/ldsb.cpp | 16 ++-- gecode/set/ldsb/brancher.hpp | 15 ++-- 20 files changed, 303 insertions(+), 248 deletions(-) diff --git a/gecode/float.hh b/gecode/float.hh index 2f6c591886..9c0a1cdb33 100644 --- a/gecode/float.hh +++ b/gecode/float.hh @@ -1865,7 +1865,7 @@ namespace Gecode { * * \ingroup TaskModelFloatBranch */ - GECODE_FLOAT_EXPORT void branch(Home home, const FloatVarArgs& x, FloatVarBranch vars, FloatValBranch vals, + GECODE_FLOAT_EXPORT void branch(Home home, const FloatVarArgs& x, FloatVarBranch vars, const FloatValBranch& vals, FloatBranchFilter bf = nullptr, FloatVarValPrint vvp = nullptr); /** * \brief Branch over \a x with tie-breaking variable selection \a vars and value selection \a vals @@ -1873,35 +1873,37 @@ namespace Gecode { * \ingroup TaskModelFloatBranch */ GECODE_FLOAT_EXPORT void branch(Home home, const FloatVarArgs& x, TieBreak vars, - FloatValBranch vals, FloatBranchFilter bf = nullptr, + const FloatValBranch& vals, FloatBranchFilter bf = nullptr, FloatVarValPrint vvp = nullptr); /** * \brief Branch over \a x with value selection \a vals * * \ingroup TaskModelFloatBranch */ - GECODE_FLOAT_EXPORT void branch(Home home, FloatVar x, FloatValBranch vals, FloatVarValPrint vvp = nullptr); + GECODE_FLOAT_EXPORT void branch(Home home, FloatVar x, const FloatValBranch& vals, FloatVarValPrint vvp = nullptr); /** * \brief Assign all \a x with variable selection \a vars and value selection \a vals * * \ingroup TaskModelFloatBranch */ - GECODE_FLOAT_EXPORT void assign(Home home, const FloatVarArgs& x, FloatVarBranch vars, FloatAssign vals, - FloatBranchFilter bf = nullptr, FloatVarValPrint vvp = nullptr); + GECODE_FLOAT_EXPORT void assign(Home home, const FloatVarArgs& x, const 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 * * \ingroup TaskModelFloatBranch */ - GECODE_FLOAT_EXPORT void assign(Home home, const FloatVarArgs& x, TieBreak vars, FloatAssign vals, - FloatBranchFilter bf = nullptr, FloatVarValPrint vvp = nullptr); + GECODE_FLOAT_EXPORT void assign(Home home, const FloatVarArgs& x, TieBreak vars, + const FloatAssign& vals, FloatBranchFilter bf = nullptr, + FloatVarValPrint vvp = nullptr); /** * \brief Assign \a x with value selection \a vals * * \ingroup TaskModelFloatBranch */ - GECODE_FLOAT_EXPORT void assign(Home home, FloatVar x, FloatAssign vals, FloatVarValPrint vvp = nullptr); + GECODE_FLOAT_EXPORT void assign(Home home, FloatVar x, const FloatAssign& vals, FloatVarValPrint vvp = nullptr); } // namespace Gecode @@ -1912,14 +1914,14 @@ namespace Gecode { * * \ingroup TaskModelFloatBranch */ - void branch(Home home, const FloatVarArgs& x, FloatValBranch vals, FloatBranchFilter bf = nullptr, + void branch(Home home, const FloatVarArgs& x, const FloatValBranch& vals, FloatBranchFilter bf = nullptr, FloatVarValPrint vvp = nullptr); /** * \brief Assign all \a x with value selection \a vals * * \ingroup TaskModelFloatBranch */ - void assign(Home home, const FloatVarArgs& x, FloatAssign vals, FloatBranchFilter bf = nullptr, + void assign(Home home, const FloatVarArgs& x, const FloatAssign& vals, FloatBranchFilter bf = nullptr, FloatVarValPrint vvp = nullptr); } // namespace Gecode diff --git a/gecode/float/branch.cpp b/gecode/float/branch.cpp index a847909eff..f7c39c23c8 100644 --- a/gecode/float/branch.cpp +++ b/gecode/float/branch.cpp @@ -35,7 +35,7 @@ namespace Gecode { void - branch(Home home, const FloatVarArgs& x, FloatVarBranch vars, FloatValBranch vals, FloatBranchFilter bf, + branch(Home home, const FloatVarArgs& x, FloatVarBranch vars, const FloatValBranch& vals, FloatBranchFilter bf, FloatVarValPrint vvp) { using namespace Float; if (home.failed()) @@ -43,13 +43,13 @@ namespace Gecode { vars.expand(home, x); ViewArray xv(home, x); ViewSel* vs[1] = {Branch::view_selection(home, vars)}; - post_view_value_brancher(home, xv, vs, - Branch::value_selection_commit(home, vals), bf, vvp); + post_view_value_brancher( + home, xv, vs, Branch::value_selection_commit(home, vals), std::move(bf), std::move(vvp)); } void - branch(Home home, const FloatVarArgs& x, TieBreak vars, FloatValBranch vals, FloatBranchFilter bf, - FloatVarValPrint vvp) { + branch(Home home, const FloatVarArgs& x, TieBreak vars, const FloatValBranch& vals, + FloatBranchFilter bf, FloatVarValPrint vvp) { using namespace Float; if (home.failed()) return; @@ -64,49 +64,52 @@ namespace Gecode { vars.d = FLOAT_VAR_NONE(); vars.d.expand(home, x); if (vars.b.select() == FloatVarBranch::SEL_NONE) { - branch(home, x, vars.a, vals, bf, vvp); + branch(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); if (vars.c.select() == FloatVarBranch::SEL_NONE) { ViewSel* vs[2] = {Branch::view_selection(home, vars.a), Branch::view_selection(home, vars.b)}; - post_view_value_brancher(home, xv, vs, vsc, bf, vvp); + post_view_value_brancher(home, xv, vs, vsc, std::move(bf), + std::move(vvp)); } else if (vars.d.select() == FloatVarBranch::SEL_NONE) { ViewSel* vs[3] = {Branch::view_selection(home, vars.a), Branch::view_selection(home, vars.b), Branch::view_selection(home, vars.c)}; - post_view_value_brancher(home, xv, vs, vsc, bf, vvp); + post_view_value_brancher(home, xv, vs, vsc, std::move(bf), + std::move(vvp)); } else { ViewSel* vs[4] = {Branch::view_selection(home, vars.a), Branch::view_selection(home, vars.b), Branch::view_selection(home, vars.c), Branch::view_selection(home, vars.d)}; - post_view_value_brancher(home, xv, vs, vsc, bf, vvp); + post_view_value_brancher(home, xv, vs, vsc, std::move(bf), + std::move(vvp)); } } } void - branch(Home home, FloatVar x, FloatValBranch vals, FloatVarValPrint vvp) { + branch(Home home, FloatVar x, const FloatValBranch& vals, FloatVarValPrint vvp) { FloatVarArgs xv(1); xv[0] = x; - branch(home, xv, FLOAT_VAR_NONE(), vals, nullptr, vvp); + branch(home, xv, FLOAT_VAR_NONE(), vals, nullptr, std::move(vvp)); } void - assign(Home home, const FloatVarArgs& x, FloatVarBranch vars, FloatAssign vals, FloatBranchFilter bf, + assign(Home home, const FloatVarArgs& x, const FloatVarBranch& vars, const FloatAssign& vals, FloatBranchFilter bf, FloatVarValPrint vvp) { using namespace Float; if (home.failed()) return; ViewArray xv(home, x); ViewSel* vs[1] = {new (home) ViewSelNone(home, vars)}; - post_view_value_brancher(home, xv, vs, - Branch::value_selection_commit(home, vals), bf, vvp); + post_view_value_brancher( + home, xv, vs, Branch::value_selection_commit(home, vals), std::move(bf), std::move(vvp)); } void - assign(Home home, const FloatVarArgs& x, TieBreak vars, FloatAssign vals, FloatBranchFilter bf, - FloatVarValPrint vvp) { + assign(Home home, const FloatVarArgs& x, TieBreak vars, const FloatAssign& vals, + FloatBranchFilter bf, FloatVarValPrint vvp) { using namespace Float; if (home.failed()) return; @@ -121,32 +124,35 @@ 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, bf, vvp); + assign(home, x, vars.a, vals, std::move(bf), std::move(vvp)); } else { ViewArray xv(home, x); ValSelCommitBase* vsc = Branch::value_selection_commit(home, vals); if (vars.c.select() == FloatVarBranch::SEL_NONE) { ViewSel* vs[2] = {Branch::view_selection(home, vars.a), Branch::view_selection(home, vars.b)}; - post_view_value_brancher(home, xv, vs, vsc, bf, vvp); + post_view_value_brancher(home, xv, vs, vsc, std::move(bf), + std::move(vvp)); } else if (vars.d.select() == FloatVarBranch::SEL_NONE) { ViewSel* vs[3] = {Branch::view_selection(home, vars.a), Branch::view_selection(home, vars.b), Branch::view_selection(home, vars.c)}; - post_view_value_brancher(home, xv, vs, vsc, bf, vvp); + post_view_value_brancher(home, xv, vs, vsc, std::move(bf), + std::move(vvp)); } else { ViewSel* vs[4] = {Branch::view_selection(home, vars.a), Branch::view_selection(home, vars.b), Branch::view_selection(home, vars.c), Branch::view_selection(home, vars.d)}; - post_view_value_brancher(home, xv, vs, vsc, bf, vvp); + post_view_value_brancher(home, xv, vs, vsc, std::move(bf), + std::move(vvp)); } } } void - assign(Home home, FloatVar x, FloatAssign vals, FloatVarValPrint vvp) { + assign(Home home, FloatVar x, const FloatAssign& vals, FloatVarValPrint vvp) { FloatVarArgs xv(1); xv[0] = x; - assign(home, xv, FLOAT_VAR_NONE(), vals, nullptr, vvp); + assign(home, xv, FLOAT_VAR_NONE(), vals, nullptr, std::move(vvp)); } } // namespace Gecode diff --git a/gecode/float/branch.hpp b/gecode/float/branch.hpp index 580458e4f3..28558d868a 100644 --- a/gecode/float/branch.hpp +++ b/gecode/float/branch.hpp @@ -33,13 +33,13 @@ namespace Gecode { forceinline void - branch(Home home, const FloatVarArgs& x, FloatValBranch vals, FloatBranchFilter bf, FloatVarValPrint vvp) { - branch(home, x, FLOAT_VAR_NONE(), vals, bf, vvp); + branch(Home home, const FloatVarArgs& x, const FloatValBranch& vals, FloatBranchFilter bf, FloatVarValPrint vvp) { + branch(home, x, FLOAT_VAR_NONE(), vals, std::move(bf), std::move(vvp)); } forceinline void - assign(Home home, const FloatVarArgs& x, FloatAssign vals, FloatBranchFilter bf, FloatVarValPrint vvp) { - assign(home, x, FLOAT_VAR_NONE(), vals, bf, vvp); + assign(Home home, const FloatVarArgs& x, const FloatAssign& vals, FloatBranchFilter bf, FloatVarValPrint vvp) { + assign(home, x, FLOAT_VAR_NONE(), vals, std::move(bf), std::move(vvp)); } } // namespace Gecode diff --git a/gecode/int.hh b/gecode/int.hh index 26ffe6aea9..956a741a17 100644 --- a/gecode/int.hh +++ b/gecode/int.hh @@ -5721,21 +5721,21 @@ namespace Gecode { * * \ingroup TaskModelIntBranch */ - GECODE_INT_EXPORT void branch(Home home, const IntVarArgs& x, IntVarBranch vars, IntValBranch vals, + GECODE_INT_EXPORT void branch(Home home, const IntVarArgs& x, IntVarBranch vars, const IntValBranch& vals, IntBranchFilter bf = nullptr, IntVarValPrint vvp = nullptr); /** * \brief Branch over \a x with tie-breaking variable selection \a vars and value selection \a vals * * \ingroup TaskModelIntBranch */ - GECODE_INT_EXPORT void branch(Home home, const IntVarArgs& x, TieBreak vars, IntValBranch vals, + GECODE_INT_EXPORT void branch(Home home, const IntVarArgs& x, TieBreak vars, const IntValBranch& vals, IntBranchFilter bf = nullptr, IntVarValPrint vvp = nullptr); /** * \brief Branch over \a x with value selection \a vals * * \ingroup TaskModelIntBranch */ - GECODE_INT_EXPORT void branch(Home home, IntVar x, IntValBranch vals, IntVarValPrint vvp = nullptr); + GECODE_INT_EXPORT void branch(Home home, IntVar x, const IntValBranch& vals, IntVarValPrint vvp = nullptr); /** * \brief Branch over the eventual integer list \a x * @@ -5773,11 +5773,11 @@ namespace Gecode { * when posting; otherwise Int::UnknownBranching is thrown. * \ingroup TaskModelIntBranch */ - GECODE_INT_EXPORT void branch(Home home, OpenIntVarList x, IntVarBranch vars, IntValBranch vals, + GECODE_INT_EXPORT void branch(Home home, OpenIntVarList x, IntVarBranch vars, const IntValBranch& vals, IntBranchFilter bf = nullptr, IntVarValPrint vvp = nullptr); /// Branch over an open integer list with tie-breaking selectors - GECODE_INT_EXPORT void branch(Home home, OpenIntVarList x, TieBreak vars, IntValBranch vals, - IntBranchFilter bf = nullptr, IntVarValPrint vvp = nullptr); + GECODE_INT_EXPORT void branch(Home home, OpenIntVarList x, const TieBreak& vars, + const IntValBranch& vals, IntBranchFilter bf = nullptr, IntVarValPrint vvp = nullptr); /** * \brief Branch over an open Boolean list with standard selectors * @@ -5785,72 +5785,74 @@ namespace Gecode { * for integers. * \ingroup TaskModelIntBranch */ - GECODE_INT_EXPORT void branch(Home home, OpenBoolVarList x, BoolVarBranch vars, BoolValBranch vals, + GECODE_INT_EXPORT void branch(Home home, OpenBoolVarList x, BoolVarBranch vars, const BoolValBranch& vals, BoolBranchFilter bf = nullptr, BoolVarValPrint vvp = nullptr); /// Branch over an open Boolean list with tie-breaking selectors - GECODE_INT_EXPORT void branch(Home home, OpenBoolVarList x, TieBreak vars, BoolValBranch vals, - BoolBranchFilter bf = nullptr, BoolVarValPrint vvp = nullptr); + GECODE_INT_EXPORT void branch(Home home, OpenBoolVarList x, const TieBreak& vars, + const BoolValBranch& vals, BoolBranchFilter bf = nullptr, + BoolVarValPrint vvp = nullptr); /** * \brief Branch over \a x with variable selection \a vars and value selection \a vals * * \ingroup TaskModelIntBranch */ - GECODE_INT_EXPORT void branch(Home home, const BoolVarArgs& x, BoolVarBranch vars, BoolValBranch vals, + GECODE_INT_EXPORT void branch(Home home, const BoolVarArgs& x, BoolVarBranch vars, const BoolValBranch& vals, BoolBranchFilter bf = nullptr, BoolVarValPrint vvp = nullptr); /** * \brief Branch over \a x with tie-breaking variable selection \a vars and value selection \a vals * * \ingroup TaskModelIntBranch */ - GECODE_INT_EXPORT void branch(Home home, const BoolVarArgs& x, TieBreak vars, BoolValBranch vals, - BoolBranchFilter bf = nullptr, BoolVarValPrint vvp = nullptr); + GECODE_INT_EXPORT void branch(Home home, const BoolVarArgs& x, TieBreak vars, + const BoolValBranch& vals, BoolBranchFilter bf = nullptr, + BoolVarValPrint vvp = nullptr); /** * \brief Branch over \a x with value selection \a vals * * \ingroup TaskModelIntBranch */ - GECODE_INT_EXPORT void branch(Home home, BoolVar x, BoolValBranch vals, BoolVarValPrint vvp = nullptr); + GECODE_INT_EXPORT void branch(Home home, BoolVar x, const BoolValBranch& vals, BoolVarValPrint vvp = nullptr); /** * \brief Assign all \a x with variable selection \a vars with value selection \a vals * * \ingroup TaskModelIntBranch */ - GECODE_INT_EXPORT void assign(Home home, const IntVarArgs& x, IntVarBranch vars, IntAssign vals, + GECODE_INT_EXPORT void assign(Home home, const IntVarArgs& x, const 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 * * \ingroup TaskModelIntBranch */ - GECODE_INT_EXPORT void assign(Home home, const IntVarArgs& x, TieBreak vars, IntAssign vals, + GECODE_INT_EXPORT void assign(Home home, const IntVarArgs& x, TieBreak vars, const IntAssign& vals, IntBranchFilter bf = nullptr, IntVarValPrint vvp = nullptr); /** * \brief Assign \a x with value selection \a vals * * \ingroup TaskModelIntBranch */ - GECODE_INT_EXPORT void assign(Home home, IntVar x, IntAssign vals, IntVarValPrint vvp = nullptr); + GECODE_INT_EXPORT void assign(Home home, IntVar x, const IntAssign& vals, IntVarValPrint vvp = nullptr); /** * \brief Assign all \a x with variable selection \a vars with value selection \a vals * * \ingroup TaskModelIntBranch */ - GECODE_INT_EXPORT void assign(Home home, const BoolVarArgs& x, BoolVarBranch vars, BoolAssign vals, + GECODE_INT_EXPORT void assign(Home home, const BoolVarArgs& x, const 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 * * \ingroup TaskModelIntBranch */ - GECODE_INT_EXPORT void assign(Home home, const BoolVarArgs& x, TieBreak vars, BoolAssign vals, + GECODE_INT_EXPORT void assign(Home home, const BoolVarArgs& x, TieBreak vars, const BoolAssign& vals, IntBranchFilter bf = nullptr, IntVarValPrint vvp = nullptr); /** * \brief Assign \a x with value selection \a vals * * \ingroup TaskModelIntBranch */ - GECODE_INT_EXPORT void assign(Home home, BoolVar x, BoolAssign vals, BoolVarValPrint vvp = nullptr); + GECODE_INT_EXPORT void assign(Home home, BoolVar x, const BoolAssign& vals, BoolVarValPrint vvp = nullptr); } // namespace Gecode @@ -5861,14 +5863,14 @@ namespace Gecode { * * \ingroup TaskModelIntBranch */ - void branch(Home home, const IntVarArgs& x, IntValBranch vals, IntBranchFilter bf = nullptr, + void branch(Home home, const IntVarArgs& x, const IntValBranch& vals, IntBranchFilter bf = nullptr, IntVarValPrint vvp = nullptr); /** * \brief Branch over \a x with value selection \a vals * * \ingroup TaskModelIntBranch */ - void branch(Home home, const BoolVarArgs& x, BoolValBranch vals, BoolBranchFilter bf = nullptr, + void branch(Home home, const BoolVarArgs& x, const BoolValBranch& vals, BoolBranchFilter bf = nullptr, BoolVarValPrint vvp = nullptr); /** @@ -5876,14 +5878,14 @@ namespace Gecode { * * \ingroup TaskModelIntBranch */ - void assign(Home home, const IntVarArgs& x, IntAssign vals, IntBranchFilter bf = nullptr, + void assign(Home home, const IntVarArgs& x, const IntAssign& vals, IntBranchFilter bf = nullptr, IntVarValPrint vvp = nullptr); /** * \brief Assign all \a x with value selection \a vals * * \ingroup TaskModelIntBranch */ - void assign(Home home, const BoolVarArgs& x, BoolAssign vals, BoolBranchFilter bf = nullptr, + void assign(Home home, const BoolVarArgs& x, const BoolAssign& vals, BoolBranchFilter bf = nullptr, BoolVarValPrint vvp = nullptr); } // namespace Gecode @@ -6011,7 +6013,7 @@ namespace Gecode { * * \ingroup TaskModelIntBranch */ - GECODE_INT_EXPORT void branch(Home home, const IntVarArgs& x, IntVarBranch vars, IntValBranch vals, + GECODE_INT_EXPORT void branch(Home home, const IntVarArgs& x, IntVarBranch vars, const IntValBranch& vals, const Symmetries& syms, IntBranchFilter bf = nullptr, IntVarValPrint vvp = nullptr); /** * \brief Branch over \a x with tie-breaking variable selection \a @@ -6024,7 +6026,7 @@ namespace Gecode { * * \ingroup TaskModelIntBranch */ - GECODE_INT_EXPORT void branch(Home home, const IntVarArgs& x, TieBreak vars, IntValBranch vals, + GECODE_INT_EXPORT void branch(Home home, const IntVarArgs& x, TieBreak vars, const IntValBranch& vals, const Symmetries& syms, IntBranchFilter bf = nullptr, IntVarValPrint vvp = nullptr); /** * \brief Branch over \a x with variable selection \a vars and value @@ -6037,7 +6039,7 @@ namespace Gecode { * * \ingroup TaskModelIntBranch */ - GECODE_INT_EXPORT void branch(Home home, const BoolVarArgs& x, BoolVarBranch vars, BoolValBranch vals, + GECODE_INT_EXPORT void branch(Home home, const BoolVarArgs& x, BoolVarBranch vars, const BoolValBranch& vals, const Symmetries& syms, BoolBranchFilter bf = nullptr, BoolVarValPrint vvp = nullptr); /** * \brief Branch over \a x with tie-breaking variable selection \a @@ -6050,8 +6052,9 @@ namespace Gecode { * * \ingroup TaskModelIntBranch */ - GECODE_INT_EXPORT void branch(Home home, const BoolVarArgs& x, TieBreak vars, BoolValBranch vals, - const Symmetries& syms, BoolBranchFilter bf = nullptr, BoolVarValPrint vvp = nullptr); + GECODE_INT_EXPORT void branch(Home home, const BoolVarArgs& x, TieBreak vars, + const BoolValBranch& vals, const Symmetries& syms, BoolBranchFilter bf = nullptr, + BoolVarValPrint vvp = nullptr); #ifdef GECODE_HAS_CBS diff --git a/gecode/int/branch.cpp b/gecode/int/branch.cpp index c15c31ca28..f957127899 100644 --- a/gecode/int/branch.cpp +++ b/gecode/int/branch.cpp @@ -35,7 +35,7 @@ namespace Gecode { void - branch(Home home, const IntVarArgs& x, IntVarBranch vars, IntValBranch vals, IntBranchFilter bf, + branch(Home home, const IntVarArgs& x, IntVarBranch vars, const IntValBranch& vals, IntBranchFilter bf, IntVarValPrint vvp) { using namespace Int; if (home.failed()) @@ -45,20 +45,20 @@ namespace Gecode { ViewSel* vs[1] = {Branch::view_selection(home, vars)}; switch (vals.select()) { case IntValBranch::SEL_VALUES_MIN: - Branch::post_view_values_brancher<1, true>(home, xv, vs, bf, vvp); + Branch::post_view_values_brancher<1, true>(home, xv, vs, std::move(bf), std::move(vvp)); break; case IntValBranch::SEL_VALUES_MAX: - Branch::post_view_values_brancher<1, false>(home, xv, vs, bf, vvp); + Branch::post_view_values_brancher<1, false>(home, xv, vs, std::move(bf), std::move(vvp)); break; default: - post_view_value_brancher(home, xv, vs, Branch::value_selection_commit(home, vals), bf, - vvp); + post_view_value_brancher(home, xv, vs, Branch::value_selection_commit(home, vals), + std::move(bf), std::move(vvp)); break; } } void - branch(Home home, const IntVarArgs& x, TieBreak vars, IntValBranch vals, IntBranchFilter bf, + branch(Home home, const IntVarArgs& x, TieBreak vars, const IntValBranch& vals, IntBranchFilter bf, IntVarValPrint vvp) { using namespace Int; if (home.failed()) @@ -74,73 +74,75 @@ namespace Gecode { vars.d = INT_VAR_NONE(); vars.d.expand(home, x); if (vars.b.select() == IntVarBranch::SEL_NONE) { - branch(home, x, vars.a, vals, bf, vvp); + branch(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) { ViewSel* vs[2] = {Branch::view_selection(home, vars.a), Branch::view_selection(home, vars.b)}; switch (vals.select()) { case IntValBranch::SEL_VALUES_MIN: - Branch::post_view_values_brancher<2, true>(home, xv, vs, bf, vvp); + Branch::post_view_values_brancher<2, true>(home, xv, vs, std::move(bf), std::move(vvp)); break; case IntValBranch::SEL_VALUES_MAX: - Branch::post_view_values_brancher<2, false>(home, xv, vs, bf, vvp); + Branch::post_view_values_brancher<2, false>(home, xv, vs, std::move(bf), std::move(vvp)); break; default: - post_view_value_brancher(home, xv, vs, - Branch::value_selection_commit(home, vals), bf, vvp); + post_view_value_brancher( + home, xv, vs, Branch::value_selection_commit(home, vals), std::move(bf), std::move(vvp)); } } else if (vars.d.select() == IntVarBranch::SEL_NONE) { ViewSel* vs[3] = {Branch::view_selection(home, vars.a), Branch::view_selection(home, vars.b), Branch::view_selection(home, vars.c)}; switch (vals.select()) { case IntValBranch::SEL_VALUES_MIN: - Branch::post_view_values_brancher<3, true>(home, xv, vs, bf, vvp); + Branch::post_view_values_brancher<3, true>(home, xv, vs, std::move(bf), std::move(vvp)); break; case IntValBranch::SEL_VALUES_MAX: - Branch::post_view_values_brancher<3, false>(home, xv, vs, bf, vvp); + Branch::post_view_values_brancher<3, false>(home, xv, vs, std::move(bf), std::move(vvp)); break; default: - post_view_value_brancher(home, xv, vs, - Branch::value_selection_commit(home, vals), bf, vvp); + post_view_value_brancher( + home, xv, vs, Branch::value_selection_commit(home, vals), std::move(bf), std::move(vvp)); } } else { ViewSel* vs[4] = {Branch::view_selection(home, vars.a), Branch::view_selection(home, vars.b), Branch::view_selection(home, vars.c), Branch::view_selection(home, vars.d)}; switch (vals.select()) { case IntValBranch::SEL_VALUES_MIN: - Branch::post_view_values_brancher<4, true>(home, xv, vs, bf, vvp); + Branch::post_view_values_brancher<4, true>(home, xv, vs, std::move(bf), std::move(vvp)); break; case IntValBranch::SEL_VALUES_MAX: - Branch::post_view_values_brancher<4, false>(home, xv, vs, bf, vvp); + Branch::post_view_values_brancher<4, false>(home, xv, vs, std::move(bf), std::move(vvp)); break; default: - post_view_value_brancher(home, xv, vs, - Branch::value_selection_commit(home, vals), bf, vvp); + post_view_value_brancher( + home, xv, vs, Branch::value_selection_commit(home, vals), std::move(bf), std::move(vvp)); } } } } void - branch(Home home, IntVar x, IntValBranch vals, IntVarValPrint vvp) { + branch(Home home, IntVar x, const IntValBranch& vals, IntVarValPrint vvp) { IntVarArgs xv(1); xv[0] = x; - branch(home, xv, INT_VAR_NONE(), vals, nullptr, vvp); + branch(home, xv, INT_VAR_NONE(), vals, nullptr, std::move(vvp)); } void - assign(Home home, const IntVarArgs& x, IntVarBranch vars, IntAssign vals, IntBranchFilter bf, IntVarValPrint vvp) { + assign(Home home, const IntVarArgs& x, const IntVarBranch& vars, const IntAssign& vals, IntBranchFilter bf, + IntVarValPrint vvp) { using namespace Int; if (home.failed()) return; ViewArray xv(home, x); ViewSel* vs[1] = {new (home) ViewSelNone(home, vars)}; - post_view_value_brancher(home, xv, vs, Branch::value_selection_commit(home, vals), bf, vvp); + 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, IntAssign vals, IntBranchFilter bf, + branch(Home home, const IntVarArgs& x, TieBreak vars, const IntAssign& vals, IntBranchFilter bf, IntVarValPrint vvp) { using namespace Int; if (home.failed()) @@ -156,36 +158,36 @@ 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, bf, vvp); + assign(home, x, vars.a, vals, std::move(bf), std::move(vvp)); } else { ViewArray xv(home, x); if (vars.c.select() == IntVarBranch::SEL_NONE) { ViewSel* vs[2] = {Branch::view_selection(home, vars.a), Branch::view_selection(home, vars.b)}; post_view_value_brancher(home, xv, vs, Branch::value_selection_commit(home, vals), - bf, vvp); + std::move(bf), std::move(vvp)); } else if (vars.d.select() == IntVarBranch::SEL_NONE) { ViewSel* vs[3] = {Branch::view_selection(home, vars.a), Branch::view_selection(home, vars.b), Branch::view_selection(home, vars.c)}; post_view_value_brancher(home, xv, vs, Branch::value_selection_commit(home, vals), - bf, vvp); + std::move(bf), std::move(vvp)); } else { ViewSel* vs[4] = {Branch::view_selection(home, vars.a), Branch::view_selection(home, vars.b), Branch::view_selection(home, vars.c), Branch::view_selection(home, vars.d)}; post_view_value_brancher(home, xv, vs, Branch::value_selection_commit(home, vals), - bf, vvp); + std::move(bf), std::move(vvp)); } } } void - assign(Home home, IntVar x, IntAssign ia, IntVarValPrint vvp) { + assign(Home home, IntVar x, const IntAssign& ia, IntVarValPrint vvp) { IntVarArgs xv(1); xv[0] = x; - assign(home, xv, INT_VAR_NONE(), ia, nullptr, vvp); + assign(home, xv, INT_VAR_NONE(), ia, nullptr, std::move(vvp)); } void - branch(Home home, const BoolVarArgs& x, BoolVarBranch vars, BoolValBranch vals, BoolBranchFilter bf, + branch(Home home, const BoolVarArgs& x, BoolVarBranch vars, const BoolValBranch& vals, BoolBranchFilter bf, BoolVarValPrint vvp) { using namespace Int; if (home.failed()) @@ -193,13 +195,13 @@ namespace Gecode { vars.expand(home, x); ViewArray xv(home, x); ViewSel* vs[1] = {Branch::view_selection(home, vars)}; - post_view_value_brancher(home, xv, vs, Branch::value_selection_commit(home, vals), bf, - vvp); + post_view_value_brancher(home, xv, vs, Branch::value_selection_commit(home, vals), + std::move(bf), std::move(vvp)); } void - branch(Home home, const BoolVarArgs& x, TieBreak vars, BoolValBranch vals, BoolBranchFilter bf, - BoolVarValPrint vvp) { + branch(Home home, const BoolVarArgs& x, TieBreak vars, const BoolValBranch& vals, + BoolBranchFilter bf, BoolVarValPrint vvp) { using namespace Int; if (home.failed()) return; @@ -214,46 +216,46 @@ namespace Gecode { vars.d = BOOL_VAR_NONE(); vars.d.expand(home, x); if (vars.b.select() == BoolVarBranch::SEL_NONE) { - branch(home, x, vars.a, vals, bf, vvp); + branch(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); if (vars.c.select() == BoolVarBranch::SEL_NONE) { ViewSel* vs[2] = {Branch::view_selection(home, vars.a), Branch::view_selection(home, vars.b)}; - post_view_value_brancher(home, xv, vs, vsc, bf, vvp); + post_view_value_brancher(home, xv, vs, vsc, std::move(bf), std::move(vvp)); } else if (vars.d.select() == BoolVarBranch::SEL_NONE) { ViewSel* vs[3] = {Branch::view_selection(home, vars.a), Branch::view_selection(home, vars.b), Branch::view_selection(home, vars.c)}; - post_view_value_brancher(home, xv, vs, vsc, bf, vvp); + post_view_value_brancher(home, xv, vs, vsc, std::move(bf), std::move(vvp)); } else { ViewSel* vs[4] = {Branch::view_selection(home, vars.a), Branch::view_selection(home, vars.b), Branch::view_selection(home, vars.c), Branch::view_selection(home, vars.d)}; - post_view_value_brancher(home, xv, vs, vsc, bf, vvp); + post_view_value_brancher(home, xv, vs, vsc, std::move(bf), std::move(vvp)); } } } void - branch(Home home, BoolVar x, BoolValBranch vals, BoolVarValPrint vvp) { + branch(Home home, BoolVar x, const BoolValBranch& vals, BoolVarValPrint vvp) { BoolVarArgs xv(1); xv[0] = x; - branch(home, xv, BOOL_VAR_NONE(), vals, nullptr, vvp); + branch(home, xv, BOOL_VAR_NONE(), vals, nullptr, std::move(vvp)); } void - assign(Home home, const BoolVarArgs& x, BoolVarBranch vars, BoolAssign vals, BoolBranchFilter bf, + assign(Home home, const BoolVarArgs& x, const BoolVarBranch& vars, const BoolAssign& vals, BoolBranchFilter bf, BoolVarValPrint vvp) { using namespace Int; if (home.failed()) return; ViewArray xv(home, x); ViewSel* vs[1] = {new (home) ViewSelNone(home, vars)}; - post_view_value_brancher(home, xv, vs, Branch::value_selection_commit(home, vals), bf, - vvp); + post_view_value_brancher(home, xv, vs, Branch::value_selection_commit(home, vals), + std::move(bf), std::move(vvp)); } void - assign(Home home, const BoolVarArgs& x, TieBreak vars, BoolAssign vals, BoolBranchFilter bf, + assign(Home home, const BoolVarArgs& x, TieBreak vars, const BoolAssign& vals, BoolBranchFilter bf, BoolVarValPrint vvp) { using namespace Int; if (home.failed()) @@ -269,30 +271,30 @@ 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, bf, vvp); + assign(home, x, vars.a, vals, std::move(bf), std::move(vvp)); } else { ViewArray xv(home, x); ValSelCommitBase* vsc = Branch::value_selection_commit(home, vals); if (vars.c.select() == BoolVarBranch::SEL_NONE) { ViewSel* vs[2] = {Branch::view_selection(home, vars.a), Branch::view_selection(home, vars.b)}; - post_view_value_brancher(home, xv, vs, vsc, bf, vvp); + post_view_value_brancher(home, xv, vs, vsc, std::move(bf), std::move(vvp)); } else if (vars.d.select() == BoolVarBranch::SEL_NONE) { ViewSel* vs[3] = {Branch::view_selection(home, vars.a), Branch::view_selection(home, vars.b), Branch::view_selection(home, vars.c)}; - post_view_value_brancher(home, xv, vs, vsc, bf, vvp); + post_view_value_brancher(home, xv, vs, vsc, std::move(bf), std::move(vvp)); } else { ViewSel* vs[4] = {Branch::view_selection(home, vars.a), Branch::view_selection(home, vars.b), Branch::view_selection(home, vars.c), Branch::view_selection(home, vars.d)}; - post_view_value_brancher(home, xv, vs, vsc, bf, vvp); + post_view_value_brancher(home, xv, vs, vsc, std::move(bf), std::move(vvp)); } } } void - assign(Home home, BoolVar x, BoolAssign ba, BoolVarValPrint vvp) { + assign(Home home, BoolVar x, const BoolAssign& ba, BoolVarValPrint vvp) { BoolVarArgs xv(1); xv[0] = x; - assign(home, xv, BOOL_VAR_NONE(), ba, nullptr, vvp); + assign(home, xv, BOOL_VAR_NONE(), ba, nullptr, std::move(vvp)); } void @@ -306,29 +308,31 @@ namespace Gecode { } void - branch(Home home, OpenIntVarList list, IntVarBranch vars, IntValBranch vals, IntBranchFilter bf, + branch(Home home, OpenIntVarList list, IntVarBranch vars, const IntValBranch& vals, IntBranchFilter bf, IntVarValPrint vvp) { - branch(home, list, TieBreak(vars), vals, bf, vvp); + branch(home, list, TieBreak(std::move(vars)), vals, std::move(bf), std::move(vvp)); } void - branch(Home home, OpenIntVarList list, TieBreak vars, IntValBranch vals, IntBranchFilter bf, - IntVarValPrint vvp) { + branch(Home home, OpenIntVarList list, const TieBreak& vars, const IntValBranch& vals, + IntBranchFilter bf, IntVarValPrint vvp) { GECODE_POST; - Int::Branch::post_open_brancher(home, OpenViewList(list), vars, vals, bf, vvp); + Int::Branch::post_open_brancher(home, OpenViewList(list), vars, vals, std::move(bf), + std::move(vvp)); } void - branch(Home home, OpenBoolVarList list, BoolVarBranch vars, BoolValBranch vals, BoolBranchFilter bf, + branch(Home home, OpenBoolVarList list, BoolVarBranch vars, const BoolValBranch& vals, BoolBranchFilter bf, BoolVarValPrint vvp) { - branch(home, list, TieBreak(vars), vals, bf, vvp); + branch(home, list, TieBreak(std::move(vars)), vals, std::move(bf), std::move(vvp)); } void - branch(Home home, OpenBoolVarList list, TieBreak vars, BoolValBranch vals, BoolBranchFilter bf, - BoolVarValPrint vvp) { + branch(Home home, OpenBoolVarList list, const TieBreak& vars, const BoolValBranch& vals, + BoolBranchFilter bf, BoolVarValPrint vvp) { GECODE_POST; - Int::Branch::post_open_brancher(home, OpenViewList(list), vars, vals, bf, vvp); + Int::Branch::post_open_brancher(home, OpenViewList(list), vars, vals, + std::move(bf), std::move(vvp)); } #ifdef GECODE_HAS_CBS diff --git a/gecode/int/branch.hpp b/gecode/int/branch.hpp index 06cb8ce14e..1190b89d23 100644 --- a/gecode/int/branch.hpp +++ b/gecode/int/branch.hpp @@ -33,21 +33,21 @@ namespace Gecode { forceinline void - branch(Home home, const IntVarArgs& x, IntValBranch vals, IntBranchFilter bf, IntVarValPrint vvp) { - branch(home, x, INT_VAR_NONE(), vals, bf, vvp); + branch(Home home, const IntVarArgs& x, const IntValBranch& vals, IntBranchFilter bf, IntVarValPrint vvp) { + branch(home, x, INT_VAR_NONE(), vals, std::move(bf), std::move(vvp)); } forceinline void - branch(Home home, const BoolVarArgs& x, BoolValBranch vals, BoolBranchFilter bf, BoolVarValPrint vvp) { - branch(home, x, BOOL_VAR_NONE(), vals, bf, vvp); + branch(Home home, const BoolVarArgs& x, const BoolValBranch& vals, BoolBranchFilter bf, BoolVarValPrint vvp) { + branch(home, x, BOOL_VAR_NONE(), vals, std::move(bf), std::move(vvp)); } forceinline void - assign(Home home, const IntVarArgs& x, IntAssign vals, IntBranchFilter bf, IntVarValPrint vvp) { - assign(home, x, INT_VAR_NONE(), vals, bf, vvp); + assign(Home home, const IntVarArgs& x, const IntAssign& vals, IntBranchFilter bf, IntVarValPrint vvp) { + assign(home, x, INT_VAR_NONE(), vals, std::move(bf), std::move(vvp)); } forceinline void - assign(Home home, const BoolVarArgs& x, BoolAssign vals, BoolBranchFilter bf, BoolVarValPrint vvp) { - assign(home, x, BOOL_VAR_NONE(), vals, bf, vvp); + assign(Home home, const BoolVarArgs& x, const BoolAssign& vals, BoolBranchFilter bf, BoolVarValPrint vvp) { + assign(home, x, BOOL_VAR_NONE(), vals, std::move(bf), std::move(vvp)); } } // namespace Gecode diff --git a/gecode/int/branch/open.hpp b/gecode/int/branch/open.hpp index 62fa0d87d1..0ef2a46002 100644 --- a/gecode/int/branch/open.hpp +++ b/gecode/int/branch/open.hpp @@ -55,8 +55,8 @@ namespace Gecode { namespace Int { namespace Branch { OpenListBrancher(Home home, OpenViewList list0, ViewSel* vs0[n], ValSelCommitBase* vsc0, bool values_min0, bool select_first0, BranchFilter bf, VarValPrint vvp) - : Brancher(home), list(list0), vsc(vsc0), filter(bf), printer(vvp), values_min(values_min0), - select_first(select_first0), start(0) { + : Brancher(home), list(list0), vsc(vsc0), filter(std::move(bf)), printer(std::move(vvp)), + values_min(values_min0), select_first(select_first0), start(0) { // Key each selector by brancher and role, as for ViewValBrancher. for (int i = 0; i < n; i++) { vs[i] = vs0[i]; @@ -262,14 +262,14 @@ namespace Gecode { namespace Int { namespace Branch { ViewSel* vs[n]; for (int i = 0; i < n; i++) vs[i] = view_selection(home, vars[i]); - (void)new (home) - OpenListBrancher(home, list, vs, vsc, values_min, vars[0].select() == VarBranch::SEL_NONE, bf, vvp); + (void)new (home) OpenListBrancher(home, list, vs, vsc, values_min, vars[0].select() == VarBranch::SEL_NONE, + std::move(bf), std::move(vvp)); } }; /// Reject fixed-position statistics while new variables can still appear inline void - check_open_selector(IntVarBranch vars, bool open) { + check_open_selector(const IntVarBranch& vars, bool open) { switch (vars.select()) { case IntVarBranch::SEL_ACTION_MIN: case IntVarBranch::SEL_ACTION_MAX: @@ -288,7 +288,7 @@ namespace Gecode { namespace Int { namespace Branch { } inline void - check_open_selector(BoolVarBranch vars, bool open) { + check_open_selector(const BoolVarBranch& vars, bool open) { switch (vars.select()) { case BoolVarBranch::SEL_ACTION_MIN: case BoolVarBranch::SEL_ACTION_MAX: @@ -304,7 +304,7 @@ namespace Gecode { namespace Int { namespace Branch { /// Select binary branching or enumeration of integer domain values inline ValSelCommitBase* - open_valselcommit(Home home, IntValBranch vals, bool& values_min) { + open_valselcommit(Home home, const IntValBranch& vals, bool& values_min) { values_min = vals.select() != IntValBranch::SEL_VALUES_MAX; return ((vals.select() == IntValBranch::SEL_VALUES_MIN) || (vals.select() == IntValBranch::SEL_VALUES_MAX)) ? nullptr @@ -313,7 +313,7 @@ namespace Gecode { namespace Int { namespace Branch { /// Boolean value branching always uses a binary selector inline ValSelCommitBase* - open_valselcommit(Home home, BoolValBranch vals, bool& values_min) { + open_valselcommit(Home home, const BoolValBranch& vals, bool& values_min) { values_min = true; return value_selection_commit(home, vals); } @@ -325,14 +325,16 @@ namespace Gecode { namespace Int { namespace Branch { bool values_min, BranchFilter bf, VarValPrint vvp) { if (bf) - OpenListBrancher, n>::post(home, list, vars, vsc, values_min, bf, vvp); + OpenListBrancher, n>::post(home, list, vars, vsc, values_min, std::move(bf), + std::move(vvp)); else - OpenListBrancher, n>::post(home, list, vars, vsc, values_min, bf, vvp); + OpenListBrancher, n>::post(home, list, vars, vsc, values_min, std::move(bf), + std::move(vvp)); } template void - post_open_brancher(Home home, OpenViewList list, TieBreak vars, ValBranch vals, + post_open_brancher(Home home, OpenViewList list, const TieBreak& vars, const ValBranch& vals, BranchFilter bf, VarValPrint vvp) { VarBranch selectors[4] = {vars.a, vars.b, vars.c, vars.d}; int n = 1; @@ -351,16 +353,16 @@ namespace Gecode { namespace Int { namespace Branch { ValSelCommitBase* vsc = open_valselcommit(home, vals, values_min); switch (n) { case 1: - post_open_brancher(home, list, selectors, vsc, values_min, bf, vvp); + post_open_brancher(home, list, selectors, vsc, values_min, std::move(bf), std::move(vvp)); break; case 2: - post_open_brancher(home, list, selectors, vsc, values_min, bf, vvp); + post_open_brancher(home, list, selectors, vsc, values_min, std::move(bf), std::move(vvp)); break; case 3: - post_open_brancher(home, list, selectors, vsc, values_min, bf, vvp); + post_open_brancher(home, list, selectors, vsc, values_min, std::move(bf), std::move(vvp)); break; case 4: - post_open_brancher(home, list, selectors, vsc, values_min, bf, vvp); + post_open_brancher(home, list, selectors, vsc, values_min, std::move(bf), std::move(vvp)); break; } } diff --git a/gecode/int/branch/view-values.hpp b/gecode/int/branch/view-values.hpp index 40c98f7677..c2ddf70e74 100644 --- a/gecode/int/branch/view-values.hpp +++ b/gecode/int/branch/view-values.hpp @@ -88,7 +88,7 @@ namespace Gecode { namespace Int { namespace Branch { ViewValuesBrancher::ViewValuesBrancher(Home home, ViewArray& x, ViewSel* vs[n], IntBranchFilter bf, IntVarValPrint vvp) - : ViewBrancher(home, x, vs, bf), p(vvp) { + : ViewBrancher(home, x, vs, std::move(bf)), p(std::move(vvp)) { if (p.notice()) home.notice(*this, AP_DISPOSE, true); } @@ -97,7 +97,7 @@ namespace Gecode { namespace Int { namespace Branch { forceinline void ViewValuesBrancher::post(Home home, ViewArray& x, ViewSel* vs[n], IntBranchFilter bf, IntVarValPrint vvp) { - (void)new (home) ViewValuesBrancher(home, x, vs, bf, vvp); + (void)new (home) ViewValuesBrancher(home, x, vs, std::move(bf), std::move(vvp)); } template @@ -178,19 +178,19 @@ namespace Gecode { namespace Int { namespace Branch { IntVarValPrint vvp) { if (bf) { if (vvp) { - ViewValuesBrancher, BrancherPrint>::post(home, x, vs, bf, - vvp); + ViewValuesBrancher, BrancherPrint>::post( + home, x, vs, std::move(bf), std::move(vvp)); } else { - ViewValuesBrancher, BrancherNoPrint>::post(home, x, vs, - bf, vvp); + ViewValuesBrancher, BrancherNoPrint>::post( + home, x, vs, std::move(bf), std::move(vvp)); } } else { if (vvp) { - ViewValuesBrancher, BrancherPrint>::post(home, x, vs, - bf, vvp); + ViewValuesBrancher, BrancherPrint>::post( + home, x, vs, std::move(bf), std::move(vvp)); } else { - ViewValuesBrancher, BrancherNoPrint>::post(home, x, vs, - bf, vvp); + ViewValuesBrancher, BrancherNoPrint>::post( + home, x, vs, std::move(bf), std::move(vvp)); } } } diff --git a/gecode/int/ldsb.cpp b/gecode/int/ldsb.cpp index 67390f7e6a..52e77ffd87 100644 --- a/gecode/int/ldsb.cpp +++ b/gecode/int/ldsb.cpp @@ -286,7 +286,7 @@ namespace Gecode { using namespace Int::LDSB; void - branch(Home home, const IntVarArgs& x, IntVarBranch vars, IntValBranch vals, const Symmetries& syms, + branch(Home home, const IntVarArgs& x, IntVarBranch vars, const IntValBranch& vals, const Symmetries& syms, IntBranchFilter bf, IntVarValPrint vvp) { using namespace Int; if (home.failed()) @@ -322,13 +322,13 @@ namespace Gecode { SymmetryImp** array = create_syms(home, syms, variable_map, create_int_sym, n); post_ldsb_brancher(home, xv, vs, Branch::value_selection_commit(home, vals), array, n, - bf, vvp); + std::move(bf), std::move(vvp)); } } void - branch(Home home, const IntVarArgs& x, TieBreak vars, IntValBranch vals, const Symmetries& syms, - IntBranchFilter bf, IntVarValPrint vvp) { + branch(Home home, const IntVarArgs& x, TieBreak vars, const IntValBranch& vals, + const Symmetries& syms, IntBranchFilter bf, IntVarValPrint vvp) { using namespace Int; if (home.failed()) return; @@ -343,7 +343,7 @@ namespace Gecode { vars.d = INT_VAR_NONE(); vars.d.expand(home, x); if (vars.b.select() == IntVarBranch::SEL_NONE) { - branch(home, x, vars.a, vals, syms, bf, vvp); + branch(home, x, std::move(vars.a), vals, syms, std::move(bf), std::move(vvp)); } else { // Construct mapping from each variable in the array to its index // in the array. @@ -376,7 +376,7 @@ namespace Gecode { // fall through default: post_ldsb_brancher(home, xv, vs, Branch::value_selection_commit(home, vals), - array, n, bf, vvp); + array, n, std::move(bf), std::move(vvp)); } } else if (vars.d.select() == IntVarBranch::SEL_NONE) { ViewSel* vs[3] = {Branch::view_selection(home, vars.a), Branch::view_selection(home, vars.b), @@ -398,7 +398,7 @@ namespace Gecode { // fall through default: post_ldsb_brancher(home, xv, vs, Branch::value_selection_commit(home, vals), - array, n, bf, vvp); + array, n, std::move(bf), std::move(vvp)); } } else { ViewSel* vs[4] = {Branch::view_selection(home, vars.a), Branch::view_selection(home, vars.b), @@ -420,14 +420,14 @@ namespace Gecode { // fall through default: post_ldsb_brancher(home, xv, vs, Branch::value_selection_commit(home, vals), - array, n, bf, vvp); + array, n, std::move(bf), std::move(vvp)); } } } } void - branch(Home home, const BoolVarArgs& x, BoolVarBranch vars, BoolValBranch vals, const Symmetries& syms, + branch(Home home, const BoolVarArgs& x, BoolVarBranch vars, const BoolValBranch& vals, const Symmetries& syms, BoolBranchFilter bf, BoolVarValPrint vvp) { using namespace Int; if (home.failed()) @@ -460,13 +460,13 @@ namespace Gecode { // fall through default: post_ldsb_brancher(home, xv, vs, Branch::value_selection_commit(home, vals), array, n, - bf, vvp); + std::move(bf), std::move(vvp)); } } void - branch(Home home, const BoolVarArgs& x, TieBreak vars, BoolValBranch vals, const Symmetries& syms, - BoolBranchFilter bf, BoolVarValPrint vvp) { + branch(Home home, const BoolVarArgs& x, TieBreak vars, const BoolValBranch& vals, + const Symmetries& syms, BoolBranchFilter bf, BoolVarValPrint vvp) { using namespace Int; if (home.failed()) return; @@ -481,7 +481,7 @@ namespace Gecode { vars.d = BOOL_VAR_NONE(); vars.d.expand(home, x); if (vars.b.select() == BoolVarBranch::SEL_NONE) { - branch(home, x, vars.a, vals, syms, bf, vvp); + branch(home, x, std::move(vars.a), vals, syms, std::move(bf), std::move(vvp)); } else { // Construct mapping from each variable in the array to its index // in the array. @@ -513,15 +513,15 @@ namespace Gecode { ValSelCommitBase* vsc = Branch::value_selection_commit(home, vals); if (vars.c.select() == BoolVarBranch::SEL_NONE) { ViewSel* vs[2] = {Branch::view_selection(home, vars.a), Branch::view_selection(home, vars.b)}; - post_ldsb_brancher(home, xv, vs, vsc, array, n, bf, vvp); + post_ldsb_brancher(home, xv, vs, vsc, array, n, std::move(bf), std::move(vvp)); } else if (vars.d.select() == BoolVarBranch::SEL_NONE) { ViewSel* vs[3] = {Branch::view_selection(home, vars.a), Branch::view_selection(home, vars.b), Branch::view_selection(home, vars.c)}; - post_ldsb_brancher(home, xv, vs, vsc, array, n, bf, vvp); + post_ldsb_brancher(home, xv, vs, vsc, array, n, std::move(bf), std::move(vvp)); } else { ViewSel* vs[4] = {Branch::view_selection(home, vars.a), Branch::view_selection(home, vars.b), Branch::view_selection(home, vars.c), Branch::view_selection(home, vars.d)}; - post_ldsb_brancher(home, xv, vs, vsc, array, n, bf, vvp); + post_ldsb_brancher(home, xv, vs, vsc, array, n, std::move(bf), std::move(vvp)); } } } diff --git a/gecode/int/ldsb/brancher.hpp b/gecode/int/ldsb/brancher.hpp index 3f2ae9c2e2..c8056c7812 100644 --- a/gecode/int/ldsb/brancher.hpp +++ b/gecode/int/ldsb/brancher.hpp @@ -92,8 +92,8 @@ namespace Gecode { namespace Int { namespace LDSB { Home home, ViewArray& x, ViewSel* vs[n], ValSelCommitBase* vsc, SymmetryImp** syms, int nsyms, BranchFilter::Var> bf, VarValPrint::Var, Val> vvp) - : ViewValBrancher(home, x, vs, vsc, bf, vvp), _syms(syms), _nsyms(nsyms), - _prev_pos(-1) { + : ViewValBrancher(home, x, vs, vsc, std::move(bf), std::move(vvp)), _syms(syms), + _nsyms(nsyms), _prev_pos(-1) { home.notice(*this, AP_DISPOSE, true); } @@ -103,7 +103,8 @@ namespace Gecode { namespace Int { namespace LDSB { Home home, ViewArray& x, ViewSel* vs[n], ValSelCommitBase* vsc, SymmetryImp** syms, int nsyms, BranchFilter::Var> bf, VarValPrint::Var, Val> vvp) { - (void)new (home) LDSBBrancher(home, x, vs, vsc, syms, nsyms, bf, vvp); + (void)new (home) + LDSBBrancher(home, x, vs, vsc, syms, nsyms, std::move(bf), std::move(vvp)); } template @@ -253,18 +254,18 @@ namespace Gecode { namespace Int { namespace LDSB { if (bf) { if (vvp) { LDSBBrancher, BrancherPrint>::post( - home, x, vs, vsc, syms, nsyms, bf, vvp); + home, x, vs, vsc, syms, nsyms, std::move(bf), std::move(vvp)); } else { LDSBBrancher, BrancherNoPrint>::post( - home, x, vs, vsc, syms, nsyms, bf, vvp); + home, x, vs, vsc, syms, nsyms, std::move(bf), std::move(vvp)); } } else { if (vvp) { LDSBBrancher, BrancherPrint>::post( - home, x, vs, vsc, syms, nsyms, bf, vvp); + home, x, vs, vsc, syms, nsyms, std::move(bf), std::move(vvp)); } else { LDSBBrancher, BrancherNoPrint>::post( - home, x, vs, vsc, syms, nsyms, bf, vvp); + home, x, vs, vsc, syms, nsyms, std::move(bf), std::move(vvp)); } } } diff --git a/gecode/kernel/branch/filter.hpp b/gecode/kernel/branch/filter.hpp index 81fa565823..b9e7585cb1 100644 --- a/gecode/kernel/branch/filter.hpp +++ b/gecode/kernel/branch/filter.hpp @@ -71,8 +71,10 @@ namespace Gecode { typedef typename View::VarType Var; public: - /// Initialize - BrancherNoFilter(BranchFilter bf); + /// Initialize from the empty filter \a bf + BrancherNoFilter(const BranchFilter& bf); + /// Initialize from the empty filter \a bf, moved in as for BrancherFilter + BrancherNoFilter(BranchFilter&& bf); /// Initialize during cloning BrancherNoFilter(BrancherNoFilter& bf); /// Whether filtering is enabled @@ -88,8 +90,8 @@ namespace Gecode { template forceinline BrancherFilter::BrancherFilter(BranchFilter bf) - : f(bf) { - if (!bf) + : f(std::move(bf)) { + if (!f()) throw Gecode::InvalidFunction("BrancherFilter::BrancherFilter"); } @@ -126,7 +128,14 @@ namespace Gecode { template forceinline - BrancherNoFilter::BrancherNoFilter(BranchFilter bf) { + BrancherNoFilter::BrancherNoFilter(const BranchFilter& bf) { + assert(!bf); + (void)bf; + } + + template + forceinline + BrancherNoFilter::BrancherNoFilter(BranchFilter&& bf) { assert(!bf); (void)bf; } diff --git a/gecode/kernel/branch/print.hpp b/gecode/kernel/branch/print.hpp index 34960c44a8..fc1b47356d 100644 --- a/gecode/kernel/branch/print.hpp +++ b/gecode/kernel/branch/print.hpp @@ -73,8 +73,10 @@ namespace Gecode { typedef typename View::VarType Var; public: - /// Initialize - BrancherNoPrint(VarValPrint vvp); + /// Initialize from the empty print function \a vvp + BrancherNoPrint(const VarValPrint& vvp); + /// Initialize from the empty print function \a vvp, moved in as for BrancherPrint + BrancherNoPrint(VarValPrint&& vvp); /// Initialize during cloning BrancherNoPrint(BrancherNoPrint& bp); /// Whether printing is enabled @@ -91,8 +93,8 @@ namespace Gecode { template forceinline BrancherPrint::BrancherPrint(VarValPrint vvp) - : p(vvp) { - if (!vvp) + : p(std::move(vvp)) { + if (!p()) throw Gecode::InvalidFunction("BrancherPrint::BrancherPrint"); } @@ -130,7 +132,14 @@ namespace Gecode { template forceinline - BrancherNoPrint::BrancherNoPrint(VarValPrint vvp) { + BrancherNoPrint::BrancherNoPrint(const VarValPrint& vvp) { + assert(!vvp); + (void)vvp; + } + + template + forceinline + BrancherNoPrint::BrancherNoPrint(VarValPrint&& vvp) { assert(!vvp); (void)vvp; } diff --git a/gecode/kernel/branch/view-val.hpp b/gecode/kernel/branch/view-val.hpp index fe6d2b7e86..c9f3b7ca3d 100644 --- a/gecode/kernel/branch/view-val.hpp +++ b/gecode/kernel/branch/view-val.hpp @@ -212,7 +212,7 @@ namespace Gecode { ViewSel* vs[n], ValSelCommitBase* vsc0, BranchFilter bf, VarValPrint vvp) - : ViewBrancher(home, x, vs, bf), vsc(vsc0), p(vvp) { + : ViewBrancher(home, x, vs, std::move(bf)), vsc(vsc0), p(std::move(vvp)) { vsc->random_split(this->id()); vsc->random_split(0U); this->random_state = this->random_state || vsc->random(); @@ -225,7 +225,8 @@ namespace Gecode { ViewValBrancher::post(Home home, ViewArray& x, ViewSel* vs[n], ValSelCommitBase* vsc, BranchFilter bf, VarValPrint vvp) { - (void)new (home) ViewValBrancher(home, x, vs, vsc, bf, vvp); + (void)new (home) + ViewValBrancher(home, x, vs, vsc, std::move(bf), std::move(vvp)); } template @@ -322,19 +323,19 @@ namespace Gecode { BranchFilter bf, VarValPrint vvp) { if (bf) { if (vvp) { - ViewValBrancher, BrancherPrint>::post(home, x, vs, vsc, - bf, vvp); + ViewValBrancher, BrancherPrint>::post( + home, x, vs, vsc, std::move(bf), std::move(vvp)); } else { - ViewValBrancher, BrancherNoPrint>::post(home, x, vs, - vsc, bf, vvp); + ViewValBrancher, BrancherNoPrint>::post( + home, x, vs, vsc, std::move(bf), std::move(vvp)); } } else { if (vvp) - ViewValBrancher, BrancherPrint>::post(home, x, vs, - vsc, bf, vvp); + ViewValBrancher, BrancherPrint>::post( + home, x, vs, vsc, std::move(bf), std::move(vvp)); else ViewValBrancher, BrancherNoPrint>::post( - home, x, vs, vsc, bf, vvp); + home, x, vs, vsc, std::move(bf), std::move(vvp)); } } diff --git a/gecode/kernel/branch/view.hpp b/gecode/kernel/branch/view.hpp index feccceb1cf..35699dafd1 100644 --- a/gecode/kernel/branch/view.hpp +++ b/gecode/kernel/branch/view.hpp @@ -142,7 +142,7 @@ namespace Gecode { forceinline ViewBrancher::ViewBrancher(Home home, ViewArray& x0, ViewSel* vs0[n], BranchFilter bf) - : Brancher(home), x(x0), start(0), random_state(false), f(bf) { + : Brancher(home), x(x0), start(0), random_state(false), f(std::move(bf)) { for (int i = 0; i < n; i++) { vs[i] = vs0[i]; // Key each selector by brancher and role; value selectors use role 0. diff --git a/gecode/kernel/data/shared-data.hpp b/gecode/kernel/data/shared-data.hpp index 7d9c74c975..75642210b6 100644 --- a/gecode/kernel/data/shared-data.hpp +++ b/gecode/kernel/data/shared-data.hpp @@ -43,6 +43,8 @@ namespace Gecode { const Data d; /// Initialization SDO(const Data& d0); + /// Initialization by moving \a d0 + SDO(Data&& d0); /// Destructor ~SDO(void) override; }; @@ -50,6 +52,8 @@ namespace Gecode { public: /// Initialize with data \a d SharedData(const Data& d); + /// Initialize by moving data \a d + SharedData(Data&& d); /// Create as uninitialized SharedData(void); /// Copy constructor @@ -67,6 +71,11 @@ namespace Gecode { SharedData::SDO::SDO(const Data& d0) : d(d0) {} + template + forceinline + SharedData::SDO::SDO(Data&& d0) + : d(std::move(d0)) {} + template forceinline SharedData::SDO::~SDO(void) {} @@ -75,6 +84,11 @@ namespace Gecode { SharedData::SharedData(const Data& d) : SharedHandle(new SDO(d)) {} + template + forceinline + SharedData::SharedData(Data&& d) + : SharedHandle(new SDO(std::move(d))) {} + template forceinline SharedData::SharedData(void) {} diff --git a/gecode/set.hh b/gecode/set.hh index 61689fb0a9..ca7e91a12f 100644 --- a/gecode/set.hh +++ b/gecode/set.hh @@ -1489,42 +1489,42 @@ namespace Gecode { * * \ingroup TaskModelSetBranch */ - GECODE_SET_EXPORT void branch(Home home, const SetVarArgs& x, SetVarBranch vars, SetValBranch vals, + GECODE_SET_EXPORT void branch(Home home, const SetVarArgs& x, SetVarBranch vars, const SetValBranch& vals, SetBranchFilter bf = nullptr, SetVarValPrint vvp = nullptr); /** * \brief Branch over \a x with tie-breaking variable selection \a vars and value selection \a vals * * \ingroup TaskModelSetBranch */ - GECODE_SET_EXPORT void branch(Home home, const SetVarArgs& x, TieBreak vars, SetValBranch vals, + GECODE_SET_EXPORT void branch(Home home, const SetVarArgs& x, TieBreak vars, const SetValBranch& vals, SetBranchFilter bf = nullptr, SetVarValPrint vvp = nullptr); /** * \brief Branch over \a x with value selection \a vals * * \ingroup TaskModelSetBranch */ - GECODE_SET_EXPORT void branch(Home home, SetVar x, SetValBranch vals, SetVarValPrint vvp = nullptr); + GECODE_SET_EXPORT void branch(Home home, SetVar x, const SetValBranch& vals, SetVarValPrint vvp = nullptr); /** * \brief Assign all \a x with variable selection \a vars and value selection \a vals * * \ingroup TaskModelSetBranch */ - GECODE_SET_EXPORT void assign(Home home, const SetVarArgs& x, SetVarBranch vars, SetAssign vals, + GECODE_SET_EXPORT void assign(Home home, const SetVarArgs& x, const 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 * * \ingroup TaskModelSetBranch */ - GECODE_SET_EXPORT void assign(Home home, const SetVarArgs& x, TieBreak vars, SetAssign vals, + GECODE_SET_EXPORT void assign(Home home, const SetVarArgs& x, TieBreak vars, const SetAssign& vals, SetBranchFilter bf = nullptr, SetVarValPrint vvp = nullptr); /** * \brief Assign \a x with value selection \a vals * * \ingroup TaskModelSetBranch */ - GECODE_SET_EXPORT void assign(Home home, SetVar x, SetAssign vals, SetVarValPrint vvp = nullptr); + GECODE_SET_EXPORT void assign(Home home, SetVar x, const SetAssign& vals, SetVarValPrint vvp = nullptr); } // namespace Gecode @@ -1535,7 +1535,7 @@ namespace Gecode { * * \ingroup TaskModelSetBranch */ - void branch(Home home, const SetVarArgs& x, SetValBranch vals, SetBranchFilter bf = nullptr, + void branch(Home home, const SetVarArgs& x, const SetValBranch& vals, SetBranchFilter bf = nullptr, SetVarValPrint vvp = nullptr); /** @@ -1543,7 +1543,7 @@ namespace Gecode { * * \ingroup TaskModelSetBranch */ - void assign(Home home, const SetVarArgs& x, SetAssign vals, SetBranchFilter bf = nullptr, + void assign(Home home, const SetVarArgs& x, const SetAssign& vals, SetBranchFilter bf = nullptr, SetVarValPrint vvp = nullptr); } // namespace Gecode @@ -1567,7 +1567,7 @@ namespace Gecode { * * \ingroup TaskModelSetBranch */ - GECODE_SET_EXPORT void branch(Home home, const SetVarArgs& x, SetVarBranch vars, SetValBranch vals, + GECODE_SET_EXPORT void branch(Home home, const SetVarArgs& x, SetVarBranch vars, const SetValBranch& vals, const Symmetries& syms, SetBranchFilter bf = nullptr, SetVarValPrint vvp = nullptr); /** * \brief Branch over \a x with tie-breaking variable selection \a @@ -1575,7 +1575,7 @@ namespace Gecode { * * \ingroup TaskModelSetBranch */ - GECODE_SET_EXPORT void branch(Home home, const SetVarArgs& x, TieBreak vars, SetValBranch vals, + GECODE_SET_EXPORT void branch(Home home, const SetVarArgs& x, TieBreak vars, const SetValBranch& vals, const Symmetries& syms, SetBranchFilter bf = nullptr, SetVarValPrint vvp = nullptr); } // namespace Gecode diff --git a/gecode/set/branch.cpp b/gecode/set/branch.cpp index 40f4f19920..11f5889d0f 100644 --- a/gecode/set/branch.cpp +++ b/gecode/set/branch.cpp @@ -35,7 +35,7 @@ namespace Gecode { void - branch(Home home, const SetVarArgs& x, SetVarBranch vars, SetValBranch vals, SetBranchFilter bf, + branch(Home home, const SetVarArgs& x, SetVarBranch vars, const SetValBranch& vals, SetBranchFilter bf, SetVarValPrint vvp) { using namespace Set; if (home.failed()) @@ -43,11 +43,12 @@ namespace Gecode { vars.expand(home, x); ViewArray xv(home, x); ViewSel* vs[1] = {Branch::view_selection(home, vars)}; - post_view_value_brancher(home, xv, vs, Branch::value_selection_commit(home, vals), bf, vvp); + post_view_value_brancher(home, xv, vs, Branch::value_selection_commit(home, vals), + std::move(bf), std::move(vvp)); } void - branch(Home home, const SetVarArgs& x, TieBreak vars, SetValBranch vals, SetBranchFilter bf, + branch(Home home, const SetVarArgs& x, TieBreak vars, const SetValBranch& vals, SetBranchFilter bf, SetVarValPrint vvp) { using namespace Set; if (home.failed()) @@ -63,44 +64,46 @@ namespace Gecode { vars.d = SET_VAR_NONE(); vars.d.expand(home, x); if (vars.b.select() == SetVarBranch::SEL_NONE) { - branch(home, x, vars.a, vals, bf, vvp); + branch(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); if (vars.c.select() == SetVarBranch::SEL_NONE) { ViewSel* vs[2] = {Branch::view_selection(home, vars.a), Branch::view_selection(home, vars.b)}; - post_view_value_brancher(home, xv, vs, vsc, bf, vvp); + post_view_value_brancher(home, xv, vs, vsc, std::move(bf), std::move(vvp)); } else if (vars.d.select() == SetVarBranch::SEL_NONE) { ViewSel* vs[3] = {Branch::view_selection(home, vars.a), Branch::view_selection(home, vars.b), Branch::view_selection(home, vars.c)}; - post_view_value_brancher(home, xv, vs, vsc, bf, vvp); + post_view_value_brancher(home, xv, vs, vsc, std::move(bf), std::move(vvp)); } else { ViewSel* vs[4] = {Branch::view_selection(home, vars.a), Branch::view_selection(home, vars.b), Branch::view_selection(home, vars.c), Branch::view_selection(home, vars.d)}; - post_view_value_brancher(home, xv, vs, vsc, bf, vvp); + post_view_value_brancher(home, xv, vs, vsc, std::move(bf), std::move(vvp)); } } } void - branch(Home home, SetVar x, SetValBranch vals, SetVarValPrint vvp) { + branch(Home home, SetVar x, const SetValBranch& vals, SetVarValPrint vvp) { SetVarArgs xv(1); xv[0] = x; - branch(home, xv, SET_VAR_NONE(), vals, nullptr, vvp); + branch(home, xv, SET_VAR_NONE(), vals, nullptr, std::move(vvp)); } void - assign(Home home, const SetVarArgs& x, SetVarBranch vars, SetAssign vals, SetBranchFilter bf, SetVarValPrint vvp) { + assign(Home home, const SetVarArgs& x, const SetVarBranch& vars, const SetAssign& vals, SetBranchFilter bf, + SetVarValPrint vvp) { using namespace Set; if (home.failed()) return; ViewArray xv(home, x); ViewSel* vs[1] = {new (home) ViewSelNone(home, vars)}; - post_view_value_brancher(home, xv, vs, Branch::value_selection_commit(home, vals), bf, vvp); + post_view_value_brancher(home, xv, vs, Branch::value_selection_commit(home, vals), + std::move(bf), std::move(vvp)); } void - assign(Home home, const SetVarArgs& x, TieBreak vars, SetAssign vals, SetBranchFilter bf, + assign(Home home, const SetVarArgs& x, TieBreak vars, const SetAssign& vals, SetBranchFilter bf, SetVarValPrint vvp) { using namespace Set; if (home.failed()) @@ -116,30 +119,30 @@ 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, bf, vvp); + assign(home, x, vars.a, vals, std::move(bf), std::move(vvp)); } else { ViewArray xv(home, x); ValSelCommitBase* vsc = Branch::value_selection_commit(home, vals); if (vars.c.select() == SetVarBranch::SEL_NONE) { ViewSel* vs[2] = {Branch::view_selection(home, vars.a), Branch::view_selection(home, vars.b)}; - post_view_value_brancher(home, xv, vs, vsc, bf, vvp); + post_view_value_brancher(home, xv, vs, vsc, std::move(bf), std::move(vvp)); } else if (vars.d.select() == SetVarBranch::SEL_NONE) { ViewSel* vs[3] = {Branch::view_selection(home, vars.a), Branch::view_selection(home, vars.b), Branch::view_selection(home, vars.c)}; - post_view_value_brancher(home, xv, vs, vsc, bf, vvp); + post_view_value_brancher(home, xv, vs, vsc, std::move(bf), std::move(vvp)); } else { ViewSel* vs[4] = {Branch::view_selection(home, vars.a), Branch::view_selection(home, vars.b), Branch::view_selection(home, vars.c), Branch::view_selection(home, vars.d)}; - post_view_value_brancher(home, xv, vs, vsc, bf, vvp); + post_view_value_brancher(home, xv, vs, vsc, std::move(bf), std::move(vvp)); } } } void - assign(Home home, SetVar x, SetAssign vars, SetVarValPrint vvp) { + assign(Home home, SetVar x, const SetAssign& vars, SetVarValPrint vvp) { SetVarArgs xv(1); xv[0] = x; - assign(home, xv, SET_VAR_NONE(), vars, nullptr, vvp); + assign(home, xv, SET_VAR_NONE(), vars, nullptr, std::move(vvp)); } } // namespace Gecode diff --git a/gecode/set/branch.hpp b/gecode/set/branch.hpp index 8956d38216..710c583896 100644 --- a/gecode/set/branch.hpp +++ b/gecode/set/branch.hpp @@ -33,13 +33,13 @@ namespace Gecode { forceinline void - branch(Home home, const SetVarArgs& x, SetValBranch vals, SetBranchFilter bf, SetVarValPrint vvp) { - branch(home, x, SET_VAR_NONE(), vals, bf, vvp); + branch(Home home, const SetVarArgs& x, const SetValBranch& vals, SetBranchFilter bf, SetVarValPrint vvp) { + branch(home, x, SET_VAR_NONE(), vals, std::move(bf), std::move(vvp)); } forceinline void - assign(Home home, const SetVarArgs& x, SetAssign vals, SetBranchFilter bf, SetVarValPrint vvp) { - assign(home, x, SET_VAR_NONE(), vals, bf, vvp); + assign(Home home, const SetVarArgs& x, const SetAssign& vals, SetBranchFilter bf, SetVarValPrint vvp) { + assign(home, x, SET_VAR_NONE(), vals, std::move(bf), std::move(vvp)); } } // namespace Gecode diff --git a/gecode/set/ldsb.cpp b/gecode/set/ldsb.cpp index 64a4294f1a..9e18baaa16 100644 --- a/gecode/set/ldsb.cpp +++ b/gecode/set/ldsb.cpp @@ -149,7 +149,7 @@ namespace Gecode { using namespace Set::LDSB; void - branch(Home home, const SetVarArgs& x, SetVarBranch vars, SetValBranch vals, const Symmetries& syms, + branch(Home home, const SetVarArgs& x, SetVarBranch vars, const SetValBranch& vals, const Symmetries& syms, SetBranchFilter bf, SetVarValPrint vvp) { using namespace Set; if (home.failed()) @@ -170,12 +170,12 @@ namespace Gecode { SymmetryImp** array = create_set_syms(home, syms, variable_map, n); post_ldsb_set_brancher(home, xv, vs, Branch::value_selection_commit(home, vals), array, n, - bf, vvp); + std::move(bf), std::move(vvp)); } void - branch(Home home, const SetVarArgs& x, TieBreak vars, SetValBranch vals, const Symmetries& syms, - SetBranchFilter bf, SetVarValPrint vvp) { + branch(Home home, const SetVarArgs& x, TieBreak vars, const SetValBranch& vals, + const Symmetries& syms, SetBranchFilter bf, SetVarValPrint vvp) { using namespace Set; if (home.failed()) return; @@ -190,7 +190,7 @@ namespace Gecode { vars.d = SET_VAR_NONE(); vars.d.expand(home, x); if (vars.b.select() == SetVarBranch::SEL_NONE) { - branch(home, x, vars.a, vals, syms, bf, vvp); + branch(home, x, std::move(vars.a), vals, syms, std::move(bf), std::move(vvp)); } else { // Construct mapping from each variable in the array to its index // in the array. @@ -207,15 +207,15 @@ namespace Gecode { ValSelCommitBase* vsc = Branch::value_selection_commit(home, vals); if (vars.c.select() == SetVarBranch::SEL_NONE) { ViewSel* vs[2] = {Branch::view_selection(home, vars.a), Branch::view_selection(home, vars.b)}; - post_ldsb_set_brancher(home, xv, vs, vsc, array, n, bf, vvp); + post_ldsb_set_brancher(home, xv, vs, vsc, array, n, std::move(bf), std::move(vvp)); } else if (vars.d.select() == SetVarBranch::SEL_NONE) { ViewSel* vs[3] = {Branch::view_selection(home, vars.a), Branch::view_selection(home, vars.b), Branch::view_selection(home, vars.c)}; - post_ldsb_set_brancher(home, xv, vs, vsc, array, n, bf, vvp); + post_ldsb_set_brancher(home, xv, vs, vsc, array, n, std::move(bf), std::move(vvp)); } else { ViewSel* vs[4] = {Branch::view_selection(home, vars.a), Branch::view_selection(home, vars.b), Branch::view_selection(home, vars.c), Branch::view_selection(home, vars.d)}; - post_ldsb_set_brancher(home, xv, vs, vsc, array, n, bf, vvp); + post_ldsb_set_brancher(home, xv, vs, vsc, array, n, std::move(bf), std::move(vvp)); } } } diff --git a/gecode/set/ldsb/brancher.hpp b/gecode/set/ldsb/brancher.hpp index 68d58ec9e6..cebccfc008 100644 --- a/gecode/set/ldsb/brancher.hpp +++ b/gecode/set/ldsb/brancher.hpp @@ -37,8 +37,8 @@ namespace Gecode { namespace Set { namespace LDSB { Home home, ViewArray& x, ViewSel* vs[n], ValSelCommitBase* vsc, SymmetryImp** syms, int nsyms, BranchFilter::Var> bf, VarValPrint::Var, Val> vvp) - : LDSBBrancher(home, x, vs, vsc, syms, nsyms, bf, vvp), _prev_pos(-1), - _copied_syms(nullptr), _n_copied_syms(0), _stable(false) { + : 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. int seen = 0; int dest = this->_nsyms - 1; @@ -231,7 +231,8 @@ namespace Gecode { namespace Set { namespace LDSB { Home home, ViewArray& x, ViewSel* vs[n], ValSelCommitBase* vsc, SymmetryImp** syms, int nsyms, BranchFilter::Var> bf, VarValPrint::Var, Val> vvp) { - (void)new (home) LDSBSetBrancher(home, x, vs, vsc, syms, nsyms, bf, vvp); + (void)new (home) LDSBSetBrancher(home, x, vs, vsc, syms, nsyms, std::move(bf), + std::move(vvp)); } template @@ -242,18 +243,18 @@ namespace Gecode { namespace Set { namespace LDSB { if (bf) { if (vvp) { LDSBSetBrancher, BrancherPrint>::post( - home, x, vs, vsc, syms, nsyms, bf, vvp); + home, x, vs, vsc, syms, nsyms, std::move(bf), std::move(vvp)); } else { LDSBSetBrancher, BrancherNoPrint>::post( - home, x, vs, vsc, syms, nsyms, bf, vvp); + home, x, vs, vsc, syms, nsyms, std::move(bf), std::move(vvp)); } } else { if (vvp) { LDSBSetBrancher, BrancherPrint>::post( - home, x, vs, vsc, syms, nsyms, bf, vvp); + home, x, vs, vsc, syms, nsyms, std::move(bf), std::move(vvp)); } else { LDSBSetBrancher, BrancherNoPrint>::post( - home, x, vs, vsc, syms, nsyms, bf, vvp); + home, x, vs, vsc, syms, nsyms, std::move(bf), std::move(vvp)); } } } From 8f2648bcd70f22c3ff8759346d5e5583c81d5c16 Mon Sep 17 00:00:00 2001 From: Mikael Zayenz Lagerkvist Date: Mon, 2 Nov 2026 04:17:24 +0100 Subject: [PATCH 3/6] Fix CBS hooks, shared posting data, execution callbacks, open lists, and tracing Zdev-Change-Id: Zf998dffd1006fff50b23b42adcc1fc221887df0830b7a06397c01341484cce7d --- gecode/float.hh | 4 +-- gecode/float/exec.cpp | 4 +-- gecode/float/relax.cpp | 2 +- gecode/float/trace.cpp | 2 +- gecode/int.hh | 28 +++++++++---------- gecode/int/count.hh | 32 ++++++++++----------- gecode/int/count/int-base.hpp | 2 +- gecode/int/count/int-eq.hpp | 4 +-- gecode/int/count/int-gq.hpp | 4 +-- gecode/int/count/int-lq.hpp | 4 +-- gecode/int/count/rel.hpp | 8 +++--- gecode/int/count/view-base.hpp | 2 +- gecode/int/count/view-eq.hpp | 4 +-- gecode/int/count/view-gq.hpp | 4 +-- gecode/int/count/view-lq.hpp | 4 +-- gecode/int/distinct.hh | 17 +++++------ gecode/int/distinct/bnd.hpp | 4 +-- gecode/int/distinct/cbs.hpp | 4 +-- gecode/int/distinct/dom.hpp | 4 +-- gecode/int/distinct/val.hpp | 4 +-- gecode/int/element.cpp | 8 +++--- gecode/int/exec.cpp | 12 ++++---- gecode/int/exec/when.hpp | 4 +-- gecode/int/extensional-regular.cpp | 8 +++--- gecode/int/extensional/open.hpp | 4 +-- gecode/int/ldsb.hh | 2 +- gecode/int/ldsb/sym-obj.cpp | 2 +- gecode/int/open-var-list.cpp | 11 ++++---- gecode/int/relax.cpp | 4 +-- gecode/int/sequence.hh | 12 ++++---- gecode/int/sequence/int.hpp | 6 ++-- gecode/int/sequence/view.hpp | 45 ++++++++++++++++-------------- gecode/int/trace.cpp | 4 +-- gecode/kernel.hh | 2 +- gecode/kernel/branch/function.cpp | 6 ++-- gecode/kernel/core.hpp | 10 +++---- gecode/kernel/propagator/wait.hpp | 10 +++---- gecode/kernel/trace/general.cpp | 2 +- gecode/kernel/trace/recorder.hpp | 16 +++++------ gecode/minimodel.hh | 6 ++-- gecode/minimodel/aliases.hpp | 2 +- gecode/minimodel/matrix.hpp | 4 +-- gecode/set.hh | 7 +++-- gecode/set/exec.cpp | 4 +-- gecode/set/int.cpp | 2 +- gecode/set/ldsb/brancher.hpp | 2 +- gecode/set/relax.cpp | 2 +- gecode/set/trace.cpp | 2 +- 48 files changed, 173 insertions(+), 167 deletions(-) diff --git a/gecode/float.hh b/gecode/float.hh index 9c0a1cdb33..f9f5527727 100644 --- a/gecode/float.hh +++ b/gecode/float.hh @@ -1951,7 +1951,7 @@ namespace Gecode { * * \ingroup TaskModeFloat */ - GECODE_FLOAT_EXPORT void relax(Home home, const FloatVarArgs& x, const FloatVarArgs& sx, Rnd r, double p); + GECODE_FLOAT_EXPORT void relax(Home home, const FloatVarArgs& x, const FloatVarArgs& sx, const Rnd& r, double p); } // namespace Gecode @@ -2040,7 +2040,7 @@ namespace Gecode { * \brief Create a tracer for float variables * \ingroup TaskFloatTrace */ - GECODE_FLOAT_EXPORT void trace(Home home, const FloatVarArgs& x, TraceFilter tf, + GECODE_FLOAT_EXPORT void trace(Home home, const FloatVarArgs& x, const TraceFilter& tf, int te = (TE_INIT | TE_PRUNE | TE_FIX | TE_FAIL | TE_DONE), FloatTracer& t = StdFloatTracer::def); /** diff --git a/gecode/float/exec.cpp b/gecode/float/exec.cpp index 0d8ee432f6..1b7b34e012 100644 --- a/gecode/float/exec.cpp +++ b/gecode/float/exec.cpp @@ -37,14 +37,14 @@ namespace Gecode { void wait(Home home, FloatVar x, std::function c) { GECODE_POST; - GECODE_ES_FAIL(UnaryWait::post(home, x, c)); + GECODE_ES_FAIL(UnaryWait::post(home, x, std::move(c))); } void wait(Home home, const FloatVarArgs& x, std::function c) { GECODE_POST; ViewArray xv(home, x); - GECODE_ES_FAIL(NaryWait::post(home, xv, c)); + GECODE_ES_FAIL(NaryWait::post(home, xv, std::move(c))); } } // namespace Gecode diff --git a/gecode/float/relax.cpp b/gecode/float/relax.cpp index 93d123ba0b..8a63caedab 100644 --- a/gecode/float/relax.cpp +++ b/gecode/float/relax.cpp @@ -53,7 +53,7 @@ namespace Gecode { namespace Float { namespace Gecode { void - relax(Home home, const FloatVarArgs& x, const FloatVarArgs& sx, Rnd r, double p) { + relax(Home home, const FloatVarArgs& x, const FloatVarArgs& sx, const Rnd& r, double p) { if (x.size() != sx.size()) throw Float::ArgumentSizeMismatch("Float::relax"); if ((p < 0.0) || (p > 1.0)) diff --git a/gecode/float/trace.cpp b/gecode/float/trace.cpp index 51a959423d..e5ea3b3836 100644 --- a/gecode/float/trace.cpp +++ b/gecode/float/trace.cpp @@ -35,7 +35,7 @@ namespace Gecode { void - trace(Home home, const FloatVarArgs& x, TraceFilter tf, int te, FloatTracer& t) { + trace(Home home, const FloatVarArgs& x, const TraceFilter& tf, int te, FloatTracer& t) { using namespace Gecode::Float; GECODE_POST; ViewArray xv(home, x); diff --git a/gecode/int.hh b/gecode/int.hh index 956a741a17..25f3ced59d 100644 --- a/gecode/int.hh +++ b/gecode/int.hh @@ -1797,7 +1797,7 @@ namespace Gecode { * Throws an exception of type Int::ArgumentSizeMismatch, if * \f$ w\cdot h\neq|a|\f$. */ - GECODE_INT_EXPORT void element(Home home, IntSharedArray a, IntVar x, int w, IntVar y, int h, IntVar z, + GECODE_INT_EXPORT void element(Home home, const IntSharedArray& a, IntVar x, int w, IntVar y, int h, IntVar z, IntPropLevel ipl = IPL_DEF); /** \brief Post domain consistent propagator for \f$ a_{x+xoff+w\cdot (y+yoff)}=z\f$ * @@ -1812,8 +1812,8 @@ namespace Gecode { * Throws an exception of type Int::ArgumentSizeMismatch, if * \f$ w\cdot h\neq|a|\f$. */ - GECODE_INT_EXPORT void element(Home home, IntSharedArray a, IntVar x, int xoff, int w, IntVar y, int yoff, int h, - IntVar z, IntPropLevel ipl = IPL_DEF); + 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); /** \brief Post domain consistent propagator for \f$ a_{x+w\cdot y}=z\f$ * * If \a a is regarded as a two-dimensional array in row-major @@ -1826,7 +1826,7 @@ namespace Gecode { * Throws an exception of type Int::ArgumentSizeMismatch, if * \f$ w\cdot h\neq|a|\f$. */ - GECODE_INT_EXPORT void element(Home home, IntSharedArray a, IntVar x, int w, IntVar y, int h, BoolVar z, + GECODE_INT_EXPORT void element(Home home, const IntSharedArray& a, IntVar x, int w, IntVar y, int h, BoolVar z, IntPropLevel ipl = IPL_DEF); /** \brief Post domain consistent propagator for \f$ a_{x+xoff+w\cdot (y+yoff)}=z\f$ * @@ -1841,8 +1841,8 @@ namespace Gecode { * Throws an exception of type Int::ArgumentSizeMismatch, if * \f$ w\cdot h\neq|a|\f$. */ - GECODE_INT_EXPORT void element(Home home, IntSharedArray a, IntVar x, int xoff, int w, IntVar y, int yoff, int h, - BoolVar z, IntPropLevel ipl = IPL_DEF); + 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); /** \brief Post propagator for \f$ a_{x+w\cdot y}=z\f$ * * If \a a is regarded as a two-dimensional array in row-major @@ -2954,7 +2954,7 @@ namespace Gecode { * * \ingroup TaskModelIntExt */ - GECODE_INT_EXPORT void extensional(Home home, const IntVarArgs& x, DFA d, IntPropLevel ipl = IPL_DEF); + GECODE_INT_EXPORT void extensional(Home home, const IntVarArgs& x, const DFA& d, IntPropLevel ipl = IPL_DEF); /** * \brief Post domain consistent propagator for extensional constraint described by a DFA @@ -2968,7 +2968,7 @@ namespace Gecode { * * \ingroup TaskModelIntExt */ - GECODE_INT_EXPORT void extensional(Home home, const BoolVarArgs& x, DFA d, IntPropLevel ipl = IPL_DEF); + GECODE_INT_EXPORT void extensional(Home home, const BoolVarArgs& x, const DFA& d, IntPropLevel ipl = IPL_DEF); /** * \brief Post an open regular-language constraint @@ -2981,7 +2981,7 @@ namespace Gecode { * * \ingroup TaskModelIntExt */ - GECODE_INT_EXPORT void extensional(Home home, OpenIntVarList x, DFA d, IntPropLevel ipl = IPL_DEF); + GECODE_INT_EXPORT void extensional(Home home, OpenIntVarList x, const DFA& d, IntPropLevel ipl = IPL_DEF); /** * \brief Post an open regular-language constraint on Boolean variables @@ -2992,7 +2992,7 @@ namespace Gecode { * * \ingroup TaskModelIntExt */ - GECODE_INT_EXPORT void extensional(Home home, OpenBoolVarList x, DFA d, IntPropLevel ipl = IPL_DEF); + GECODE_INT_EXPORT void extensional(Home home, OpenBoolVarList x, const DFA& d, IntPropLevel ipl = IPL_DEF); /** \brief Post propagator for \f$x\in t\f$. * @@ -6129,7 +6129,7 @@ namespace Gecode { * * \ingroup TaskModelInt */ - GECODE_INT_EXPORT void relax(Home home, const IntVarArgs& x, const IntVarArgs& sx, Rnd r, double p); + GECODE_INT_EXPORT void relax(Home home, const IntVarArgs& x, const IntVarArgs& sx, const Rnd& r, double p); /* * \brief Relaxed assignment of variables in \a x from values in \a sx @@ -6152,7 +6152,7 @@ namespace Gecode { * * \ingroup TaskModelInt */ - GECODE_INT_EXPORT void relax(Home home, const BoolVarArgs& x, const BoolVarArgs& sx, Rnd r, double p); + GECODE_INT_EXPORT void relax(Home home, const BoolVarArgs& x, const BoolVarArgs& sx, const Rnd& r, double p); } // namespace Gecode @@ -6308,7 +6308,7 @@ namespace Gecode { * \brief Create a tracer for integer variables * \ingroup TaskIntTrace */ - GECODE_INT_EXPORT void trace(Home home, const IntVarArgs& x, TraceFilter tf, + GECODE_INT_EXPORT void trace(Home home, const IntVarArgs& x, const TraceFilter& tf, int te = (TE_INIT | TE_PRUNE | TE_FIX | TE_FAIL | TE_DONE), IntTracer& t = StdIntTracer::def); /** @@ -6322,7 +6322,7 @@ namespace Gecode { * \brief Create a tracer for Boolean Variables * \ingroup TaskIntTrace */ - GECODE_INT_EXPORT void trace(Home home, const BoolVarArgs& x, TraceFilter tf, + GECODE_INT_EXPORT void trace(Home home, const BoolVarArgs& x, const TraceFilter& tf, int te = (TE_INIT | TE_PRUNE | TE_FIX | TE_FAIL | TE_DONE), BoolTracer& t = StdBoolTracer::def); /** diff --git a/gecode/int/count.hh b/gecode/int/count.hh index 1232ab4810..ba75ccd5a2 100644 --- a/gecode/int/count.hh +++ b/gecode/int/count.hh @@ -51,10 +51,10 @@ namespace Gecode { namespace Int { namespace Count { //@{ /// Return whether \a y is an integer set template - bool is_int_set(VY y); + bool is_int_set(const VY& y); /// Return whether \a y is a value template - bool isval(VY y); + bool isval(const VY& y); /// Subscribe propagator \a p to view \a y template @@ -146,7 +146,7 @@ namespace Gecode { namespace Int { namespace Count { /// Constructor for cloning \a p IntBase(Space& home, IntBase& p); /// Constructor for creation - IntBase(Home home, ViewArray& x, int n_s, VY y, int c); + IntBase(Home home, ViewArray& x, int n_s, const VY& y, int c); public: /// Cost function (defined as low linear) @@ -177,7 +177,7 @@ namespace Gecode { namespace Int { namespace Count { /// Constructor for cloning \a p EqInt(Space& home, EqInt& p); /// Constructor for creation - EqInt(Home home, ViewArray& x, int n_s, VY y, int c); + EqInt(Home home, ViewArray& x, int n_s, const VY& y, int c); public: /// Create copy during cloning @@ -185,7 +185,7 @@ namespace Gecode { namespace Int { namespace Count { /// Perform propagation ExecStatus propagate(Space& home, const ModEventDelta& med) override; /// Post propagator for \f$\#\{i\in\{0,\ldots,|x|-1\}\;|\;x_i=y\}=c\f$ - static ExecStatus post(Home home, ViewArray& x, VY y, int c); + static ExecStatus post(Home home, ViewArray& x, const VY& y, int c); }; /** @@ -208,7 +208,7 @@ namespace Gecode { namespace Int { namespace Count { /// Constructor for cloning \a p GqInt(Space& home, GqInt& p); /// Constructor for creation - GqInt(Home home, ViewArray& x, int n_s, VY y, int c); + GqInt(Home home, ViewArray& x, int n_s, const VY& y, int c); public: /// Create copy during cloning @@ -216,7 +216,7 @@ namespace Gecode { namespace Int { namespace Count { /// Perform propagation ExecStatus propagate(Space& home, const ModEventDelta& med) override; /// Post propagator for \f$\#\{i\in\{0,\ldots,|x|-1\}\;|\;x_i=y\}\geq c\f$ - static ExecStatus post(Home home, ViewArray& x, VY y, int c); + static ExecStatus post(Home home, ViewArray& x, const VY& y, int c); }; /** @@ -239,7 +239,7 @@ namespace Gecode { namespace Int { namespace Count { /// Constructor for cloning \a p LqInt(Space& home, LqInt& p); /// Constructor for creation - LqInt(Home home, ViewArray& x, int n_s, VY y, int c); + LqInt(Home home, ViewArray& x, int n_s, const VY& y, int c); public: /// Create copy during cloning @@ -247,7 +247,7 @@ namespace Gecode { namespace Int { namespace Count { /// Perform propagation ExecStatus propagate(Space& home, const ModEventDelta& med) override; /// Post propagator for \f$\#\{i\in\{0,\ldots,|x|-1\}\;|\;x_i=y\}\leq c\f$ - static ExecStatus post(Home home, ViewArray& x, VY y, int c); + static ExecStatus post(Home home, ViewArray& x, const VY& y, int c); }; }}} // namespace Gecode::Int::Count @@ -277,7 +277,7 @@ namespace Gecode { namespace Int { namespace Count { /// Constructor for cloning \a p ViewBase(Space& home, ViewBase& p); /// Constructor for creation - ViewBase(Home home, ViewArray& x, VY y, VZ z, int c); + ViewBase(Home home, ViewArray& x, const VY& y, VZ z, int c); public: /// Delete propagator and return its size @@ -325,13 +325,13 @@ namespace Gecode { namespace Int { namespace Count { public: /// Constructor for creation - EqView(Home home, ViewArray& x, VY y, VZ z, int c); + EqView(Home home, ViewArray& x, const VY& y, VZ z, int c); /// Create copy during cloning Actor* copy(Space& home) override; /// Perform propagation ExecStatus propagate(Space& home, const ModEventDelta& med) override; /// Post propagator for \f$\#\{i\in\{0,\ldots,|x|-1\}\;|\;x_i=y\}=z+c\f$ - static ExecStatus post(Home home, ViewArray& x, VY y, VZ z, int c); + static ExecStatus post(Home home, ViewArray& x, const VY& y, VZ z, int c); }; /** @@ -361,13 +361,13 @@ namespace Gecode { namespace Int { namespace Count { public: /// Constructor for creation - LqView(Home home, ViewArray& x, VY y, VZ z, int c); + LqView(Home home, ViewArray& x, const VY& y, VZ z, int c); /// Create copy during cloning Actor* copy(Space& home) override; /// Perform propagation ExecStatus propagate(Space& home, const ModEventDelta& med) override; /// Post propagator for \f$\#\{i\in\{0,\ldots,|x|-1\}\;|\;x_i=y\}\leq z+c\f$ - static ExecStatus post(Home home, ViewArray& x, VY y, VZ z, int c); + static ExecStatus post(Home home, ViewArray& x, const VY& y, VZ z, int c); }; /** @@ -397,13 +397,13 @@ namespace Gecode { namespace Int { namespace Count { public: /// Constructor for creation - GqView(Home home, ViewArray& x, VY y, VZ z, int c); + GqView(Home home, ViewArray& x, const VY& y, VZ z, int c); /// Create copy during cloning Actor* copy(Space& home) override; /// Perform propagation ExecStatus propagate(Space& home, const ModEventDelta& med) override; /// Post propagator for \f$\#\{i\in\{0,\ldots,|x|-1\}\;|\;x_i=y\}\geq z+c\f$ - static ExecStatus post(Home home, ViewArray& x, VY y, VZ z, int c); + static ExecStatus post(Home home, ViewArray& x, const VY& y, VZ z, int c); }; }}} // namespace Gecode::Int::Count diff --git a/gecode/int/count/int-base.hpp b/gecode/int/count/int-base.hpp index aca060cbeb..a5c53c698d 100644 --- a/gecode/int/count/int-base.hpp +++ b/gecode/int/count/int-base.hpp @@ -34,7 +34,7 @@ namespace Gecode { namespace Int { namespace Count { template forceinline - IntBase::IntBase(Home home, ViewArray& x0, int n_s0, VY y0, int c0) + IntBase::IntBase(Home home, ViewArray& x0, int n_s0, const VY& y0, int c0) : Propagator(home), x(x0), n_s(n_s0), y(y0), c(c0) { if (is_int_set(y)) home.notice(*this, AP_DISPOSE); diff --git a/gecode/int/count/int-eq.hpp b/gecode/int/count/int-eq.hpp index 0ce88f3c14..8ee4f410ca 100644 --- a/gecode/int/count/int-eq.hpp +++ b/gecode/int/count/int-eq.hpp @@ -34,12 +34,12 @@ namespace Gecode { namespace Int { namespace Count { template forceinline - EqInt::EqInt(Home home, ViewArray& x, int n_s, VY y, int c) + EqInt::EqInt(Home home, ViewArray& x, int n_s, const VY& y, int c) : IntBase(home, x, n_s, y, c) {} template ExecStatus - EqInt::post(Home home, ViewArray& x, VY y, int c) { + EqInt::post(Home home, ViewArray& x, const VY& y, int c) { // Eliminate decided views int n_x = x.size(); for (int i = n_x; i--;) diff --git a/gecode/int/count/int-gq.hpp b/gecode/int/count/int-gq.hpp index 230fb5750f..c4b7b79d97 100644 --- a/gecode/int/count/int-gq.hpp +++ b/gecode/int/count/int-gq.hpp @@ -34,12 +34,12 @@ namespace Gecode { namespace Int { namespace Count { template forceinline - GqInt::GqInt(Home home, ViewArray& x, int n_s, VY y, int c) + GqInt::GqInt(Home home, ViewArray& x, int n_s, const VY& y, int c) : IntBase(home, x, n_s, y, c) {} template ExecStatus - GqInt::post(Home home, ViewArray& x, VY y, int c) { + GqInt::post(Home home, ViewArray& x, const VY& y, int c) { // Eliminate decided views int n_x = x.size(); for (int i = n_x; i--;) diff --git a/gecode/int/count/int-lq.hpp b/gecode/int/count/int-lq.hpp index 96aaf88f94..311b34de74 100644 --- a/gecode/int/count/int-lq.hpp +++ b/gecode/int/count/int-lq.hpp @@ -34,12 +34,12 @@ namespace Gecode { namespace Int { namespace Count { template forceinline - LqInt::LqInt(Home home, ViewArray& x, int n_s, VY y, int c) + LqInt::LqInt(Home home, ViewArray& x, int n_s, const VY& y, int c) : IntBase(home, x, n_s, y, c) {} template ExecStatus - LqInt::post(Home home, ViewArray& x, VY y, int c) { + LqInt::post(Home home, ViewArray& x, const VY& y, int c) { // Eliminate decided views int n_x = x.size(); for (int i = n_x; i--;) diff --git a/gecode/int/count/rel.hpp b/gecode/int/count/rel.hpp index 675f1aa7a7..ee0807b7c8 100644 --- a/gecode/int/count/rel.hpp +++ b/gecode/int/count/rel.hpp @@ -41,25 +41,25 @@ namespace Gecode { namespace Int { namespace Count { template forceinline bool - is_int_set(VY y) { + is_int_set(const VY& y) { (void)y; return false; } template <> forceinline bool - is_int_set(IntSet y) { + is_int_set(const IntSet& y) { (void)y; return true; } template forceinline bool - isval(VY y) { + isval(const VY& y) { return y.assigned(); } template <> forceinline bool - isval(IntSet y) { + isval(const IntSet& y) { (void)y; return true; } diff --git a/gecode/int/count/view-base.hpp b/gecode/int/count/view-base.hpp index ae31a5820b..a3b0805bf2 100644 --- a/gecode/int/count/view-base.hpp +++ b/gecode/int/count/view-base.hpp @@ -34,7 +34,7 @@ namespace Gecode { namespace Int { namespace Count { template forceinline - ViewBase::ViewBase(Home home, ViewArray& x0, VY y0, VZ z0, int c0) + ViewBase::ViewBase(Home home, ViewArray& x0, const VY& y0, VZ z0, int c0) : Propagator(home), x(x0), y(y0), z(z0), c(c0) { if (is_int_set(y)) home.notice(*this, AP_DISPOSE); diff --git a/gecode/int/count/view-eq.hpp b/gecode/int/count/view-eq.hpp index 4a233cdf72..7c94fe8ad1 100644 --- a/gecode/int/count/view-eq.hpp +++ b/gecode/int/count/view-eq.hpp @@ -34,12 +34,12 @@ namespace Gecode { namespace Int { namespace Count { template forceinline - EqView::EqView(Home home, ViewArray& x, VY y, VZ z, int c) + EqView::EqView(Home home, ViewArray& x, const VY& y, VZ z, int c) : ViewBase(home, x, y, z, c) {} template ExecStatus - EqView::post(Home home, ViewArray& x, VY y, VZ z, int c) { + EqView::post(Home home, ViewArray& x, const VY& y, VZ z, int c) { GECODE_ME_CHECK(z.gq(home, -c)); GECODE_ME_CHECK(z.lq(home, x.size() - c)); if (isval(y) && z.assigned()) diff --git a/gecode/int/count/view-gq.hpp b/gecode/int/count/view-gq.hpp index 054f93cbe0..e8a9115529 100644 --- a/gecode/int/count/view-gq.hpp +++ b/gecode/int/count/view-gq.hpp @@ -34,12 +34,12 @@ namespace Gecode { namespace Int { namespace Count { template forceinline - GqView::GqView(Home home, ViewArray& x, VY y, VZ z, int c) + GqView::GqView(Home home, ViewArray& x, const VY& y, VZ z, int c) : ViewBase(home, x, y, z, c) {} template ExecStatus - GqView::post(Home home, ViewArray& x, VY y, VZ z, int c) { + GqView::post(Home home, ViewArray& x, const VY& y, VZ z, int c) { GECODE_ME_CHECK(z.lq(home, x.size() - c)); if (isval(y) && z.assigned()) return GqInt::post(home, x, y, z.val() + c); diff --git a/gecode/int/count/view-lq.hpp b/gecode/int/count/view-lq.hpp index f905533da5..4e7913be74 100644 --- a/gecode/int/count/view-lq.hpp +++ b/gecode/int/count/view-lq.hpp @@ -34,12 +34,12 @@ namespace Gecode { namespace Int { namespace Count { template forceinline - LqView::LqView(Home home, ViewArray& x, VY y, VZ z, int c) + LqView::LqView(Home home, ViewArray& x, const VY& y, VZ z, int c) : ViewBase(home, x, y, z, c) {} template ExecStatus - LqView::post(Home home, ViewArray& x, VY y, VZ z, int c) { + LqView::post(Home home, ViewArray& x, const VY& y, VZ z, int c) { GECODE_ME_CHECK(z.gq(home, -c)); if (z.assigned()) return LqInt::post(home, x, y, z.val() + c); diff --git a/gecode/int/distinct.hh b/gecode/int/distinct.hh index 129fa904ed..86a86cf0a8 100644 --- a/gecode/int/distinct.hh +++ b/gecode/int/distinct.hh @@ -72,9 +72,9 @@ namespace Gecode { namespace Int { namespace Distinct { public: #ifdef GECODE_HAS_CBS /// Solution distribution computation for branching - void solution_distribution(Space& home, Propagator::SendMarginal send) const override; + void solution_distribution(Space& home, const Propagator::SendMarginal& send) const override; /// Sum of variables cardinalities - void domain_size_sum(Propagator::InDecision in, unsigned int& size, unsigned int& size_b) const override; + void domain_size_sum(const Propagator::InDecision& in, unsigned int& size, unsigned int& size_b) const override; #endif /// Copy propagator during cloning Actor* copy(Space& home) override; @@ -96,10 +96,11 @@ namespace Gecode { namespace Int { namespace Distinct { * Available at http://www.polymtl.ca/labo-quosseca/en/publications */ template - void cbs_distinct(Space& home, unsigned int prop_id, const ViewArray& x, Propagator::SendMarginal send); + void cbs_distinct(Space& home, unsigned int prop_id, const ViewArray& x, + const Propagator::SendMarginal& send); template - void cbs_size(const ViewArray& x, Propagator::InDecision in, unsigned int& size, unsigned int& size_b); + void cbs_size(const ViewArray& x, const Propagator::InDecision& in, unsigned int& size, unsigned int& size_b); #endif /** @@ -162,9 +163,9 @@ namespace Gecode { namespace Int { namespace Distinct { public: #ifdef GECODE_HAS_CBS /// Solution distribution computation for branching - void solution_distribution(Space& home, Propagator::SendMarginal send) const override; + void solution_distribution(Space& home, const Propagator::SendMarginal& send) const override; /// Sum of variables cardinalities - void domain_size_sum(Propagator::InDecision in, unsigned int& size, unsigned int& size_b) const override; + void domain_size_sum(const Propagator::InDecision& in, unsigned int& size, unsigned int& size_b) const override; #endif /// Post propagator for view array \a x static ExecStatus post(Home home, ViewArray& x); @@ -288,9 +289,9 @@ namespace Gecode { namespace Int { namespace Distinct { public: #ifdef GECODE_HAS_CBS /// Solution distribution computation for branching - void solution_distribution(Space& home, Propagator::SendMarginal send) const override; + void solution_distribution(Space& home, const Propagator::SendMarginal& send) const override; /// Sum of variables cardinalities - void domain_size_sum(Propagator::InDecision in, unsigned int& size, unsigned int& size_b) const override; + void domain_size_sum(const Propagator::InDecision& in, unsigned int& size, unsigned int& size_b) const override; #endif /// Perform propagation ExecStatus propagate(Space& home, const ModEventDelta& med) override; diff --git a/gecode/int/distinct/bnd.hpp b/gecode/int/distinct/bnd.hpp index 409e5f627f..1dfa328a07 100644 --- a/gecode/int/distinct/bnd.hpp +++ b/gecode/int/distinct/bnd.hpp @@ -459,13 +459,13 @@ namespace Gecode { namespace Int { namespace Distinct { #ifdef GECODE_HAS_CBS template void - Bnd::solution_distribution(Space& home, Propagator::SendMarginal send) const { + Bnd::solution_distribution(Space& home, const Propagator::SendMarginal& send) const { cbs_distinct(home, this->id(), x, send); } template void - Bnd::domain_size_sum(Propagator::InDecision in, unsigned int& size, unsigned int& size_b) const { + Bnd::domain_size_sum(const Propagator::InDecision& in, unsigned int& size, unsigned int& size_b) const { cbs_size(x, in, size, size_b); } #endif diff --git a/gecode/int/distinct/cbs.hpp b/gecode/int/distinct/cbs.hpp index f476281dc0..d453f659dc 100644 --- a/gecode/int/distinct/cbs.hpp +++ b/gecode/int/distinct/cbs.hpp @@ -132,7 +132,7 @@ namespace Gecode { namespace Int { namespace Distinct { template void - cbs_distinct(Space&, unsigned int prop_id, const ViewArray& x, Propagator::SendMarginal send) { + cbs_distinct(Space&, unsigned int prop_id, const ViewArray& x, const Propagator::SendMarginal& send) { // Computation of Minc and Brégman and Liang and Bai upper bounds for // the permanent of the whole constraint struct UB { @@ -208,7 +208,7 @@ namespace Gecode { namespace Int { namespace Distinct { template void - cbs_size(const ViewArray& x, Propagator::InDecision in, unsigned int& size, unsigned int& size_b) { + cbs_size(const ViewArray& x, const Propagator::InDecision& in, unsigned int& size, unsigned int& size_b) { size = 0; size_b = 0; for (const auto& v : x) { diff --git a/gecode/int/distinct/dom.hpp b/gecode/int/distinct/dom.hpp index 8f1cea6402..3a92c2fa73 100644 --- a/gecode/int/distinct/dom.hpp +++ b/gecode/int/distinct/dom.hpp @@ -77,13 +77,13 @@ namespace Gecode { namespace Int { namespace Distinct { #ifdef GECODE_HAS_CBS template void - Dom::solution_distribution(Space& home, Propagator::SendMarginal send) const { + Dom::solution_distribution(Space& home, const Propagator::SendMarginal& send) const { cbs_distinct(home, this->id(), x, send); } template void - Dom::domain_size_sum(Propagator::InDecision in, unsigned int& size, unsigned int& size_b) const { + Dom::domain_size_sum(const Propagator::InDecision& in, unsigned int& size, unsigned int& size_b) const { cbs_size(x, in, size, size_b); } #endif diff --git a/gecode/int/distinct/val.hpp b/gecode/int/distinct/val.hpp index 888e893841..76cf945cbe 100644 --- a/gecode/int/distinct/val.hpp +++ b/gecode/int/distinct/val.hpp @@ -157,13 +157,13 @@ namespace Gecode { namespace Int { namespace Distinct { #ifdef GECODE_HAS_CBS template void - Val::solution_distribution(Space& home, Propagator::SendMarginal send) const { + Val::solution_distribution(Space& home, const Propagator::SendMarginal& send) const { cbs_distinct(home, this->id(), x, send); } template void - Val::domain_size_sum(Propagator::InDecision in, unsigned int& size, unsigned int& size_b) const { + Val::domain_size_sum(const Propagator::InDecision& in, unsigned int& size, unsigned int& size_b) const { cbs_size(x, in, size, size_b); } #endif diff --git a/gecode/int/element.cpp b/gecode/int/element.cpp index 382d5647c7..d4b582cac6 100644 --- a/gecode/int/element.cpp +++ b/gecode/int/element.cpp @@ -279,7 +279,7 @@ namespace Gecode { } // namespace void - element(Home home, IntSharedArray a, IntVar x, int w, IntVar y, int h, IntVar z, IntPropLevel ipl) { + 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"); @@ -288,7 +288,7 @@ namespace Gecode { } void - element(Home home, IntSharedArray a, IntVar x, int xoff, int w, IntVar y, int yoff, int h, IntVar z, + 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) @@ -298,7 +298,7 @@ namespace Gecode { } void - element(Home home, IntSharedArray a, IntVar x, int w, IntVar y, int h, BoolVar z, IntPropLevel ipl) { + 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"); @@ -307,7 +307,7 @@ namespace Gecode { } void - element(Home home, IntSharedArray a, IntVar x, int xoff, int w, IntVar y, int yoff, int h, BoolVar z, + 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) diff --git a/gecode/int/exec.cpp b/gecode/int/exec.cpp index 7c599046bf..643c5fbc52 100644 --- a/gecode/int/exec.cpp +++ b/gecode/int/exec.cpp @@ -37,38 +37,38 @@ namespace Gecode { void wait(Home home, IntVar x, std::function c, IntPropLevel) { GECODE_POST; - GECODE_ES_FAIL(UnaryWait::post(home, x, c)); + GECODE_ES_FAIL(UnaryWait::post(home, x, std::move(c))); } void wait(Home home, BoolVar x, std::function c, IntPropLevel) { GECODE_POST; - GECODE_ES_FAIL(UnaryWait::post(home, x, c)); + GECODE_ES_FAIL(UnaryWait::post(home, x, std::move(c))); } void wait(Home home, const IntVarArgs& x, std::function c, IntPropLevel) { GECODE_POST; ViewArray xv(home, x); - GECODE_ES_FAIL(NaryWait::post(home, xv, c)); + GECODE_ES_FAIL(NaryWait::post(home, xv, std::move(c))); } void wait(Home home, const BoolVarArgs& x, std::function c, IntPropLevel) { GECODE_POST; ViewArray xv(home, x); - GECODE_ES_FAIL(NaryWait::post(home, xv, c)); + GECODE_ES_FAIL(NaryWait::post(home, xv, std::move(c))); } void when(Home home, BoolVar x, std::function t, std::function e, IntPropLevel) { GECODE_POST; - GECODE_ES_FAIL(Int::Exec::When::post(home, x, t, e)); + GECODE_ES_FAIL(Int::Exec::When::post(home, x, std::move(t), std::move(e))); } void when(Home home, BoolVar x, std::function t, IntPropLevel) { - when(home, x, t, [](Space&) {}); + when(home, x, std::move(t), [](Space&) {}); } } // namespace Gecode diff --git a/gecode/int/exec/when.hpp b/gecode/int/exec/when.hpp index b2ed62dccd..c1667abb54 100644 --- a/gecode/int/exec/when.hpp +++ b/gecode/int/exec/when.hpp @@ -34,7 +34,7 @@ namespace Gecode { namespace Int { namespace Exec { forceinline When::When(Home home, BoolView x, std::function t0, std::function e0) - : UnaryPropagator(home, x), t(t0), e(e0) { + : UnaryPropagator(home, x), t(std::move(t0)), e(std::move(e0)) { home.notice(*this, AP_DISPOSE); } @@ -55,7 +55,7 @@ namespace Gecode { namespace Int { namespace Exec { t(home); return home.failed() ? ES_FAILED : ES_OK; } else { - (void)new (home) When(home, x, t, e); + (void)new (home) When(home, x, std::move(t), std::move(e)); return ES_OK; } } diff --git a/gecode/int/extensional-regular.cpp b/gecode/int/extensional-regular.cpp index d488be52c3..037e944b7b 100644 --- a/gecode/int/extensional-regular.cpp +++ b/gecode/int/extensional-regular.cpp @@ -35,7 +35,7 @@ namespace Gecode { void - extensional(Home home, const IntVarArgs& x, DFA dfa, IntPropLevel) { + extensional(Home home, const IntVarArgs& x, const DFA& dfa, IntPropLevel) { using namespace Int; if (same(x)) throw ArgumentSame("Int::extensional"); @@ -44,7 +44,7 @@ namespace Gecode { } void - extensional(Home home, const BoolVarArgs& x, DFA dfa, IntPropLevel) { + extensional(Home home, const BoolVarArgs& x, const DFA& dfa, IntPropLevel) { using namespace Int; if (same(x)) throw ArgumentSame("Int::extensional"); @@ -53,14 +53,14 @@ namespace Gecode { } void - extensional(Home home, OpenIntVarList list, DFA dfa, IntPropLevel) { + extensional(Home home, OpenIntVarList list, const DFA& dfa, IntPropLevel) { GECODE_POST; GECODE_ES_FAIL((Int::Extensional::OpenRegular::post( home, OpenViewList(list), dfa))); } void - extensional(Home home, OpenBoolVarList list, DFA dfa, IntPropLevel) { + extensional(Home home, OpenBoolVarList list, const DFA& dfa, IntPropLevel) { GECODE_POST; GECODE_ES_FAIL((Int::Extensional::OpenRegular::post( home, OpenViewList(list), dfa))); diff --git a/gecode/int/extensional/open.hpp b/gecode/int/extensional/open.hpp index ded95a5893..e9d680e60b 100644 --- a/gecode/int/extensional/open.hpp +++ b/gecode/int/extensional/open.hpp @@ -105,7 +105,7 @@ namespace Gecode { namespace Int { namespace Extensional { int offset; int subscribed; - OpenRegular(Home home, OpenViewList list0, DFA dfa0) + OpenRegular(Home home, OpenViewList list0, const DFA& dfa0) : Propagator(home), list(list0), length(list0.length()), dfa(dfa0), distance(accepting_distances(dfa0)), start(static_cast(home).alloc(dfa.n_states())), offset(0), subscribed(list0.known_length()) { @@ -293,7 +293,7 @@ namespace Gecode { namespace Int { namespace Extensional { } static ExecStatus - post(Home home, OpenViewList list, DFA dfa) { + post(Home home, OpenViewList list, const DFA& dfa) { for (int i = 0; i < list.known_length(); i++) { DFA::Symbols symbols(dfa); View x(list[i]); diff --git a/gecode/int/ldsb.hh b/gecode/int/ldsb.hh index 306a36b871..9401c4aa81 100644 --- a/gecode/int/ldsb.hh +++ b/gecode/int/ldsb.hh @@ -152,7 +152,7 @@ namespace Gecode { namespace Int { namespace LDSB { /// Size of each sequence in symmetry int seq_size; /// Constructor for creation - ValueSequenceSymmetryObject(IntArgs vs, int ss); + ValueSequenceSymmetryObject(const IntArgs& vs, int ss); }; /** diff --git a/gecode/int/ldsb/sym-obj.cpp b/gecode/int/ldsb/sym-obj.cpp index fc9d49e13c..f7b95ccf87 100644 --- a/gecode/int/ldsb/sym-obj.cpp +++ b/gecode/int/ldsb/sym-obj.cpp @@ -94,7 +94,7 @@ namespace Gecode { namespace Int { namespace LDSB { delete[] xs; } - ValueSequenceSymmetryObject::ValueSequenceSymmetryObject(IntArgs vs, int ss) : values(vs), seq_size(ss) {} + ValueSequenceSymmetryObject::ValueSequenceSymmetryObject(const IntArgs& vs, int ss) : values(vs), seq_size(ss) {} }}} // namespace Gecode::Int::LDSB diff --git a/gecode/int/open-var-list.cpp b/gecode/int/open-var-list.cpp index cc4a6eaa9a..ec2138c0c7 100644 --- a/gecode/int/open-var-list.cpp +++ b/gecode/int/open-var-list.cpp @@ -40,7 +40,7 @@ namespace Gecode { OpenIntVarList::factory(Domain d) { if (!d) throw InvalidFunction("OpenIntVarList"); - return [d](Space& home, int i) { return IntVar(home, d(i)); }; + return [d = std::move(d)](Space& home, int i) { return IntVar(home, d(i)); }; } OpenIntVarList::OpenIntVarList(Space& home, int max) @@ -50,12 +50,13 @@ namespace Gecode { : OpenIntVarList(home, [d](int) { return d; }, max) {} OpenIntVarList::OpenIntVarList(Space& home, const IntSet& d, Transition t, int max) - : OpenIntVarList(home, [d](int) { return d; }, t, max) {} + : OpenIntVarList(home, [d](int) { return d; }, std::move(t), max) {} - OpenIntVarList::OpenIntVarList(Space& home, Domain d, int max) : OpenVarList(home, factory(d), max) {} + OpenIntVarList::OpenIntVarList(Space& home, Domain d, int max) + : OpenVarList(home, factory(std::move(d)), max) {} OpenIntVarList::OpenIntVarList(Space& home, Domain d, Transition t, int max) - : OpenVarList(home, factory(d), t, max) {} + : OpenVarList(home, factory(std::move(d)), std::move(t), max) {} OpenBoolVarList::OpenBoolVarList(void) {} @@ -63,7 +64,7 @@ namespace Gecode { : OpenVarList(home, [](Space& home, int) { return BoolVar(home, 0, 1); }, max) {} OpenBoolVarList::OpenBoolVarList(Space& home, Transition t, int max) - : OpenVarList(home, [](Space& home, int) { return BoolVar(home, 0, 1); }, t, max) {} + : OpenVarList(home, [](Space& home, int) { return BoolVar(home, 0, 1); }, std::move(t), max) {} } // namespace Gecode diff --git a/gecode/int/relax.cpp b/gecode/int/relax.cpp index e79eb0b351..5f8fc05782 100644 --- a/gecode/int/relax.cpp +++ b/gecode/int/relax.cpp @@ -61,7 +61,7 @@ namespace Gecode { namespace Int { namespace Gecode { void - relax(Home home, const IntVarArgs& x, const IntVarArgs& sx, Rnd r, double p) { + relax(Home home, const IntVarArgs& x, const IntVarArgs& sx, const Rnd& r, double p) { if (x.size() != sx.size()) throw Int::ArgumentSizeMismatch("Int::relax"); if ((p < 0.0) || (p > 1.0)) @@ -73,7 +73,7 @@ namespace Gecode { } void - relax(Home home, const BoolVarArgs& x, const BoolVarArgs& sx, Rnd r, double p) { + relax(Home home, const BoolVarArgs& x, const BoolVarArgs& sx, const Rnd& r, double p) { if (x.size() != sx.size()) throw Int::ArgumentSizeMismatch("Int::relax"); if ((p < 0.0) || (p > 1.0)) diff --git a/gecode/int/sequence.hh b/gecode/int/sequence.hh index 2d1f11a2b1..e0636dfff6 100644 --- a/gecode/int/sequence.hh +++ b/gecode/int/sequence.hh @@ -74,7 +74,7 @@ namespace Gecode { namespace Int { namespace Sequence { /// Copy constructor ViewValSupportArray(const ViewValSupportArray&); /// Construct an ViewValSupportArray from \a x - ViewValSupportArray(Space& home, ViewArray&, Val s, int q); + ViewValSupportArray(Space& home, ViewArray&, const Val& s, int q); /// Construct an ViewValSupportArray of size \a n ViewValSupportArray(Space& home, int n); /// Return the current size @@ -86,9 +86,9 @@ namespace Gecode { namespace Int { namespace Sequence { /// Cloning void update(Space& home, ViewValSupportArray& x); /// Propagate - ExecStatus propagate(Space& home, ViewArray& a, Val s, int q, int l, int u); + ExecStatus propagate(Space& home, ViewArray& a, const Val& s, int q, int l, int u); /// Advise - ExecStatus advise(Space& home, ViewArray& a, Val s, int q, int j, const Delta& d); + ExecStatus advise(Space& home, ViewArray& a, const Val& s, int q, int j, const Delta& d); }; /** @@ -103,7 +103,7 @@ namespace Gecode { namespace Int { namespace Sequence { /// Constructor for cloning \a p Sequence(Space& home, Sequence& p); /// Constructor for creation - Sequence(Home home, ViewArray& x, Val s, int q, int l, int u); + Sequence(Home home, ViewArray& x, const Val& s, int q, int l, int u); public: /// Perform copying during cloning @@ -117,9 +117,9 @@ namespace Gecode { namespace Int { namespace Sequence { /// Perform propagation ExecStatus propagate(Space& home, const ModEventDelta& med) override; /// Post propagator for - static ExecStatus post(Home home, ViewArray& x, Val s, int q, int l, int u); + static ExecStatus post(Home home, ViewArray& x, const Val& s, int q, int l, int u); /// Check for consistency - static ExecStatus check(ViewArray& x, Val s, int q, int l, int u); + static ExecStatus check(ViewArray& x, const Val& s, int q, int l, int u); /// Delete propagator and return its size size_t dispose(Space& home) override; diff --git a/gecode/int/sequence/int.hpp b/gecode/int/sequence/int.hpp index d12290e6d7..0cc10d42b7 100644 --- a/gecode/int/sequence/int.hpp +++ b/gecode/int/sequence/int.hpp @@ -38,7 +38,7 @@ namespace Gecode { namespace Int { namespace Sequence { template forceinline - Sequence::Sequence(Home home, ViewArray& x0, Val s0, int q0, int l0, int u0) + Sequence::Sequence(Home home, ViewArray& x0, const Val& s0, int q0, int l0, int u0) : Propagator(home), x(x0), s(s0), q(q0), l(l0), u(u0), vvsamax(home, x, s0, q0), vvsamin(home, x, s0, q0), ac(home), tofail(false) { home.notice(*this, AP_DISPOSE); @@ -102,7 +102,7 @@ namespace Gecode { namespace Int { namespace Sequence { template forceinline ExecStatus - Sequence::check(ViewArray& x, Val s, int q, int l, int u) { + Sequence::check(ViewArray& x, const Val& s, int q, int l, int u) { Region r; // could do this with an array of length q... int* upper = r.alloc(x.size() + 1); @@ -126,7 +126,7 @@ namespace Gecode { namespace Int { namespace Sequence { template ExecStatus - Sequence::post(Home home, ViewArray& x, Val s, int q, int l, int u) { + Sequence::post(Home home, ViewArray& x, const Val& s, int q, int l, int u) { GECODE_ES_CHECK(check(x, s, q, l, u)); Sequence* p = new (home) Sequence(home, x, s, q, l, u); diff --git a/gecode/int/sequence/view.hpp b/gecode/int/sequence/view.hpp index 9679742ad9..d8f5cdeda9 100644 --- a/gecode/int/sequence/view.hpp +++ b/gecode/int/sequence/view.hpp @@ -75,13 +75,13 @@ namespace Gecode { namespace Int { namespace Sequence { class ViewValSupport { public: /// Initialize - void init(Space& home, ViewArray& x, Val s, int i, int q); + void init(Space& home, ViewArray& x, const Val& s, int i, int q); /// Update void update(Space& home, ViewValSupport& vvs, int n0); /// Advise - ExecStatus advise(Space& home, ViewArray& a, Val s, int i, int q, int j, const Delta& d); + ExecStatus advise(Space& home, ViewArray& a, const Val& s, int i, int q, int j, const Delta& d); /// Propagate - ExecStatus propagate(Space& home, ViewArray& a, Val s, int i, int q, int l, int u); + ExecStatus propagate(Space& home, ViewArray& a, const Val& s, int i, int q, int l, int u); /// Return true if sequence j has been violated bool violated(int j, int q, int l, int u) const; /// Check if retired @@ -91,7 +91,7 @@ namespace Gecode { namespace Int { namespace Sequence { private: /// Schedules the invoking support to be concluded (to be shaved) - ExecStatus schedule_conclusion(ViewArray& a, Val s, int i); + ExecStatus schedule_conclusion(ViewArray& a, const Val& s, int i); /// Returns true if a conclusion to be made has been scheduled bool conlusion_scheduled(void) const; /// Retires invoking instance @@ -99,15 +99,15 @@ namespace Gecode { namespace Int { namespace Sequence { /// Return number of forced to s elements in sequence j int values(int j, int q) const; /// Checks if x[i] has been shaved - bool shaved(const View& x, Val s, int i) const; + bool shaved(const View& x, const Val& s, int i) const; /// Push up the cumulative array - bool pushup(ViewArray& a, Val s, int i, int q, int idx, int v); + bool pushup(ViewArray& a, const Val& s, int i, int q, int idx, int v); /// Make conclusion - ExecStatus conclude(Space& home, ViewArray& a, Val s, int i); + ExecStatus conclude(Space& home, ViewArray& a, const Val& s, int i); /// Returns true if a[idx]=s not possible taking into account a[i]=s if iss or a[i]!=s if ! iss - bool s_not_possible(ViewArray& a, Val s, int i, int idx) const; + bool s_not_possible(ViewArray& a, const Val& s, int i, int idx) const; /// Returns true if a[idx] can be not s taking into account a[i]=s if iss or a[i]!=s if ! iss - bool alternative_not_possible(ViewArray& a, Val s, int i, int idx) const; + bool alternative_not_possible(ViewArray& a, const Val& s, int i, int idx) const; /// Returns true if there are potential violations marked bool has_potential_violation(void) const; /// Returns next potential violation and removes it @@ -162,21 +162,21 @@ namespace Gecode { namespace Int { namespace Sequence { template forceinline bool - ViewValSupport::alternative_not_possible(ViewArray& a, Val s, int i, int idx) const { + ViewValSupport::alternative_not_possible(ViewArray& a, const Val& s, int i, int idx) const { (void)i; return includes(a[idx - 1], s) || (iss && (idx - 1 == i)); } template forceinline bool - ViewValSupport::s_not_possible(ViewArray& a, Val s, int i, int idx) const { + ViewValSupport::s_not_possible(ViewArray& a, const Val& s, int i, int idx) const { (void)i; return excludes(a[idx - 1], s) || (!iss && (i == idx - 1)); } template forceinline void - ViewValSupport::init(Space& home, ViewArray& a, Val s, int i, int q) { + ViewValSupport::init(Space& home, ViewArray& a, const Val& s, int i, int q) { y = home.alloc(a.size() + 1); v.init(home, static_cast(a.size())); y[0] = 0; @@ -211,7 +211,7 @@ namespace Gecode { namespace Int { namespace Sequence { template forceinline bool - ViewValSupport::shaved(const View& x, Val s, int) const { + ViewValSupport::shaved(const View& x, const Val& s, int) const { if (iss) return excludes(x, s); else @@ -220,7 +220,7 @@ namespace Gecode { namespace Int { namespace Sequence { template forceinline ExecStatus - ViewValSupport::schedule_conclusion(ViewArray& a, Val s, int i) { + ViewValSupport::schedule_conclusion(ViewArray& a, const Val& s, int i) { if (!retired()) { if ((iss && includes(a[i], s)) || (!iss && excludes(a[i], s))) return ES_FAILED; @@ -251,7 +251,7 @@ namespace Gecode { namespace Int { namespace Sequence { template forceinline ExecStatus - ViewValSupport::conclude(Space& home, ViewArray& a, Val s, int i) { + ViewValSupport::conclude(Space& home, ViewArray& a, const Val& s, int i) { if (iss) { GECODE_ME_CHECK(exclude(home, a[i], s)); } else { @@ -286,7 +286,7 @@ namespace Gecode { namespace Int { namespace Sequence { template forceinline bool - ViewValSupport::pushup(ViewArray& a, Val s, int i, int q, int idx, int v) { + ViewValSupport::pushup(ViewArray& a, const Val& s, int i, int q, int idx, int v) { if (!retired()) { int n = a.size() + 1; @@ -331,7 +331,8 @@ namespace Gecode { namespace Int { namespace Sequence { template forceinline ExecStatus - ViewValSupport::advise(Space&, ViewArray& a, Val s, int i, int q, int j, const Delta&) { + ViewValSupport::advise(Space&, ViewArray& a, const Val& s, int i, int q, int j, + const Delta&) { ExecStatus status = ES_FIX; if (!retired()) { if ((j == i) && shaved(a[j], s, j)) { @@ -368,7 +369,8 @@ namespace Gecode { namespace Int { namespace Sequence { template forceinline ExecStatus - ViewValSupport::propagate(Space& home, ViewArray& a, Val s, int i, int q, int l, int u) { + ViewValSupport::propagate(Space& home, ViewArray& a, const Val& s, int i, int q, int l, + int u) { if (!retired()) { if (conlusion_scheduled()) { return conclude(home, a, s, i); @@ -403,7 +405,7 @@ namespace Gecode { namespace Int { namespace Sequence { } template - ViewValSupportArray::ViewValSupportArray(Space& home, ViewArray& x, Val s, int q) + ViewValSupportArray::ViewValSupportArray(Space& home, ViewArray& x, const Val& s, int q) : xs(nullptr) { n = x.size(); if (n > 0) { @@ -456,7 +458,7 @@ namespace Gecode { namespace Int { namespace Sequence { template ExecStatus - ViewValSupportArray::propagate(Space& home, ViewArray& a, Val s, int q, int l, int u) { + ViewValSupportArray::propagate(Space& home, ViewArray& a, const Val& s, int q, int l, int u) { for (int i = n; i--;) { GECODE_ES_CHECK(xs[i].propagate(home, a, s, i, q, l, u)); } @@ -465,7 +467,8 @@ namespace Gecode { namespace Int { namespace Sequence { template ExecStatus - ViewValSupportArray::advise(Space& home, ViewArray& a, Val s, int q, int j, const Delta& d) { + ViewValSupportArray::advise(Space& home, ViewArray& a, const Val& s, int q, int j, + const Delta& d) { ExecStatus status = ES_FIX; for (int i = n; i--;) { if (ES_NOFIX == xs[i].advise(home, a, s, i, q, j, d)) diff --git a/gecode/int/trace.cpp b/gecode/int/trace.cpp index 2827dded84..a1ee9050c2 100644 --- a/gecode/int/trace.cpp +++ b/gecode/int/trace.cpp @@ -35,7 +35,7 @@ namespace Gecode { void - trace(Home home, const IntVarArgs& x, TraceFilter tf, int te, IntTracer& t) { + trace(Home home, const IntVarArgs& x, const TraceFilter& tf, int te, IntTracer& t) { using namespace Gecode::Int; GECODE_POST; ViewArray xv(home, x); @@ -43,7 +43,7 @@ namespace Gecode { } void - trace(Home home, const BoolVarArgs& x, TraceFilter tf, int te, BoolTracer& t) { + trace(Home home, const BoolVarArgs& x, const TraceFilter& tf, int te, BoolTracer& t) { using namespace Gecode::Int; GECODE_POST; ViewArray xv(home, x); diff --git a/gecode/kernel.hh b/gecode/kernel.hh index afaa48d796..08b22624e5 100644 --- a/gecode/kernel.hh +++ b/gecode/kernel.hh @@ -248,7 +248,7 @@ namespace Gecode { * \brief Create tracer * \ingroup TaskTrace */ - GECODE_KERNEL_EXPORT void trace(Home home, TraceFilter tf, int te = (TE_PROPAGATE | TE_COMMIT | TE_POST), + GECODE_KERNEL_EXPORT void trace(Home home, const TraceFilter& tf, int te = (TE_PROPAGATE | TE_COMMIT | TE_POST), Tracer& t = StdTracer::def); /** * \brief Create tracer diff --git a/gecode/kernel/branch/function.cpp b/gecode/kernel/branch/function.cpp index e0365dd9dc..681f2678dc 100644 --- a/gecode/kernel/branch/function.cpp +++ b/gecode/kernel/branch/function.cpp @@ -85,7 +85,7 @@ namespace Gecode { namespace Kernel { forceinline FunctionBranch::FunctionBranch(Home home, std::function f0) - : Brancher(home), f(f0), done(false) { + : Brancher(home), f(std::move(f0)), done(false) { if (!f()) throw InvalidFunction("FunctionBranch::FunctionBranch"); home.notice(*this, AP_DISPOSE); @@ -125,7 +125,7 @@ namespace Gecode { namespace Kernel { FunctionBranch::post(Home home, std::function f) { if (!f) throw InvalidFunction("FunctionBranch::post"); - (void)new (home) FunctionBranch(home, f); + (void)new (home) FunctionBranch(home, std::move(f)); } size_t FunctionBranch::dispose(Space& home) { @@ -141,7 +141,7 @@ namespace Gecode { void branch(Home home, std::function f) { - Kernel::FunctionBranch::post(home, f); + Kernel::FunctionBranch::post(home, std::move(f)); } } // namespace Gecode diff --git a/gecode/kernel/core.hpp b/gecode/kernel/core.hpp index 4264bb555c..7b075bb0e2 100644 --- a/gecode/kernel/core.hpp +++ b/gecode/kernel/core.hpp @@ -1278,7 +1278,7 @@ namespace Gecode { */ /// Signature for function transmitting marginal distributions typedef std::function SendMarginal; - virtual void solution_distribution(Space& home, SendMarginal send) const; + virtual void solution_distribution(Space& home, const SendMarginal& send) const; /** * \brief Sum of variable cardinalities * @@ -1288,7 +1288,7 @@ namespace Gecode { */ /// Signature for function testing if variables are candidates to branching decisions typedef std::function InDecision; - virtual void domain_size_sum(InDecision in, unsigned int& size, unsigned int& size_b) const; + virtual void domain_size_sum(const InDecision& in, unsigned int& size, unsigned int& size_b) const; //@} #endif /// \name Id and group support @@ -2061,7 +2061,7 @@ namespace Gecode { friend class Region; friend class AFC; friend class PostInfo; - friend GECODE_KERNEL_EXPORT void trace(Home home, TraceFilter tf, int te, Tracer& t); + friend GECODE_KERNEL_EXPORT void trace(Home home, const TraceFilter& tf, int te, Tracer& t); private: /// Allocate tagged space-local propagator information @@ -4095,10 +4095,10 @@ namespace Gecode { #ifdef GECODE_HAS_CBS forceinline void - Propagator::solution_distribution(Space&, SendMarginal) const {} + Propagator::solution_distribution(Space&, const SendMarginal&) const {} forceinline void - Propagator::domain_size_sum(InDecision, unsigned int& size, unsigned int& size_b) const { + Propagator::domain_size_sum(const InDecision&, unsigned int& size, unsigned int& size_b) const { size = 0; size_b = 0; } diff --git a/gecode/kernel/propagator/wait.hpp b/gecode/kernel/propagator/wait.hpp index c1be7d5a14..6751af4b2a 100644 --- a/gecode/kernel/propagator/wait.hpp +++ b/gecode/kernel/propagator/wait.hpp @@ -105,7 +105,7 @@ namespace Gecode { template forceinline UnaryWait::UnaryWait(Home home, View x0, std::function c0) - : Propagator(home), x(x0), c(c0) { + : Propagator(home), x(x0), c(std::move(c0)) { x.subscribe(home, *this, PC_GEN_ASSIGNED); home.notice(*this, AP_DISPOSE); } @@ -147,7 +147,7 @@ namespace Gecode { c(home); return home.failed() ? ES_FAILED : ES_OK; } else { - (void)new (home) UnaryWait(home, x, c); + (void)new (home) UnaryWait(home, x, std::move(c)); return ES_OK; } } @@ -168,7 +168,7 @@ namespace Gecode { template forceinline NaryWait::NaryWait(Home home, ViewArray& x0, std::function c0) - : Propagator(home), x(x0), c(c0) { + : Propagator(home), x(x0), c(std::move(c0)) { assert(!x[0].assigned()); x[0].subscribe(home, *this, PC_GEN_ASSIGNED); home.notice(*this, AP_DISPOSE); @@ -234,9 +234,9 @@ namespace Gecode { } else { x.unique(); if (x.size() == 1) { - return UnaryWait::post(home, x[0], c); + return UnaryWait::post(home, x[0], std::move(c)); } else { - (void)new (home) NaryWait(home, x, c); + (void)new (home) NaryWait(home, x, std::move(c)); return ES_OK; } } diff --git a/gecode/kernel/trace/general.cpp b/gecode/kernel/trace/general.cpp index e74fd0e6fd..dbe7ae8ede 100644 --- a/gecode/kernel/trace/general.cpp +++ b/gecode/kernel/trace/general.cpp @@ -35,7 +35,7 @@ namespace Gecode { void - trace(Home home, TraceFilter tf, int te, Tracer& t) { + trace(Home home, const TraceFilter& tf, int te, Tracer& t) { if (static_cast(home).find_trace_recorder()) throw MoreThanOneTracer("trace()"); GECODE_POST; diff --git a/gecode/kernel/trace/recorder.hpp b/gecode/kernel/trace/recorder.hpp index c32b6b2ca1..feb2711e3e 100644 --- a/gecode/kernel/trace/recorder.hpp +++ b/gecode/kernel/trace/recorder.hpp @@ -120,7 +120,7 @@ namespace Gecode { public: /// Constructor for creation - ViewTraceRecorder(Home home, ViewArray& x, TraceFilter tf, int te, ViewTracer& t); + ViewTraceRecorder(Home home, ViewArray& x, const TraceFilter& tf, int te, ViewTracer& t); /// Copy propagator during cloning Propagator* copy(Space& home) override; /// Cost function (record so that propagator runs last) @@ -134,7 +134,7 @@ namespace Gecode { /// Delete propagator and return its size size_t dispose(Space& home) override; /// Post recorder propagator - static ExecStatus post(Home home, ViewArray& x, TraceFilter tf, int te, ViewTracer& t); + static ExecStatus post(Home home, ViewArray& x, const TraceFilter& tf, int te, ViewTracer& t); /// \name Trace information //@{ /// Return variable being traced at position \a i @@ -167,7 +167,7 @@ namespace Gecode { public: /// Constructor for creation - TraceRecorder(Home home, TraceFilter tf, int te, Tracer& t); + TraceRecorder(Home home, const TraceFilter& tf, int te, Tracer& t); /// Copy propagator during cloning Propagator* copy(Space& home) override; /// Cost function (record so that propagator runs last) @@ -179,7 +179,7 @@ namespace Gecode { /// Delete propagator and return its size size_t dispose(Space& home) override; /// Post propagator - static ExecStatus post(Home home, TraceFilter tf, int te, Tracer& t); + static ExecStatus post(Home home, const TraceFilter& tf, int te, Tracer& t); /// \name Trace information //@{ /// Return trace filter @@ -257,7 +257,7 @@ namespace Gecode { */ template forceinline - ViewTraceRecorder::ViewTraceRecorder(Home home, ViewArray& x, TraceFilter tf0, int te0, + ViewTraceRecorder::ViewTraceRecorder(Home home, ViewArray& x, const TraceFilter& tf0, int te0, ViewTracer& t0) : Propagator(home), o(home, x.size()), n(x), c(home), tf(tf0), te(te0), t(t0) { home.notice(*this, AP_VIEW_TRACE); @@ -278,7 +278,7 @@ namespace Gecode { template forceinline ExecStatus - ViewTraceRecorder::post(Home home, ViewArray& x, TraceFilter tf, int te, ViewTracer& t) { + ViewTraceRecorder::post(Home home, ViewArray& x, const TraceFilter& tf, int te, ViewTracer& t) { if ((x.size() > 0) && (te & (TE_INIT | TE_PRUNE | TE_FIX | TE_FAIL | TE_DONE))) (void)new (home) ViewTraceRecorder(home, x, tf, te, t); return ES_OK; @@ -387,14 +387,14 @@ namespace Gecode { * */ forceinline - TraceRecorder::TraceRecorder(Home home, TraceFilter tf0, int te0, Tracer& t0) + TraceRecorder::TraceRecorder(Home home, const TraceFilter& tf0, int te0, Tracer& t0) : Propagator(home), tf(tf0), te(te0), t(t0) { home.notice(*this, AP_DISPOSE); home.notice(*this, AP_TRACE); } forceinline ExecStatus - TraceRecorder::post(Home home, TraceFilter tf, int te, Tracer& t) { + TraceRecorder::post(Home home, const TraceFilter& tf, int te, Tracer& t) { if (te & (TE_PROPAGATE | TE_COMMIT | TE_POST)) (void)new (home) TraceRecorder(home, tf, te, t); return ES_OK; diff --git a/gecode/minimodel.hh b/gecode/minimodel.hh index 29d059ebc2..a5b267d7d8 100644 --- a/gecode/minimodel.hh +++ b/gecode/minimodel.hh @@ -1741,7 +1741,7 @@ namespace Gecode { /** \brief Post constraint \f$\{x_0,\dots,x_{n-1}\}=y\f$ */ - void values(Home home, const IntVarArgs& x, IntSet y, IntPropLevel ipl = IPL_DEF); + void values(Home home, const IntVarArgs& x, const IntSet& y, IntPropLevel ipl = IPL_DEF); //@} #ifdef GECODE_HAS_SET_VARS @@ -1880,7 +1880,7 @@ namespace Gecode { * parameters \a w and \a h doesn't match the size * of the array \a a. */ - Matrix(A a, int w, int h); + Matrix(const A& a, int w, int h); /** \brief Basic constructor * @@ -1894,7 +1894,7 @@ namespace Gecode { * parameter \a n doesn't match the size * of the array \a a. */ - Matrix(A a, int n); + Matrix(const A& a, int n); /// Return the width of the matrix int width(void) const; diff --git a/gecode/minimodel/aliases.hpp b/gecode/minimodel/aliases.hpp index dbe4498426..7f20e93a0c 100644 --- a/gecode/minimodel/aliases.hpp +++ b/gecode/minimodel/aliases.hpp @@ -119,7 +119,7 @@ namespace Gecode { } inline void - values(Home home, const IntVarArgs& x, IntSet y, IntPropLevel ipl) { + values(Home home, const IntVarArgs& x, const IntSet& y, IntPropLevel ipl) { dom(home, x, y, ipl); nvalues(home, x, IRT_EQ, static_cast(y.size()), ipl); } diff --git a/gecode/minimodel/matrix.hpp b/gecode/minimodel/matrix.hpp index 477d8e040f..a0fdd4b236 100644 --- a/gecode/minimodel/matrix.hpp +++ b/gecode/minimodel/matrix.hpp @@ -125,7 +125,7 @@ namespace Gecode { template forceinline - Matrix::Matrix(A a, int w, int h) + Matrix::Matrix(const A& a, int w, int h) : _a(a), _w(w), _h(h) { if ((_w * _h) != _a.size()) throw MiniModel::ArgumentSizeMismatch("Matrix::Matrix(A, w, h)"); @@ -133,7 +133,7 @@ namespace Gecode { template forceinline - Matrix::Matrix(A a, int n) + Matrix::Matrix(const A& a, int n) : _a(a), _w(n), _h(n) { if (n * n != _a.size()) throw MiniModel::ArgumentSizeMismatch("Matrix::Matrix(A, n)"); diff --git a/gecode/set.hh b/gecode/set.hh index ca7e91a12f..a7dbc555f6 100644 --- a/gecode/set.hh +++ b/gecode/set.hh @@ -835,7 +835,8 @@ namespace Gecode { * * \ingroup TaskModelSetConnect */ - GECODE_SET_EXPORT void weights(Home home, IntSharedArray elements, IntSharedArray weights, SetVar x, IntVar y); + GECODE_SET_EXPORT void weights(Home home, const IntSharedArray& elements, const IntSharedArray& weights, SetVar x, + IntVar y); /** * \defgroup TaskModelSetChannel Channel constraints @@ -1602,7 +1603,7 @@ namespace Gecode { * * \ingroup TaskModeSet */ - GECODE_SET_EXPORT void relax(Home home, const SetVarArgs& x, const SetVarArgs& sx, Rnd r, double p); + GECODE_SET_EXPORT void relax(Home home, const SetVarArgs& x, const SetVarArgs& sx, const Rnd& r, double p); } // namespace Gecode @@ -1719,7 +1720,7 @@ namespace Gecode { * \brief Create a tracer for set variables * \ingroup TaskSetTrace */ - GECODE_SET_EXPORT void trace(Home home, const SetVarArgs& x, TraceFilter tf, + GECODE_SET_EXPORT void trace(Home home, const SetVarArgs& x, const TraceFilter& tf, int te = (TE_INIT | TE_PRUNE | TE_FIX | TE_FAIL | TE_DONE), SetTracer& t = StdSetTracer::def); /** diff --git a/gecode/set/exec.cpp b/gecode/set/exec.cpp index b666c0d022..5ecca530cb 100644 --- a/gecode/set/exec.cpp +++ b/gecode/set/exec.cpp @@ -37,14 +37,14 @@ namespace Gecode { void wait(Home home, SetVar x, std::function c) { GECODE_POST; - GECODE_ES_FAIL(UnaryWait::post(home, x, c)); + GECODE_ES_FAIL(UnaryWait::post(home, x, std::move(c))); } void wait(Home home, const SetVarArgs& x, std::function c) { GECODE_POST; ViewArray xv(home, x); - GECODE_ES_FAIL(NaryWait::post(home, xv, c)); + GECODE_ES_FAIL(NaryWait::post(home, xv, std::move(c))); } } // namespace Gecode diff --git a/gecode/set/int.cpp b/gecode/set/int.cpp index 41be42a945..32cac20135 100644 --- a/gecode/set/int.cpp +++ b/gecode/set/int.cpp @@ -257,7 +257,7 @@ namespace Gecode { } void - weights(Home home, IntSharedArray elements, IntSharedArray weights, SetVar x, IntVar y) { + weights(Home home, const IntSharedArray& elements, const IntSharedArray& weights, SetVar x, IntVar y) { GECODE_POST; GECODE_ES_FAIL(Set::Int::Weights::post(home, elements, weights, x, y)); } diff --git a/gecode/set/ldsb/brancher.hpp b/gecode/set/ldsb/brancher.hpp index cebccfc008..705199730d 100644 --- a/gecode/set/ldsb/brancher.hpp +++ b/gecode/set/ldsb/brancher.hpp @@ -81,7 +81,7 @@ namespace Gecode { namespace Set { namespace LDSB { */ template ValueSymmetryImp* - special_update(Space& home, ValueSymmetryImp* s, IntSet used_values) { + special_update(Space& home, ValueSymmetryImp* s, const IntSet& used_values) { // Calculate intersection and difference. IntArgs intersection; IntArgs difference; diff --git a/gecode/set/relax.cpp b/gecode/set/relax.cpp index 6482628431..1ae23c8886 100644 --- a/gecode/set/relax.cpp +++ b/gecode/set/relax.cpp @@ -58,7 +58,7 @@ namespace Gecode { namespace Set { namespace Gecode { void - relax(Home home, const SetVarArgs& x, const SetVarArgs& sx, Rnd r, double p) { + relax(Home home, const SetVarArgs& x, const SetVarArgs& sx, const Rnd& r, double p) { if (x.size() != sx.size()) throw Set::ArgumentSizeMismatch("Set::relax"); if ((p < 0.0) || (p > 1.0)) diff --git a/gecode/set/trace.cpp b/gecode/set/trace.cpp index 7426b97bc2..c0f5817b38 100644 --- a/gecode/set/trace.cpp +++ b/gecode/set/trace.cpp @@ -35,7 +35,7 @@ namespace Gecode { void - trace(Home home, const SetVarArgs& x, TraceFilter tf, int te, SetTracer& t) { + trace(Home home, const SetVarArgs& x, const TraceFilter& tf, int te, SetTracer& t) { using namespace Gecode::Set; GECODE_POST; ViewArray xv(home, x); From 116cb192631854365321fe266be574d7851c6753 Mon Sep 17 00:00:00 2001 From: Mikael Zayenz Lagerkvist Date: Mon, 2 Nov 2026 04:58:06 +0100 Subject: [PATCH 4/6] Fix value parameters in FlatZinc, Gist, search, tests, and examples Zdev-Change-Id: Za9107647ee8a830efc792dd21dd7b38a4435f208b81cc6f685607cf606421094 --- examples/job-shop.cpp | 2 +- examples/pentominoes.cpp | 4 +-- gecode/flatzinc/blackbox-propagator.cpp | 9 ++--- gecode/flatzinc/branch.cpp | 2 +- gecode/flatzinc/branch.hh | 20 +++++------ gecode/flatzinc/branch.hpp | 18 +++++----- gecode/flatzinc/flatzinc.cpp | 45 +++++++++++++------------ gecode/flatzinc/parser.hh | 2 +- gecode/flatzinc/parser.tab.cpp | 6 ++-- gecode/flatzinc/parser.yxx | 6 ++-- gecode/gist.hh | 12 +++---- gecode/gist/gist.hpp | 12 +++---- gecode/search/cpprofiler/tracer.cpp | 3 +- test/branch/int.cpp | 2 +- test/flatzinc.cpp | 11 +++--- test/instance.cpp | 2 +- test/int/extensional.cpp | 8 ++--- test/int/gcc.cpp | 2 +- test/int/min-distance.cpp | 2 +- test/int/open-var-list.cpp | 6 ++-- test/ldsb.cpp | 10 +++--- test/nogoods.cpp | 10 +++--- test/search.cpp | 2 +- test/test.cpp | 4 +-- 24 files changed, 103 insertions(+), 97 deletions(-) diff --git a/examples/job-shop.cpp b/examples/job-shop.cpp index 09e78981ea..4f9649ed53 100644 --- a/examples/job-shop.cpp +++ b/examples/job-shop.cpp @@ -456,7 +456,7 @@ class JobShopProbe : public JobShopBase { post_no_overload(); } void - branch(unsigned int p, Rnd r) { + branch(unsigned int p, const Rnd& r) { switch (p) { case 0U: Gecode::branch(*this, start, INT_VAR_MIN_MIN(), INT_VAL_MIN()); diff --git a/examples/pentominoes.cpp b/examples/pentominoes.cpp index 097a17964a..849eb7c58b 100644 --- a/examples/pentominoes.cpp +++ b/examples/pentominoes.cpp @@ -297,7 +297,7 @@ class Pentominoes : public Script { /// Returns the regular expression for placing a specific tile \a /// tile in a specific rotation. REG - tile_reg(int twidth, int theight, const char* tile, REG mark, REG other, REG eol) const { + tile_reg(int twidth, int theight, const char* tile, const REG& mark, REG other, const REG& eol) const { REG oe = other | eol; REG res = *oe; REG color[] = {other, mark}; @@ -317,7 +317,7 @@ class Pentominoes : public Script { /// Returns the regular expression for placing tile number \a t in /// any rotation. REG - get_constraint(int t, REG mark, REG other, REG eol) { + get_constraint(int t, const REG& mark, const REG& other, const REG& eol) { // This should be done for all rotations REG res; char* t2 = new char[width * height]; diff --git a/gecode/flatzinc/blackbox-propagator.cpp b/gecode/flatzinc/blackbox-propagator.cpp index 7b5146b2d9..127f132b56 100644 --- a/gecode/flatzinc/blackbox-propagator.cpp +++ b/gecode/flatzinc/blackbox-propagator.cpp @@ -40,6 +40,7 @@ #include #include #include +#include #include namespace Gecode { namespace FlatZinc { @@ -104,7 +105,7 @@ namespace Gecode { namespace FlatZinc { void BlackBoxContextHandle::fail(std::exception_ptr e) const { - static_cast(object())->fail(e); + static_cast(object())->fail(std::move(e)); } bool @@ -143,7 +144,7 @@ namespace Gecode { namespace FlatZinc { BlackBoxContext::fail(std::exception_ptr e) { Support::Lock lock(mutex); if (!error_recorded.load(std::memory_order_relaxed)) { - exception = e; + exception = std::move(e); error_recorded.store(true, std::memory_order_release); } } @@ -283,9 +284,9 @@ namespace Gecode { namespace FlatZinc { #ifdef GECODE_HAS_FLOAT_VARS ViewArray& fvar0, #endif - SharedArray sub_int0, + const SharedArray& sub_int0, #ifdef GECODE_HAS_FLOAT_VARS - SharedArray sub_float0, + const SharedArray& sub_float0, #endif const BlackBoxHandle& backend0, const BlackBoxContextHandle& context0) : Propagator(home), ivar(ivar0), diff --git a/gecode/flatzinc/branch.cpp b/gecode/flatzinc/branch.cpp index d882db79e1..c910beadf3 100644 --- a/gecode/flatzinc/branch.cpp +++ b/gecode/flatzinc/branch.cpp @@ -116,7 +116,7 @@ namespace Gecode { namespace FlatZinc { } void - branch(Home home, const IntVarArgs& x, const BoolVarArgs& y, IntBoolVarBranch vars, IntValBranch vals) { + branch(Home home, const IntVarArgs& x, const BoolVarArgs& y, IntBoolVarBranch vars, const IntValBranch& vals) { if (home.failed()) return; vars.expand(home, x, y); diff --git a/gecode/flatzinc/branch.hh b/gecode/flatzinc/branch.hh index 4984afe921..bff6d7e307 100644 --- a/gecode/flatzinc/branch.hh +++ b/gecode/flatzinc/branch.hh @@ -72,11 +72,11 @@ namespace Gecode { namespace FlatZinc { /// Initialize with selection strategy \a s and decay factor \a d IntBoolVarBranch(Select s, double d); /// Initialize with selection strategy \a s and AFC \a i and \a b - IntBoolVarBranch(Select s, IntAFC i, BoolAFC b); + IntBoolVarBranch(Select s, const IntAFC& i, const BoolAFC& b); /// Initialize with selection strategy \a s and action \a i and \a b - IntBoolVarBranch(Select s, IntAction i, BoolAction b); + IntBoolVarBranch(Select s, const IntAction& i, const BoolAction& b); /// Initialize with selection strategy \a s and CHB \a i and \a b - IntBoolVarBranch(Select s, IntCHB i, BoolCHB b); + IntBoolVarBranch(Select s, const IntCHB& i, const BoolCHB& b); /// Return selection strategy Select select(void) const; /// Return integer AFC @@ -100,27 +100,27 @@ namespace Gecode { namespace FlatZinc { /// Select variable with largest accumulated failure count IntBoolVarBranch int_bool_var_afc_max(double d = 1.0); /// Select variable with largest accumulated failure count - IntBoolVarBranch int_bool_var_afc_max(IntAFC ia, BoolAFC ba); + IntBoolVarBranch int_bool_var_afc_max(const IntAFC& ia, const BoolAFC& ba); /// Select variable with highest action IntBoolVarBranch int_bool_var_action_max(double d = 1.0); /// Select variable with highest action - IntBoolVarBranch int_bool_var_action_max(IntAction ia, BoolAction ba); + IntBoolVarBranch int_bool_var_action_max(const IntAction& ia, const BoolAction& ba); /// Select variable with largest CHB Q-score IntBoolVarBranch int_bool_var_chb_max(double d = 1.0); /// Select variable with largest CHB Q-score - IntBoolVarBranch int_bool_var_chb_max(IntCHB ic, BoolCHB bc); + IntBoolVarBranch int_bool_var_chb_max(const IntCHB& ic, const BoolCHB& bc); /// Select variable with largest accumulated failure count divided by domain size IntBoolVarBranch int_bool_var_afc_size_max(double d = 1.0); /// Select variable with largest accumulated failure count divided by domain size - IntBoolVarBranch int_bool_var_afc_size_max(IntAFC ia, BoolAFC ba); + IntBoolVarBranch int_bool_var_afc_size_max(const IntAFC& ia, const BoolAFC& ba); /// Select variable with largest action divided by domain size IntBoolVarBranch int_bool_var_action_size_max(double d = 1.0); /// Select variable with largest action divided by domain size - IntBoolVarBranch int_bool_var_action_size_max(IntAction ia, BoolAction ba); + IntBoolVarBranch int_bool_var_action_size_max(const IntAction& ia, const BoolAction& ba); /// Select variable with largest CHB Q-score divided by domain size IntBoolVarBranch int_bool_var_chb_size_max(double d = 1.0); /// Select variable with largest CHB Q-score divided by domain size - IntBoolVarBranch int_bool_var_chb_size_max(IntCHB ic, BoolCHB bc); + IntBoolVarBranch int_bool_var_chb_size_max(const IntCHB& ic, const BoolCHB& bc); //@} /// Select by maximal AFC @@ -335,7 +335,7 @@ namespace Gecode { namespace FlatZinc { /// Branch function for integer and Boolean variables GECODE_FLATZINC_EXPORT void branch(Home home, const IntVarArgs& x, const BoolVarArgs& y, IntBoolVarBranch vars, - IntValBranch vals); + const IntValBranch& vals); }} // namespace Gecode::FlatZinc diff --git a/gecode/flatzinc/branch.hpp b/gecode/flatzinc/branch.hpp index fee3830f2e..a2d6f99ee4 100644 --- a/gecode/flatzinc/branch.hpp +++ b/gecode/flatzinc/branch.hpp @@ -37,15 +37,15 @@ namespace Gecode { namespace FlatZinc { : VarBranch(d, nullptr), s(s0) {} forceinline - IntBoolVarBranch::IntBoolVarBranch(Select s0, IntAFC i, BoolAFC b) + IntBoolVarBranch::IntBoolVarBranch(Select s0, const IntAFC& i, const BoolAFC& b) : s(s0), int_afc_data(i), bool_afc_data(b) {} forceinline - IntBoolVarBranch::IntBoolVarBranch(Select s0, IntAction i, BoolAction b) + IntBoolVarBranch::IntBoolVarBranch(Select s0, const IntAction& i, const BoolAction& b) : s(s0), int_action_data(i), bool_action_data(b) {} forceinline - IntBoolVarBranch::IntBoolVarBranch(Select s0, IntCHB i, BoolCHB b) + IntBoolVarBranch::IntBoolVarBranch(Select s0, const IntCHB& i, const BoolCHB& b) : s(s0), int_chb_data(i), bool_chb_data(b) {} forceinline IntBoolVarBranch::Select @@ -112,7 +112,7 @@ namespace Gecode { namespace FlatZinc { return IntBoolVarBranch(IntBoolVarBranch::SEL_AFC_MAX, d); } inline IntBoolVarBranch - int_bool_var_afc_max(IntAFC ia, BoolAFC ba) { + int_bool_var_afc_max(const IntAFC& ia, const BoolAFC& ba) { return IntBoolVarBranch(IntBoolVarBranch::SEL_AFC_MAX, ia, ba); } inline IntBoolVarBranch @@ -120,7 +120,7 @@ namespace Gecode { namespace FlatZinc { return IntBoolVarBranch(IntBoolVarBranch::SEL_ACTION_MAX, d); } inline IntBoolVarBranch - int_bool_var_action_max(IntAction ia, BoolAction ba) { + int_bool_var_action_max(const IntAction& ia, const BoolAction& ba) { return IntBoolVarBranch(IntBoolVarBranch::SEL_ACTION_MAX, ia, ba); } inline IntBoolVarBranch @@ -128,7 +128,7 @@ namespace Gecode { namespace FlatZinc { return IntBoolVarBranch(IntBoolVarBranch::SEL_CHB_MAX, d); } inline IntBoolVarBranch - int_bool_var_chb_max(IntCHB ic, BoolCHB bc) { + int_bool_var_chb_max(const IntCHB& ic, const BoolCHB& bc) { return IntBoolVarBranch(IntBoolVarBranch::SEL_CHB_MAX, ic, bc); } inline IntBoolVarBranch @@ -136,7 +136,7 @@ namespace Gecode { namespace FlatZinc { return IntBoolVarBranch(IntBoolVarBranch::SEL_AFC_SIZE_MAX, d); } inline IntBoolVarBranch - int_bool_var_afc_size_max(IntAFC ia, BoolAFC ba) { + int_bool_var_afc_size_max(const IntAFC& ia, const BoolAFC& ba) { return IntBoolVarBranch(IntBoolVarBranch::SEL_AFC_SIZE_MAX, ia, ba); } inline IntBoolVarBranch @@ -144,7 +144,7 @@ namespace Gecode { namespace FlatZinc { return IntBoolVarBranch(IntBoolVarBranch::SEL_ACTION_SIZE_MAX, d); } inline IntBoolVarBranch - int_bool_var_action_size_max(IntAction ia, BoolAction ba) { + int_bool_var_action_size_max(const IntAction& ia, const BoolAction& ba) { return IntBoolVarBranch(IntBoolVarBranch::SEL_ACTION_SIZE_MAX, ia, ba); } inline IntBoolVarBranch @@ -152,7 +152,7 @@ namespace Gecode { namespace FlatZinc { return IntBoolVarBranch(IntBoolVarBranch::SEL_CHB_SIZE_MAX, d); } inline IntBoolVarBranch - int_bool_var_chb_size_max(IntCHB ic, BoolCHB bc) { + int_bool_var_chb_size_max(const IntCHB& ic, const BoolCHB& bc) { return IntBoolVarBranch(IntBoolVarBranch::SEL_CHB_SIZE_MAX, ic, bc); } diff --git a/gecode/flatzinc/flatzinc.cpp b/gecode/flatzinc/flatzinc.cpp index a055a69c41..86143e6ef5 100644 --- a/gecode/flatzinc/flatzinc.cpp +++ b/gecode/flatzinc/flatzinc.cpp @@ -122,15 +122,15 @@ namespace Gecode { namespace FlatZinc { TieBreak float_varsel0, FloatValBranch float_valsel0 #endif ) - : Brancher(home), done(false), int_varsel(int_varsel0), int_valsel(int_valsel0), bool_varsel(bool_varsel0), - bool_valsel(bool_valsel0) + : Brancher(home), done(false), int_varsel(std::move(int_varsel0)), int_valsel(std::move(int_valsel0)), + bool_varsel(std::move(bool_varsel0)), bool_valsel(std::move(bool_valsel0)) #ifdef GECODE_HAS_SET_VARS , - set_varsel(set_varsel0), set_valsel(set_valsel0) + set_varsel(std::move(set_varsel0)), set_valsel(std::move(set_valsel0)) #endif #ifdef GECODE_HAS_FLOAT_VARS , - float_varsel(float_varsel0), float_valsel(float_valsel0) + float_varsel(std::move(float_varsel0)), float_valsel(std::move(float_valsel0)) #endif { } @@ -255,14 +255,15 @@ namespace Gecode { namespace FlatZinc { TieBreak float_varsel, FloatValBranch float_valsel #endif ) { - (void)new (home) AuxVarBrancher(home, int_varsel, int_valsel, bool_varsel, bool_valsel + (void)new (home) AuxVarBrancher(home, std::move(int_varsel), std::move(int_valsel), std::move(bool_varsel), + std::move(bool_valsel) #ifdef GECODE_HAS_SET_VARS - , - set_varsel, set_valsel + , + std::move(set_varsel), std::move(set_valsel) #endif #ifdef GECODE_HAS_FLOAT_VARS - , - float_varsel, float_valsel + , + std::move(float_varsel), std::move(float_valsel) #endif ); } @@ -284,7 +285,7 @@ namespace Gecode { namespace FlatZinc { : r0(r00), r1(r10), n(n0) {} }; std::vector v; - BranchInformationO(std::vector v0) : v(v0) {} + BranchInformationO(std::vector v0) : v(std::move(v0)) {} public: BranchInformationO(void) {} @@ -402,7 +403,7 @@ namespace Gecode { namespace FlatZinc { } TieBreak - annotation_to_int_var_branch(AST::Node* ann, Rnd rnd, double decay) { + annotation_to_int_var_branch(AST::Node* ann, const Rnd& rnd, double decay) { if (AST::Atom* s = dynamic_cast(ann)) { if (s->id == "input_order") return TieBreak(INT_VAR_NONE()); @@ -451,7 +452,7 @@ namespace Gecode { namespace FlatZinc { } IntValBranch - annotation_to_int_val_branch(AST::Node* ann, std::string& r0, std::string& r1, Rnd rnd) { + annotation_to_int_val_branch(AST::Node* ann, std::string& r0, std::string& r1, const Rnd& rnd) { if (AST::Atom* s = dynamic_cast(ann)) { if (s->id == "indomain_min") { r0 = "="; @@ -512,7 +513,7 @@ namespace Gecode { namespace FlatZinc { } IntAssign - annotation_to_int_assign(AST::Node* ann, Rnd rnd) { + annotation_to_int_assign(AST::Node* ann, const Rnd& rnd) { if (AST::Atom* s = dynamic_cast(ann)) { if (s->id == "indomain_min") return INT_ASSIGN_MIN(); @@ -531,7 +532,7 @@ namespace Gecode { namespace FlatZinc { } TieBreak - annotation_to_bool_var_branch(AST::Node* ann, Rnd rnd, double decay) { + annotation_to_bool_var_branch(AST::Node* ann, const Rnd& rnd, double decay) { if (AST::Atom* s = dynamic_cast(ann)) { if ((s->id == "input_order") || (s->id == "first_fail") || (s->id == "anti_first_fail") || (s->id == "smallest") || (s->id == "largest") || (s->id == "max_regret")) @@ -556,7 +557,7 @@ namespace Gecode { namespace FlatZinc { } BoolValBranch - annotation_to_bool_val_branch(AST::Node* ann, std::string& r0, std::string& r1, Rnd rnd) { + annotation_to_bool_val_branch(AST::Node* ann, std::string& r0, std::string& r1, const Rnd& rnd) { if (AST::Atom* s = dynamic_cast(ann)) { if (s->id == "indomain_min") { r0 = "="; @@ -617,7 +618,7 @@ namespace Gecode { namespace FlatZinc { } BoolAssign - annotation_to_bool_assign(AST::Node* ann, Rnd rnd) { + annotation_to_bool_assign(AST::Node* ann, const Rnd& rnd) { if (AST::Atom* s = dynamic_cast(ann)) { if ((s->id == "indomain_min") || (s->id == "indomain_median")) return BOOL_ASSIGN_MIN(); @@ -635,7 +636,7 @@ namespace Gecode { namespace FlatZinc { #ifdef GECODE_HAS_SET_VARS SetVarBranch - annotation_to_set_var_branch(AST::Node* ann, Rnd rnd, double decay) { + annotation_to_set_var_branch(AST::Node* ann, const Rnd& rnd, double decay) { if (AST::Atom* s = dynamic_cast(ann)) { if (s->id == "input_order") return SET_VAR_NONE(); @@ -674,7 +675,7 @@ namespace Gecode { namespace FlatZinc { } SetValBranch - annotation_to_set_val_branch(AST::Node* ann, std::string r0, std::string r1, 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") { @@ -709,7 +710,7 @@ namespace Gecode { namespace FlatZinc { #ifdef GECODE_HAS_FLOAT_VARS TieBreak - annotation_to_float_var_branch(AST::Node* ann, Rnd rnd, double decay) { + annotation_to_float_var_branch(AST::Node* ann, const Rnd& rnd, double decay) { if (AST::Atom* s = dynamic_cast(ann)) { if (s->id == "input_order") return TieBreak(FLOAT_VAR_NONE()); @@ -1796,7 +1797,7 @@ namespace Gecode { namespace FlatZinc { }; void - print_int_var(std::ostream& os, const std::string name, const Int::IntView& x) { + print_int_var(std::ostream& os, const std::string& name, const Int::IntView& x) { os << "var "; if (x.assigned()) { os << "int: " << name << " = " << x.val() << ";"; @@ -1817,7 +1818,7 @@ namespace Gecode { namespace FlatZinc { os << "\n"; } void - print_bool_var(std::ostream& os, const std::string name, const BoolVar& b) { + print_bool_var(std::ostream& os, const std::string& name, const BoolVar& b) { os << "var bool: " << name; if (b.assigned()) os << " = " << (b.val() ? "true" : "false"); @@ -1825,7 +1826,7 @@ namespace Gecode { namespace FlatZinc { } #ifdef GECODE_HAS_FLOAT_VARS void - print_float_var(std::ostream& os, const std::string name, const Float::FloatView& f) { + print_float_var(std::ostream& os, const std::string& name, const Float::FloatView& f) { os << "var "; if (f.assigned()) os << "float: " << name << " = " << f.med() << ";"; diff --git a/gecode/flatzinc/parser.hh b/gecode/flatzinc/parser.hh index acc145916a..b02f1152b8 100644 --- a/gecode/flatzinc/parser.hh +++ b/gecode/flatzinc/parser.hh @@ -256,7 +256,7 @@ namespace Gecode { namespace FlatZinc { void output(std::string x, AST::Node* n) { - output_items.push_back(std::pair(x, n)); + output_items.emplace_back(std::move(x), n); } AST::Array* diff --git a/gecode/flatzinc/parser.tab.cpp b/gecode/flatzinc/parser.tab.cpp index 00b260bb26..7bc2b155ce 100644 --- a/gecode/flatzinc/parser.tab.cpp +++ b/gecode/flatzinc/parser.tab.cpp @@ -130,7 +130,7 @@ void yyassert(ParserState* pp, bool cond, const char* str) * */ -AST::Node* get_array_element(ParserState* pp, string id, int offset, +AST::Node* get_array_element(ParserState* pp, const string& id, int offset, bool annotation) { if (offset > 0) { SymbolEntry e; @@ -208,7 +208,7 @@ AST::Node* get_array_element(ParserState* pp, string id, int offset, pp->had_error = true; return new AST::IntVar(0); // keep things consistent } -AST::Node* get_var_ref_arg(ParserState* pp, string id, bool annotation = false) { +AST::Node* get_var_ref_arg(ParserState* pp, const string& id, bool annotation = false) { SymbolEntry e; string n; if (annotation) @@ -232,7 +232,7 @@ AST::Node* get_var_ref_arg(ParserState* pp, string id, bool annotation = false) return new AST::IntVar(0); // keep things consistent } -void add_domain_constraint(ParserState* pp, std::string id, AST::Node* var, +void add_domain_constraint(ParserState* pp, const std::string& id, AST::Node* var, Option& dom) { if (!dom()) return; diff --git a/gecode/flatzinc/parser.yxx b/gecode/flatzinc/parser.yxx index e97f05ab46..eaef50d631 100755 --- a/gecode/flatzinc/parser.yxx +++ b/gecode/flatzinc/parser.yxx @@ -95,7 +95,7 @@ void yyassert(ParserState* pp, bool cond, const char* str) * */ -AST::Node* get_array_element(ParserState* pp, string id, int offset, +AST::Node* get_array_element(ParserState* pp, const string& id, int offset, bool annotation) { if (offset > 0) { SymbolEntry e; @@ -173,7 +173,7 @@ error: pp->had_error = true; return new AST::IntVar(0); // keep things consistent } -AST::Node* get_var_ref_arg(ParserState* pp, string id, bool annotation = false) { +AST::Node* get_var_ref_arg(ParserState* pp, const string& id, bool annotation = false) { SymbolEntry e; string n; if (annotation) @@ -197,7 +197,7 @@ AST::Node* get_var_ref_arg(ParserState* pp, string id, bool annotation = false) return new AST::IntVar(0); // keep things consistent } -void add_domain_constraint(ParserState* pp, std::string id, AST::Node* var, +void add_domain_constraint(ParserState* pp, const std::string& id, AST::Node* var, Option& dom) { if (!dom()) return; diff --git a/gecode/gist.hh b/gecode/gist.hh index f2a72e1476..26a21ab0a3 100644 --- a/gecode/gist.hh +++ b/gecode/gist.hh @@ -131,18 +131,18 @@ namespace Gecode { /// Return string representation of difference between arrays \a x and \a y, which are called \a x_n template - static std::string compare(std::string x_n, const VarArgArray& x, const VarArgArray& y); + static std::string compare(const std::string& x_n, const VarArgArray& x, const VarArgArray& y); /// Return string representation of difference between \a x and \a y, which are called \a x_n - static std::string compare(std::string x_n, IntVar x, IntVar y); + static std::string compare(const std::string& x_n, IntVar x, IntVar y); /// Return string representation of difference between \a x and \a y, which are called \a x_n - static std::string compare(std::string x_n, BoolVar x, BoolVar y); + static std::string compare(const std::string& x_n, BoolVar x, BoolVar y); #ifdef GECODE_HAS_SET_VARS /// Return string representation of difference between \a x and \a y, which are called \a x_n - static std::string compare(std::string x_n, SetVar x, SetVar y); + static std::string compare(const std::string& x_n, SetVar x, SetVar y); #endif #ifdef GECODE_HAS_FLOAT_VARS /// Return string representation of difference between \a x and \a y, which are called \a x_n - static std::string compare(std::string x_n, FloatVar x, FloatVar y); + static std::string compare(const std::string& x_n, FloatVar x, FloatVar y); #endif //@} }; @@ -206,7 +206,7 @@ namespace Gecode { class VarComparator : public TextOutput, public Comparator { public: /// Constructor - VarComparator(std::string name); + VarComparator(const std::string& name); /// Compare \a s0 to \a s1 void compare(const Space& s0, const Space& s1) override; /// Return name diff --git a/gecode/gist/gist.hpp b/gecode/gist/gist.hpp index bd20c007ef..fb79e9a0d7 100644 --- a/gecode/gist/gist.hpp +++ b/gecode/gist/gist.hpp @@ -33,7 +33,7 @@ namespace Gecode { namespace Gist { template - VarComparator::VarComparator(std::string name) : TextOutput(name) {} + VarComparator::VarComparator(const std::string& name) : TextOutput(name) {} template void @@ -61,7 +61,7 @@ namespace Gecode { namespace Gist { } inline std::string - Comparator::compare(std::string x_n, IntVar x, IntVar y) { + Comparator::compare(const std::string& x_n, IntVar x, IntVar y) { IntVarRanges xr(x), yr(y); if (!Iter::Ranges::equal(xr, yr)) { std::ostringstream ret; @@ -71,7 +71,7 @@ namespace Gecode { namespace Gist { return ""; } inline std::string - Comparator::compare(std::string x_n, BoolVar x, BoolVar y) { + Comparator::compare(const std::string& x_n, BoolVar x, BoolVar y) { if (!(x.min() == y.min() && x.max() == y.max())) { std::ostringstream ret; ret << x_n << "=" << x << " -> " << y; @@ -81,7 +81,7 @@ namespace Gecode { namespace Gist { } #ifdef GECODE_HAS_SET_VARS inline std::string - Comparator::compare(std::string x_n, SetVar x, SetVar y) { + Comparator::compare(const std::string& x_n, SetVar x, SetVar y) { SetVarGlbRanges xglbr(x), yglbr(y); SetVarLubRanges xlubr(x), ylubr(y); if (!(Iter::Ranges::equal(xglbr, yglbr) && Iter::Ranges::equal(xlubr, ylubr) && x.card_min() == y.card_min() && @@ -95,7 +95,7 @@ namespace Gecode { namespace Gist { #endif #ifdef GECODE_HAS_FLOAT_VARS inline std::string - Comparator::compare(std::string x_n, FloatVar x, FloatVar y) { + Comparator::compare(const std::string& x_n, FloatVar x, FloatVar y) { if (!(x.min() == y.min() && x.max() == y.max())) { std::ostringstream ret; ret << x_n << "=" << x << " -> " << y; @@ -106,7 +106,7 @@ namespace Gecode { namespace Gist { #endif template std::string - Comparator::compare(std::string x_n, const VarArgArray& x, const VarArgArray& y) { + Comparator::compare(const std::string& x_n, const VarArgArray& x, const VarArgArray& y) { if (x.size() != y.size()) return "Error: array size mismatch"; std::ostringstream ret; diff --git a/gecode/search/cpprofiler/tracer.cpp b/gecode/search/cpprofiler/tracer.cpp index b5adb32241..076451bacf 100644 --- a/gecode/search/cpprofiler/tracer.cpp +++ b/gecode/search/cpprofiler/tracer.cpp @@ -53,7 +53,8 @@ namespace Gecode { CPProfilerSearchTracer::CPProfilerSearchTracer(int eid, std::string name0, unsigned int port, const GetInfo* pgetinfo) - : connector(new CPProfiler::Connector(port)), execution_id(eid), name(name0), restart(0), pgi(pgetinfo) {} + : connector(new CPProfiler::Connector(port)), execution_id(eid), name(std::move(name0)), restart(0), + pgi(pgetinfo) {} void CPProfilerSearchTracer::init(void) { diff --git a/test/branch/int.cpp b/test/branch/int.cpp index 01b53beb09..476494d647 100644 --- a/test/branch/int.cpp +++ b/test/branch/int.cpp @@ -46,7 +46,7 @@ namespace Test { namespace Branch { Gecode::IntVarArray x; /// Initialize space - FilteredRndTiesSpace(Gecode::Rnd r) : x(*this, 4, 0, 1) { + FilteredRndTiesSpace(const Gecode::Rnd& r) : x(*this, 4, 0, 1) { Gecode::IntVarArgs xa(x); Gecode::ViewArray xv(*this, xa); Gecode::ViewSel* vs[2] = { diff --git a/test/flatzinc.cpp b/test/flatzinc.cpp index 3d90d25ddb..d0f32a7535 100644 --- a/test/flatzinc.cpp +++ b/test/flatzinc.cpp @@ -290,21 +290,24 @@ namespace Test { namespace FlatZinc { FlatZincTest::FlatZincTest(const std::string& name, const std::string& source, const std::string& expected, bool all_solutions, std::vector cmdline_opt, OutputCheck check, BeforeRun before) - : FlatZincTest(TestTags::standard(), name, source, expected, all_solutions, cmdline_opt, check, before) {} + : FlatZincTest(TestTags::standard(), name, source, expected, all_solutions, std::move(cmdline_opt), + std::move(check), std::move(before)) {} FlatZincTest::FlatZincTest(TestTags tags, const std::string& name, const std::string& source, const std::string& expected, bool all_solutions, std::vector cmdline_opt, OutputCheck check, BeforeRun before) : Base("FlatZinc::" + name, tags), _name(name), _source(source), _expected(expected), - _all_solutions(all_solutions), _cmdline_opt(cmdline_opt), _check(check), _before(before) {} + _all_solutions(all_solutions), _cmdline_opt(std::move(cmdline_opt)), _check(std::move(check)), + _before(std::move(before)) {} FlatZincErrorTest::FlatZincErrorTest(const std::string& name, const std::string& source, std::vector cmdline_opt, std::string expected_message) - : FlatZincErrorTest(TestTags::standard(), name, source, cmdline_opt, expected_message) {} + : FlatZincErrorTest(TestTags::standard(), name, source, std::move(cmdline_opt), std::move(expected_message)) {} FlatZincErrorTest::FlatZincErrorTest(TestTags tags, const std::string& name, const std::string& source, std::vector cmdline_opt, std::string expected_message) - : FlatZincTest(tags, name, source, "", false, cmdline_opt), _expected_message(expected_message) {} + : FlatZincTest(tags, name, source, "", false, std::move(cmdline_opt)), + _expected_message(std::move(expected_message)) {} bool FlatZincTest::run(void) { diff --git a/test/instance.cpp b/test/instance.cpp index 677114cf6b..2ed8be1c5a 100644 --- a/test/instance.cpp +++ b/test/instance.cpp @@ -117,7 +117,7 @@ namespace Test { namespace Instance { public: /// Create test \a n running \a f0 - Case(const std::string& n, std::function f0) : Base("Instance::" + n), f(f0) {} + Case(const std::string& n, std::function f0) : Base("Instance::" + n), f(std::move(f0)) {} /// Run the test bool run(void) override { diff --git a/test/int/extensional.cpp b/test/int/extensional.cpp index d726d5a850..6ac74bfe59 100644 --- a/test/int/extensional.cpp +++ b/test/int/extensional.cpp @@ -833,7 +833,7 @@ namespace Test { namespace Int { Gecode::IntVarArray x; Gecode::OpenIntVarList list; - OpenRegularSpace(Gecode::DFA d, int max = 8) : x(*this, 3, 0, 2), list(*this, max) { + OpenRegularSpace(const Gecode::DFA& d, int max = 8) : x(*this, 3, 0, 2), list(*this, max) { Gecode::extensional(*this, list, d); } @@ -1081,7 +1081,7 @@ namespace Test { namespace Int { ///% Transform a TupleSet into a DFA Gecode::DFA - tuple_set_to_dfa(Gecode::TupleSet ts) { + tuple_set_to_dfa(const Gecode::TupleSet& ts) { using namespace Gecode; REG expression; for (int i = 0; i < ts.tuples(); i++) { @@ -1191,7 +1191,7 @@ namespace Test { namespace Int { public: /// Create and register test - TupleSetTest(const std::string& s, bool p, Gecode::IntSet d0, Gecode::TupleSet ts0, bool td, + TupleSetTest(const std::string& s, bool p, const Gecode::IntSet& d0, const Gecode::TupleSet& ts0, bool td, Gecode::ExtensionalPropKind epk0, TestTags tags = TestTags::sweep()) : Test(tags, "Extensional::TupleSet::" + extensional_kind_name(epk0) + "::" + str(p) + "::" + s, ts0.arity(), d0, true, Gecode::IPL_DOM), @@ -1233,7 +1233,7 @@ namespace Test { namespace Int { class RandomTupleSetTest : public TupleSetTest { public: /// Create and register test - RandomTupleSetTest(const std::string& s, bool p, Gecode::IntSet d0, Gecode::TupleSet ts0, + RandomTupleSetTest(const std::string& s, bool p, const Gecode::IntSet& d0, const Gecode::TupleSet& ts0, Gecode::ExtensionalPropKind epk0) : TupleSetTest(s, p, d0, ts0, false, epk0) { test_search = false; diff --git a/test/int/gcc.cpp b/test/int/gcc.cpp index d59a05c448..7549f1d0f5 100644 --- a/test/int/gcc.cpp +++ b/test/int/gcc.cpp @@ -246,7 +246,7 @@ namespace Test { namespace Int { public: /// Create and register test - VarSome(std::string s, int n0, int min, int max, Gecode::IntPropLevel ipl) + VarSome(const std::string& s, int n0, int min, int max, Gecode::IntPropLevel ipl) : Test(TestTags::sweep(), "GCC::Var::Some::" + s + "::" + str(ipl), n0 + (max - min) + 1, min, max, false, ipl), n(n0) { diff --git a/test/int/min-distance.cpp b/test/int/min-distance.cpp index 3062755f3a..830ccbddf6 100644 --- a/test/int/min-distance.cpp +++ b/test/int/min-distance.cpp @@ -113,7 +113,7 @@ namespace Test { namespace Int { namespace MinDistance { Model(int n, int sites, int lower, int upper, Gecode::MinDistancePropKind kind, Gecode::IntPropLevel level, std::function distance) : x(*this, n, 0, sites - 1), z(*this, lower, upper) { - Gecode::minimum_distance(*this, x, z, Gecode::IntDistance(sites, distance), level, kind); + Gecode::minimum_distance(*this, x, z, Gecode::IntDistance(sites, std::move(distance)), level, kind); } Model(Model& s) : Gecode::Space(s) { x.update(*this, s.x); diff --git a/test/int/open-var-list.cpp b/test/int/open-var-list.cpp index a25b210eeb..8a5a0d78b4 100644 --- a/test/int/open-var-list.cpp +++ b/test/int/open-var-list.cpp @@ -164,7 +164,7 @@ namespace Test { namespace Int { namespace OpenList { public: Gecode::OpenIntVarList list; - SelectorSpace(Gecode::IntValBranch vals, bool length_first = false) + SelectorSpace(const Gecode::IntValBranch& vals, bool length_first = false) : list(*this, [](int i) { return Gecode::IntSet(i, i + 1); }, 3) { using namespace Gecode; if (length_first) @@ -271,7 +271,7 @@ namespace Test { namespace Int { namespace OpenList { public: Gecode::OpenIntVarList list; - SelectorChoiceSpace(Gecode::IntValBranch vals) : list(*this, Gecode::IntSet({0, 2, 5}), 3) { + SelectorChoiceSpace(const Gecode::IntValBranch& vals) : list(*this, Gecode::IntSet({0, 2, 5}), 3) { using namespace Gecode; list.materialize(*this, 3); branch( @@ -1021,7 +1021,7 @@ namespace Test { namespace Int { namespace OpenList { Gecode::OpenIntVarList list; CallbackSpace(Gecode::OpenIntVarList::Domain domain, Gecode::OpenIntVarList::Transition transition) - : list(*this, domain, transition, 8) {} + : list(*this, std::move(domain), std::move(transition), 8) {} CallbackSpace(CallbackSpace& s) : Gecode::Space(s) { list.update(*this, s.list); diff --git a/test/ldsb.cpp b/test/ldsb.cpp index 0fc9c04bad..590f28ff4c 100644 --- a/test/ldsb.cpp +++ b/test/ldsb.cpp @@ -213,7 +213,7 @@ namespace Test { namespace LDSB { /// Adaptation distance unsigned int a_d; /// Initialize test - LDSB(std::string label, unsigned int c = 0, unsigned int a = 0) + LDSB(const std::string& label, unsigned int c = 0, unsigned int a = 0) : Test::Base("LDSB::" + label), c_d(c), a_d(a) {} /// Perform actual tests bool @@ -242,7 +242,7 @@ namespace Test { namespace LDSB { /// Adaptation distance unsigned int a_d; /// Initialize test - LDSBSet(std::string label, unsigned int c = 0, unsigned int a = 0) + LDSBSet(const std::string& label, unsigned int c = 0, unsigned int a = 0) : Test::Base("LDSB::" + label), c_d(c), a_d(a) {} /// Perform actual tests bool @@ -1249,7 +1249,7 @@ namespace Test { namespace LDSB { } }; /// Initialize test - LDSBLatin(std::string label) : Test::Base("LDSB::" + label) {} + LDSBLatin(const std::string& label) : Test::Base("LDSB::" + label) {} /// Perform actual tests bool run(void) override { @@ -1719,7 +1719,7 @@ namespace Test { namespace LDSB { VarArray x; /// Constructor for creation of \a n variables with domain \a d template - EmptyFixture(int n, Domain... d) : x(*this, n, d...) {} + EmptyFixture(int n, const Domain&... d) : x(*this, n, d...) {} /// Constructor for cloning \a s EmptyFixture(EmptyFixture& s) : Space(s) { x.update(*this, s.x); @@ -1781,7 +1781,7 @@ namespace Test { namespace LDSB { using Fixture = EmptyFixture; /// Branch on the variables of \a s with symmetries \a spec, tie-breaking if \a tie static void - post_branching(Fixture& s, SymmetrySpec spec, bool tie, IntValBranch vals) { + post_branching(Fixture& s, SymmetrySpec spec, bool tie, const IntValBranch& vals) { IntVarArgs x(s.x); Symmetries syms = symmetries(spec, x); if (spec != SymmetrySpec::NONE) diff --git a/test/nogoods.cpp b/test/nogoods.cpp index 183f5609ad..08a5f6c7ec 100644 --- a/test/nogoods.cpp +++ b/test/nogoods.cpp @@ -58,7 +58,7 @@ namespace Test { /// Position of queens on boards IntVarArray q; /// The actual problem - Queens(IntValBranch ivb, bool assign, bool null) : q(*this, n, 0, n - 1) { + Queens(const IntValBranch& ivb, bool assign, bool null) : q(*this, n, 0, n - 1) { distinct(*this, IntArgs::create(n, 0, 1), q, IPL_VAL); distinct(*this, IntArgs::create(n, 0, -1), q, IPL_VAL); distinct(*this, q, IPL_VAL); @@ -111,7 +111,7 @@ namespace Test { } /// Return name for branching static std::string - val(IntValBranch ivb) { + val(const IntValBranch& ivb) { switch (ivb.select()) { case IntValBranch::SEL_MIN: return "INT_VAL_MIN"; @@ -147,7 +147,7 @@ namespace Test { public: /// Actual model - Hamming(SetValBranch svb, bool assign, bool null) : x(*this, size, IntSet::empty, 1, bits) { + Hamming(const SetValBranch& svb, bool assign, bool null) : x(*this, size, IntSet::empty, 1, bits) { SetVarArgs cx(x.size()); for (int i = x.size(); i--;) cx[i] = expr(*this, -x[i]); @@ -207,7 +207,7 @@ namespace Test { } /// Return name for branching static std::string - val(SetValBranch svb) { + val(const SetValBranch& svb) { switch (svb.select()) { case SetValBranch::SEL_MIN_INC: return "SET_VAL_MIN_INC"; @@ -251,7 +251,7 @@ namespace Test { : Base("NoGoods::" + Model::name() + "::" + Model::val(vb0) + "::" + str(t0) + "::" + (a0 ? "+" : "-") + "::" + (n0 ? "+" : "-"), tags), - vb(vb0), t(t0), a(a0), n(n0) {} + vb(std::move(vb0)), t(t0), a(a0), n(n0) {} /// Run test bool run(void) override { diff --git a/test/search.cpp b/test/search.cpp index c4bdd6f201..25bb6fac96 100644 --- a/test/search.cpp +++ b/test/search.cpp @@ -143,7 +143,7 @@ namespace Test { } }; TreeSpace(std::shared_ptr g, bool max) - : graph(g), maximize(max), vertex(0), ceiling(std::numeric_limits::max()) { + : graph(std::move(g)), maximize(max), vertex(0), ceiling(std::numeric_limits::max()) { (void)new (*this) Decisions(*this); } TreeSpace(TreeSpace& s) diff --git a/test/test.cpp b/test/test.cpp index 76a92bd35e..420699a4e6 100644 --- a/test/test.cpp +++ b/test/test.cpp @@ -119,7 +119,7 @@ namespace Test { * Base class for tests * */ - Base::Base(std::string s) : Base(s, TestTags::standard()) {} + Base::Base(std::string s) : Base(std::move(s), TestTags::standard()) {} Base::Base(std::string s, TestTags t) : _name(std::move(s)), _tags(t), _next(_tests), _rand(Gecode::Support::RandomGenerator()) { @@ -545,7 +545,7 @@ namespace Test { /// Write a string to standard output, synchronized across all test runners void - write_output(std::string output) { + write_output(const std::string& output) { Gecode::Support::Lock lock(output_mutex); std::cout << output; std::cout.flush(); From 3d93f52e042eecab5c613fce92753748496f833c Mon Sep 17 00:00:00 2001 From: Mikael Zayenz Lagerkvist Date: Mon, 2 Nov 2026 05:34:39 +0100 Subject: [PATCH 5/6] Pass FloatVal by const& Zdev-Change-Id: Z9c9aa854f95a78c2fbb7e6930e3b50733187129e78720bdcdb1a830d578321ad --- gecode/float.hh | 20 ++++++++++---------- gecode/float/dom.cpp | 6 +++--- gecode/float/linear.cpp | 8 ++++---- gecode/float/linear.hh | 14 +++++++------- gecode/float/linear/nary.hpp | 10 +++++----- gecode/float/linear/post.cpp | 8 ++++---- gecode/float/rel.cpp | 6 +++--- gecode/float/rel.hh | 16 ++++++++-------- gecode/float/rel/eq.hpp | 4 ++-- gecode/float/rel/lq-le.hpp | 8 ++++---- gecode/float/rel/nq.hpp | 4 ++-- gecode/float/view.hpp | 24 ++++++++++++------------ gecode/float/view/float.hpp | 4 ++-- gecode/float/view/minus.hpp | 4 ++-- gecode/float/view/offset.hpp | 4 ++-- gecode/float/view/rel-test.hpp | 6 +++--- gecode/float/view/scale.hpp | 6 +++--- gecode/minimodel.hh | 8 ++++---- gecode/minimodel/dom.cpp | 9 ++++----- gecode/minimodel/float-expr.cpp | 8 ++++---- gecode/minimodel/float-rel.hpp | 4 ++-- test/flatzinc.cpp | 4 ++-- test/float.cpp | 2 +- test/float.hh | 8 ++++---- test/float.hpp | 6 +++--- test/float/basic.cpp | 2 +- test/float/dom.cpp | 2 +- test/search.cpp | 8 +++++--- 28 files changed, 107 insertions(+), 106 deletions(-) diff --git a/gecode/float.hh b/gecode/float.hh index f9f5527727..2bac7c288c 100644 --- a/gecode/float.hh +++ b/gecode/float.hh @@ -1079,15 +1079,15 @@ namespace Gecode { //@{ /// Propagates \f$x=n\f$ - GECODE_FLOAT_EXPORT void dom(Home home, FloatVar x, FloatVal n); + GECODE_FLOAT_EXPORT void dom(Home home, FloatVar x, const FloatVal& n); /// Propagates \f$ x_i=n\f$ for all \f$0\leq i<|x|\f$ - GECODE_FLOAT_EXPORT void dom(Home home, const FloatVarArgs& x, FloatVal n); + GECODE_FLOAT_EXPORT void dom(Home home, const FloatVarArgs& x, const FloatVal& n); /// Propagates \f$ l\leq x\leq u\f$ GECODE_FLOAT_EXPORT void dom(Home home, FloatVar x, FloatNum l, FloatNum m); /// Propagates \f$ l\leq x_i\leq u\f$ for all \f$0\leq i<|x|\f$ GECODE_FLOAT_EXPORT void dom(Home home, const FloatVarArgs& x, FloatNum l, FloatNum u); /// Post domain consistent propagator for \f$ (x=n) \equiv r\f$ - GECODE_FLOAT_EXPORT void dom(Home home, FloatVar x, FloatVal n, Reify r); + GECODE_FLOAT_EXPORT void dom(Home home, FloatVar x, const FloatVal& n, Reify r); /// Post domain consistent propagator for \f$ (l\leq x \leq u) \equiv r\f$ GECODE_FLOAT_EXPORT void dom(Home home, FloatVar x, FloatNum l, FloatNum u, Reify r); /// Constrain domain of \a x according to domain of \a d @@ -1108,11 +1108,11 @@ namespace Gecode { /** \brief Propagates \f$ x \sim_{frt} c\f$ * \ingroup TaskModelFloatRelFloat */ - GECODE_FLOAT_EXPORT void rel(Home home, FloatVar x, FloatRelType frt, FloatVal c); + GECODE_FLOAT_EXPORT void rel(Home home, FloatVar x, FloatRelType frt, const FloatVal& c); /** \brief Post propagator for \f$(x \sim_{frt} c)\equiv r\f$ * \ingroup TaskModelFloatRelFloat */ - GECODE_FLOAT_EXPORT void rel(Home home, FloatVar x, FloatRelType frt, FloatVal c, Reify r); + GECODE_FLOAT_EXPORT void rel(Home home, FloatVar x, FloatRelType frt, const FloatVal& c, Reify r); /** \brief Post propagator for \f$(x_0 \sim_{frt} x_1)\equiv r\f$ * \ingroup TaskModelFloatRelFloat */ @@ -1120,7 +1120,7 @@ namespace Gecode { /** \brief Propagates \f$ x_i \sim_{frt} c \f$ for all \f$0\leq i<|x|\f$ * \ingroup TaskModelFloatRelFloat */ - GECODE_FLOAT_EXPORT void rel(Home home, const FloatVarArgs& x, FloatRelType frt, FloatVal c); + GECODE_FLOAT_EXPORT void rel(Home home, const FloatVarArgs& x, FloatRelType frt, const FloatVal& c); /** \brief Propagates \f$ x_i \sim_{frt} y \f$ for all \f$0\leq i<|x|\f$ * \ingroup TaskModelFloatRelFloat */ @@ -1233,7 +1233,7 @@ namespace Gecode { * * \ingroup TaskModelFloatLI */ - GECODE_FLOAT_EXPORT void linear(Home home, const FloatVarArgs& x, FloatRelType frt, FloatVal c); + GECODE_FLOAT_EXPORT void linear(Home home, const FloatVarArgs& x, FloatRelType frt, const FloatVal& c); /** \brief Post propagator for \f$\sum_{i=0}^{|x|-1}x_i\sim_{frt} y\f$ * \ingroup TaskModelFloatLI * @@ -1255,7 +1255,7 @@ namespace Gecode { * * \ingroup TaskModelFloatLI */ - GECODE_FLOAT_EXPORT void linear(Home home, const FloatVarArgs& x, FloatRelType frt, FloatVal c, Reify r); + GECODE_FLOAT_EXPORT void linear(Home home, const FloatVarArgs& x, FloatRelType frt, const FloatVal& c, Reify r); /** \brief Post propagator for \f$\left(\sum_{i=0}^{|x|-1}x_i\sim_{frt} y\right)\equiv r\f$ * * \li Throws an exception of type Float::OutOfLimits, if the variables, @@ -1280,7 +1280,7 @@ namespace Gecode { * \ingroup TaskModelFloatLI */ GECODE_FLOAT_EXPORT void linear(Home home, const FloatValArgs& a, const FloatVarArgs& x, FloatRelType frt, - FloatVal c); + const FloatVal& c); /** \brief Post propagator for \f$\sum_{i=0}^{|x|-1}a_i\cdot x_i\sim_{frt} y\f$ * * @@ -1310,7 +1310,7 @@ namespace Gecode { * \ingroup TaskModelFloatLI */ GECODE_FLOAT_EXPORT void linear(Home home, const FloatValArgs& a, const FloatVarArgs& x, FloatRelType frt, - FloatVal c, Reify r); + const FloatVal& c, Reify r); /** \brief Post propagator for \f$\left(\sum_{i=0}^{|x|-1}a_i\cdot x_i\sim_{frt} y\right)\equiv r\f$ * * diff --git a/gecode/float/dom.cpp b/gecode/float/dom.cpp index 59494257d4..c5177724c6 100644 --- a/gecode/float/dom.cpp +++ b/gecode/float/dom.cpp @@ -35,7 +35,7 @@ namespace Gecode { void - dom(Home home, FloatVar x, FloatVal n) { + dom(Home home, FloatVar x, const FloatVal& n) { using namespace Float; Limits::check(n, "Float::dom"); GECODE_POST; @@ -44,7 +44,7 @@ namespace Gecode { } void - dom(Home home, const FloatVarArgs& x, FloatVal n) { + dom(Home home, const FloatVarArgs& x, const FloatVal& n) { using namespace Float; Limits::check(n, "Float::dom"); GECODE_POST; @@ -79,7 +79,7 @@ namespace Gecode { } void - dom(Home home, FloatVar x, FloatVal n, Reify r) { + dom(Home home, FloatVar x, const FloatVal& n, Reify r) { using namespace Float; Limits::check(n, "Float::dom"); GECODE_POST; diff --git a/gecode/float/linear.cpp b/gecode/float/linear.cpp index fa196d712b..149d128639 100644 --- a/gecode/float/linear.cpp +++ b/gecode/float/linear.cpp @@ -37,7 +37,7 @@ o * Main authors: namespace Gecode { void - linear(Home home, const FloatVarArgs& x, FloatRelType frt, FloatVal c) { + linear(Home home, const FloatVarArgs& x, FloatRelType frt, const FloatVal& c) { using namespace Float; GECODE_POST; Region re; @@ -51,7 +51,7 @@ namespace Gecode { } void - linear(Home home, const FloatVarArgs& x, FloatRelType frt, FloatVal c, Reify r) { + linear(Home home, const FloatVarArgs& x, FloatRelType frt, const FloatVal& c, Reify r) { using namespace Float; GECODE_POST; Region re; @@ -65,7 +65,7 @@ namespace Gecode { } void - linear(Home home, const FloatValArgs& a, const FloatVarArgs& x, FloatRelType frt, FloatVal c) { + linear(Home home, const FloatValArgs& a, const FloatVarArgs& x, FloatRelType frt, const FloatVal& c) { using namespace Float; if (a.size() != x.size()) throw ArgumentSizeMismatch("Float::linear"); @@ -81,7 +81,7 @@ namespace Gecode { } void - linear(Home home, const FloatValArgs& a, const FloatVarArgs& x, FloatRelType frt, FloatVal c, Reify r) { + linear(Home home, const FloatValArgs& a, const FloatVarArgs& x, FloatRelType frt, const FloatVal& c, Reify r) { using namespace Float; if (a.size() != x.size()) throw ArgumentSizeMismatch("Float::linear"); diff --git a/gecode/float/linear.hh b/gecode/float/linear.hh index 89f7ba9d4f..996d92d01f 100644 --- a/gecode/float/linear.hh +++ b/gecode/float/linear.hh @@ -65,7 +65,7 @@ namespace Gecode { namespace Float { namespace Linear { /// Constructor for cloning \a p Lin(Space& home, Lin& p); /// Constructor for creation - Lin(Home home, ViewArray

& x, ViewArray& y, FloatVal c); + Lin(Home home, ViewArray

& x, ViewArray& y, const FloatVal& c); public: /// Cost function (defined as low linear) @@ -112,13 +112,13 @@ namespace Gecode { namespace Float { namespace Linear { public: /// Constructor for creation - Eq(Home home, ViewArray

& x, ViewArray& y, FloatVal c); + Eq(Home home, ViewArray

& x, ViewArray& y, const FloatVal& c); /// Create copy during cloning Actor* copy(Space& home) override; /// Perform propagation ExecStatus propagate(Space& home, const ModEventDelta& med) override; /// Post propagator for \f$\sum_{i=0}^{|x|-1}x_i-\sum_{i=0}^{|y|-1}y_i=c\f$ - static ExecStatus post(Home home, ViewArray

& x, ViewArray& y, FloatVal c); + static ExecStatus post(Home home, ViewArray

& x, ViewArray& y, const FloatVal& c); }; /** @@ -141,13 +141,13 @@ namespace Gecode { namespace Float { namespace Linear { public: /// Constructor for creation - Lq(Home home, ViewArray

& x, ViewArray& y, FloatVal c); + Lq(Home home, ViewArray

& x, ViewArray& y, const FloatVal& c); /// Create copy during cloning Actor* copy(Space& home) override; /// Perform propagation ExecStatus propagate(Space& home, const ModEventDelta& med) override; /// Post propagator for \f$\sum_{i=0}^{|x|-1}x_i-\sum_{i=0}^{|y|-1}y_i\leq c\f$ - static ExecStatus post(Home home, ViewArray

& x, ViewArray& y, FloatVal c); + static ExecStatus post(Home home, ViewArray

& x, ViewArray& y, const FloatVal& c); }; }}} // namespace Gecode::Float::Linear @@ -182,7 +182,7 @@ namespace Gecode { namespace Float { namespace Linear { * \param u upper bound * */ - GECODE_FLOAT_EXPORT void estimate(Term* t, int n, FloatVal c, FloatNum& l, FloatNum& u); + GECODE_FLOAT_EXPORT void estimate(Term* t, int n, const FloatVal& c, FloatNum& l, FloatNum& u); /** * \brief Post propagator for linear constraint over floats @@ -219,7 +219,7 @@ namespace Gecode { namespace Float { namespace Linear { * Requires \code #include \endcode * \ingroup FuncFloatProp */ - GECODE_FLOAT_EXPORT void post(Home home, Term* t, int n, FloatRelType frt, FloatVal c, Reify r); + GECODE_FLOAT_EXPORT void post(Home home, Term* t, int n, FloatRelType frt, const FloatVal& c, Reify r); }}} // namespace Gecode::Float::Linear diff --git a/gecode/float/linear/nary.hpp b/gecode/float/linear/nary.hpp index 5107862596..0fc41b8837 100644 --- a/gecode/float/linear/nary.hpp +++ b/gecode/float/linear/nary.hpp @@ -40,7 +40,7 @@ namespace Gecode { namespace Float { namespace Linear { */ template forceinline - Lin::Lin(Home home, ViewArray

& x0, ViewArray& y0, FloatVal c0) + Lin::Lin(Home home, ViewArray

& x0, ViewArray& y0, const FloatVal& c0) : Propagator(home), x(x0), y(y0), c(c0) { x.subscribe(home, *this, pc); y.subscribe(home, *this, pc); @@ -119,12 +119,12 @@ namespace Gecode { namespace Float { namespace Linear { template forceinline - Eq::Eq(Home home, ViewArray

& x, ViewArray& y, FloatVal c) + Eq::Eq(Home home, ViewArray

& x, ViewArray& y, const FloatVal& c) : Lin(home, x, y, c) {} template ExecStatus - Eq::post(Home home, ViewArray

& x, ViewArray& y, FloatVal c) { + Eq::post(Home home, ViewArray

& x, ViewArray& y, const FloatVal& c) { (void)new (home) Eq(home, x, y, c); return ES_OK; } @@ -251,12 +251,12 @@ namespace Gecode { namespace Float { namespace Linear { template forceinline - Lq::Lq(Home home, ViewArray

& x, ViewArray& y, FloatVal c) + Lq::Lq(Home home, ViewArray

& x, ViewArray& y, const FloatVal& c) : Lin(home, x, y, c) {} template ExecStatus - Lq::post(Home home, ViewArray

& x, ViewArray& y, FloatVal c) { + Lq::post(Home home, ViewArray

& x, ViewArray& y, const FloatVal& c) { (void)new (home) Lq(home, x, y, c); return ES_OK; } diff --git a/gecode/float/linear/post.cpp b/gecode/float/linear/post.cpp index 66d3273622..e78e6582cc 100644 --- a/gecode/float/linear/post.cpp +++ b/gecode/float/linear/post.cpp @@ -41,7 +41,7 @@ namespace Gecode { namespace Float { namespace Linear { void - estimate(Term* t, int n, FloatVal c, FloatNum& l, FloatNum& u) { + estimate(Term* t, int n, const FloatVal& c, FloatNum& l, FloatNum& u) { FloatVal est = c; for (int i = n; i--;) est += t[i].a * t[i].x.domain(); @@ -60,7 +60,7 @@ namespace Gecode { namespace Float { namespace Linear { } forceinline bool - overflow(Term* t, int n, FloatVal c) { + overflow(Term* t, int n, const FloatVal& c) { FloatVal est = c; for (int i = n; i--;) est += t[i].a * t[i].x.domain(); @@ -100,7 +100,7 @@ namespace Gecode { namespace Float { namespace Linear { */ template forceinline void - post_nary(Home home, ViewArray& x, ViewArray& y, FloatRelType frt, FloatVal c) { + post_nary(Home home, ViewArray& x, ViewArray& y, FloatRelType frt, const FloatVal& c) { switch (frt) { case FRT_EQ: GECODE_ES_FAIL((Eq::post(home, x, y, c))); @@ -272,7 +272,7 @@ namespace Gecode { namespace Float { namespace Linear { } void - post(Home home, Term* t, int n, FloatRelType frt, FloatVal c, Reify r) { + post(Home home, Term* t, int n, FloatRelType frt, const FloatVal& c, Reify r) { Region re; rel(home, extend(home, re, t, n), frt, c, r); post_linear(home, t, n, FRT_EQ, 0.0); diff --git a/gecode/float/rel.cpp b/gecode/float/rel.cpp index fa7c6137b3..ba8a5230c5 100644 --- a/gecode/float/rel.cpp +++ b/gecode/float/rel.cpp @@ -39,7 +39,7 @@ namespace Gecode { void - rel(Home home, FloatVar x0, FloatRelType frt, FloatVal n) { + rel(Home home, FloatVar x0, FloatRelType frt, const FloatVal& n) { using namespace Float; Limits::check(n, "Float::rel"); GECODE_POST; @@ -175,7 +175,7 @@ namespace Gecode { } void - rel(Home home, FloatVar x, FloatRelType frt, FloatVal n, Reify r) { + rel(Home home, FloatVar x, FloatRelType frt, const FloatVal& n, Reify r) { using namespace Float; Limits::check(n, "Float::rel"); GECODE_POST; @@ -282,7 +282,7 @@ namespace Gecode { } void - rel(Home home, const FloatVarArgs& x, FloatRelType frt, FloatVal c) { + rel(Home home, const FloatVarArgs& x, FloatRelType frt, const FloatVal& c) { using namespace Float; Limits::check(c, "Float::rel"); GECODE_POST; diff --git a/gecode/float/rel.hh b/gecode/float/rel.hh index f164d3b4aa..8a675aa36d 100644 --- a/gecode/float/rel.hh +++ b/gecode/float/rel.hh @@ -159,7 +159,7 @@ namespace Gecode { namespace Float { namespace Rel { /// Constructor for cloning \a p ReEqFloat(Space& home, ReEqFloat& p); /// Constructor for posting - ReEqFloat(Home home, View x, FloatVal c, CtrlView b); + ReEqFloat(Home home, View x, const FloatVal& c, CtrlView b); public: /// Copy propagator during cloning @@ -167,7 +167,7 @@ namespace Gecode { namespace Float { namespace Rel { /// Perform propagation ExecStatus propagate(Space& home, const ModEventDelta& med) override; /// Post bounds consistent propagator \f$ (x = c)\Leftrightarrow b\f$ - static ExecStatus post(Home home, View x, FloatVal c, CtrlView b); + static ExecStatus post(Home home, View x, const FloatVal& c, CtrlView b); }; /** @@ -216,13 +216,13 @@ namespace Gecode { namespace Float { namespace Rel { public: /// Constructor for posting - NqFloat(Home home, View x, FloatVal c); + NqFloat(Home home, View x, const FloatVal& c); /// Copy propagator during cloning Actor* copy(Space& home) override; /// Perform propagation ExecStatus propagate(Space& home, const ModEventDelta& med) override; /// Post bounds consistent propagator \f$ x_0 \neq c\f$ - static ExecStatus post(Home home, View x0, FloatVal c); + static ExecStatus post(Home home, View x0, const FloatVal& c); }; /* @@ -307,7 +307,7 @@ namespace Gecode { namespace Float { namespace Rel { /// Constructor for cloning \a p ReLqFloat(Space& home, ReLqFloat& p); /// Constructor for posting - ReLqFloat(Home home, View x, FloatVal c, CtrlView b); + ReLqFloat(Home home, View x, const FloatVal& c, CtrlView b); public: /// Copy propagator during cloning @@ -315,7 +315,7 @@ namespace Gecode { namespace Float { namespace Rel { /// Perform propagation ExecStatus propagate(Space& home, const ModEventDelta& med) override; /// Post propagator for \f$ (x \leq c)\Leftrightarrow b\f$ - static ExecStatus post(Home home, View x, FloatVal c, CtrlView b); + static ExecStatus post(Home home, View x, const FloatVal& c, CtrlView b); }; /** @@ -336,7 +336,7 @@ namespace Gecode { namespace Float { namespace Rel { /// Constructor for cloning \a p ReLeFloat(Space& home, ReLeFloat& p); /// Constructor for posting - ReLeFloat(Home home, View x, FloatVal c, CtrlView b); + ReLeFloat(Home home, View x, const FloatVal& c, CtrlView b); public: /// Copy propagator during cloning @@ -344,7 +344,7 @@ namespace Gecode { namespace Float { namespace Rel { /// Perform propagation ExecStatus propagate(Space& home, const ModEventDelta& med) override; /// Post propagator for \f$ (x < c)\Leftrightarrow b\f$ - static ExecStatus post(Home home, View x, FloatVal c, CtrlView b); + static ExecStatus post(Home home, View x, const FloatVal& c, CtrlView b); }; /** diff --git a/gecode/float/rel/eq.hpp b/gecode/float/rel/eq.hpp index 1874f39738..3ac6127659 100644 --- a/gecode/float/rel/eq.hpp +++ b/gecode/float/rel/eq.hpp @@ -269,12 +269,12 @@ namespace Gecode { namespace Float { namespace Rel { template forceinline - ReEqFloat::ReEqFloat(Home home, View x, FloatVal c0, CtrlView b) + ReEqFloat::ReEqFloat(Home home, View x, const FloatVal& c0, CtrlView b) : Int::ReUnaryPropagator(home, x, b), c(c0) {} template ExecStatus - ReEqFloat::post(Home home, View x, FloatVal c, CtrlView b) { + ReEqFloat::post(Home home, View x, const FloatVal& c, CtrlView b) { if (b.one()) { if (rm != RM_PMI) GECODE_ME_CHECK(x.eq(home, c)); diff --git a/gecode/float/rel/lq-le.hpp b/gecode/float/rel/lq-le.hpp index b7673fdb57..8679dc2aa6 100644 --- a/gecode/float/rel/lq-le.hpp +++ b/gecode/float/rel/lq-le.hpp @@ -223,12 +223,12 @@ namespace Gecode { namespace Float { namespace Rel { template forceinline - ReLqFloat::ReLqFloat(Home home, View x, FloatVal c0, CtrlView b) + ReLqFloat::ReLqFloat(Home home, View x, const FloatVal& c0, CtrlView b) : Int::ReUnaryPropagator(home, x, b), c(c0) {} template ExecStatus - ReLqFloat::post(Home home, View x, FloatVal c, CtrlView b) { + ReLqFloat::post(Home home, View x, const FloatVal& c, CtrlView b) { if (b.one()) { if (rm != RM_PMI) GECODE_ME_CHECK(x.lq(home, c.max())); @@ -310,12 +310,12 @@ namespace Gecode { namespace Float { namespace Rel { template forceinline - ReLeFloat::ReLeFloat(Home home, View x, FloatVal c0, CtrlView b) + ReLeFloat::ReLeFloat(Home home, View x, const FloatVal& c0, CtrlView b) : Int::ReUnaryPropagator(home, x, b), c(c0) {} template ExecStatus - ReLeFloat::post(Home home, View x, FloatVal c, CtrlView b) { + ReLeFloat::post(Home home, View x, const FloatVal& c, CtrlView b) { if (b.one()) { if (rm != RM_PMI) { GECODE_ME_CHECK(x.lq(home, c.max())); diff --git a/gecode/float/rel/nq.hpp b/gecode/float/rel/nq.hpp index 3c23daba7c..712ff31fb4 100644 --- a/gecode/float/rel/nq.hpp +++ b/gecode/float/rel/nq.hpp @@ -83,12 +83,12 @@ namespace Gecode { namespace Float { namespace Rel { */ template forceinline - NqFloat::NqFloat(Home home, View x, FloatVal _c) + NqFloat::NqFloat(Home home, View x, const FloatVal& _c) : UnaryPropagator(home, x), c(_c) {} template ExecStatus - NqFloat::post(Home home, View x, FloatVal c) { + NqFloat::post(Home home, View x, const FloatVal& c) { if (x.assigned()) { if (overlap(x.val(), c)) return ES_FAILED; diff --git a/gecode/float/view.hpp b/gecode/float/view.hpp index 2f938b8144..8f646ddb33 100644 --- a/gecode/float/view.hpp +++ b/gecode/float/view.hpp @@ -103,14 +103,14 @@ namespace Gecode { namespace Float { /// Restrict domain values to be less or equal than \a n ModEvent lq(Space& home, FloatNum n); /// Restrict domain values to be less or equal than \a n - ModEvent lq(Space& home, FloatVal n); + ModEvent lq(Space& home, const FloatVal& n); /// Restrict domain values to be greater or equal than \a n ModEvent gq(Space& home, int n); /// Restrict domain values to be greater or equal than \a n ModEvent gq(Space& home, FloatNum n); /// Restrict domain values to be greater or equal than \a n - ModEvent gq(Space& home, FloatVal n); + ModEvent gq(Space& home, const FloatVal& n); /// Restrict domain values to be equal to \a n ModEvent eq(Space& home, int n); @@ -203,14 +203,14 @@ namespace Gecode { namespace Float { /// Restrict domain values to be less or equal than \a n ModEvent lq(Space& home, FloatNum n); /// Restrict domain values to be less or equal than \a n - ModEvent lq(Space& home, FloatVal n); + ModEvent lq(Space& home, const FloatVal& n); /// Restrict domain values to be greater or equal than \a n ModEvent gq(Space& home, int n); /// Restrict domain values to be greater or equal than \a n ModEvent gq(Space& home, FloatNum n); /// Restrict domain values to be greater or equal than \a n - ModEvent gq(Space& home, FloatVal n); + ModEvent gq(Space& home, const FloatVal& n); /// Restrict domain values to be equal to \a n ModEvent eq(Space& home, int n); @@ -320,14 +320,14 @@ namespace Gecode { namespace Float { /// Restrict domain values to be less or equal than \a n ModEvent lq(Space& home, FloatNum n); /// Restrict domain values to be less or equal than \a n - ModEvent lq(Space& home, FloatVal n); + ModEvent lq(Space& home, const FloatVal& n); /// Restrict domain values to be greater or equal than \a n ModEvent gq(Space& home, int n); /// Restrict domain values to be greater or equal than \a n ModEvent gq(Space& home, FloatNum n); /// Restrict domain values to be greater or equal than \a n - ModEvent gq(Space& home, FloatVal n); + ModEvent gq(Space& home, const FloatVal& n); /// Restrict domain values to be equal to \a n ModEvent eq(Space& home, int n); @@ -402,7 +402,7 @@ namespace Gecode { namespace Float { /// Default constructor ScaleView(void); /// Initialize as \f$b\cdot y\f$ - ScaleView(FloatVal b, const FloatView& y); + ScaleView(const FloatVal& b, const FloatView& y); //@} /// \name Value access @@ -448,14 +448,14 @@ namespace Gecode { namespace Float { /// Restrict domain values to be less or equal than \a n ModEvent lq(Space& home, FloatNum n); /// Restrict domain values to be less or equal than \a n - ModEvent lq(Space& home, FloatVal n); + ModEvent lq(Space& home, const FloatVal& n); /// Restrict domain values to be greater or equal than \a n ModEvent gq(Space& home, int n); /// Restrict domain values to be greater or equal than \a n ModEvent gq(Space& home, FloatNum n); /// Restrict domain values to be greater or equal than \a n - ModEvent gq(Space& home, FloatVal n); + ModEvent gq(Space& home, const FloatVal& n); /// Restrict domain values to be equal to \a n ModEvent eq(Space& home, int n); @@ -538,21 +538,21 @@ namespace Gecode { namespace Float { RelTest rtest_eq(View x, View y); /// Test whether view \a x and Float \a n are equal template - RelTest rtest_eq(View x, FloatVal n); + RelTest rtest_eq(View x, const FloatVal& n); /// Test whether view \a x is less or equal than view \a y template RelTest rtest_lq(View x, View y); /// Test whether view \a x is less or equal than float \a n template - RelTest rtest_lq(View x, FloatVal n); + RelTest rtest_lq(View x, const FloatVal& n); /// Test whether view \a x is less than view \a y template RelTest rtest_lt(View x, View y); /// Test whether view \a x is less or equal than float \a n template - RelTest rtest_lt(View x, FloatVal n); + RelTest rtest_lt(View x, const FloatVal& n); //@} diff --git a/gecode/float/view/float.hpp b/gecode/float/view/float.hpp index 2714b2187d..44eb7651dd 100644 --- a/gecode/float/view/float.hpp +++ b/gecode/float/view/float.hpp @@ -107,7 +107,7 @@ namespace Gecode { namespace Float { return x->lq(home, n); } forceinline ModEvent - FloatView::lq(Space& home, FloatVal n) { + FloatView::lq(Space& home, const FloatVal& n) { return x->lq(home, n); } @@ -120,7 +120,7 @@ namespace Gecode { namespace Float { return x->gq(home, n); } forceinline ModEvent - FloatView::gq(Space& home, FloatVal n) { + FloatView::gq(Space& home, const FloatVal& n) { return x->gq(home, n); } diff --git a/gecode/float/view/minus.hpp b/gecode/float/view/minus.hpp index 2d2b023c42..b9612b9d56 100644 --- a/gecode/float/view/minus.hpp +++ b/gecode/float/view/minus.hpp @@ -104,7 +104,7 @@ namespace Gecode { namespace Float { return x.gq(home, -n); } forceinline ModEvent - MinusView::lq(Space& home, FloatVal n) { + MinusView::lq(Space& home, const FloatVal& n) { return x.gq(home, -n); } @@ -117,7 +117,7 @@ namespace Gecode { namespace Float { return x.lq(home, -n); } forceinline ModEvent - MinusView::gq(Space& home, FloatVal n) { + MinusView::gq(Space& home, const FloatVal& n) { return x.lq(home, -n); } diff --git a/gecode/float/view/offset.hpp b/gecode/float/view/offset.hpp index 3de51c3a9d..d0d6f8e10d 100644 --- a/gecode/float/view/offset.hpp +++ b/gecode/float/view/offset.hpp @@ -112,7 +112,7 @@ namespace Gecode { namespace Float { return x.lq(home, n - c); } forceinline ModEvent - OffsetView::lq(Space& home, FloatVal n) { + OffsetView::lq(Space& home, const FloatVal& n) { return x.lq(home, n - c); } @@ -125,7 +125,7 @@ namespace Gecode { namespace Float { return x.gq(home, n - c); } forceinline ModEvent - OffsetView::gq(Space& home, FloatVal n) { + OffsetView::gq(Space& home, const FloatVal& n) { return x.gq(home, n - c); } diff --git a/gecode/float/view/rel-test.hpp b/gecode/float/view/rel-test.hpp index 1eac63190d..71f7932c35 100644 --- a/gecode/float/view/rel-test.hpp +++ b/gecode/float/view/rel-test.hpp @@ -44,7 +44,7 @@ namespace Gecode { namespace Float { template forceinline RelTest - rtest_eq(View x, FloatVal n) { + rtest_eq(View x, const FloatVal& n) { if ((x.min() > n.max()) || (x.max() < n.min())) return RT_FALSE; return x.assigned() ? RT_TRUE : RT_MAYBE; @@ -62,7 +62,7 @@ namespace Gecode { namespace Float { template forceinline RelTest - rtest_lq(View x, FloatVal n) { + rtest_lq(View x, const FloatVal& n) { if (x.max() <= n.min()) return RT_TRUE; if (x.min() > n.max()) @@ -82,7 +82,7 @@ namespace Gecode { namespace Float { template forceinline RelTest - rtest_lt(View x, FloatVal n) { + rtest_lt(View x, const FloatVal& n) { if (x.max() < n.min()) return RT_TRUE; if (x.min() >= n.max()) diff --git a/gecode/float/view/scale.hpp b/gecode/float/view/scale.hpp index 4478311f17..0af370cf7c 100644 --- a/gecode/float/view/scale.hpp +++ b/gecode/float/view/scale.hpp @@ -41,7 +41,7 @@ namespace Gecode { namespace Float { forceinline ScaleView::ScaleView(void) {} forceinline - ScaleView::ScaleView(FloatVal d, const FloatView& y) + ScaleView::ScaleView(const FloatVal& d, const FloatView& y) : DerivedView(y), a(d) {} /* @@ -122,7 +122,7 @@ namespace Gecode { namespace Float { return x.lq(home, c.max()); } forceinline ModEvent - ScaleView::lq(Space& home, FloatVal n) { + ScaleView::lq(Space& home, const FloatVal& n) { FloatVal c = n; c /= a; return x.lq(home, c.max()); @@ -141,7 +141,7 @@ namespace Gecode { namespace Float { return x.gq(home, c.min()); } forceinline ModEvent - ScaleView::gq(Space& home, FloatVal n) { + ScaleView::gq(Space& home, const FloatVal& n) { FloatVal c = n; c /= a; return x.gq(home, c.min()); diff --git a/gecode/minimodel.hh b/gecode/minimodel.hh index a5b267d7d8..d28a0840eb 100644 --- a/gecode/minimodel.hh +++ b/gecode/minimodel.hh @@ -732,7 +732,7 @@ namespace Gecode { LinFloatExpr(const FloatVar& x); /// Create expression GECODE_MINIMODEL_EXPORT - LinFloatExpr(const FloatVar& x, FloatVal a); + LinFloatExpr(const FloatVar& x, const FloatVal& a); /// Create sum expression GECODE_MINIMODEL_EXPORT explicit LinFloatExpr(const FloatVarArgs& x); @@ -750,7 +750,7 @@ namespace Gecode { LinFloatExpr(const LinFloatExpr& e0, NodeType t, const FloatVal& c); /// Create expression for multiplication GECODE_MINIMODEL_EXPORT - LinFloatExpr(FloatVal a, const LinFloatExpr& e); + LinFloatExpr(const FloatVal& a, const LinFloatExpr& e); /// Create non-linear expression GECODE_MINIMODEL_EXPORT explicit LinFloatExpr(NonLinFloatExpr* e); @@ -794,9 +794,9 @@ namespace Gecode { /// Create linear float relation for expressions \a l and \a r LinFloatRel(const LinFloatExpr& l, FloatRelType frt, const LinFloatExpr& r); /// Create linear float relation for expression \a l and FloatVal \a r - LinFloatRel(const LinFloatExpr& l, FloatRelType frt, FloatVal r); + LinFloatRel(const LinFloatExpr& l, FloatRelType frt, const FloatVal& r); /// Create linear float relation for FloatVal \a l and expression \a r - LinFloatRel(FloatVal l, FloatRelType frt, const LinFloatExpr& r); + LinFloatRel(const FloatVal& l, FloatRelType frt, const LinFloatExpr& r); /// Post propagator for relation (if \a t is false for negated relation) void post(Home home, bool t) const; /// Post reified propagator for relation (if \a t is false for negated relation) diff --git a/gecode/minimodel/dom.cpp b/gecode/minimodel/dom.cpp index 4ad0e9da92..33771835c5 100644 --- a/gecode/minimodel/dom.cpp +++ b/gecode/minimodel/dom.cpp @@ -34,7 +34,6 @@ #include #include -#include /// reproduce C++-14 std::index_sequence namespace { namespace cxx14 { @@ -68,7 +67,7 @@ namespace Gecode { class DomArgs { public: /// Constructor - DomArgs(Args...); + DomArgs(const Args&...); protected: /// Post reified domain constraint using the stored arguments @@ -85,7 +84,7 @@ namespace Gecode { class DomArgs { public: /// Constructor - DomArgs(IntVar, Args...); + DomArgs(IntVar, const Args&...); protected: /// Post reified domain constraint using stored arguments @@ -102,7 +101,7 @@ namespace Gecode { * */ template - DomArgs::DomArgs(Args... args) : _args(std::forward(args)...) {} + DomArgs::DomArgs(const Args&... args) : _args(args...) {} template template @@ -112,7 +111,7 @@ namespace Gecode { } template - DomArgs::DomArgs(IntVar x, Args... args) : _args(x, std::forward(args)...) {} + DomArgs::DomArgs(IntVar x, const Args&... args) : _args(x, args...) {} template template diff --git a/gecode/minimodel/float-expr.cpp b/gecode/minimodel/float-expr.cpp index 2aedf9e8fa..dbb42e202a 100644 --- a/gecode/minimodel/float-expr.cpp +++ b/gecode/minimodel/float-expr.cpp @@ -64,7 +64,7 @@ namespace Gecode { Node(void); /// Generate linear terms from expression GECODE_MINIMODEL_EXPORT - void fill(Home home, Float::Linear::Term*& tf, FloatVal m, FloatVal& d) const; + void fill(Home home, Float::Linear::Term*& tf, const FloatVal& m, FloatVal& d) const; /// Generate linear terms for expressions FloatVal fill(Home home, Float::Linear::Term* tf) const; /// Decrement reference count and possibly free memory @@ -254,7 +254,7 @@ namespace Gecode { n->x_float = x; } - LinFloatExpr::LinFloatExpr(const FloatVar& x, FloatVal a) : n(new Node) { + LinFloatExpr::LinFloatExpr(const FloatVar& x, const FloatVal& a) : n(new Node) { n->n_float = 1; n->t = NT_VAR; n->l = n->r = nullptr; @@ -308,7 +308,7 @@ namespace Gecode { n->c = c; } - LinFloatExpr::LinFloatExpr(FloatVal a, const LinFloatExpr& e) : n(new Node) { + LinFloatExpr::LinFloatExpr(const FloatVal& a, const LinFloatExpr& e) : n(new Node) { n->n_float = e.n->n_float; n->t = NT_MUL; n->l = e.n; @@ -342,7 +342,7 @@ namespace Gecode { } void - LinFloatExpr::Node::fill(Home home, Float::Linear::Term*& tf, FloatVal m, FloatVal& d) const { + LinFloatExpr::Node::fill(Home home, Float::Linear::Term*& tf, const FloatVal& m, FloatVal& d) const { switch (this->t) { case NT_CONST: Float::Limits::check(m * c, "MiniModel::LinFloatExpr"); diff --git a/gecode/minimodel/float-rel.hpp b/gecode/minimodel/float-rel.hpp index edecf02aa7..cee77d802f 100644 --- a/gecode/minimodel/float-rel.hpp +++ b/gecode/minimodel/float-rel.hpp @@ -46,11 +46,11 @@ namespace Gecode { : e(l - r), frt(frt0) {} forceinline - LinFloatRel::LinFloatRel(const LinFloatExpr& l, FloatRelType frt0, FloatVal r) + LinFloatRel::LinFloatRel(const LinFloatExpr& l, FloatRelType frt0, const FloatVal& r) : e(l - r), frt(frt0) {} forceinline - LinFloatRel::LinFloatRel(FloatVal l, FloatRelType frt0, const LinFloatExpr& r) + LinFloatRel::LinFloatRel(const FloatVal& l, FloatRelType frt0, const LinFloatExpr& r) : e(l - r), frt(frt0) {} forceinline FloatRelType diff --git a/test/flatzinc.cpp b/test/flatzinc.cpp index d0f32a7535..5e6ccd36ec 100644 --- a/test/flatzinc.cpp +++ b/test/flatzinc.cpp @@ -156,7 +156,7 @@ namespace Test { namespace FlatZinc { class FloatObjectiveComparison : public Base { private: static std::unique_ptr - model(Gecode::FloatVal v, bool minimize, Gecode::FloatNum step = 0.0) { + model(const Gecode::FloatVal& v, bool minimize, Gecode::FloatNum step = 0.0) { std::stringstream source; source << std::showpoint << std::setprecision(std::numeric_limits::max_digits10) << "var float: x = " << v.min() << "; solve " << (minimize ? "minimize" : "maximize") << " x;\n"; @@ -170,7 +170,7 @@ namespace Test { namespace FlatZinc { } static bool - admitted(Gecode::FloatVal candidate, const Gecode::FlatZinc::FlatZincSpace& incumbent, bool minimize, + admitted(const Gecode::FloatVal& candidate, const Gecode::FlatZinc::FlatZincSpace& incumbent, bool minimize, Gecode::FloatNum step) { std::unique_ptr c = model(candidate, minimize, step); c->constrain(incumbent); diff --git a/test/float.cpp b/test/float.cpp index 141a4908ea..e53517be2f 100644 --- a/test/float.cpp +++ b/test/float.cpp @@ -219,7 +219,7 @@ namespace Test { namespace Float { } void - TestSpace::rel(int i, Gecode::FloatRelType frt, Gecode::FloatVal n) { + TestSpace::rel(int i, Gecode::FloatRelType frt, const Gecode::FloatVal& n) { if (opt.log) { olog << ind(4) << "x[" << i << "] "; switch (frt) { diff --git a/test/float.hh b/test/float.hh index f42422e5f6..9f1e0d9225 100644 --- a/test/float.hh +++ b/test/float.hh @@ -218,7 +218,7 @@ namespace Test { /// Compute a fixpoint and check for failure bool failed(void); /// Perform integer tell operation on \a x[i] - void rel(int i, Gecode::FloatRelType frt, Gecode::FloatVal n); + void rel(int i, Gecode::FloatRelType frt, const Gecode::FloatVal& n); /// Perform Boolean tell on \a b void rel(bool sol); /// Assign all (or all but one, if \a skip is true) variables to values in \a a @@ -328,16 +328,16 @@ namespace Test { /// Map floatNum to string static std::string str(Gecode::FloatNum f); /// Map floatVal to string - static std::string str(Gecode::FloatVal f); + static std::string str(const Gecode::FloatVal& f); /// Map float array to string static std::string str(const Gecode::FloatValArgs& f); //@} /// \name General support //@{ /// Compare \a x and \a y with respect to \a r - static MaybeType cmp(Gecode::FloatVal x, Gecode::FloatRelType r, Gecode::FloatVal y); + static MaybeType cmp(const Gecode::FloatVal& x, Gecode::FloatRelType r, const Gecode::FloatVal& y); /// Whether \a x and \a y are equal - static MaybeType eq(Gecode::FloatVal x, Gecode::FloatVal y); + static MaybeType eq(const Gecode::FloatVal& x, const Gecode::FloatVal& y); /// Flip a coin and return true or false randomly bool flip(void); //@} diff --git a/test/float.hpp b/test/float.hpp index 3441cdbad5..e5ab7a142e 100644 --- a/test/float.hpp +++ b/test/float.hpp @@ -198,7 +198,7 @@ namespace Test { namespace Float { } inline std::string - Test::str(Gecode::FloatVal f) { + Test::str(const Gecode::FloatVal& f) { std::stringstream s; s << "[" << f.min() << ":" << f.max() << "]"; return s.str(); @@ -213,7 +213,7 @@ namespace Test { namespace Float { } inline MaybeType - Test::cmp(Gecode::FloatVal x, Gecode::FloatRelType r, Gecode::FloatVal y) { + Test::cmp(const Gecode::FloatVal& x, Gecode::FloatRelType r, const Gecode::FloatVal& y) { using namespace Gecode; switch (r) { case FRT_EQ: @@ -258,7 +258,7 @@ namespace Test { namespace Float { } inline MaybeType - Test::eq(Gecode::FloatVal x, Gecode::FloatVal y) { + Test::eq(const Gecode::FloatVal& x, const Gecode::FloatVal& y) { return cmp(x, Gecode::FRT_EQ, y); } diff --git a/test/float/basic.cpp b/test/float/basic.cpp index 63950c4cf5..36d2c21ac6 100644 --- a/test/float/basic.cpp +++ b/test/float/basic.cpp @@ -56,7 +56,7 @@ namespace Test { namespace Float { /// Initialize test Basic(Gecode::FloatNum n, Gecode::FloatNum s) : Test("Basic", 3, -n, n, s, CPLT_ASSIGNMENT, false) {} /// Initialize test - Basic(Gecode::FloatVal v, Gecode::FloatNum s) : Test("Basic", 3, v, s, CPLT_ASSIGNMENT, false) {} + Basic(const Gecode::FloatVal& v, Gecode::FloatNum s) : Test("Basic", 3, v, s, CPLT_ASSIGNMENT, false) {} /// Check whether \a x is a solution MaybeType solution(const Assignment&) const override { diff --git a/test/float/dom.cpp b/test/float/dom.cpp index 1ff6fe664a..f74c0e2188 100644 --- a/test/float/dom.cpp +++ b/test/float/dom.cpp @@ -54,7 +54,7 @@ namespace Test { namespace Float { public: /// Create and register test - Val(int n, Gecode::FloatVal c0, Gecode::FloatNum st) + Val(int n, const Gecode::FloatVal& c0, Gecode::FloatNum st) : Test("Dom::Val::" + str(n) + "::" + str(c0), n, -3, 3, st, CPLT_ASSIGNMENT, n == 1), c(c0) { test_subsumption = false; } diff --git a/test/search.cpp b/test/search.cpp index 25bb6fac96..27ef3cfaba 100644 --- a/test/search.cpp +++ b/test/search.cpp @@ -2398,7 +2398,8 @@ namespace Test { class FloatMinObjective : public FloatMinimizeSpace { public: FloatVar x; - FloatMinObjective(FloatVal v, FloatNum s = 0.0) : FloatMinimizeSpace(s), x(*this, v.min(), v.max()) {} + FloatMinObjective(const FloatVal& v, FloatNum s = 0.0) + : FloatMinimizeSpace(s), x(*this, v.min(), v.max()) {} FloatMinObjective(FloatMinObjective& s) : FloatMinimizeSpace(s) { x.update(*this, s.x); } @@ -2416,7 +2417,8 @@ namespace Test { class FloatMaxObjective : public FloatMaximizeSpace { public: FloatVar x; - FloatMaxObjective(FloatVal v, FloatNum s = 0.0) : FloatMaximizeSpace(s), x(*this, v.min(), v.max()) {} + FloatMaxObjective(const FloatVal& v, FloatNum s = 0.0) + : FloatMaximizeSpace(s), x(*this, v.min(), v.max()) {} FloatMaxObjective(FloatMaxObjective& s) : FloatMaximizeSpace(s) { x.update(*this, s.x); } @@ -2458,7 +2460,7 @@ namespace Test { private: template static bool - admitted(FloatVal candidate, FloatNum step, const Objective& incumbent) { + admitted(const FloatVal& candidate, FloatNum step, const Objective& incumbent) { Objective c(candidate, step); c.constrain(incumbent); return c.status() != SS_FAILED; From 763e70f37f8b72be870a1533ee6a32c3056998e5 Mon Sep 17 00:00:00 2001 From: Mikael Zayenz Lagerkvist Date: Mon, 2 Nov 2026 07:11:09 +0100 Subject: [PATCH 6/6] Enable performance-unnecessary-value-param and document the parameter rule Zdev-Change-Id: Z866642b8abb6de44b9e3b3ba31eea59a5ee562ec86fa93292ba9ce73ab1d698a --- .clang-tidy | 4 ++++ changelog.in | 23 +++++++++++++++++++++++ docs/code-style.md | 20 ++++++++++++++++---- gecode/kernel/data/shared-data.hpp | 14 ++++++++++++-- test/array.cpp | 27 +++++++++++++++++++++++++++ 5 files changed, 82 insertions(+), 6 deletions(-) diff --git a/.clang-tidy b/.clang-tidy index a3bff09bca..54744f3955 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -30,6 +30,7 @@ Checks: >- performance-move-constructor-init, performance-no-automatic-move, performance-unnecessary-copy-initialization, + performance-unnecessary-value-param, readability-identifier-naming WarningsAsErrors: '*' HeaderFilterRegex: '(gecode|test|examples|tools)/' @@ -39,6 +40,9 @@ FormatStyle: file CheckOptions: # Explicit discards document intentional ownership handoffs. bugprone-unused-return-value.AllowCastToVoid: true + # Shallow handles stay passed by value: a copy duplicates a few pointers or + # ids, with no reference count or allocation. See docs/code-style.md. + performance-unnecessary-value-param.AllowedTypes: '^Gecode::(Home|Group|PropagatorGroup|BrancherGroup|Pos|Reify)$;^Gecode::(Int|Bool|Set|Float)Var$;^Gecode::(Int|Bool|Set|Float)VarArray$;^Gecode::(VarArray|ViewArray)(<.*>)?$;^Gecode::(OpenIntVarList|OpenBoolVarList|OpenVarList|OpenViewList)(<.*>)?$;^Gecode::(VarImpView|DerivedView|ConstView)(<.*>)?$;^Gecode::(Int|Set|Float)::[A-Za-z]*View(<.*>)?$;^Gecode::.*::VarType$' readability-identifier-naming.FunctionCase: lower_case readability-identifier-naming.MethodCase: lower_case readability-identifier-naming.VariableCase: lower_case diff --git a/changelog.in b/changelog.in index f3fd7b477d..5cd72636c9 100644 --- a/changelog.in +++ b/changelog.in @@ -170,6 +170,29 @@ output while flushing complete solutions, progress, and protocol messages. Expand clang-tidy checks for hidden copies, container operations, missed moves, stream flushing, and correctness errors. +[ENTRY] +Module: other +What: change +Rank: major +[DESCRIPTION] +Pass owned and reference-counted parameters, and FloatVal, by const +reference instead of by value. Values that a function keeps and whose type +has a real move constructor, such as callbacks and branching configurations, +stay by value and are moved into place. This changes the exact signatures +and the ABI of many public functions: branch and assign with their +value-selection arguments, the variable- and value-selection functions and +constructors taking Rnd, AFC, Action, CHB, or merit functions, the Action +and CHB constructors taking merit functions, relax, trace, extensional with +a DFA, element with an IntSharedArray, and floating-point posting functions +and expressions taking a FloatVal. Calls compile unchanged, except that an +argument passed by value and moved must now be movable: a type with a +deleted move constructor no longer compiles there. Propagators that override +solution_distribution or domain_size_sum must take their SendMarginal or +InDecision argument by const reference. +[MORE] +Enable clang-tidy's performance-unnecessary-value-param check. Variables, +views, variable arrays, and other shallow handles stay passed by value. + [ENTRY] Module: other What: change diff --git a/docs/code-style.md b/docs/code-style.md index 6d8b0689ae..996dbf62b9 100644 --- a/docs/code-style.md +++ b/docs/code-style.md @@ -117,10 +117,22 @@ printer should not flush each row of a multi-line solution. The unused-return-value check accepts explicit `(void)` discards for reviewed operations such as ownership handoff after successful engine construction. -`performance-unnecessary-value-param` is reserved for manual performance audits. -Its suggestions mix Gecode's small, intentionally copied variable/view handles -with ownership-sensitive callbacks and argument arrays. Review actual copy -cost and lifetime requirements before changing those public signatures. +`performance-unnecessary-value-param` reports parameters that are copied but +only read. Take such a parameter by `const&`. When the callee keeps the value +and the type has a real move constructor, such as `std::function`, +`std::string`, `std::vector`, or a branching configuration, take it by value +and `std::move` it into place instead. + +The check's `AllowedTypes` keeps Gecode's shallow handles passed by value: +`Home`, the groups, `Pos`, `Reify`, the variables (`IntVar` and so on), the +variable arrays and `ViewArray`, the open variable and view lists, the views, +and `View::VarType`. Copying one copies a few pointers or ids, with no +reference count or allocation, and Gecode code relies on their value +semantics. Owned and reference-counted types are not exempt: `SharedHandle` +types such as `IntSet`, `TupleSet`, `DFA`, `Rnd`, `Action`, and `CHB`, +`SharedArray`, the `*Args` arrays, `REG`, strings, and callbacks. Their copies +touch a reference count or allocate, so they follow the rule above. `FloatVal` +is not exempt either: it is two doubles, not a handle. Other performance checks need focused review: `performance-enum-size` changes layouts and ABI, and `performance-no-int-to-ptr` conflicts with deliberate diff --git a/gecode/kernel/data/shared-data.hpp b/gecode/kernel/data/shared-data.hpp index 75642210b6..2f33669144 100644 --- a/gecode/kernel/data/shared-data.hpp +++ b/gecode/kernel/data/shared-data.hpp @@ -30,6 +30,9 @@ * */ +#include +#include + namespace Gecode { /// Class for sharing data between spaces @@ -52,8 +55,14 @@ namespace Gecode { public: /// Initialize with data \a d SharedData(const Data& d); - /// Initialize by moving data \a d - SharedData(Data&& d); + /** + * \brief Initialize by moving data \a d + * + * Only for movable data, so that copyable data without a move + * constructor still binds to the copying constructor. + */ + SharedData(Data&& d) + requires std::is_move_constructible_v; /// Create as uninitialized SharedData(void); /// Copy constructor @@ -87,6 +96,7 @@ namespace Gecode { template forceinline SharedData::SharedData(Data&& d) + requires std::is_move_constructible_v : SharedHandle(new SDO(std::move(d))) {} template diff --git a/test/array.cpp b/test/array.cpp index 4818e19150..40c59bfaf7 100644 --- a/test/array.cpp +++ b/test/array.cpp @@ -314,6 +314,33 @@ namespace Test { } } shared_array_iterator_test; + /// Copyable data whose move constructor is deleted + class CopyOnlyData { + public: + /// The stored value + int value; + /// Initialize with \a v + CopyOnlyData(int v) : value(v) {} + /// Copy constructor + CopyOnlyData(const CopyOnlyData&) = default; + /// Deleted move constructor + CopyOnlyData(CopyOnlyData&&) = delete; + }; + + /// %Class for testing SharedData with copyable data that cannot move + class SharedDataCopyOnly : public Test::Base { + public: + /// Initialize test + SharedDataCopyOnly(void) : Test::Base("Array::SharedData::CopyOnly") {} + /// Perform actual tests + bool + run(void) override { + // A temporary must bind to the copying constructor + Gecode::SharedData d(CopyOnlyData(3)); + return d().value == 3; + } + } shared_data_copy_only_test; + } // namespace Array } // namespace Test