MCPcopy Create free account
hub / github.com/Gecode/gecode / rel

Function rel

gecode/set/int.cpp:43–101  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

41namespace Gecode {
42
43 void
44 rel(Home home, SetVar s, IntRelType rt, IntVar x) {
45 GECODE_POST;
46 switch (rt) {
47 case IRT_EQ:
48 {
49 Gecode::Int::IntView xv(x);
50 Set::SingletonView xsingle(xv);
51 GECODE_ES_FAIL(
52 (Set::Rel::Eq<Set::SetView,Set::SingletonView>
53 ::post(home,s,xsingle)));
54
55 }
56 break;
57 case IRT_NQ:
58 {
59 Gecode::Set::SetView sv(s);
60 GECODE_ME_FAIL( sv.cardMin(home, 1));
61 Gecode::Int::IntView xv(x);
62 Set::SingletonView xsingle(xv);
63 GECODE_ES_FAIL(
64 (Set::Rel::NoSubset<Set::SingletonView,Set::SetView>
65 ::post(home,xsingle,sv)));
66
67 }
68 break;
69 case IRT_LQ:
70 {
71 IntVar tmp(home, Int::Limits::min, Int::Limits::max);
72 rel(home, tmp, IRT_LQ, x);
73 GECODE_ES_FAIL(Set::Int::MaxElement<Set::SetView>::post(home,s,tmp));
74 }
75 break;
76 case IRT_LE:
77 {
78 IntVar tmp(home, Int::Limits::min, Int::Limits::max);
79 rel(home, tmp, IRT_LE, x);
80 GECODE_ES_FAIL(Set::Int::MaxElement<Set::SetView>::post(home,s,tmp));
81 }
82 break;
83 case IRT_GQ:
84 {
85 IntVar tmp(home, Int::Limits::min, Int::Limits::max);
86 rel(home, tmp, IRT_GQ, x);
87 GECODE_ES_FAIL(Set::Int::MinElement<Set::SetView>::post(home,s,tmp));
88 }
89 break;
90 case IRT_GR:
91 {
92 IntVar tmp(home, Int::Limits::min, Int::Limits::max);
93 rel(home, tmp, IRT_GR, x);
94 GECODE_ES_FAIL(Set::Int::MinElement<Set::SetView>::post(home,s,tmp));
95 }
96 break;
97 default:
98 throw Int::UnknownRelation("Set::rel");
99 }
100

Callers 2

reminFunction · 0.70
remaxFunction · 0.70

Calls 9

clauseFunction · 0.85
remaxFunction · 0.85
reminFunction · 0.85
cardinalityFunction · 0.70
postFunction · 0.50
BoolVarClass · 0.50
cardMinMethod · 0.45
modeMethod · 0.45
varMethod · 0.45

Tested by

no test coverage detected