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

Function p_global_cardinality_low_up

gecode/flatzinc/registry.cpp:1067–1096  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1065 }
1066
1067 void p_global_cardinality_low_up(FlatZincSpace& s, const ConExpr& ce,
1068 AST::Node* ann) {
1069 IntVarArgs x = s.arg2intvarargs(ce[0]);
1070 IntArgs cover = s.arg2intargs(ce[1]);
1071
1072 IntArgs lbound = s.arg2intargs(ce[2]);
1073 IntArgs ubound = s.arg2intargs(ce[3]);
1074 IntSetArgs y(cover.size());
1075 for (int i=cover.size(); i--;)
1076 y[i] = IntSet(lbound[i],ubound[i]);
1077
1078 IntSet cover_s(cover);
1079 Region re;
1080 IntVarRanges* xrs = re.alloc<IntVarRanges>(x.size());
1081 for (int i=x.size(); i--;)
1082 xrs[i].init(x[i]);
1083 Iter::Ranges::NaryUnion u(re, xrs, x.size());
1084 Iter::Ranges::ToValues<Iter::Ranges::NaryUnion> uv(u);
1085 for (; uv(); ++uv) {
1086 if (!cover_s.in(uv.val())) {
1087 cover << uv.val();
1088 y << IntSet(0,x.size());
1089 }
1090 }
1091 unshare(s, x);
1092 IntPropLevel ipl = s.ann2ipl(ann);
1093 if (ipl==IPL_DEF)
1094 ipl=IPL_BND;
1095 count(s, x, y, cover, ipl);
1096 }
1097
1098 void p_global_cardinality_low_up_closed(FlatZincSpace& s,
1099 const ConExpr& ce,

Callers

nothing calls this directly

Calls 10

IntSetClass · 0.85
unshareFunction · 0.85
arg2intvarargsMethod · 0.80
arg2intargsMethod · 0.80
ann2iplMethod · 0.80
countFunction · 0.50
sizeMethod · 0.45
initMethod · 0.45
inMethod · 0.45
valMethod · 0.45

Tested by

no test coverage detected