Skip to content

Commit

Permalink
Support variable selection criteria for assigning variables during se…
Browse files Browse the repository at this point in the history
…arch
  • Loading branch information
chschulte committed Mar 6, 2019
1 parent cbfdc08 commit c3ece81
Show file tree
Hide file tree
Showing 12 changed files with 20,009 additions and 19,353 deletions.
38,754 changes: 19,431 additions & 19,323 deletions Makefile.dep

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ INTHDR0 = \
branch/traits.hpp branch/var.hpp branch/val.hpp branch/assign.hpp \
branch/view-values.hpp branch/merit.hpp \
branch/val-sel.hpp branch/val-commit.hpp branch/ngl.hpp \
branch/cbs.hpp \
branch/cbs.hpp branch.hpp \
count.hh count/rel.hpp \
count/int-base.hpp count/int-eq.hpp \
count/int-gq.hpp count/int-lq.hpp \
Expand Down Expand Up @@ -495,7 +495,7 @@ FLOATHDR0 = \
rel.hh rel/eq.hpp rel/lq-le.hpp rel/nq.hpp \
bool.hh bool/ite.hpp \
branch.hh branch/afc.hpp branch/action.hpp branch/chb.hpp \
branch/traits.hpp \
branch/traits.hpp branch.hpp \
branch/var.hpp branch/val.hpp branch/assign.hpp \
branch/val-commit.hpp branch/val-sel.hpp branch/merit.hpp \
num.hpp val.hpp rounding.hpp nextafter.hpp \
Expand Down Expand Up @@ -589,7 +589,7 @@ SETHDR0 = \
precede.hh precede/single.hpp \
rel-op.hh \
branch.hh branch/afc.hpp branch/action.hpp branch/chb.hpp \
branch/traits.hpp \
branch/traits.hpp branch.hpp \
branch/var.hpp branch/val.hpp branch/assign.hpp \
branch/merit.hpp branch/val-commit.hpp branch/val-sel.hpp \
branch/ngl.hpp \
Expand Down
48 changes: 48 additions & 0 deletions changelog.in
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,54 @@ Date: 2019-??-??
[DESCRIPTION]
Let's see.

[ENTRY]
Module: int
What: new
Rank: major
[DESCRIPTION]
Variables to be assigned during search can now be selected with
all available selection criteria available for branching.

[ENTRY]
Module: int
What: new
Rank: minor
[DESCRIPTION]
Omitting the variable selection criterion is equivalent to
INT_VAR_NONE().

[ENTRY]
Module: set
What: new
Rank: major
[DESCRIPTION]
Variables to be assigned during search can now be selected with
all available selection criteria available for branching.

[ENTRY]
Module: set
What: new
Rank: minor
[DESCRIPTION]
Omitting the variable selection criterion is equivalent to
SET_VAR_NONE().

[ENTRY]
Module: float
What: new
Rank: major
[DESCRIPTION]
Variables to be assigned during search can now be selected with
all available selection criteria available for branching.

[ENTRY]
Module: float
What: new
Rank: minor
[DESCRIPTION]
Omitting the variable selection criterion is equivalent to
FLOAT_VAR_NONE().


[RELEASE]
Version: 6.1.1
Expand Down
42 changes: 39 additions & 3 deletions gecode/float.hh
Original file line number Diff line number Diff line change
Expand Up @@ -1949,12 +1949,23 @@ namespace Gecode {
FloatVarValPrint vvp=nullptr);

/**
* \brief Assign all \a x with value selection \a vals
* \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, FloatAssign vals,
assign(Home home, const FloatVarArgs& x,
FloatVarBranch vars, 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<FloatVarBranch> vars, FloatAssign vals,
FloatBranchFilter bf=nullptr,
FloatVarValPrint vvp=nullptr);
/**
Expand All @@ -1965,10 +1976,35 @@ namespace Gecode {
GECODE_FLOAT_EXPORT void
assign(Home home, FloatVar x, FloatAssign vals,
FloatVarValPrint vvp=nullptr);
//@}

}

namespace Gecode {

/**
* \brief Branch over \a x with value selection \a vals
*
* \ingroup TaskModelFloatBranch
*/
void
branch(Home home, const FloatVarArgs& x, 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,
FloatVarValPrint vvp=nullptr);

}

#include <gecode/float/branch.hpp>

namespace Gecode {

/*
Expand Down
61 changes: 56 additions & 5 deletions gecode/float/branch.cpp
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -108,23 +108,74 @@ namespace Gecode {
}

void
assign(Home home, const FloatVarArgs& x, FloatAssign fa,
assign(Home home, const FloatVarArgs& x,
FloatVarBranch vars, FloatAssign vals,
FloatBranchFilter bf,
FloatVarValPrint vvp) {
using namespace Float;
if (home.failed()) return;
ViewArray<FloatView> xv(home,x);
ViewSel<FloatView>* vs[1] = {
new (home) ViewSelNone<FloatView>(home,FLOAT_VAR_NONE())
new (home) ViewSelNone<FloatView>(home,vars)
};
postviewvalbrancher<FloatView,1,FloatNumBranch,1>
(home,xv,vs,Branch::valselcommit(home,fa),bf,vvp);
(home,xv,vs,Branch::valselcommit(home,vals),bf,vvp);
}

void
assign(Home home, const FloatVarArgs& x,
TieBreak<FloatVarBranch> vars, FloatAssign vals,
FloatBranchFilter bf,
FloatVarValPrint vvp) {
using namespace Float;
if (home.failed()) return;
vars.a.expand(home,x);
if ((vars.a.select() == FloatVarBranch::SEL_NONE) ||
(vars.a.select() == FloatVarBranch::SEL_RND))
vars.b = FLOAT_VAR_NONE();
vars.b.expand(home,x);
if ((vars.b.select() == FloatVarBranch::SEL_NONE) ||
(vars.b.select() == FloatVarBranch::SEL_RND))
vars.c = FLOAT_VAR_NONE();
vars.c.expand(home,x);
if ((vars.c.select() == FloatVarBranch::SEL_NONE) ||
(vars.c.select() == FloatVarBranch::SEL_RND))
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);
} else {
ViewArray<FloatView> xv(home,x);
ValSelCommitBase<FloatView,FloatNumBranch>*
vsc = Branch::valselcommit(home,vals);
if (vars.c.select() == FloatVarBranch::SEL_NONE) {
ViewSel<FloatView>* vs[2] = {
Branch::viewsel(home,vars.a),Branch::viewsel(home,vars.b)
};
postviewvalbrancher<FloatView,2,FloatNumBranch,1>
(home,xv,vs,vsc,bf,vvp);
} else if (vars.d.select() == FloatVarBranch::SEL_NONE) {
ViewSel<FloatView>* vs[3] = {
Branch::viewsel(home,vars.a),Branch::viewsel(home,vars.b),
Branch::viewsel(home,vars.c)
};
postviewvalbrancher<FloatView,3,FloatNumBranch,1>
(home,xv,vs,vsc,bf,vvp);
} else {
ViewSel<FloatView>* vs[4] = {
Branch::viewsel(home,vars.a),Branch::viewsel(home,vars.b),
Branch::viewsel(home,vars.c),Branch::viewsel(home,vars.d)
};
postviewvalbrancher<FloatView,4,FloatNumBranch,1>
(home,xv,vs,vsc,bf,vvp);
}
}
}

void
assign(Home home, FloatVar x, FloatAssign fa, FloatVarValPrint vvp) {
assign(Home home, FloatVar x, FloatAssign vals, FloatVarValPrint vvp) {
FloatVarArgs xv(1); xv[0]=x;
assign(home, xv, fa, nullptr, vvp);
assign(home, xv, FLOAT_VAR_NONE(), vals, nullptr, vvp);
}

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

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);
}

forceinline void
assign(Home home, const FloatVarArgs& x, FloatAssign vals,
FloatBranchFilter bf, FloatVarValPrint vvp) {
assign(home, x, FLOAT_VAR_NONE(), vals, bf, vvp);
}

}

// STATISTICS: float-branch
75 changes: 71 additions & 4 deletions gecode/int.hh
Original file line number Diff line number Diff line change
Expand Up @@ -4999,6 +4999,7 @@ namespace Gecode {
#include <gecode/int/branch/assign.hpp>

namespace Gecode {

/**
* \brief Branch over \a x with variable selection \a vars and value selection \a vals
*
Expand Down Expand Up @@ -5057,12 +5058,23 @@ namespace Gecode {
BoolVarValPrint vvp=nullptr);

/**
* \brief Assign all \a x with value selection \a vals
* \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, IntAssign vals,
assign(Home home, const IntVarArgs& x,
IntVarBranch vars, 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<IntVarBranch> vars, IntAssign vals,
IntBranchFilter bf=nullptr,
IntVarValPrint vvp=nullptr);
/**
Expand All @@ -5074,14 +5086,25 @@ namespace Gecode {
assign(Home home, IntVar x, IntAssign vals,
IntVarValPrint vvp=nullptr);
/**
* \brief Assign all \a x with value selection \a vals
* \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, BoolAssign vals,
assign(Home home, const BoolVarArgs& x,
BoolVarBranch vars, 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<BoolVarBranch> vars, BoolAssign vals,
IntBranchFilter bf=nullptr,
IntVarValPrint vvp=nullptr);
/**
* \brief Assign \a x with value selection \a vals
*
Expand All @@ -5093,6 +5116,50 @@ namespace Gecode {

}

namespace Gecode {

/**
* \brief Branch over \a x with value selection \a vals
*
* \ingroup TaskModelIntBranch
*/
void
branch(Home home, const IntVarArgs& x, 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,
BoolVarValPrint vvp=nullptr);

/**
* \brief Assign all \a x with value selection \a vals
*
* \ingroup TaskModelIntBranch
*/
void
assign(Home home, const IntVarArgs& x, 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,
BoolVarValPrint vvp=nullptr);

}

#include <gecode/int/branch.hpp>

namespace Gecode {

/** Print DFA \a d
Expand Down
Loading

0 comments on commit c3ece81

Please sign in to comment.