Generated on Mon Nov 25 2013 15:55:57 for Gecode by doxygen 1.8.5
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: 2013-08-29 16:05:54 +0200 (Thu, 29 Aug 2013) $ by $Author: schulte $
11  * $Revision: 13993 $
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 
753 
755  class Create {
756  public:
758  Create(void) {
759 
760  const int va[7] = {
762  -1,0,1,
763  Gecode::Int::Limits::max-1, Gecode::Int::Limits::max
764  };
765  const int vb[9] = {
766  static_cast<int>(-sqrt(static_cast<double>
768  -4,-2,-1,0,1,2,4,
769  static_cast<int>(sqrt(static_cast<double>
771  };
772 
773  Gecode::IntSet a(va,7);
774  Gecode::IntSet b(vb,9);
775  Gecode::IntSet c(-8,8);
776  Gecode::IntSet d(-70,70);
777 
778  (void) new DivMod("A",a);
779  (void) new DivMod("B",b);
780  (void) new DivMod("C",c);
781 
782  (void) new Div("A",a);
783  (void) new Div("B",b);
784  (void) new Div("C",c);
785 
786  (void) new Mod("A",a);
787  (void) new Mod("B",b);
788  (void) new Mod("C",c);
789 
790 
791  for (IntConLevels icls; icls(); ++icls)
792  if (icls.icl() != Gecode::ICL_VAL) {
793  (void) new MultXYZ("A",a,icls.icl());
794  (void) new MultXYZ("B",b,icls.icl());
795  (void) new MultXYZ("C",c,icls.icl());
796 
797  (void) new MultXXY("A",a,icls.icl());
798  (void) new MultXXY("B",b,icls.icl());
799  (void) new MultXXY("C",c,icls.icl());
800 
801  (void) new MultXYX("A",a,icls.icl());
802  (void) new MultXYX("B",b,icls.icl());
803  (void) new MultXYX("C",c,icls.icl());
804 
805  (void) new MultXYY("A",a,icls.icl());
806  (void) new MultXYY("B",b,icls.icl());
807  (void) new MultXYY("C",c,icls.icl());
808 
809  (void) new MultXXX("A",a,icls.icl());
810  (void) new MultXXX("B",b,icls.icl());
811  (void) new MultXXX("C",c,icls.icl());
812 
813  (void) new SqrXY("A",a,icls.icl());
814  (void) new SqrXY("B",b,icls.icl());
815  (void) new SqrXY("C",c,icls.icl());
816 
817  (void) new SqrXX("A",a,icls.icl());
818  (void) new SqrXX("B",b,icls.icl());
819  (void) new SqrXX("C",c,icls.icl());
820 
821  for (int n=0; n<=6; n++) {
822  (void) new PowXY("A",n,a,icls.icl());
823  (void) new PowXY("B",n,b,icls.icl());
824  (void) new PowXY("C",n,c,icls.icl());
825  (void) new PowXY("D",n,d,icls.icl());
826 
827  (void) new PowXX("A",n,a,icls.icl());
828  (void) new PowXX("B",n,b,icls.icl());
829  (void) new PowXX("C",n,c,icls.icl());
830  (void) new PowXX("D",n,d,icls.icl());
831  }
832 
833  for (int n=1; n<=6; n++) {
834  (void) new NrootXY("A",n,a,icls.icl());
835  (void) new NrootXY("B",n,b,icls.icl());
836  (void) new NrootXY("C",n,c,icls.icl());
837  (void) new NrootXY("D",n,d,icls.icl());
838 
839  (void) new NrootXX("A",n,a,icls.icl());
840  (void) new NrootXX("B",n,b,icls.icl());
841  (void) new NrootXX("C",n,c,icls.icl());
842  (void) new NrootXX("D",n,d,icls.icl());
843  }
844 
845  for (int n=30; n<=34; n++) {
846  (void) new PowXY("C",n,c,icls.icl());
847  (void) new PowXX("C",n,c,icls.icl());
848  (void) new NrootXY("C",n,c,icls.icl());
849  (void) new NrootXX("C",n,c,icls.icl());
850  }
851 
852  (void) new SqrtXY("A",a,icls.icl());
853  (void) new SqrtXY("B",b,icls.icl());
854  (void) new SqrtXY("C",c,icls.icl());
855 
856  (void) new SqrtXX("A",a,icls.icl());
857  (void) new SqrtXX("B",b,icls.icl());
858  (void) new SqrtXX("C",c,icls.icl());
859 
860  (void) new AbsXY("A",a,icls.icl());
861  (void) new AbsXY("B",b,icls.icl());
862  (void) new AbsXY("C",c,icls.icl());
863 
864  (void) new AbsXX("A",a,icls.icl());
865  (void) new AbsXX("B",b,icls.icl());
866  (void) new AbsXX("C",c,icls.icl());
867 
868  (void) new MinXYZ("A",a,icls.icl());
869  (void) new MinXYZ("B",b,icls.icl());
870  (void) new MinXYZ("C",c,icls.icl());
871 
872  (void) new MinXXY("A",a,icls.icl());
873  (void) new MinXXY("B",b,icls.icl());
874  (void) new MinXXY("C",c,icls.icl());
875 
876  (void) new MinXYX("A",a,icls.icl());
877  (void) new MinXYX("B",b,icls.icl());
878  (void) new MinXYX("C",c,icls.icl());
879 
880  (void) new MinXYY("A",a,icls.icl());
881  (void) new MinXYY("B",b,icls.icl());
882  (void) new MinXYY("C",c,icls.icl());
883 
884  (void) new MinXXX("A",a,icls.icl());
885  (void) new MinXXX("B",b,icls.icl());
886  (void) new MinXXX("C",c,icls.icl());
887 
888  (void) new MaxXYZ("A",a,icls.icl());
889  (void) new MaxXYZ("B",b,icls.icl());
890  (void) new MaxXYZ("C",c,icls.icl());
891 
892  (void) new MaxXXY("A",a,icls.icl());
893  (void) new MaxXXY("B",b,icls.icl());
894  (void) new MaxXXY("C",c,icls.icl());
895 
896  (void) new MaxXYX("A",a,icls.icl());
897  (void) new MaxXYX("B",b,icls.icl());
898  (void) new MaxXYX("C",c,icls.icl());
899 
900  (void) new MaxXYY("A",a,icls.icl());
901  (void) new MaxXYY("B",b,icls.icl());
902  (void) new MaxXYY("C",c,icls.icl());
903 
904  (void) new MaxXXX("A",a,icls.icl());
905  (void) new MaxXXX("B",b,icls.icl());
906  (void) new MaxXXX("C",c,icls.icl());
907 
908  (void) new MinNary(icls.icl());
909  (void) new MinNaryShared(icls.icl());
910  (void) new MaxNary(icls.icl());
911  (void) new MaxNaryShared(icls.icl());
912  }
913  }
914  };
915 
918 
919  }
920 }}
921 
922 // 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
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
Test for binary minimum constraint with shared variables
Definition: arithmetic.cpp:578
IntConLevel
Consistency levels for integer propagators.
Definition: int.hh:935
void mult(Home home, FloatVar x0, FloatVar x1, FloatVar x2)
Post propagator for .
Definition: arithmetic.cpp:96
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:160
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
const FloatNum max
Largest allowed float value.
Definition: float.hh:831
virtual bool solution(const Assignment &x) const
Test whether x is solution
Definition: arithmetic.cpp:585
union Gecode::@512::NNF::@54 u
Union depending on nodetype t.
Test for squaring constraint
Definition: arithmetic.cpp:156
Help class to create and register tests.
Definition: arithmetic.cpp:755
MultXYY(const std::string &s, const Gecode::IntSet &d, Gecode::IntConLevel icl)
Create and register test.
Definition: arithmetic.cpp:119
virtual bool solution(const Assignment &x) const
Test whether x is solution
Definition: arithmetic.cpp:387
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: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:936
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
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 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:739
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
Test for binary minimum constraint
Definition: arithmetic.cpp:510
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:111
Computation spaces.
Definition: core.hpp:1325
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:113
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
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
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
const FloatNum min
Smallest allowed float value.
Definition: float.hh:833
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:902
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:758
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:638
void sqr(Home home, FloatVar x0, FloatVar x1)
Post propagator for .
Definition: arithmetic.cpp:103
Base class for tests with integer constraints
Definition: int.hh:215
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:169
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
struct Gecode::@512::NNF::@54::@55 b
For binary nodes (and, or, eqv)
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:634
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:127
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
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
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
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
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
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
Test for absolute value constraint
Definition: arithmetic.cpp:472
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
MaxXYY(const std::string &s, const Gecode::IntSet &d, Gecode::IntConLevel icl)
Create and register test.
Definition: arithmetic.cpp:651
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
struct Gecode::@512::NNF::@54::@56 a
For atomic nodes.
virtual bool solution(const Assignment &x) const
Test whether x is solution
Definition: arithmetic.cpp:63
Test for nroot constraint
Definition: arithmetic.cpp:345
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
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
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
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