Skip to content

Commit eaab1fc

Browse files
committed
Renamed channel to channelSorted and added the more intuitive channel as aliases in minimodel
git-svn-id: file:///Users/tack/GecodeGitMigration/gecode-svn-mirror/gecode/trunk@11761 e85b7adc-8362-4630-8c63-7469d557c915
1 parent 98abb33 commit eaab1fc

File tree

5 files changed

+33
-6
lines changed

5 files changed

+33
-6
lines changed

examples/steiner.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,8 @@ class Steiner : public Script {
101101
* Using matching constraints
102102
*/
103103

104-
channel(*this, IntVarArgs()<<x1<<x2<<x3, x);
105-
channel(*this, IntVarArgs()<<y1<<y2<<y3, y);
104+
channelSorted(*this, IntVarArgs()<<x1<<x2<<x3, x);
105+
channelSorted(*this, IntVarArgs()<<y1<<y2<<y3, y);
106106
} else if (opt.model() == MODEL_SEQ) {
107107
SetVar sx1 = expr(*this, singleton(x1));
108108
SetVar sx2 = expr(*this, singleton(x2));

gecode/minimodel.hh

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1314,6 +1314,14 @@ namespace Gecode {
13141314
IntVar x(home,0,1); channel(home,b,x);
13151315
return x;
13161316
}
1317+
/// Return set variable equal to \f$\{x_0,\dots,x_{n-1}\}\f$
1318+
inline SetVar
1319+
channel(Home home, const IntVarArgs& x, IntConLevel icl=ICL_DEF) {
1320+
(void) icl;
1321+
SetVar s(home,IntSet::empty,Set::Limits::min,Set::Limits::max);
1322+
rel(home,SOT_UNION,x,s);
1323+
return s;
1324+
}
13171325
//@}
13181326

13191327
}
@@ -1535,6 +1543,25 @@ namespace Gecode {
15351543

15361544
//@}
15371545

1546+
/**
1547+
* \defgroup TaskModelMiniModelSetAlias Aliases for set constraints
1548+
*
1549+
* Contains definitions of common constraints which have different
1550+
* names in Gecode.
1551+
*
1552+
* \ingroup TaskModelMiniModel
1553+
*/
1554+
1555+
//@{
1556+
/** \brief Post propagator for \f$\{x_0,\dots,x_{n-1}\}=y\f$
1557+
*/
1558+
inline void
1559+
channel(Home home, const IntVarArgs& x, SetVar y) {
1560+
rel(home,SOT_UNION,x,y);
1561+
}
1562+
//@}
1563+
1564+
15381565
}
15391566

15401567
namespace Gecode {

gecode/set.hh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -873,7 +873,7 @@ namespace Gecode {
873873

874874
/// Post propagator for \f$\{x_0,\dots,x_{n-1}\}=y\f$ and \f$x_i<x_{i+1}\f$
875875
GECODE_SET_EXPORT void
876-
channel(Home home, const IntVarArgs& x, SetVar y);
876+
channelSorted(Home home, const IntVarArgs& x, SetVar y);
877877

878878
/// Post propagator for \f$x_i=j \Leftrightarrow i\in y_j\f$
879879
GECODE_SET_EXPORT void

gecode/set/int.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,10 +153,10 @@ namespace Gecode {
153153
}
154154

155155
void
156-
channel(Home home, const IntVarArgs& x, SetVar y) {
156+
channelSorted(Home home, const IntVarArgs& x, SetVar y) {
157157
if (home.failed()) return;
158158
ViewArray<IntView> xa(home,x);
159-
GECODE_ES_FAIL(Set::Int::Match<Set::SetView>::post(home,s,xa));
159+
GECODE_ES_FAIL(Set::Int::Match<Set::SetView>::post(home,y,xa));
160160
}
161161

162162
void

test/set/int.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,7 @@ namespace Test { namespace Set {
446446
}
447447
/// Post constraint on \a x
448448
virtual void post(Space& home, SetVarArray& x, IntVarArray& y) {
449-
Gecode::channel(home, y, x[0]);
449+
Gecode::channelSorted(home, y, x[0]);
450450
}
451451
};
452452
Match _match("Int::Match");

0 commit comments

Comments
 (0)