Generated on Sat Jul 28 2018 17:09:48 for Gecode by doxygen 1.8.14
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: 2017-02-22 03:37:18 +0100 (Wed, 22 Feb 2017) $ by $Author: schulte $
11  * $Revision: 15468 $
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(ipl)+"::"+s,3,d,false,ipl) {}
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], ipl);
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(ipl)+"::"+s,2,d,false,ipl) {}
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], ipl);
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(ipl)+"::"+s,2,d,false,ipl) {}
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], ipl);
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(ipl)+"::"+s,2,d,false,ipl) {}
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], ipl);
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(ipl)+"::"+s,1,d,false,ipl) {}
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], ipl);
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(ipl)+"::"+s,2,d,false,ipl) {}
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], ipl);
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(ipl)+"::"+s,1,d,false,ipl) {}
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], ipl);
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(ipl)+"::"+s,2,d,false,ipl) {}
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], ipl);
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(ipl)+"::"+s,1,d,false,ipl) {}
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], ipl);
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(ipl)+"::"+s,
239  2,d,false,ipl), 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], ipl);
256  else
257  rel(home, expr(home, pow(x[0],n), ipl), IRT_EQ, x[1], ipl);
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(ipl)+"::"+s,
271  1,d,false,ipl), 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], ipl);
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(ipl)+"::"+s,
355  2,d,false,ipl), 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], ipl);
370  else
371  rel(home, expr(home, nroot(x[0],n), ipl), IRT_EQ, x[1], ipl);
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(ipl)+"::"+s,
385  1,d,false,ipl), 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], ipl);
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(ipl)+"::"+s,2,d,false,ipl) {}
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], ipl);
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(ipl)+"::"+s,1,d,false,ipl) {}
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], ipl);
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(ipl)+"::"+s,3,d,false,ipl) {}
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], ipl);
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(ipl)+"::"+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], ipl);
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(ipl)+"::"+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], ipl);
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(ipl)+"::"+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], ipl);
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(ipl)+"::"+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], ipl);
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(ipl)+"::"+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], ipl);
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(ipl)+"::"+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], ipl);
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(ipl)+"::"+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], ipl);
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(ipl)+"::"+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], ipl);
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(ipl)+"::"+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], ipl);
678  }
679  };
680 
682  class MinNary : public Test {
683  public:
686  : Test("Arithmetic::Min::Nary::"+str(ipl),4,-4,4,false,ipl) {}
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], ipl);
696  }
697  };
698 
700  class MinNaryShared : public Test {
701  public:
704  : Test("Arithmetic::Min::Nary::Shared::"+str(ipl),3,-4,4,false,ipl) {}
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], ipl);
714  }
715  };
716 
718  class MaxNary : public Test {
719  public:
722  : Test("Arithmetic::Max::Nary::"+str(ipl),4,-4,4,false,ipl) {}
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], ipl);
732  }
733  };
734 
736  class MaxNaryShared : public Test {
737  public:
740  : Test("Arithmetic::Max::Nary::Shared::"+str(ipl),3,-4,4,false,ipl) {}
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], ipl);
750  }
751  };
752 
754  class ArgMax : public Test {
755  protected:
757  int offset;
759  bool tiebreak;
760  public:
762  ArgMax(int n, int o, bool tb)
763  : Test("Arithmetic::ArgMax::"+str(o)+"::"+str(tb)+"::"+str(n),
764  n+1,0,n+1,
765  false,tb ? Gecode::IPL_DEF : Gecode::IPL_DOM),
766  offset(o), tiebreak(tb) {}
768  virtual bool solution(const Assignment& x) const {
769  int n=x.size()-1;
770  if ((x[n] < offset) || (x[n] >= n + offset))
771  return false;
772  int m=x[0]; int p=0;
773  for (int i=1; i<n; i++)
774  if (x[i] > m) {
775  p=i; m=x[i];
776  }
777  return tiebreak ? (p + offset == x[n]) : (m == x[x[n]-offset]);
778  }
780  virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) {
781  int n=x.size()-1;
783  for (int i=0; i<n; i++)
784  m[i]=x[i];
785  Gecode::argmax(home, m, offset, x[n], tiebreak);
786  }
787  };
788 
790  class ArgMaxShared : public Test {
791  protected:
793  bool tiebreak;
794  public:
796  ArgMaxShared(int n, bool tb)
797  : Test("Arithmetic::ArgMax::Shared::"+str(tb)+"::"+str(n),n+1,0,n+1,
798  false),
799  tiebreak(tb) {
800  testfix=false;
801  }
803  virtual bool solution(const Assignment& x) const {
804  int n=x.size()-1;
805  if ((x[n] < 0) || (x[n] >= 2*n))
806  return false;
807  Gecode::IntArgs y(2*n);
808  for (int i=0; i<n; i++)
809  y[2*i+0]=y[2*i+1]=x[i];
810  int m=y[0]; int p=0;
811  for (int i=1; i<2*n; i++)
812  if (y[i] > m) {
813  p=i; m=y[i];
814  }
815  return tiebreak ? (p == x[n]) : (m == y[x[n]]);
816  }
818  virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) {
819  int n=x.size()-1;
820  Gecode::IntVarArgs m(2*n);
821  for (int i=0; i<n; i++)
822  m[2*i+0]=m[2*i+1]=x[i];
823  Gecode::argmax(home, m, x[n], tiebreak);
824  }
825  };
826 
828  class ArgMin : public Test {
829  protected:
831  int offset;
833  bool tiebreak;
834  public:
836  ArgMin(int n, int o, bool tb)
837  : Test("Arithmetic::ArgMin::"+str(o)+"::"+str(tb)+"::"+str(n),
838  n+1,0,n+1,
839  false,tb ? Gecode::IPL_DEF : Gecode::IPL_DOM),
840  offset(o), tiebreak(tb) {}
842  virtual bool solution(const Assignment& x) const {
843  int n=x.size()-1;
844  if ((x[n] < offset) || (x[n] >= n + offset))
845  return false;
846  int m=x[0]; int p=0;
847  for (int i=1; i<n; i++)
848  if (x[i] < m) {
849  p=i; m=x[i];
850  }
851  return tiebreak ? (p+offset == x[n]) : (m == x[x[n]-offset]);
852  }
854  virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) {
855  int n=x.size()-1;
857  for (int i=0; i<n; i++)
858  m[i]=x[i];
859  Gecode::argmin(home, m, offset, x[n], tiebreak);
860  }
861  };
862 
864  class ArgMinShared : public Test {
865  protected:
867  bool tiebreak;
868  public:
870  ArgMinShared(int n, bool tb)
871  : Test("Arithmetic::ArgMin::Shared::"+str(tb)+"::"+str(n),n+1,0,n+1,
872  false),
873  tiebreak(tb) {
874  testfix=false;
875  }
877  virtual bool solution(const Assignment& x) const {
878  int n=x.size()-1;
879  if ((x[n] < 0) || (x[n] >= 2*n))
880  return false;
881  Gecode::IntArgs y(2*n);
882  for (int i=0; i<n; i++)
883  y[2*i+0]=y[2*i+1]=x[i];
884  int m=y[0]; int p=0;
885  for (int i=1; i<2*n; i++)
886  if (y[i] < m) {
887  p=i; m=y[i];
888  }
889  return tiebreak ? (p == x[n]) : (m == y[x[n]]);
890  }
892  virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) {
893  int n=x.size()-1;
894  Gecode::IntVarArgs m(2*n);
895  for (int i=0; i<n; i++)
896  m[2*i+0]=m[2*i+1]=x[i];
897  Gecode::argmin(home, m, x[n], tiebreak);
898  }
899  };
900 
901 
902 
904  class Create {
905  public:
907  Create(void) {
908 
909  const int va[7] = {
911  -1,0,1,
913  };
914  const int vb[9] = {
915  static_cast<int>(-sqrt(static_cast<double>
917  -4,-2,-1,0,1,2,4,
918  static_cast<int>(sqrt(static_cast<double>
920  };
921 
922  Gecode::IntSet a(va,7);
923  Gecode::IntSet b(vb,9);
924  Gecode::IntSet c(-8,8);
925  Gecode::IntSet d(-70,70);
926 
927  (void) new DivMod("A",a);
928  (void) new DivMod("B",b);
929  (void) new DivMod("C",c);
930 
931  (void) new Div("A",a);
932  (void) new Div("B",b);
933  (void) new Div("C",c);
934 
935  (void) new Mod("A",a);
936  (void) new Mod("B",b);
937  (void) new Mod("C",c);
938 
939 
940  for (IntPropLevels ipls; ipls(); ++ipls) {
941  (void) new AbsXY("A",a,ipls.ipl());
942  (void) new AbsXY("B",b,ipls.ipl());
943  (void) new AbsXY("C",c,ipls.ipl());
944 
945  (void) new AbsXX("A",a,ipls.ipl());
946  (void) new AbsXX("B",b,ipls.ipl());
947  (void) new AbsXX("C",c,ipls.ipl());
948  if (ipls.ipl() != Gecode::IPL_VAL) {
949  (void) new MultXYZ("A",a,ipls.ipl());
950  (void) new MultXYZ("B",b,ipls.ipl());
951  (void) new MultXYZ("C",c,ipls.ipl());
952 
953  (void) new MultXXY("A",a,ipls.ipl());
954  (void) new MultXXY("B",b,ipls.ipl());
955  (void) new MultXXY("C",c,ipls.ipl());
956 
957  (void) new MultXYX("A",a,ipls.ipl());
958  (void) new MultXYX("B",b,ipls.ipl());
959  (void) new MultXYX("C",c,ipls.ipl());
960 
961  (void) new MultXYY("A",a,ipls.ipl());
962  (void) new MultXYY("B",b,ipls.ipl());
963  (void) new MultXYY("C",c,ipls.ipl());
964 
965  (void) new MultXXX("A",a,ipls.ipl());
966  (void) new MultXXX("B",b,ipls.ipl());
967  (void) new MultXXX("C",c,ipls.ipl());
968 
969  (void) new SqrXY("A",a,ipls.ipl());
970  (void) new SqrXY("B",b,ipls.ipl());
971  (void) new SqrXY("C",c,ipls.ipl());
972 
973  (void) new SqrXX("A",a,ipls.ipl());
974  (void) new SqrXX("B",b,ipls.ipl());
975  (void) new SqrXX("C",c,ipls.ipl());
976 
977  for (int n=0; n<=6; n++) {
978  (void) new PowXY("A",n,a,ipls.ipl());
979  (void) new PowXY("B",n,b,ipls.ipl());
980  (void) new PowXY("C",n,c,ipls.ipl());
981  (void) new PowXY("D",n,d,ipls.ipl());
982 
983  (void) new PowXX("A",n,a,ipls.ipl());
984  (void) new PowXX("B",n,b,ipls.ipl());
985  (void) new PowXX("C",n,c,ipls.ipl());
986  (void) new PowXX("D",n,d,ipls.ipl());
987  }
988 
989  for (int n=1; n<=6; n++) {
990  (void) new NrootXY("A",n,a,ipls.ipl());
991  (void) new NrootXY("B",n,b,ipls.ipl());
992  (void) new NrootXY("C",n,c,ipls.ipl());
993  (void) new NrootXY("D",n,d,ipls.ipl());
994 
995  (void) new NrootXX("A",n,a,ipls.ipl());
996  (void) new NrootXX("B",n,b,ipls.ipl());
997  (void) new NrootXX("C",n,c,ipls.ipl());
998  (void) new NrootXX("D",n,d,ipls.ipl());
999  }
1000 
1001  for (int n=30; n<=34; n++) {
1002  (void) new PowXY("C",n,c,ipls.ipl());
1003  (void) new PowXX("C",n,c,ipls.ipl());
1004  (void) new NrootXY("C",n,c,ipls.ipl());
1005  (void) new NrootXX("C",n,c,ipls.ipl());
1006  }
1007 
1008  (void) new SqrtXY("A",a,ipls.ipl());
1009  (void) new SqrtXY("B",b,ipls.ipl());
1010  (void) new SqrtXY("C",c,ipls.ipl());
1011 
1012  (void) new SqrtXX("A",a,ipls.ipl());
1013  (void) new SqrtXX("B",b,ipls.ipl());
1014  (void) new SqrtXX("C",c,ipls.ipl());
1015 
1016  (void) new MinXYZ("A",a,ipls.ipl());
1017  (void) new MinXYZ("B",b,ipls.ipl());
1018  (void) new MinXYZ("C",c,ipls.ipl());
1019 
1020  (void) new MinXXY("A",a,ipls.ipl());
1021  (void) new MinXXY("B",b,ipls.ipl());
1022  (void) new MinXXY("C",c,ipls.ipl());
1023 
1024  (void) new MinXYX("A",a,ipls.ipl());
1025  (void) new MinXYX("B",b,ipls.ipl());
1026  (void) new MinXYX("C",c,ipls.ipl());
1027 
1028  (void) new MinXYY("A",a,ipls.ipl());
1029  (void) new MinXYY("B",b,ipls.ipl());
1030  (void) new MinXYY("C",c,ipls.ipl());
1031 
1032  (void) new MinXXX("A",a,ipls.ipl());
1033  (void) new MinXXX("B",b,ipls.ipl());
1034  (void) new MinXXX("C",c,ipls.ipl());
1035 
1036  (void) new MaxXYZ("A",a,ipls.ipl());
1037  (void) new MaxXYZ("B",b,ipls.ipl());
1038  (void) new MaxXYZ("C",c,ipls.ipl());
1039 
1040  (void) new MaxXXY("A",a,ipls.ipl());
1041  (void) new MaxXXY("B",b,ipls.ipl());
1042  (void) new MaxXXY("C",c,ipls.ipl());
1043 
1044  (void) new MaxXYX("A",a,ipls.ipl());
1045  (void) new MaxXYX("B",b,ipls.ipl());
1046  (void) new MaxXYX("C",c,ipls.ipl());
1047 
1048  (void) new MaxXYY("A",a,ipls.ipl());
1049  (void) new MaxXYY("B",b,ipls.ipl());
1050  (void) new MaxXYY("C",c,ipls.ipl());
1051 
1052  (void) new MaxXXX("A",a,ipls.ipl());
1053  (void) new MaxXXX("B",b,ipls.ipl());
1054  (void) new MaxXXX("C",c,ipls.ipl());
1055 
1056  (void) new MinNary(ipls.ipl());
1057  (void) new MinNaryShared(ipls.ipl());
1058  (void) new MaxNary(ipls.ipl());
1059  (void) new MaxNaryShared(ipls.ipl());
1060  }
1061  }
1062 
1063  for (int i=1; i<5; i++) {
1064  (void) new ArgMax(i,0,true);
1065  (void) new ArgMax(i,1,true);
1066  (void) new ArgMaxShared(i,true);
1067  (void) new ArgMin(i,0,true);
1068  (void) new ArgMin(i,1,true);
1069  (void) new ArgMinShared(i,true);
1070  (void) new ArgMax(i,0,false);
1071  (void) new ArgMax(i,1,false);
1072  (void) new ArgMaxShared(i,false);
1073  (void) new ArgMin(i,0,false);
1074  (void) new ArgMin(i,1,false);
1075  (void) new ArgMinShared(i,false);
1076  }
1077  }
1078  };
1079 
1082 
1083  }
1084 }}
1085 
1086 // STATISTICS: test-int
Test for power constraint
Definition: arithmetic.cpp:230
Test for multiplication constraint
Definition: arithmetic.cpp:56
virtual bool solution(const Assignment &x) const
Test whether x is solution
Definition: arithmetic.cpp:742
void mod(Home home, IntVar x0, IntVar x1, IntVar x2, IntPropLevel ipl)
Post propagator for .
Definition: arithmetic.cpp:267
Test for argument maximum constraint with shared variables
Definition: arithmetic.cpp:790
static std::string str(Gecode::IntPropLevel ipl)
Map integer propagation level to string.
Definition: int.hpp:212
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:780
Test for binary minimum constraint with shared variables
Definition: arithmetic.cpp:578
void min(Home home, const IntVarArgs &x, IntVar y, IntPropLevel ipl)
Post propagator for .
Definition: arithmetic.cpp:95
void mult(Home home, FloatVar x0, FloatVar x1, FloatVar x2)
Post propagator for .
Definition: arithmetic.cpp:92
bool tiebreak
Whether to use tie-breaking.
Definition: arithmetic.cpp:833
virtual bool solution(const Assignment &x) const
Test whether x is solution
Definition: arithmetic.cpp:83
NNF * l
Left subtree.
Definition: bool-expr.cpp:244
void sqrt(Home home, IntVar x0, IntVar x1, IntPropLevel ipl)
Post propagator for .
Definition: arithmetic.cpp:290
Test for binary maximum constraint with shared variables
Definition: arithmetic.cpp:648
SqrXX(const std::string &s, const Gecode::IntSet &d, Gecode::IntPropLevel ipl)
Create and register test.
Definition: arithmetic.cpp:178
union Gecode::@579::NNF::@61 u
Union depending on nodetype t.
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
MaxXYZ(const std::string &s, const Gecode::IntSet &d, Gecode::IntPropLevel ipl)
Create and register test.
Definition: arithmetic.cpp:598
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
Definition: arithmetic.cpp:252
PowXX(const std::string &s, int n0, const Gecode::IntSet &d, Gecode::IntPropLevel ipl)
Create and register test.
Definition: arithmetic.cpp:268
virtual bool solution(const Assignment &x) const
Test whether x is solution
Definition: arithmetic.cpp:273
MaxXYY(const std::string &s, const Gecode::IntSet &d, Gecode::IntPropLevel ipl)
Create and register test.
Definition: arithmetic.cpp:651
Test for argument minimum constraint with shared variables
Definition: arithmetic.cpp:864
virtual bool solution(const Assignment &x) const
Test whether x is solution
Definition: arithmetic.cpp:724
Test for squaring constraint
Definition: arithmetic.cpp:156
Help class to create and register tests.
Definition: arithmetic.cpp:904
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
Definition: arithmetic.cpp:818
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
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
Definition: arithmetic.cpp:676
MultXXY(const std::string &s, const Gecode::IntSet &d, Gecode::IntPropLevel ipl)
Create and register test.
Definition: arithmetic.cpp:79
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
Definition: arithmetic.cpp:892
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:842
MinXXY(const std::string &s, const Gecode::IntSet &d, Gecode::IntPropLevel ipl)
Create and register test.
Definition: arithmetic.cpp:530
void max(Home home, FloatVar x0, FloatVar x1, FloatVar x2)
Post propagator for .
Definition: arithmetic.cpp:53
void abs(Home home, FloatVar x0, FloatVar x1)
Post propagator for .
Definition: arithmetic.cpp:45
virtual bool solution(const Assignment &x) const
Test whether x is solution
Definition: arithmetic.cpp:803
void nroot(Home home, FloatVar x0, int n, FloatVar x1)
Post propagator for for $n 0$.
Definition: arithmetic.cpp:122
NrootXY(const std::string &s, int n0, const Gecode::IntSet &d, Gecode::IntPropLevel ipl)
Floor.
Definition: arithmetic.cpp:352
MultXYX(const std::string &s, const Gecode::IntSet &d, Gecode::IntPropLevel ipl)
Create and register test.
Definition: arithmetic.cpp:99
bool tiebreak
Whether to use tie-breaking.
Definition: arithmetic.cpp:759
virtual bool solution(const Assignment &x) const
Test whether x is solution
Definition: arithmetic.cpp:655
void pow(Home home, FloatVar x0, int n, FloatVar x1)
Post propagator for for $n 0$.
Definition: arithmetic.cpp:113
bool powle(int n, long long int r, int x)
Definition: arithmetic.cpp:316
void abs(Home home, IntVar x0, IntVar x1, IntPropLevel ipl)
Post propagator for .
Definition: arithmetic.cpp:43
MinXYY(const std::string &s, const Gecode::IntSet &d, Gecode::IntPropLevel ipl)
Create and register test.
Definition: arithmetic.cpp:564
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
SqrtXX(const std::string &s, const Gecode::IntSet &d, Gecode::IntPropLevel ipl)
Create and register test.
Definition: arithmetic.cpp:215
virtual bool solution(const Assignment &x) const
Test whether x is solution
Definition: arithmetic.cpp:200
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
Definition: arithmetic.cpp:110
Integer variable array.
Definition: int.hh:744
void argmin(Home home, const IntVarArgs &x, IntVar y, bool tiebreak, IntPropLevel)
Post propagator for .
Definition: arithmetic.cpp:167
virtual bool solution(const Assignment &x) const
Test whether x is solution
Definition: arithmetic.cpp:432
int offset
Offset to be used.
Definition: arithmetic.cpp:757
virtual bool solution(const Assignment &x) const
Test whether x is solution
Definition: arithmetic.cpp:498
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:240
const int max
Largest allowed integer value.
Definition: int.hh:116
Computation spaces.
Definition: core.hpp:1748
Test for binary maximum constraint
Definition: arithmetic.cpp:595
const int min
Smallest allowed integer value.
Definition: int.hh:118
Mod(const std::string &s, const Gecode::IntSet &d)
Create and register test.
Definition: arithmetic.cpp:452
virtual bool solution(const Assignment &x) const
Test whether x is solution
Definition: arithmetic.cpp:163
MinNaryShared(Gecode::IntPropLevel ipl)
Create and register test.
Definition: arithmetic.cpp:703
Gecode::IntSet d1(v1, 7)
virtual bool solution(const Assignment &x) const
Test whether x is solution
Definition: arithmetic.cpp:604
Gecode::IntSet d(v, 7)
virtual bool solution(const Assignment &x) const
Test whether x is solution
Definition: arithmetic.cpp:672
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:143
ArgMinShared(int n, bool tb)
Create and register test.
Definition: arithmetic.cpp:870
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
MultXXX(const std::string &s, const Gecode::IntSet &d, Gecode::IntPropLevel ipl)
Create and register test.
Definition: arithmetic.cpp:139
MinXXX(const std::string &s, const Gecode::IntSet &d, Gecode::IntPropLevel ipl)
Create and register test.
Definition: arithmetic.cpp:581
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
Gecode::IntArgs i(4, 1, 2, 3, 4)
ArgMin(int n, int o, bool tb)
Create and register test.
Definition: arithmetic.cpp:836
Div(const std::string &s, const Gecode::IntSet &d)
Create and register test.
Definition: arithmetic.cpp:429
Equality ( )
Definition: int.hh:907
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
Definition: arithmetic.cpp:521
AbsXX(const std::string &s, const Gecode::IntSet &d, Gecode::IntPropLevel ipl)
Create and register test.
Definition: arithmetic.cpp:494
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)
void divmod(Home home, IntVar x0, IntVar x1, IntVar x2, IntVar x3, IntPropLevel)
Post propagator for .
Definition: arithmetic.cpp:234
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:907
Test for binary maximum constraint with shared variables
Definition: arithmetic.cpp:614
void sqr(Home home, FloatVar x0, FloatVar x1)
Post propagator for .
Definition: arithmetic.cpp:99
Simple propagation levels.
Definition: int.hh:957
virtual bool solution(const Assignment &x) const
Test whether x is solution
Definition: arithmetic.cpp:241
void sqrt(Home home, FloatVar x0, FloatVar x1)
Post propagator for .
Definition: arithmetic.cpp:106
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
Value propagation.
Definition: int.hh:958
MultXYZ(const std::string &s, const Gecode::IntSet &d, Gecode::IntPropLevel ipl)
Create and register test.
Definition: arithmetic.cpp:59
void argmax(Home home, const IntVarArgs &x, IntVar y, bool tiebreak, IntPropLevel)
Post propagator for .
Definition: arithmetic.cpp:114
Test for bounds(z)-consistency.
Definition: int.hh:147
virtual bool solution(const Assignment &x) const
Test whether x is solution
Definition: arithmetic.cpp:621
Test for modulo constraint
Definition: arithmetic.cpp:449
LDSB< TieBreak > tiebreak("TieBreak")
virtual bool solution(const Assignment &x) const
Test whether x is solution
Definition: arithmetic.cpp:638
NrootXX(const std::string &s, int n0, const Gecode::IntSet &d, Gecode::IntPropLevel ipl)
Create and register test.
Definition: arithmetic.cpp:382
virtual bool solution(const Assignment &x) const
Test whether x is solution
Definition: arithmetic.cpp:357
Integer sets.
Definition: int.hh:174
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
Definition: arithmetic.cpp:466
int cnroot(int n, int x)
Definition: arithmetic.cpp:329
MultXYY(const std::string &s, const Gecode::IntSet &d, Gecode::IntPropLevel ipl)
Create and register test.
Definition: arithmetic.cpp:119
Test for multiplication constraint with shared variables
Definition: arithmetic.cpp:96
ArgMax(int n, int o, bool tb)
Create and register test.
Definition: arithmetic.cpp:762
Test for multiplication constraint with shared variables
Definition: arithmetic.cpp:76
Gecode::IntPropLevel ipl
Propagation level.
Definition: int.hh:238
Passing integer variables.
Definition: int.hh:639
Passing integer arguments.
Definition: int.hh:610
void nroot(Home home, IntVar x0, int n, IntVar x1, IntPropLevel ipl)
Post propagator for .
Definition: arithmetic.cpp:323
virtual bool solution(const Assignment &x) const
Test whether x is solution
Definition: arithmetic.cpp:182
virtual bool solution(const Assignment &x) const
Test whether x is solution
Definition: arithmetic.cpp:219
BoolVar expr(Home home, const BoolExpr &e, IntPropLevel ipl)
Post Boolean expression and return its value.
Definition: bool-expr.cpp:632
MaxXXY(const std::string &s, const Gecode::IntSet &d, Gecode::IntPropLevel ipl)
Create and register test.
Definition: arithmetic.cpp:617
bool powgr(int n, long long int r, int x)
Definition: arithmetic.cpp:289
virtual bool solution(const Assignment &x) const
Test whether x is solution
Definition: arithmetic.cpp:585
bool testfix
Whether to perform fixpoint test.
Definition: int.hh:244
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:71
virtual bool solution(const Assignment &x) const
Test whether x is solution
Definition: arithmetic.cpp:877
AbsXY(const std::string &s, const Gecode::IntSet &d, Gecode::IntPropLevel ipl)
Create and register test.
Definition: arithmetic.cpp:475
General test support.
Definition: afc.cpp:43
IntPropLevel
Propagation levels for integer propagators.
Definition: int.hh:955
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 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:793
Post propagator for SetVar SetOpType SetVar y
Definition: set.hh:784
SqrXY(const std::string &s, const Gecode::IntSet &d, Gecode::IntPropLevel ipl)
Create and register test.
Definition: arithmetic.cpp:159
void div(Home home, FloatVar x0, FloatVar x1, FloatVar x2)
Post propagator for .
Definition: arithmetic.cpp:131
PowXY(const std::string &s, int n0, const Gecode::IntSet &d, Gecode::IntPropLevel ipl)
Create and register test.
Definition: arithmetic.cpp:236
MinXYZ(const std::string &s, const Gecode::IntSet &d, Gecode::IntPropLevel ipl)
Create and register test.
Definition: arithmetic.cpp:513
void max(Home home, const IntVarArgs &x, IntVar y, IntPropLevel ipl)
Post propagator for .
Definition: arithmetic.cpp:67
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
virtual bool solution(const Assignment &x) const
Test whether x is solution
Definition: arithmetic.cpp:551
virtual bool solution(const Assignment &x) const
Test whether x is solution
Definition: arithmetic.cpp:688
Test for division/modulo constraint
Definition: arithmetic.cpp:403
Test for nroot constraint with shared variables
Definition: arithmetic.cpp:376
virtual bool solution(const Assignment &x) const
Test whether x is solution
Definition: arithmetic.cpp:706
MaxNary(Gecode::IntPropLevel ipl)
Create and register test.
Definition: arithmetic.cpp:721
virtual bool solution(const Assignment &x) const
Test whether x is solution
Definition: arithmetic.cpp:534
Test for binary minimum constraint with shared variables
Definition: arithmetic.cpp:544
Test for square root constraint
Definition: arithmetic.cpp:193
virtual bool solution(const Assignment &x) const
Test whether x is solution
Definition: arithmetic.cpp:455
Region r
Definition: region.cpp:82
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
void pow(Home home, IntVar x0, int n, IntVar x1, IntPropLevel ipl)
Post propagator for .
Definition: arithmetic.cpp:304
Test for binary maximum constraint with shared variables
Definition: arithmetic.cpp:631
void rel(Home home, FloatVar x0, FloatRelType frt, FloatVal n)
Propagates .
Definition: rel.cpp:47
MinNary(Gecode::IntPropLevel ipl)
Create and register test.
Definition: arithmetic.cpp:685
MaxXXX(const std::string &s, const Gecode::IntSet &d, Gecode::IntPropLevel ipl)
Create and register test.
Definition: arithmetic.cpp:668
virtual bool solution(const Assignment &x) const
Test whether x is solution
Definition: arithmetic.cpp:387
Domain propagation Preferences: prefer speed or memory.
Definition: int.hh:960
Gecode::FloatVal a(-8, 5)
Test for squaring constraint with shared variables
Definition: arithmetic.cpp:175
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:854
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
MaxXYX(const std::string &s, const Gecode::IntSet &d, Gecode::IntPropLevel ipl)
Create and register test.
Definition: arithmetic.cpp:634
Gecode toplevel namespace
virtual bool solution(const Assignment &x) const
Test whether x is solution
Definition: arithmetic.cpp:103
Test for argument minimum constraint
Definition: arithmetic.cpp:828
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
Definition: arithmetic.cpp:692
virtual bool solution(const Assignment &x) const
Test whether x is solution
Definition: arithmetic.cpp:414
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:796
virtual bool solution(const Assignment &x) const
Test whether x is solution
Definition: arithmetic.cpp:123
MinXYX(const std::string &s, const Gecode::IntSet &d, Gecode::IntPropLevel ipl)
Create and register test.
Definition: arithmetic.cpp:547
virtual bool solution(const Assignment &x) const
Test whether x is solution
Definition: arithmetic.cpp:63
Test for nroot constraint
Definition: arithmetic.cpp:345
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
virtual bool solution(const Assignment &x) const
Test whether x is solution
Definition: arithmetic.cpp:517
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
Definition: arithmetic.cpp:224
int offset
Which offset to use.
Definition: arithmetic.cpp:831
virtual bool solution(const Assignment &x) const
Test whether x is solution
Definition: arithmetic.cpp:568
virtual bool solution(const Assignment &x) const
Test whether x is solution
Definition: arithmetic.cpp:768
SqrtXY(const std::string &s, const Gecode::IntSet &d, Gecode::IntPropLevel ipl)
Create and register test.
Definition: arithmetic.cpp:196
Iterator for simple integer propagation levels.
Definition: int.hh:334
Test for n-ary minimmum constraint with shared variables
Definition: arithmetic.cpp:700
MaxNaryShared(Gecode::IntPropLevel ipl)
Create and register test.
Definition: arithmetic.cpp:739
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:867
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:206
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
Definition: arithmetic.cpp:728