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

Method solution

test/set/dom.cpp:103–159  ·  view source on GitHub ↗

%Test whether \a x is solution

Source from the content-addressed store, hash-verified

101 srt(srt0), is(srt == Gecode::SRT_CMPL ? ds_33c: ds_33) {}
102 /// %Test whether \a x is solution
103 virtual bool solution(const SetAssignment& x) const {
104 for (int i=x.size(); i--; ) {
105 CountableSetRanges xr(x.lub, x[i]);
106 IntSetRanges dr(is);
107 switch (srt) {
108 case SRT_EQ:
109 if (!Iter::Ranges::equal(xr, dr))
110 return false;
111 break;
112 case SRT_LQ:
113 if (!((!xr()) || in(minSymDiff(x,i,is),dr,true)))
114 return false;
115 break;
116 case SRT_LE:
117 if (!(xr() ? in(minSymDiff(x,i,is),dr) : dr()))
118 return false;
119 break;
120 case SRT_GQ:
121 if (!((!dr()) || in(minSymDiff(x,i,is),xr,true)))
122 return false;
123 break;
124 case SRT_GR:
125 if (!(dr() ? in(minSymDiff(x,i,is),xr) : xr()))
126 return false;
127 break;
128 case SRT_NQ:
129 if (Iter::Ranges::equal(xr, dr))
130 return false;
131 break;
132 case SRT_SUB:
133 if (!Iter::Ranges::subset(xr, dr))
134 return false;
135 break;
136 case SRT_SUP:
137 if (!Iter::Ranges::subset(dr, xr))
138 return false;
139 break;
140 case SRT_DISJ:
141 {
142 Gecode::Iter::Ranges::Inter<CountableSetRanges,IntSetRanges>
143 inter(xr, dr);
144 if (inter())
145 return false;
146 }
147 break;
148 case SRT_CMPL:
149 {
150 Gecode::Set::RangesCompl<IntSetRanges> drc(dr);
151 if (!Iter::Ranges::equal(xr,drc))
152 return false;
153 }
154 break;
155 default: GECODE_NEVER;
156 }
157 }
158 return true;
159 }
160 /// Post constraint on \a x

Callers

nothing calls this directly

Calls 6

minSymDiffFunction · 0.85
interFunction · 0.85
inFunction · 0.70
equalFunction · 0.50
subsetFunction · 0.50
sizeMethod · 0.45

Tested by

no test coverage detected