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

Function argmax

gecode/int/arithmetic.cpp:109–133  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

107
108
109 void
110 argmax(Home home, const IntVarArgs& x, IntVar y, bool tiebreak,
111 IntPropLevel) {
112 using namespace Int;
113 if (x.size() == 0)
114 throw TooFewArguments("Int::argmax");
115 if (same(x,y))
116 throw ArgumentSame("Int::argmax");
117 GECODE_POST;
118 // Constrain y properly
119 IntView yv(y);
120 GECODE_ME_FAIL(yv.gq(home,0));
121 GECODE_ME_FAIL(yv.le(home,x.size()));
122 // Construct index view array
123 IdxViewArray<IntView> ix(home,x.size());
124 for (int i=0; i<x.size(); i++) {
125 ix[i].idx=i; ix[i].view=x[i];
126 }
127 if (tiebreak)
128 GECODE_ES_FAIL((Arithmetic::ArgMax<IntView,IntView,true>
129 ::post(home,ix,yv)));
130 else
131 GECODE_ES_FAIL((Arithmetic::ArgMax<IntView,IntView,false>
132 ::post(home,ix,yv)));
133 }
134
135 void
136 argmax(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_maximum_argFunction · 0.85
p_maximum_arg_boolFunction · 0.85

Calls 5

sameFunction · 0.50
postFunction · 0.50
sizeMethod · 0.45
gqMethod · 0.45
leMethod · 0.45

Tested by

no test coverage detected