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

Function min

gecode/minimodel/int-arith.cpp:310–341  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

308 }
309
310 LinIntExpr
311 min(const LinIntExpr& e0, const LinIntExpr& e1) {
312 using namespace MiniModel;
313 int n = 0;
314 if (hasType(e0, ArithNonLinIntExpr::ANLE_MIN))
315 n += static_cast<ArithNonLinIntExpr*>(e0.nle())->n;
316 else
317 n += 1;
318 if (hasType(e1, ArithNonLinIntExpr::ANLE_MIN))
319 n += static_cast<ArithNonLinIntExpr*>(e1.nle())->n;
320 else
321 n += 1;
322 ArithNonLinIntExpr* ae =
323 new ArithNonLinIntExpr(ArithNonLinIntExpr::ANLE_MIN,n);
324 int i=0;
325 if (hasType(e0, ArithNonLinIntExpr::ANLE_MIN)) {
326 ArithNonLinIntExpr* e0e = static_cast<ArithNonLinIntExpr*>(e0.nle());
327 for (; i<e0e->n; i++)
328 ae->a[i] = e0e->a[i];
329 } else {
330 ae->a[i++] = e0;
331 }
332 if (hasType(e1, ArithNonLinIntExpr::ANLE_MIN)) {
333 ArithNonLinIntExpr* e1e = static_cast<ArithNonLinIntExpr*>(e1.nle());
334 int curN = i;
335 for (; i<curN+e1e->n; i++)
336 ae->a[i] = e1e->a[i-curN];
337 } else {
338 ae->a[i++] = e1;
339 }
340 return LinIntExpr(ae);
341 }
342
343 LinIntExpr
344 max(const LinIntExpr& e0, const LinIntExpr& e1) {

Callers 1

postFunction · 0.70

Calls 4

LinIntExprClass · 0.85
nleMethod · 0.80
hasTypeFunction · 0.70
sizeMethod · 0.45

Tested by

no test coverage detected