Generated on Sat Feb 7 2015 02:01:14 for Gecode by doxygen 1.8.9.1
arithmetic.cpp
Go to the documentation of this file.
1 /* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
2 /*
3  * Main authors:
4  * Christian Schulte <schulte@gecode.org>
5  *
6  * Copyright:
7  * Christian Schulte, 2005
8  *
9  * Last modified:
10  * $Date: 2015-01-16 14:10:48 +0100 (Fri, 16 Jan 2015) $ by $Author: schulte $
11  * $Revision: 14362 $
12  *
13  * This file is part of Gecode, the generic constraint
14  * development environment:
15  * http://www.gecode.org
16  *
17  * Permission is hereby granted, free of charge, to any person obtaining
18  * a copy of this software and associated documentation files (the
19  * "Software"), to deal in the Software without restriction, including
20  * without limitation the rights to use, copy, modify, merge, publish,
21  * distribute, sublicense, and/or sell copies of the Software, and to
22  * permit persons to whom the Software is furnished to do so, subject to
23  * the following conditions:
24  *
25  * The above copyright notice and this permission notice shall be
26  * included in all copies or substantial portions of the Software.
27  *
28  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
29  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
30  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
31  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
32  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
33  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
34  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
35  *
36  */
37 
38 #include "test/int.hh"
39 
40 #include <cmath>
41 #include <algorithm>
42 
43 #include <gecode/minimodel.hh>
44 
45 namespace Test { namespace Int {
46 
48  namespace Arithmetic {
49 
55  class MultXYZ : public Test {
57  public:
59  MultXYZ(const std::string& s, const Gecode::IntSet& d,
61  : Test("Arithmetic::Mult::XYZ::"+str(icl)+"::"+s,3,d,false,icl) {}
63  virtual bool solution(const Assignment& x) const {
64  double d0 = static_cast<double>(x[0]);
65  double d1 = static_cast<double>(x[1]);
66  double d2 = static_cast<double>(x[2]);
67  return d0*d1 == d2;
68  }
70  virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) {
71  Gecode::mult(home, x[0], x[1], x[2], icl);
72  }
73  };
74 
76  class MultXXY : public Test {
77  public:
79  MultXXY(const std::string& s, const Gecode::IntSet& d,
81  : Test("Arithmetic::Mult::XXY::"+str(icl)+"::"+s,2,d,false,icl) {}
83  virtual bool solution(const Assignment& x) const {
84  double d0 = static_cast<double>(x[0]);
85  double d1 = static_cast<double>(x[0]);
86  double d2 = static_cast<double>(x[1]);
87  return d0*d1 == d2;
88  }
90  virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) {
91  Gecode::mult(home, x[0], x[0], x[1], icl);
92  }
93  };
94 
96  class MultXYX : public Test {
97  public:
99  MultXYX(const std::string& s, const Gecode::IntSet& d,
101  : Test("Arithmetic::Mult::XYX::"+str(icl)+"::"+s,2,d,false,icl) {}
103  virtual bool solution(const Assignment& x) const {
104  double d0 = static_cast<double>(x[0]);
105  double d1 = static_cast<double>(x[1]);
106  double d2 = static_cast<double>(x[0]);
107  return d0*d1 == d2;
108  }
110  virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) {
111  Gecode::mult(home, x[0], x[1], x[0], icl);
112  }
113  };
114 
116  class MultXYY : public Test {
117  public:
119  MultXYY(const std::string& s, const Gecode::IntSet& d,
121  : Test("Arithmetic::Mult::XYY::"+str(icl)+"::"+s,2,d,false,icl) {}
123  virtual bool solution(const Assignment& x) const {
124  double d0 = static_cast<double>(x[0]);
125  double d1 = static_cast<double>(x[1]);
126  double d2 = static_cast<double>(x[1]);
127  return d0*d1 == d2;
128  }
130  virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) {
131  Gecode::mult(home, x[0], x[1], x[1], icl);
132  }
133  };
134 
136  class MultXXX : public Test {
137  public:
139  MultXXX(const std::string& s, const Gecode::IntSet& d,
141  : Test("Arithmetic::Mult::XXX::"+str(icl)+"::"+s,1,d,false,icl) {}
143  virtual bool solution(const Assignment& x) const {
144  double d0 = static_cast<double>(x[0]);
145  double d1 = static_cast<double>(x[0]);
146  double d2 = static_cast<double>(x[0]);
147  return d0*d1 == d2;
148  }
150  virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) {
151  Gecode::mult(home, x[0], x[0], x[0], icl);
152  }
153  };
154 
156  class SqrXY : public Test {
157  public:
159  SqrXY(const std::string& s, const Gecode::IntSet& d,
161  : Test("Arithmetic::Sqr::XY::"+str(icl)+"::"+s,2,d,false,icl) {}
163  virtual bool solution(const Assignment& x) const {
164  double d0 = static_cast<double>(x[0]);
165  double d1 = static_cast<double>(x[1]);
166  return d0*d0 == d1;
167  }
169  virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) {
170  Gecode::sqr(home, x[0], x[1], icl);
171  }
172  };
173 
175  class SqrXX : public Test {
176  public:
178  SqrXX(const std::string& s, const Gecode::IntSet& d,
180  : Test("Arithmetic::Sqr::XX::"+str(icl)+"::"+s,1,d,false,icl) {}
182  virtual bool solution(const Assignment& x) const {
183  double d0 = static_cast<double>(x[0]);
184  return d0*d0 == d0;
185  }
187  virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) {
188  Gecode::sqr(home, x[0], x[0], icl);
189  }
190  };
191 
193  class SqrtXY : public Test {
194  public:
196  SqrtXY(const std::string& s, const Gecode::IntSet& d,
198  : Test("Arithmetic::Sqrt::XY::"+str(icl)+"::"+s,2,d,false,icl) {}
200  virtual bool solution(const Assignment& x) const {
201  double d0 = static_cast<double>(x[0]);
202  double d1 = static_cast<double>(x[1]);
203  return (d0 >= 0) && (d0 >= d1*d1) && (d0 < (d1+1)*(d1+1));
204  }
206  virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) {
207  Gecode::sqrt(home, x[0], x[1], icl);
208  }
209  };
210 
212  class SqrtXX : public Test {
213  public:
215  SqrtXX(const std::string& s, const Gecode::IntSet& d,
217  : Test("Arithmetic::Sqrt::XX::"+str(icl)+"::"+s,1,d,false,icl) {}
219  virtual bool solution(const Assignment& x) const {
220  double d0 = static_cast<double>(x[0]);
221  return (d0 >= 0) && (d0 >= d0*d0) && (d0 < (d0+1)*(d0+1));
222  }
224  virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) {
225  Gecode::sqrt(home, x[0], x[0], icl);
226  }
227  };
228 
230  class PowXY : public Test {
231  protected:
233  int n;
234  public:
236  PowXY(const std::string& s, int n0, const Gecode::IntSet& d,
238  : Test("Arithmetic::Pow::XY::"+str(n0)+"::"+str(icl)+"::"+s,
239  2,d,false,icl), n(n0) {}
241  virtual bool solution(const Assignment& x) const {
242  long long int p = 1;
243  for (int i=0; i<n; i++) {
244  p *= x[0];
245  if ((p < Gecode::Int::Limits::min) ||
247  return false;
248  }
249  return p == x[1];
250  }
252  virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) {
253  using namespace Gecode;
254  if (n > 4)
255  pow(home, x[0], n, x[1], icl);
256  else
257  rel(home, expr(home, pow(x[0],n), icl), IRT_EQ, x[1], icl);
258  }
259  };
260 
262  class PowXX : public Test {
263  protected:
265  int n;
266  public:
268  PowXX(const std::string& s, int n0, const Gecode::IntSet& d,
270  : Test("Arithmetic::Pow::XX::"+str(n0)+"::"+str(icl)+"::"+s,
271  1,d,false,icl), n(n0) {}
273  virtual bool solution(const Assignment& x) const {
274  long long int p = 1;
275  for (int i=0; i<n; i++) {
276  p *= x[0];
277  if ((p < Gecode::Int::Limits::min) ||
279  return false;
280  }
281  return p == x[0];
282  }
284  virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) {
285  Gecode::pow(home, x[0], n, x[0], icl);
286  }
287  };
288 
289  bool powgr(int n, long long int r, int x) {
290  assert(r >= 0);
291  long long int y = r;
292  long long int p = 1;
293  do {
294  p *= y; n--;
295  if (p > x)
296  return true;
297  } while (n > 0);
298  return false;
299  }
300 
301  int fnroot(int n, int x) {
302  if (x < 2)
303  return x;
304  /*
305  * We look for l such that: l^n <= x < (l+1)^n
306  */
307  long long int l = 1;
308  long long int u = x;
309  do {
310  long long int m = (l + u) >> 1;
311  if (powgr(n,m,x)) u=m; else l=m;
312  } while (l+1 < u);
313  return static_cast<int>(l);
314  }
315 
316  bool powle(int n, long long int r, int x) {
317  assert(r >= 0);
318  long long int y = r;
319  long long int p = 1;
320  do {
321  p *= y; n--;
322  if (p >= x)
323  return false;
324  } while (n > 0);
325  assert(y < x);
326  return true;
327  }
328 
329  int cnroot(int n, int x) {
330  if (x < 2)
331  return x;
332  /*
333  * We look for u such that: (u-1)^n < x <= u^n
334  */
335  long long int l = 1;
336  long long int u = x;
337  do {
338  long long int m = (l + u) >> 1;
339  if (powle(n,m,x)) l=m; else u=m;
340  } while (l+1 < u);
341  return static_cast<int>(u);
342  }
343 
345  class NrootXY : public Test {
346  protected:
348  int n;
350  public:
352  NrootXY(const std::string& s, int n0, const Gecode::IntSet& d,
354  : Test("Arithmetic::Nroot::XY::"+str(n0)+"::"+str(icl)+"::"+s,
355  2,d,false,icl), n(n0) {}
357  virtual bool solution(const Assignment& x) const {
358  if (n == 1)
359  return x[0] == x[1];
360  if ((n % 2 == 0) && ((x[0] < 0) || (x[1] < 0)))
361  return false;
362  int r = (x[0] < 0) ? -cnroot(n,-x[0]) : fnroot(n,x[0]);
363  return r == x[1];
364  }
366  virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) {
367  using namespace Gecode;
368  if (n > 4)
369  nroot(home, x[0], n, x[1], icl);
370  else
371  rel(home, expr(home, nroot(x[0],n), icl), IRT_EQ, x[1], icl);
372  }
373  };
374 
376  class NrootXX : public Test {
377  protected:
379  int n;
380  public:
382  NrootXX(const std::string& s, int n0, const Gecode::IntSet& d,
384  : Test("Arithmetic::Nroot::XX::"+str(n0)+"::"+str(icl)+"::"+s,
385  1,d,false,icl), n(n0) {}
387  virtual bool solution(const Assignment& x) const {
388  if (n == 1)
389  return true;
390  if (n % 2 == 0) {
391  return (x[0] >= 0) && (x[0] <= 1);
392  } else {
393  return (x[0] >= -2) && (x[0] <= 1);
394  }
395  }
397  virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) {
398  Gecode::nroot(home, x[0], n, x[0], icl);
399  }
400  };
401 
403  class DivMod : public Test {
404  private:
406  static int abs(int a) { return a<0 ? -a:a; }
408  static int sgn(int a) { return a<0 ? -1:1; }
409  public:
411  DivMod(const std::string& s, const Gecode::IntSet& d)
412  : Test("Arithmetic::DivMod::"+s,4,d) {}
414  virtual bool solution(const Assignment& x) const {
415  return x[0] == x[1]*x[2]+x[3] &&
416  abs(x[3]) < abs(x[1]) &&
417  (x[3] == 0 || sgn(x[3]) == sgn(x[0]));
418  }
420  virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) {
421  Gecode::divmod(home, x[0], x[1], x[2], x[3]);
422  }
423  };
424 
426  class Div : public Test {
427  public:
429  Div(const std::string& s, const Gecode::IntSet& d)
430  : Test("Arithmetic::Div::"+s,3,d) {}
432  virtual bool solution(const Assignment& x) const {
433  if (x[1] == 0)
434  return false;
435  int divsign = (x[0] / x[1] < 0) ? -1 : 1;
436  int divresult =
437  divsign *
438  static_cast<int>(floor(static_cast<double>(std::abs(x[0]))/
439  static_cast<double>(std::abs(x[1]))));
440  return x[2] == divresult;
441  }
443  virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) {
444  Gecode::div(home, x[0], x[1], x[2]);
445  }
446  };
447 
449  class Mod : public Test {
450  public:
452  Mod(const std::string& s, const Gecode::IntSet& d)
453  : Test("Arithmetic::Mod::"+s,3,d) {}
455  virtual bool solution(const Assignment& x) const {
456  if (x[1] == 0)
457  return false;
458  int divsign = (x[0] / x[1] < 0) ? -1 : 1;
459  int divresult =
460  divsign *
461  static_cast<int>(floor(static_cast<double>(std::abs(x[0]))/
462  static_cast<double>(std::abs(x[1]))));
463  return x[0] == x[1]*divresult+x[2];
464  }
466  virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) {
467  Gecode::mod(home, x[0], x[1], x[2]);
468  }
469  };
470 
472  class AbsXY : public Test {
473  public:
475  AbsXY(const std::string& s, const Gecode::IntSet& d,
477  : Test("Arithmetic::Abs::XY::"+str(icl)+"::"+s,2,d,false,icl) {}
479  virtual bool solution(const Assignment& x) const {
480  double d0 = static_cast<double>(x[0]);
481  double d1 = static_cast<double>(x[1]);
482  return (d0<0 ? -d0 : d0) == d1;
483  }
485  virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) {
486  Gecode::abs(home, x[0], x[1], icl);
487  }
488  };
489 
491  class AbsXX : public Test {
492  public:
494  AbsXX(const std::string& s, const Gecode::IntSet& d,
496  : Test("Arithmetic::Abs::XX::"+str(icl)+"::"+s,1,d,false,icl) {}
498  virtual bool solution(const Assignment& x) const {
499  double d0 = static_cast<double>(x[0]);
500  double d1 = static_cast<double>(x[0]);
501  return (d0<0 ? -d0 : d0) == d1;
502  }
504  virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) {
505  Gecode::abs(home, x[0], x[0], icl);
506  }
507  };
508 
510  class MinXYZ : public Test {
511  public:
513  MinXYZ(const std::string& s, const Gecode::IntSet& d,
515  : Test("Arithmetic::Min::Bin::XYZ::"+str(icl)+"::"+s,3,d,false,icl) {}
517  virtual bool solution(const Assignment& x) const {
518  return std::min(x[0],x[1]) == x[2];
519  }
521  virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) {
522  Gecode::min(home, x[0], x[1], x[2], icl);
523  }
524  };
525 
527  class MinXXY : public Test {
528  public:
530  MinXXY(const std::string& s, const Gecode::IntSet& d,
532  : Test("Arithmetic::Min::Bin::XYX::"+str(icl)+"::"+s,2,d) {}
534  virtual bool solution(const Assignment& x) const {
535  return std::min(x[0],x[0]) == x[1];
536  }
538  virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) {
539  Gecode::min(home, x[0], x[0], x[1], icl);
540  }
541  };
542 
544  class MinXYX : public Test {
545  public:
547  MinXYX(const std::string& s, const Gecode::IntSet& d,
549  : Test("Arithmetic::Min::Bin::XYX::"+str(icl)+"::"+s,2,d) {}
551  virtual bool solution(const Assignment& x) const {
552  return std::min(x[0],x[1]) == x[0];
553  }
555  virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) {
556  Gecode::min(home, x[0], x[1], x[0], icl);
557  }
558  };
559 
561  class MinXYY : public Test {
562  public:
564  MinXYY(const std::string& s, const Gecode::IntSet& d,
566  : Test("Arithmetic::Min::Bin::XYY::"+str(icl)+"::"+s,2,d) {}
568  virtual bool solution(const Assignment& x) const {
569  return std::min(x[0],x[1]) == x[1];
570  }
572  virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) {
573  Gecode::min(home, x[0], x[1], x[1], icl);
574  }
575  };
576 
578  class MinXXX : public Test {
579  public:
581  MinXXX(const std::string& s, const Gecode::IntSet& d,
583  : Test("Arithmetic::Min::Bin::XXX::"+str(icl)+"::"+s,1,d) {}
585  virtual bool solution(const Assignment& x) const {
586  return std::min(x[0],x[0]) == x[0];
587  }
589  virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) {
590  Gecode::min(home, x[0], x[0], x[0], icl);
591  }
592  };
593 
595  class MaxXYZ : public Test {
596  public:
598  MaxXYZ(const std::string& s, const Gecode::IntSet& d,
600  : Test("Arithmetic::Max::Bin::XYZ::"+str(icl)+"::"+s,3,d) {
602  }
604  virtual bool solution(const Assignment& x) const {
605  return std::max(x[0],x[1]) == x[2];
606  }
608  virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) {
609  Gecode::max(home, x[0], x[1], x[2], icl);
610  }
611  };
612 
614  class MaxXXY : public Test {
615  public:
617  MaxXXY(const std::string& s, const Gecode::IntSet& d,
619  : Test("Arithmetic::Max::Bin::XXY::"+str(icl)+"::"+s,2,d) {}
621  virtual bool solution(const Assignment& x) const {
622  return std::max(x[0],x[0]) == x[1];
623  }
625  virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) {
626  Gecode::max(home, x[0], x[0], x[1], icl);
627  }
628  };
629 
631  class MaxXYX : public Test {
632  public:
634  MaxXYX(const std::string& s, const Gecode::IntSet& d,
636  : Test("Arithmetic::Max::Bin::XYX::"+str(icl)+"::"+s,2,d) {}
638  virtual bool solution(const Assignment& x) const {
639  return std::max(x[0],x[1]) == x[0];
640  }
642  virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) {
643  Gecode::max(home, x[0], x[1], x[0], icl);
644  }
645  };
646 
648  class MaxXYY : public Test {
649  public:
651  MaxXYY(const std::string& s, const Gecode::IntSet& d,
653  : Test("Arithmetic::Max::Bin::XYY::"+str(icl)+"::"+s,2,d) {}
655  virtual bool solution(const Assignment& x) const {
656  return std::max(x[0],x[1]) == x[1];
657  }
659  virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) {
660  Gecode::max(home, x[0], x[1], x[1], icl);
661  }
662  };
663 
665  class MaxXXX : public Test {
666  public:
668  MaxXXX(const std::string& s, const Gecode::IntSet& d,
670  : Test("Arithmetic::Max::Bin::XXX::"+str(icl)+"::"+s,1,d) {}
672  virtual bool solution(const Assignment& x) const {
673  return std::max(x[0],x[0]) == x[0];
674  }
676  virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) {
677  Gecode::max(home, x[0], x[0], x[0], icl);
678  }
679  };
680 
682  class MinNary : public Test {
683  public:
686  : Test("Arithmetic::Min::Nary::"+str(icl),4,-4,4,false,icl) {}
688  virtual bool solution(const Assignment& x) const {
689  return std::min(std::min(x[0],x[1]), x[2]) == x[3];
690  }
692  virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) {
693  Gecode::IntVarArgs m(3);
694  m[0]=x[0]; m[1]=x[1]; m[2]=x[2];
695  Gecode::min(home, m, x[3], icl);
696  }
697  };
698 
700  class MinNaryShared : public Test {
701  public:
704  : Test("Arithmetic::Min::Nary::Shared::"+str(icl),3,-4,4,false,icl) {}
706  virtual bool solution(const Assignment& x) const {
707  return std::min(std::min(x[0],x[1]), x[2]) == x[1];
708  }
710  virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) {
711  Gecode::IntVarArgs m(3);
712  m[0]=x[0]; m[1]=x[1]; m[2]=x[2];
713  Gecode::min(home, m, x[1], icl);
714  }
715  };
716 
718  class MaxNary : public Test {
719  public:
722  : Test("Arithmetic::Max::Nary::"+str(icl),4,-4,4,false,icl) {}
724  virtual bool solution(const Assignment& x) const {
725  return std::max(std::max(x[0],x[1]), x[2]) == x[3];
726  }
728  virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) {
729  Gecode::IntVarArgs m(3);
730  m[0]=x[0]; m[1]=x[1]; m[2]=x[2];
731  Gecode::max(home, m, x[3], icl);
732  }
733  };
734 
736  class MaxNaryShared : public Test {
737  public:
740  : Test("Arithmetic::Max::Nary::Shared::"+str(icl),3,-4,4,false,icl) {}
742  virtual bool solution(const Assignment& x) const {
743  return std::max(std::max(x[0],x[1]), x[2]) == x[1];
744  }
746  virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) {
747  Gecode::IntVarArgs m(3);
748  m[0]=x[0]; m[1]=x[1]; m[2]=x[2];
749  Gecode::max(home, m, x[1], icl);
750  }
751  };
752 
754  class ArgMax : public Test {
755  protected:
757  bool tiebreak;
758  public:
760  ArgMax(int n, bool tb)
761  : Test("Arithmetic::ArgMax::"+str(tb)+"::"+str(n),n+1,0,n+1,
762  false,tb ? Gecode::ICL_DEF : Gecode::ICL_DOM),
763  tiebreak(tb) {}
765  virtual bool solution(const Assignment& x) const {
766  int n=x.size()-1;
767  if ((x[n] < 0) || (x[n] >= n))
768  return false;
769  int m=x[0]; int p=0;
770  for (int i=1; i<n; i++)
771  if (x[i] > m) {
772  p=i; m=x[i];
773  }
774  return tiebreak ? (p == x[n]) : (m == x[x[n]]);
775  }
777  virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) {
778  int n=x.size()-1;
779  Gecode::IntVarArgs m(n);
780  for (int i=0; i<n; i++)
781  m[i]=x[i];
782  Gecode::argmax(home, m, x[n], tiebreak);
783  }
784  };
785 
787  class ArgMaxShared : public Test {
788  protected:
790  bool tiebreak;
791  public:
793  ArgMaxShared(int n, bool tb)
794  : Test("Arithmetic::ArgMax::Shared::"+str(tb)+"::"+str(n),n+1,0,n+1,
795  false),
796  tiebreak(tb) {}
798  virtual bool solution(const Assignment& x) const {
799  int n=x.size()-1;
800  if ((x[n] < 0) || (x[n] >= 2*n))
801  return false;
802  Gecode::IntArgs y(2*n);
803  for (int i=0; i<n; i++)
804  y[2*i+0]=y[2*i+1]=x[i];
805  int m=y[0]; int p=0;
806  for (int i=1; i<2*n; i++)
807  if (y[i] > m) {
808  p=i; m=y[i];
809  }
810  return tiebreak ? (p == x[n]) : (m == y[x[n]]);
811  }
813  virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) {
814  int n=x.size()-1;
815  Gecode::IntVarArgs m(2*n);
816  for (int i=0; i<n; i++)
817  m[2*i+0]=m[2*i+1]=x[i];
818  Gecode::argmax(home, m, x[n], tiebreak);
819  }
820  };
821 
823  class ArgMin : public Test {
824  protected:
826  bool tiebreak;
827  public:
829  ArgMin(int n, bool tb)
830  : Test("Arithmetic::ArgMin::"+str(tb)+"::"+str(n),n+1,0,n+1,
831  false,tb ? Gecode::ICL_DEF : Gecode::ICL_DOM),
832  tiebreak(tb) {}
834  virtual bool solution(const Assignment& x) const {
835  int n=x.size()-1;
836  if ((x[n] < 0) || (x[n] >= n))
837  return false;
838  int m=x[0]; int p=0;
839  for (int i=1; i<n; i++)
840  if (x[i] < m) {
841  p=i; m=x[i];
842  }
843  return tiebreak ? (p == x[n]) : (m == x[x[n]]);
844  }
846  virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) {
847  int n=x.size()-1;
848  Gecode::IntVarArgs m(n);
849  for (int i=0; i<n; i++)
850  m[i]=x[i];
851  Gecode::argmin(home, m, x[n], tiebreak);
852  }
853  };
854 
856  class ArgMinShared : public Test {
857  protected:
859  bool tiebreak;
860  public:
862  ArgMinShared(int n, bool tb)
863  : Test("Arithmetic::ArgMin::Shared::"+str(tb)+"::"+str(n),n+1,0,n+1,
864  false),
865  tiebreak(tb) {}
867  virtual bool solution(const Assignment& x) const {
868  int n=x.size()-1;
869  if ((x[n] < 0) || (x[n] >= 2*n))
870  return false;
871  Gecode::IntArgs y(2*n);
872  for (int i=0; i<n; i++)
873  y[2*i+0]=y[2*i+1]=x[i];
874  int m=y[0]; int p=0;
875  for (int i=1; i<2*n; i++)
876  if (y[i] < m) {
877  p=i; m=y[i];
878  }
879  return tiebreak ? (p == x[n]) : (m == y[x[n]]);
880  }
882  virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) {
883  int n=x.size()-1;
884  Gecode::IntVarArgs m(2*n);
885  for (int i=0; i<n; i++)
886  m[2*i+0]=m[2*i+1]=x[i];
887  Gecode::argmin(home, m, x[n], tiebreak);
888  }
889  };
890 
891 
892 
894  class Create {
895  public:
897  Create(void) {
898 
899  const int va[7] = {
901  -1,0,1,
902  Gecode::Int::Limits::max-1, Gecode::Int::Limits::max
903  };
904  const int vb[9] = {
905  static_cast<int>(-sqrt(static_cast<double>
907  -4,-2,-1,0,1,2,4,
908  static_cast<int>(sqrt(static_cast<double>
910  };
911 
912  Gecode::IntSet a(va,7);
913  Gecode::IntSet b(vb,9);
914  Gecode::IntSet c(-8,8);
915  Gecode::IntSet d(-70,70);
916 
917  (void) new DivMod("A",a);
918  (void) new DivMod("B",b);
919  (void) new DivMod("C",c);
920 
921  (void) new Div("A",a);
922  (void) new Div("B",b);
923  (void) new Div("C",c);
924 
925  (void) new Mod("A",a);
926  (void) new Mod("B",b);
927  (void) new Mod("C",c);
928 
929 
930  for (IntConLevels icls; icls(); ++icls)
931  if (icls.icl() != Gecode::ICL_VAL) {
932  (void) new MultXYZ("A",a,icls.icl());
933  (void) new MultXYZ("B",b,icls.icl());
934  (void) new MultXYZ("C",c,icls.icl());
935 
936  (void) new MultXXY("A",a,icls.icl());
937  (void) new MultXXY("B",b,icls.icl());
938  (void) new MultXXY("C",c,icls.icl());
939 
940  (void) new MultXYX("A",a,icls.icl());
941  (void) new MultXYX("B",b,icls.icl());
942  (void) new MultXYX("C",c,icls.icl());
943 
944  (void) new MultXYY("A",a,icls.icl());
945  (void) new MultXYY("B",b,icls.icl());
946  (void) new MultXYY("C",c,icls.icl());
947 
948  (void) new MultXXX("A",a,icls.icl());
949  (void) new MultXXX("B",b,icls.icl());
950  (void) new MultXXX("C",c,icls.icl());
951 
952  (void) new SqrXY("A",a,icls.icl());
953  (void) new SqrXY("B",b,icls.icl());
954  (void) new SqrXY("C",c,icls.icl());
955 
956  (void) new SqrXX("A",a,icls.icl());
957  (void) new SqrXX("B",b,icls.icl());
958  (void) new SqrXX("C",c,icls.icl());
959 
960  for (int n=0; n<=6; n++) {
961  (void) new PowXY("A",n,a,icls.icl());
962  (void) new PowXY("B",n,b,icls.icl());
963  (void) new PowXY("C",n,c,icls.icl());
964  (void) new PowXY("D",n,d,icls.icl());
965 
966  (void) new PowXX("A",n,a,icls.icl());
967  (void) new PowXX("B",n,b,icls.icl());
968  (void) new PowXX("C",n,c,icls.icl());
969  (void) new PowXX("D",n,d,icls.icl());
970  }
971 
972  for (int n=1; n<=6; n++) {
973  (void) new NrootXY("A",n,a,icls.icl());
974  (void) new NrootXY("B",n,b,icls.icl());
975  (void) new NrootXY("C",n,c,icls.icl());
976  (void) new NrootXY("D",n,d,icls.icl());
977 
978  (void) new NrootXX("A",n,a,icls.icl());
979  (void) new NrootXX("B",n,b,icls.icl());
980  (void) new NrootXX("C",n,c,icls.icl());
981  (void) new NrootXX("D",n,d,icls.icl());
982  }
983 
984  for (int n=30; n<=34; n++) {
985  (void) new PowXY("C",n,c,icls.icl());
986  (void) new PowXX("C",n,c,icls.icl());
987  (void) new NrootXY("C",n,c,icls.icl());
988  (void) new NrootXX("C",n,c,icls.icl());
989  }
990 
991  (void) new SqrtXY("A",a,icls.icl());
992  (void) new SqrtXY("B",b,icls.icl());
993  (void) new SqrtXY("C",c,icls.icl());
994 
995  (void) new SqrtXX("A",a,icls.icl());
996  (void) new SqrtXX("B",b,icls.icl());
997  (void) new SqrtXX("C",c,icls.icl());
998 
999  (void) new AbsXY("A",a,icls.icl());
1000  (void) new AbsXY("B",b,icls.icl());
1001  (void) new AbsXY("C",c,icls.icl());
1002 
1003  (void) new AbsXX("A",a,icls.icl());
1004  (void) new AbsXX("B",b,icls.icl());
1005  (void) new AbsXX("C",c,icls.icl());
1006 
1007  (void) new MinXYZ("A",a,icls.icl());
1008  (void) new MinXYZ("B",b,icls.icl());
1009  (void) new MinXYZ("C",c,icls.icl());
1010 
1011  (void) new MinXXY("A",a,icls.icl());
1012  (void) new MinXXY("B",b,icls.icl());
1013  (void) new MinXXY("C",c,icls.icl());
1014 
1015  (void) new MinXYX("A",a,icls.icl());
1016  (void) new MinXYX("B",b,icls.icl());
1017  (void) new MinXYX("C",c,icls.icl());
1018 
1019  (void) new MinXYY("A",a,icls.icl());
1020  (void) new MinXYY("B",b,icls.icl());
1021  (void) new MinXYY("C",c,icls.icl());
1022 
1023  (void) new MinXXX("A",a,icls.icl());
1024  (void) new MinXXX("B",b,icls.icl());
1025  (void) new MinXXX("C",c,icls.icl());
1026 
1027  (void) new MaxXYZ("A",a,icls.icl());
1028  (void) new MaxXYZ("B",b,icls.icl());
1029  (void) new MaxXYZ("C",c,icls.icl());
1030 
1031  (void) new MaxXXY("A",a,icls.icl());
1032  (void) new MaxXXY("B",b,icls.icl());
1033  (void) new MaxXXY("C",c,icls.icl());
1034 
1035  (void) new MaxXYX("A",a,icls.icl());
1036  (void) new MaxXYX("B",b,icls.icl());
1037  (void) new MaxXYX("C",c,icls.icl());
1038 
1039  (void) new MaxXYY("A",a,icls.icl());
1040  (void) new MaxXYY("B",b,icls.icl());
1041  (void) new MaxXYY("C",c,icls.icl());
1042 
1043  (void) new MaxXXX("A",a,icls.icl());
1044  (void) new MaxXXX("B",b,icls.icl());
1045  (void) new MaxXXX("C",c,icls.icl());
1046 
1047  (void) new MinNary(icls.icl());
1048  (void) new MinNaryShared(icls.icl());
1049  (void) new MaxNary(icls.icl());
1050  (void) new MaxNaryShared(icls.icl());
1051  }
1052  for (int i=1; i<5; i++) {
1053  (void) new ArgMax(i,true);
1054  (void) new ArgMaxShared(i,true);
1055  (void) new ArgMin(i,true);
1056  (void) new ArgMinShared(i,true);
1057  (void) new ArgMax(i,false);
1058  (void) new ArgMaxShared(i,false);
1059  (void) new ArgMin(i,false);
1060  (void) new ArgMinShared(i,false);
1061  }
1062  }
1063  };
1064 
1067 
1068  }
1069 }}
1070 
1071 // STATISTICS: test-int
Test for power constraint
Definition: arithmetic.cpp:230
Test for multiplication constraint
Definition: arithmetic.cpp:56
PowXY(const std::string &s, int n0, const Gecode::IntSet &d, Gecode::IntConLevel icl)
Create and register test.
Definition: arithmetic.cpp:236
Test for argument maximum constraint with shared variables
Definition: arithmetic.cpp:787
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
Definition: arithmetic.cpp:608
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
Definition: arithmetic.cpp:70
Test for binary minimum constraint with shared variables
Definition: arithmetic.cpp:561
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
Definition: arithmetic.cpp:777
Test for binary minimum constraint with shared variables
Definition: arithmetic.cpp:578
IntConLevel
Consistency levels for integer propagators.
Definition: int.hh:937
void mult(Home home, FloatVar x0, FloatVar x1, FloatVar x2)
Post propagator for .
Definition: arithmetic.cpp:96
bool tiebreak
Whether to use tie-breaking.
Definition: arithmetic.cpp:826
NNF * l
Left subtree.
Definition: bool-expr.cpp:244
void mod(Home home, IntVar x0, IntVar x1, IntVar x2, IntConLevel icl)
Post propagator for .
Definition: arithmetic.cpp:213
Test for binary maximum constraint with shared variables
Definition: arithmetic.cpp:648
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
Definition: arithmetic.cpp:366
Test for binary maximum constraint with shared variables
Definition: arithmetic.cpp:665
AbsXY(const std::string &s, const Gecode::IntSet &d, Gecode::IntConLevel icl)
Create and register test.
Definition: arithmetic.cpp:475
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
Definition: arithmetic.cpp:252
virtual bool solution(const Assignment &x) const
Test whether x is solution
Definition: arithmetic.cpp:585
Test for argument minimum constraint with shared variables
Definition: arithmetic.cpp:856
Test for squaring constraint
Definition: arithmetic.cpp:156
Help class to create and register tests.
Definition: arithmetic.cpp:894
MultXYY(const std::string &s, const Gecode::IntSet &d, Gecode::IntConLevel icl)
Create and register test.
Definition: arithmetic.cpp:119
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
Definition: arithmetic.cpp:813
virtual bool solution(const Assignment &x) const
Test whether x is solution
Definition: arithmetic.cpp:387
Test for argument maximum constraint
Definition: arithmetic.cpp:754
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
Definition: arithmetic.cpp:504
MultXXX(const std::string &s, const Gecode::IntSet &d, Gecode::IntConLevel icl)
Create and register test.
Definition: arithmetic.cpp:139
virtual bool solution(const Assignment &x) const
Test whether x is solution
Definition: arithmetic.cpp:123
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
Definition: arithmetic.cpp:676
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
Definition: arithmetic.cpp:882
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
Definition: arithmetic.cpp:572
virtual bool solution(const Assignment &x) const
Test whether x is solution
Definition: arithmetic.cpp:219
void max(Home home, FloatVar x0, FloatVar x1, FloatVar x2)
Post propagator for .
Definition: arithmetic.cpp:57
Value propagation or consistency (naive)
Definition: int.hh:938
void abs(Home home, FloatVar x0, FloatVar x1)
Post propagator for .
Definition: arithmetic.cpp:49
virtual bool solution(const Assignment &x) const
Test whether x is solution
Definition: arithmetic.cpp:672
void nroot(Home home, FloatVar x0, int n, FloatVar x1)
Post propagator for for $n 0$.
Definition: arithmetic.cpp:126
bool tiebreak
Whether to use tie-breaking.
Definition: arithmetic.cpp:757
MinXYY(const std::string &s, const Gecode::IntSet &d, Gecode::IntConLevel icl)
Create and register test.
Definition: arithmetic.cpp:564
void pow(Home home, FloatVar x0, int n, FloatVar x1)
Post propagator for for $n 0$.
Definition: arithmetic.cpp:117
bool powle(int n, long long int r, int x)
Definition: arithmetic.cpp:316
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
Definition: arithmetic.cpp:187
Test for multiplication constraint with shared variables
Definition: arithmetic.cpp:116
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
Definition: arithmetic.cpp:130
virtual bool solution(const Assignment &x) const
Test whether x is solution
Definition: arithmetic.cpp:867
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
Definition: arithmetic.cpp:110
Iterator for integer consistency levels.
Definition: int.hh:324
Integer variable array.
Definition: int.hh:741
ArgMin(int n, bool tb)
Create and register test.
Definition: arithmetic.cpp:829
virtual bool solution(const Assignment &x) const
Test whether x is solution
Definition: arithmetic.cpp:706
virtual bool solution(const Assignment &x) const
Test whether x is solution
Definition: arithmetic.cpp:103
MinXXX(const std::string &s, const Gecode::IntSet &d, Gecode::IntConLevel icl)
Create and register test.
Definition: arithmetic.cpp:581
NrootXX(const std::string &s, int n0, const Gecode::IntSet &d, Gecode::IntConLevel icl)
Create and register test.
Definition: arithmetic.cpp:382
void min(Home home, const IntVarArgs &x, IntVar y, IntConLevel icl)
Post propagator for .
Definition: arithmetic.cpp:95
Test for binary minimum constraint
Definition: arithmetic.cpp:510
void pow(Home home, IntVar x0, int n, IntVar x1, IntConLevel icl)
Post propagator for .
Definition: arithmetic.cpp:250
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
Definition: arithmetic.cpp:538
ConTestLevel contest
Whether to test for certain consistency.
Definition: int.hh:228
const int max
Largest allowed integer value.
Definition: int.hh:113
Computation spaces.
Definition: core.hpp:1362
Test for binary maximum constraint
Definition: arithmetic.cpp:595
MinXYZ(const std::string &s, const Gecode::IntSet &d, Gecode::IntConLevel icl)
Create and register test.
Definition: arithmetic.cpp:513
const int min
Smallest allowed integer value.
Definition: int.hh:115
void argmin(Home home, const IntVarArgs &x, IntVar y, bool tiebreak, IntConLevel)
Post propagator for .
Definition: arithmetic.cpp:140
Mod(const std::string &s, const Gecode::IntSet &d)
Create and register test.
Definition: arithmetic.cpp:452
Gecode::IntSet d1(v1, 7)
Gecode::IntSet d(v, 7)
Test for n-ary maximum constraint
Definition: arithmetic.cpp:718
ArgMinShared(int n, bool tb)
Create and register test.
Definition: arithmetic.cpp:862
virtual bool solution(const Assignment &x) const
Test whether x is solution
Definition: arithmetic.cpp:163
static std::string str(Gecode::ExtensionalPropKind epk)
Map extensional propagation kind to string.
Definition: int.hpp:212
void argmax(Home home, const IntVarArgs &x, IntVar y, bool tiebreak, IntConLevel)
Post propagator for .
Definition: arithmetic.cpp:114
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
Definition: arithmetic.cpp:746
Test for n-ary minimmum constraint
Definition: arithmetic.cpp:682
AbsXX(const std::string &s, const Gecode::IntSet &d, Gecode::IntConLevel icl)
Create and register test.
Definition: arithmetic.cpp:494
MaxXXX(const std::string &s, const Gecode::IntSet &d, Gecode::IntConLevel icl)
Create and register test.
Definition: arithmetic.cpp:668
virtual bool solution(const Assignment &x) const
Test whether x is solution
Definition: arithmetic.cpp:498
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
Definition: arithmetic.cpp:284
int p
Number of positive literals for node type.
Definition: bool-expr.cpp:236
virtual bool solution(const Assignment &x) const
Test whether x is solution
Definition: arithmetic.cpp:143
Gecode::IntArgs i(4, 1, 2, 3, 4)
Div(const std::string &s, const Gecode::IntSet &d)
Create and register test.
Definition: arithmetic.cpp:429
Equality ( )
Definition: int.hh:904
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
Definition: arithmetic.cpp:521
MinXYX(const std::string &s, const Gecode::IntSet &d, Gecode::IntConLevel icl)
Create and register test.
Definition: arithmetic.cpp:547
virtual bool solution(const Assignment &x) const
Test whether x is solution
Definition: arithmetic.cpp:414
virtual bool solution(const Assignment &x) const
Test whether x is solution
Definition: arithmetic.cpp:534
Test for n-ary maximum constraint with shared variables
Definition: arithmetic.cpp:736
Test for binary minimum constraint with shared variables
Definition: arithmetic.cpp:527
Gecode::IntSet d2(v2, 9)
Gecode::IntConLevel icl
Consistency level.
Definition: int.hh:226
Test for absolute value constraint with shared variables
Definition: arithmetic.cpp:491
int fnroot(int n, int x)
Definition: arithmetic.cpp:301
Create(void)
Perform creation and registration.
Definition: arithmetic.cpp:897
NNF * r
Right subtree.
Definition: bool-expr.cpp:246
Test for binary maximum constraint with shared variables
Definition: arithmetic.cpp:614
virtual bool solution(const Assignment &x) const
Test whether x is solution
Definition: arithmetic.cpp:798
virtual bool solution(const Assignment &x) const
Test whether x is solution
Definition: arithmetic.cpp:638
void sqr(Home home, FloatVar x0, FloatVar x1)
Post propagator for .
Definition: arithmetic.cpp:103
virtual bool solution(const Assignment &x) const
Test whether x is solution
Definition: arithmetic.cpp:83
virtual bool solution(const Assignment &x) const
Test whether x is solution
Definition: arithmetic.cpp:604
MinXXY(const std::string &s, const Gecode::IntSet &d, Gecode::IntConLevel icl)
Create and register test.
Definition: arithmetic.cpp:530
NrootXY(const std::string &s, int n0, const Gecode::IntSet &d, Gecode::IntConLevel icl)
Floor.
Definition: arithmetic.cpp:352
void sqrt(Home home, FloatVar x0, FloatVar x1)
Post propagator for .
Definition: arithmetic.cpp:110
Test for square root constraint with shared variables
Definition: arithmetic.cpp:212
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
Definition: arithmetic.cpp:169
virtual bool solution(const Assignment &x) const
Test whether x is solution
Definition: arithmetic.cpp:357
MaxXYZ(const std::string &s, const Gecode::IntSet &d, Gecode::IntConLevel icl)
Create and register test.
Definition: arithmetic.cpp:598
virtual bool solution(const Assignment &x) const
Test whether x is solution
Definition: arithmetic.cpp:724
MaxXXY(const std::string &s, const Gecode::IntSet &d, Gecode::IntConLevel icl)
Create and register test.
Definition: arithmetic.cpp:617
Test for bounds(z)-consistency.
Definition: int.hh:147
Test for modulo constraint
Definition: arithmetic.cpp:449
MinNary(Gecode::IntConLevel icl)
Create and register test.
Definition: arithmetic.cpp:685
SqrXX(const std::string &s, const Gecode::IntSet &d, Gecode::IntConLevel icl)
Create and register test.
Definition: arithmetic.cpp:178
virtual bool solution(const Assignment &x) const
Test whether x is solution
Definition: arithmetic.cpp:182
MaxNaryShared(Gecode::IntConLevel icl)
Create and register test.
Definition: arithmetic.cpp:739
MinNaryShared(Gecode::IntConLevel icl)
Create and register test.
Definition: arithmetic.cpp:703
Integer sets.
Definition: int.hh:171
void max(Home home, const IntVarArgs &x, IntVar y, IntConLevel icl)
Post propagator for .
Definition: arithmetic.cpp:67
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
Definition: arithmetic.cpp:466
virtual bool solution(const Assignment &x) const
Test whether x is solution
Definition: arithmetic.cpp:655
int cnroot(int n, int x)
Definition: arithmetic.cpp:329
PowXX(const std::string &s, int n0, const Gecode::IntSet &d, Gecode::IntConLevel icl)
Create and register test.
Definition: arithmetic.cpp:268
Test for multiplication constraint with shared variables
Definition: arithmetic.cpp:96
Test for multiplication constraint with shared variables
Definition: arithmetic.cpp:76
MaxNary(Gecode::IntConLevel icl)
Create and register test.
Definition: arithmetic.cpp:721
Passing integer variables.
Definition: int.hh:636
virtual bool solution(const Assignment &x) const
Test whether x is solution
Definition: arithmetic.cpp:621
void divmod(Home home, IntVar x0, IntVar x1, IntVar x2, IntVar x3, IntConLevel)
Post propagator for .
Definition: arithmetic.cpp:180
Passing integer arguments.
Definition: int.hh:607
void sqrt(Home home, IntVar x0, IntVar x1, IntConLevel icl)
Post propagator for .
Definition: arithmetic.cpp:236
bool powgr(int n, long long int r, int x)
Definition: arithmetic.cpp:289
MultXXY(const std::string &s, const Gecode::IntSet &d, Gecode::IntConLevel icl)
Create and register test.
Definition: arithmetic.cpp:79
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
Definition: arithmetic.cpp:625
union Gecode::@518::NNF::@57 u
Union depending on nodetype t.
void min(Home home, FloatVar x0, FloatVar x1, FloatVar x2)
Post propagator for .
Definition: arithmetic.cpp:75
virtual bool solution(const Assignment &x) const
Test whether x is solution
Definition: arithmetic.cpp:688
General test support.
Definition: afc.cpp:43
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
Definition: arithmetic.cpp:659
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
Definition: arithmetic.cpp:589
Test for power constraint with shared variables
Definition: arithmetic.cpp:262
Gecode::FloatVal b(9, 12)
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
Definition: arithmetic.cpp:485
virtual bool solution(const Assignment &x) const
Test whether x is solution
Definition: arithmetic.cpp:568
SqrtXY(const std::string &s, const Gecode::IntSet &d, Gecode::IntConLevel icl)
Create and register test.
Definition: arithmetic.cpp:196
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
Definition: arithmetic.cpp:443
bool tiebreak
Whether to use tie-breaking.
Definition: arithmetic.cpp:790
virtual bool solution(const Assignment &x) const
Test whether x is solution
Definition: arithmetic.cpp:200
BoolVar expr(Home home, const BoolExpr &e, IntConLevel icl)
Post Boolean expression and return its value.
Definition: bool-expr.cpp:632
void div(Home home, FloatVar x0, FloatVar x1, FloatVar x2)
Post propagator for .
Definition: arithmetic.cpp:135
virtual bool solution(const Assignment &x) const
Test whether x is solution
Definition: arithmetic.cpp:551
Node * x
Pointer to corresponding Boolean expression node.
Definition: bool-expr.cpp:253
Test for division constraint
Definition: arithmetic.cpp:426
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
Definition: arithmetic.cpp:397
Test for division/modulo constraint
Definition: arithmetic.cpp:403
Test for nroot constraint with shared variables
Definition: arithmetic.cpp:376
Test for binary minimum constraint with shared variables
Definition: arithmetic.cpp:544
Test for square root constraint
Definition: arithmetic.cpp:193
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
Definition: arithmetic.cpp:420
Base class for assignments
Definition: int.hh:63
virtual bool solution(const Assignment &x) const
Test whether x is solution
Definition: arithmetic.cpp:273
Test for binary maximum constraint with shared variables
Definition: arithmetic.cpp:631
SqrtXX(const std::string &s, const Gecode::IntSet &d, Gecode::IntConLevel icl)
Create and register test.
Definition: arithmetic.cpp:215
void rel(Home home, FloatVar x0, FloatRelType frt, FloatVal n)
Propagates .
Definition: rel.cpp:47
Gecode::FloatVal a(-8, 5)
The default consistency for a constraint.
Definition: int.hh:941
Test for squaring constraint with shared variables
Definition: arithmetic.cpp:175
virtual bool solution(const Assignment &x) const
Test whether x is solution
Definition: arithmetic.cpp:742
virtual bool solution(const Assignment &x) const
Test whether x is solution
Definition: arithmetic.cpp:834
Test for absolute value constraint
Definition: arithmetic.cpp:472
ArgMax(int n, bool tb)
Create and register test.
Definition: arithmetic.cpp:760
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
Definition: arithmetic.cpp:846
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
Definition: arithmetic.cpp:90
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
Definition: arithmetic.cpp:150
Gecode toplevel namespace
MaxXYY(const std::string &s, const Gecode::IntSet &d, Gecode::IntConLevel icl)
Create and register test.
Definition: arithmetic.cpp:651
Test for argument minimum constraint
Definition: arithmetic.cpp:823
virtual bool solution(const Assignment &x) const
Test whether x is solution
Definition: arithmetic.cpp:455
virtual bool solution(const Assignment &x) const
Test whether x is solution
Definition: arithmetic.cpp:479
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
Definition: arithmetic.cpp:692
MultXYZ(const std::string &s, const Gecode::IntSet &d, Gecode::IntConLevel icl)
Create and register test.
Definition: arithmetic.cpp:59
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
Definition: arithmetic.cpp:710
ArgMaxShared(int n, bool tb)
Create and register test.
Definition: arithmetic.cpp:793
void abs(Home home, IntVar x0, IntVar x1, IntConLevel icl)
Post propagator for .
Definition: arithmetic.cpp:43
void nroot(Home home, IntVar x0, int n, IntVar x1, IntConLevel icl)
Post propagator for .
Definition: arithmetic.cpp:269
virtual bool solution(const Assignment &x) const
Test whether x is solution
Definition: arithmetic.cpp:63
Test for nroot constraint
Definition: arithmetic.cpp:345
int size(void) const
Return size of array (number of elements)
Definition: array.hpp:985
SqrXY(const std::string &s, const Gecode::IntSet &d, Gecode::IntConLevel icl)
Create and register test.
Definition: arithmetic.cpp:159
DivMod(const std::string &s, const Gecode::IntSet &d)
Create and register test.
Definition: arithmetic.cpp:411
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
Definition: arithmetic.cpp:642
Test for multiplication constraint with shared variables
Definition: arithmetic.cpp:136
MaxXYX(const std::string &s, const Gecode::IntSet &d, Gecode::IntConLevel icl)
Create and register test.
Definition: arithmetic.cpp:634
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
Definition: arithmetic.cpp:224
int size(void) const
Return number of variables.
Definition: int.hpp:50
Domain propagation or consistency.
Definition: int.hh:940
virtual bool solution(const Assignment &x) const
Test whether x is solution
Definition: arithmetic.cpp:432
virtual bool solution(const Assignment &x) const
Test whether x is solution
Definition: arithmetic.cpp:517
virtual bool solution(const Assignment &x) const
Test whether x is solution
Definition: arithmetic.cpp:765
MultXYX(const std::string &s, const Gecode::IntSet &d, Gecode::IntConLevel icl)
Create and register test.
Definition: arithmetic.cpp:99
virtual bool solution(const Assignment &x) const
Test whether x is solution
Definition: arithmetic.cpp:241
Test for n-ary minimmum constraint with shared variables
Definition: arithmetic.cpp:700
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
Definition: arithmetic.cpp:555
bool tiebreak
Whether to use tie-breaking.
Definition: arithmetic.cpp:859
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
Definition: arithmetic.cpp:206
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
Definition: arithmetic.cpp:728