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

Method solution

test/set/rel-op-const.cpp:94–142  ·  view source on GitHub ↗

%Test whether \a x is solution

Source from the content-addressed store, hash-verified

92 , is(iss[intSet]), sot(sot0), srt(srt0), inverse(inverse0) {}
93 /// %Test whether \a x is solution
94 bool solution(const SetAssignment& x) const {
95 IntSetRanges isr(is);
96 CountableSetRanges xr0(x.lub, x[0]);
97 CountableSetRanges xr1(x.lub, x[1]);
98 switch (sot) {
99 case SOT_UNION:
100 {
101 Iter::Ranges::Union<IntSetRanges, CountableSetRanges>
102 u(isr, xr0);
103 return sol(u,xr1);
104 }
105 break;
106 case SOT_DUNION:
107 {
108 Iter::Ranges::Inter<IntSetRanges, CountableSetRanges>
109 inter(isr, xr0);
110 if (inter())
111 return false;
112 Iter::Ranges::Union<IntSetRanges, CountableSetRanges>
113 u(isr,xr0);
114 return sol(u,xr1);
115 }
116 break;
117 case SOT_INTER:
118 {
119 Iter::Ranges::Inter<IntSetRanges, CountableSetRanges>
120 u(isr,xr0);
121 return sol(u,xr1);
122 }
123 break;
124 case SOT_MINUS:
125 {
126 if (!inverse) {
127 Iter::Ranges::Diff<IntSetRanges, CountableSetRanges>
128 u(isr,xr0);
129 return sol(u,xr1);
130 } else {
131 Iter::Ranges::Diff<CountableSetRanges, IntSetRanges>
132 u(xr0,isr);
133 return sol(u,xr1);
134
135 }
136 }
137 break;
138 default: GECODE_NEVER;
139 }
140 GECODE_NEVER;
141 return false;
142 }
143 /// Post constraint on \a x
144 void post(Space& home, SetVarArray& x, IntVarArray&) {
145 if (!inverse)

Callers

nothing calls this directly

Calls 1

interFunction · 0.85

Tested by

no test coverage detected