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

Function argmin

gecode/int/arithmetic.cpp:162–186  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

160 }
161
162 void
163 argmin(Home home, const IntVarArgs& x, IntVar y, bool tiebreak,
164 IntPropLevel) {
165 using namespace Int;
166 if (x.size() == 0)
167 throw TooFewArguments("Int::argmin");
168 if (same(x,y))
169 throw ArgumentSame("Int::argmin");
170 GECODE_POST;
171 // Constrain y properly
172 IntView yv(y);
173 GECODE_ME_FAIL(yv.gq(home,0));
174 GECODE_ME_FAIL(yv.le(home,x.size()));
175 // Construct index view array
176 IdxViewArray<MinusView> ix(home,x.size());
177 for (int i=0; i<x.size(); i++) {
178 ix[i].idx=i; ix[i].view=MinusView(x[i]);
179 }
180 if (tiebreak)
181 GECODE_ES_FAIL((Arithmetic::ArgMax<MinusView,IntView,true>
182 ::post(home,ix,yv)));
183 else
184 GECODE_ES_FAIL((Arithmetic::ArgMax<MinusView,IntView,false>
185 ::post(home,ix,yv)));
186 }
187
188 void
189 argmin(Home home, const IntVarArgs& x, int o, IntVar y, bool tiebreak,

Callers 6

postMethod · 0.85
postMethod · 0.85
postMethod · 0.85
postMethod · 0.85
p_minimum_argFunction · 0.85
p_minimum_arg_boolFunction · 0.85

Calls 7

NegBoolViewClass · 0.85
MinusViewClass · 0.70
sameFunction · 0.50
postFunction · 0.50
sizeMethod · 0.45
gqMethod · 0.45
leMethod · 0.45

Tested by

no test coverage detected