Generated on Tue Jan 19 2021 06:15:49 for Gecode by doxygen 1.8.13
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  * This file is part of Gecode, the generic constraint
10  * development environment:
11  * http://www.gecode.org
12  *
13  * Permission is hereby granted, free of charge, to any person obtaining
14  * a copy of this software and associated documentation files (the
15  * "Software"), to deal in the Software without restriction, including
16  * without limitation the rights to use, copy, modify, merge, publish,
17  * distribute, sublicense, and/or sell copies of the Software, and to
18  * permit persons to whom the Software is furnished to do so, subject to
19  * the following conditions:
20  *
21  * The above copyright notice and this permission notice shall be
22  * included in all copies or substantial portions of the Software.
23  *
24  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
25  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
26  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
27  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
28  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
29  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
30  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
31  *
32  */
33 
34 #include "test/int.hh"
35 
36 #include <cmath>
37 #include <algorithm>
38 
39 #include <gecode/minimodel.hh>
40 
41 namespace Test { namespace Int {
42 
44  namespace Arithmetic {
45 
51  class MultXYZ : public Test {
53  public:
55  MultXYZ(const std::string& s, const Gecode::IntSet& d,
57  : Test("Arithmetic::Mult::XYZ::"+str(ipl)+"::"+s,3,d,false,ipl) {}
59  virtual bool solution(const Assignment& x) const {
60  double d0 = static_cast<double>(x[0]);
61  double d1 = static_cast<double>(x[1]);
62  double d2 = static_cast<double>(x[2]);
63  return d0*d1 == d2;
64  }
66  virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) {
67  Gecode::mult(home, x[0], x[1], x[2], ipl);
68  }
69  };
70 
72  class MultXXY : public Test {
73  public:
75  MultXXY(const std::string& s, const Gecode::IntSet& d,
77  : Test("Arithmetic::Mult::XXY::"+str(ipl)+"::"+s,2,d,false,ipl) {}
79  virtual bool solution(const Assignment& x) const {
80  double d0 = static_cast<double>(x[0]);
81  double d1 = static_cast<double>(x[0]);
82  double d2 = static_cast<double>(x[1]);
83  return d0*d1 == d2;
84  }
86  virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) {
87  Gecode::mult(home, x[0], x[0], x[1], ipl);
88  }
89  };
90 
92  class MultXYX : public Test {
93  public:
95  MultXYX(const std::string& s, const Gecode::IntSet& d,
97  : Test("Arithmetic::Mult::XYX::"+str(ipl)+"::"+s,2,d,false,ipl) {}
99  virtual bool solution(const Assignment& x) const {
100  double d0 = static_cast<double>(x[0]);
101  double d1 = static_cast<double>(x[1]);
102  double d2 = static_cast<double>(x[0]);
103  return d0*d1 == d2;
104  }
106  virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) {
107  Gecode::mult(home, x[0], x[1], x[0], ipl);
108  }
109  };
110 
112  class MultXYY : public Test {
113  public:
115  MultXYY(const std::string& s, const Gecode::IntSet& d,
117  : Test("Arithmetic::Mult::XYY::"+str(ipl)+"::"+s,2,d,false,ipl) {}
119  virtual bool solution(const Assignment& x) const {
120  double d0 = static_cast<double>(x[0]);
121  double d1 = static_cast<double>(x[1]);
122  double d2 = static_cast<double>(x[1]);
123  return d0*d1 == d2;
124  }
126  virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) {
127  Gecode::mult(home, x[0], x[1], x[1], ipl);
128  }
129  };
130 
132  class MultXXX : public Test {
133  public:
135  MultXXX(const std::string& s, const Gecode::IntSet& d,
137  : Test("Arithmetic::Mult::XXX::"+str(ipl)+"::"+s,1,d,false,ipl) {}
139  virtual bool solution(const Assignment& x) const {
140  double d0 = static_cast<double>(x[0]);
141  double d1 = static_cast<double>(x[0]);
142  double d2 = static_cast<double>(x[0]);
143  return d0*d1 == d2;
144  }
146  virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) {
147  Gecode::mult(home, x[0], x[0], x[0], ipl);
148  }
149  };
150 
152  class SqrXY : public Test {
153  public:
155  SqrXY(const std::string& s, const Gecode::IntSet& d,
157  : Test("Arithmetic::Sqr::XY::"+str(ipl)+"::"+s,2,d,false,ipl) {}
159  virtual bool solution(const Assignment& x) const {
160  double d0 = static_cast<double>(x[0]);
161  double d1 = static_cast<double>(x[1]);
162  return d0*d0 == d1;
163  }
165  virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) {
166  Gecode::sqr(home, x[0], x[1], ipl);
167  }
168  };
169 
171  class SqrXX : public Test {
172  public:
174  SqrXX(const std::string& s, const Gecode::IntSet& d,
176  : Test("Arithmetic::Sqr::XX::"+str(ipl)+"::"+s,1,d,false,ipl) {}
178  virtual bool solution(const Assignment& x) const {
179  double d0 = static_cast<double>(x[0]);
180  return d0*d0 == d0;
181  }
183  virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) {
184  Gecode::sqr(home, x[0], x[0], ipl);
185  }
186  };
187 
189  class SqrtXY : public Test {
190  public:
192  SqrtXY(const std::string& s, const Gecode::IntSet& d,
194  : Test("Arithmetic::Sqrt::XY::"+str(ipl)+"::"+s,2,d,false,ipl) {}
196  virtual bool solution(const Assignment& x) const {
197  double d0 = static_cast<double>(x[0]);
198  double d1 = static_cast<double>(x[1]);
199  return (d0 >= 0) && (d0 >= d1*d1) && (d0 < (d1+1)*(d1+1));
200  }
202  virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) {
203  Gecode::sqrt(home, x[0], x[1], ipl);
204  }
205  };
206 
208  class SqrtXX : public Test {
209  public:
211  SqrtXX(const std::string& s, const Gecode::IntSet& d,
213  : Test("Arithmetic::Sqrt::XX::"+str(ipl)+"::"+s,1,d,false,ipl) {}
215  virtual bool solution(const Assignment& x) const {
216  double d0 = static_cast<double>(x[0]);
217  return (d0 >= 0) && (d0 >= d0*d0) && (d0 < (d0+1)*(d0+1));
218  }
220  virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) {
221  Gecode::sqrt(home, x[0], x[0], ipl);
222  }
223  };
224 
226  class PowXY : public Test {
227  protected:
229  int n;
230  public:
232  PowXY(const std::string& s, int n0, const Gecode::IntSet& d,
234  : Test("Arithmetic::Pow::XY::"+str(n0)+"::"+str(ipl)+"::"+s,
235  2,d,false,ipl), n(n0) {}
237  virtual bool solution(const Assignment& x) const {
238  long long int p = 1;
239  for (int i=0; i<n; i++) {
240  p *= x[0];
241  if ((p < Gecode::Int::Limits::min) ||
243  return false;
244  }
245  return p == x[1];
246  }
248  virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) {
249  using namespace Gecode;
250  if (n > 4)
251  pow(home, x[0], n, x[1], ipl);
252  else
253  rel(home, expr(home, pow(x[0],n), ipl), IRT_EQ, x[1], ipl);
254  }
255  };
256 
258  class PowXX : public Test {
259  protected:
261  int n;
262  public:
264  PowXX(const std::string& s, int n0, const Gecode::IntSet& d,
266  : Test("Arithmetic::Pow::XX::"+str(n0)+"::"+str(ipl)+"::"+s,
267  1,d,false,ipl), n(n0) {}
269  virtual bool solution(const Assignment& x) const {
270  long long int p = 1;
271  for (int i=0; i<n; i++) {
272  p *= x[0];
273  if ((p < Gecode::Int::Limits::min) ||
275  return false;
276  }
277  return p == x[0];
278  }
280  virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) {
281  Gecode::pow(home, x[0], n, x[0], ipl);
282  }
283  };
284 
285  bool powgr(int n, long long int r, int x) {
286  assert(r >= 0);
287  long long int y = r;
288  long long int p = 1;
289  do {
290  p *= y; n--;
291  if (p > x)
292  return true;
293  } while (n > 0);
294  return false;
295  }
296 
297  int fnroot(int n, int x) {
298  if (x < 2)
299  return x;
300  /*
301  * We look for l such that: l^n <= x < (l+1)^n
302  */
303  long long int l = 1;
304  long long int u = x;
305  do {
306  long long int m = (l + u) >> 1;
307  if (powgr(n,m,x)) u=m; else l=m;
308  } while (l+1 < u);
309  return static_cast<int>(l);
310  }
311 
312  bool powle(int n, long long int r, int x) {
313  assert(r >= 0);
314  long long int y = r;
315  long long int p = 1;
316  do {
317  p *= y; n--;
318  if (p >= x)
319  return false;
320  } while (n > 0);
321  assert(y < x);
322  return true;
323  }
324 
325  int cnroot(int n, int x) {
326  if (x < 2)
327  return x;
328  /*
329  * We look for u such that: (u-1)^n < x <= u^n
330  */
331  long long int l = 1;
332  long long int u = x;
333  do {
334  long long int m = (l + u) >> 1;
335  if (powle(n,m,x)) l=m; else u=m;
336  } while (l+1 < u);
337  return static_cast<int>(u);
338  }
339 
341  class NrootXY : public Test {
342  protected:
344  int n;
346  public:
348  NrootXY(const std::string& s, int n0, const Gecode::IntSet& d,
350  : Test("Arithmetic::Nroot::XY::"+str(n0)+"::"+str(ipl)+"::"+s,
351  2,d,false,ipl), n(n0) {}
353  virtual bool solution(const Assignment& x) const {
354  if (n == 1)
355  return x[0] == x[1];
356  if ((n % 2 == 0) && ((x[0] < 0) || (x[1] < 0)))
357  return false;
358  int r = (x[0] < 0) ? -cnroot(n,-x[0]) : fnroot(n,x[0]);
359  return r == x[1];
360  }
362  virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) {
363  using namespace Gecode;
364  if (n > 4)
365  nroot(home, x[0], n, x[1], ipl);
366  else
367  rel(home, expr(home, nroot(x[0],n), ipl), IRT_EQ, x[1], ipl);
368  }
369  };
370 
372  class NrootXX : public Test {
373  protected:
375  int n;
376  public:
378  NrootXX(const std::string& s, int n0, const Gecode::IntSet& d,
380  : Test("Arithmetic::Nroot::XX::"+str(n0)+"::"+str(ipl)+"::"+s,
381  1,d,false,ipl), n(n0) {}
383  virtual bool solution(const Assignment& x) const {
384  if (n == 1)
385  return true;
386  if (n % 2 == 0) {
387  return (x[0] >= 0) && (x[0] <= 1);
388  } else {
389  return (x[0] >= -2) && (x[0] <= 1);
390  }
391  }
393  virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) {
394  Gecode::nroot(home, x[0], n, x[0], ipl);
395  }
396  };
397 
399  class DivMod : public Test {
400  private:
402  static int abs(int a) { return a<0 ? -a:a; }
404  static int sgn(int a) { return a<0 ? -1:1; }
405  public:
407  DivMod(const std::string& s, const Gecode::IntSet& d)
408  : Test("Arithmetic::DivMod::"+s,4,d) {}
410  virtual bool solution(const Assignment& x) const {
411  return x[0] == x[1]*x[2]+x[3] &&
412  abs(x[3]) < abs(x[1]) &&
413  (x[3] == 0 || sgn(x[3]) == sgn(x[0]));
414  }
416  virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) {
417  Gecode::divmod(home, x[0], x[1], x[2], x[3]);
418  }
419  };
420 
422  class Div : public Test {
423  public:
425  Div(const std::string& s, const Gecode::IntSet& d)
426  : Test("Arithmetic::Div::"+s,3,d) {}
428  virtual bool solution(const Assignment& x) const {
429  if (x[1] == 0)
430  return false;
431  int divsign = (x[0] / x[1] < 0) ? -1 : 1;
432  int divresult =
433  divsign *
434  static_cast<int>(floor(static_cast<double>(std::abs(x[0]))/
435  static_cast<double>(std::abs(x[1]))));
436  return x[2] == divresult;
437  }
439  virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) {
440  Gecode::div(home, x[0], x[1], x[2]);
441  }
442  };
443 
445  class Mod : public Test {
446  public:
448  Mod(const std::string& s, const Gecode::IntSet& d)
449  : Test("Arithmetic::Mod::"+s,3,d) {}
451  virtual bool solution(const Assignment& x) const {
452  if (x[1] == 0)
453  return false;
454  int divsign = (x[0] / x[1] < 0) ? -1 : 1;
455  int divresult =
456  divsign *
457  static_cast<int>(floor(static_cast<double>(std::abs(x[0]))/
458  static_cast<double>(std::abs(x[1]))));
459  return x[0] == x[1]*divresult+x[2];
460  }
462  virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) {
463  Gecode::mod(home, x[0], x[1], x[2]);
464  }
465  };
466 
468  class AbsXY : public Test {
469  public:
471  AbsXY(const std::string& s, const Gecode::IntSet& d,
473  : Test("Arithmetic::Abs::XY::"+str(ipl)+"::"+s,2,d,false,ipl) {}
475  virtual bool solution(const Assignment& x) const {
476  double d0 = static_cast<double>(x[0]);
477  double d1 = static_cast<double>(x[1]);
478  return (d0<0 ? -d0 : d0) == d1;
479  }
481  virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) {
482  Gecode::abs(home, x[0], x[1], ipl);
483  }
484  };
485 
487  class AbsXX : public Test {
488  public:
490  AbsXX(const std::string& s, const Gecode::IntSet& d,
492  : Test("Arithmetic::Abs::XX::"+str(ipl)+"::"+s,1,d,false,ipl) {}
494  virtual bool solution(const Assignment& x) const {
495  double d0 = static_cast<double>(x[0]);
496  double d1 = static_cast<double>(x[0]);
497  return (d0<0 ? -d0 : d0) == d1;
498  }
500  virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) {
501  Gecode::abs(home, x[0], x[0], ipl);
502  }
503  };
504 
506  class MinXYZ : public Test {
507  public:
509  MinXYZ(const std::string& s, const Gecode::IntSet& d,
511  : Test("Arithmetic::Min::Bin::XYZ::"+str(ipl)+"::"+s,3,d,false,ipl) {}
513  virtual bool solution(const Assignment& x) const {
514  return std::min(x[0],x[1]) == x[2];
515  }
517  virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) {
518  Gecode::min(home, x[0], x[1], x[2], ipl);
519  }
520  };
521 
523  class MinXXY : public Test {
524  public:
526  MinXXY(const std::string& s, const Gecode::IntSet& d,
528  : Test("Arithmetic::Min::Bin::XYX::"+str(ipl)+"::"+s,2,d) {}
530  virtual bool solution(const Assignment& x) const {
531  return std::min(x[0],x[0]) == x[1];
532  }
534  virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) {
535  Gecode::min(home, x[0], x[0], x[1], ipl);
536  }
537  };
538 
540  class MinXYX : public Test {
541  public:
543  MinXYX(const std::string& s, const Gecode::IntSet& d,
545  : Test("Arithmetic::Min::Bin::XYX::"+str(ipl)+"::"+s,2,d) {}
547  virtual bool solution(const Assignment& x) const {
548  return std::min(x[0],x[1]) == x[0];
549  }
551  virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) {
552  Gecode::min(home, x[0], x[1], x[0], ipl);
553  }
554  };
555 
557  class MinXYY : public Test {
558  public:
560  MinXYY(const std::string& s, const Gecode::IntSet& d,
562  : Test("Arithmetic::Min::Bin::XYY::"+str(ipl)+"::"+s,2,d) {}
564  virtual bool solution(const Assignment& x) const {
565  return std::min(x[0],x[1]) == x[1];
566  }
568  virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) {
569  Gecode::min(home, x[0], x[1], x[1], ipl);
570  }
571  };
572 
574  class MinXXX : public Test {
575  public:
577  MinXXX(const std::string& s, const Gecode::IntSet& d,
579  : Test("Arithmetic::Min::Bin::XXX::"+str(ipl)+"::"+s,1,d) {}
581  virtual bool solution(const Assignment& x) const {
582  return std::min(x[0],x[0]) == x[0];
583  }
585  virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) {
586  Gecode::min(home, x[0], x[0], x[0], ipl);
587  }
588  };
589 
591  class MaxXYZ : public Test {
592  public:
594  MaxXYZ(const std::string& s, const Gecode::IntSet& d,
596  : Test("Arithmetic::Max::Bin::XYZ::"+str(ipl)+"::"+s,3,d) {
598  }
600  virtual bool solution(const Assignment& x) const {
601  return std::max(x[0],x[1]) == x[2];
602  }
604  virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) {
605  Gecode::max(home, x[0], x[1], x[2], ipl);
606  }
607  };
608 
610  class MaxXXY : public Test {
611  public:
613  MaxXXY(const std::string& s, const Gecode::IntSet& d,
615  : Test("Arithmetic::Max::Bin::XXY::"+str(ipl)+"::"+s,2,d) {}
617  virtual bool solution(const Assignment& x) const {
618  return std::max(x[0],x[0]) == x[1];
619  }
621  virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) {
622  Gecode::max(home, x[0], x[0], x[1], ipl);
623  }
624  };
625 
627  class MaxXYX : public Test {
628  public:
630  MaxXYX(const std::string& s, const Gecode::IntSet& d,
632  : Test("Arithmetic::Max::Bin::XYX::"+str(ipl)+"::"+s,2,d) {}
634  virtual bool solution(const Assignment& x) const {
635  return std::max(x[0],x[1]) == x[0];
636  }
638  virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) {
639  Gecode::max(home, x[0], x[1], x[0], ipl);
640  }
641  };
642 
644  class MaxXYY : public Test {
645  public:
647  MaxXYY(const std::string& s, const Gecode::IntSet& d,
649  : Test("Arithmetic::Max::Bin::XYY::"+str(ipl)+"::"+s,2,d) {}
651  virtual bool solution(const Assignment& x) const {
652  return std::max(x[0],x[1]) == x[1];
653  }
655  virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) {
656  Gecode::max(home, x[0], x[1], x[1], ipl);
657  }
658  };
659 
661  class MaxXXX : public Test {
662  public:
664  MaxXXX(const std::string& s, const Gecode::IntSet& d,
666  : Test("Arithmetic::Max::Bin::XXX::"+str(ipl)+"::"+s,1,d) {}
668  virtual bool solution(const Assignment& x) const {
669  return std::max(x[0],x[0]) == x[0];
670  }
672  virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) {
673  Gecode::max(home, x[0], x[0], x[0], ipl);
674  }
675  };
676 
678  class MinNary : public Test {
679  public:
682  : Test("Arithmetic::Min::Nary::"+str(ipl),4,-4,4,false,ipl) {}
684  virtual bool solution(const Assignment& x) const {
685  return std::min(std::min(x[0],x[1]), x[2]) == x[3];
686  }
688  virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) {
689  Gecode::IntVarArgs m(3);
690  m[0]=x[0]; m[1]=x[1]; m[2]=x[2];
691  Gecode::min(home, m, x[3], ipl);
692  }
693  };
694 
696  class MinNaryShared : public Test {
697  public:
700  : Test("Arithmetic::Min::Nary::Shared::"+str(ipl),3,-4,4,false,ipl) {}
702  virtual bool solution(const Assignment& x) const {
703  return std::min(std::min(x[0],x[1]), x[2]) == x[1];
704  }
706  virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) {
707  Gecode::IntVarArgs m(3);
708  m[0]=x[0]; m[1]=x[1]; m[2]=x[2];
709  Gecode::min(home, m, x[1], ipl);
710  }
711  };
712 
714  class MaxNary : public Test {
715  public:
718  : Test("Arithmetic::Max::Nary::"+str(ipl),4,-4,4,false,ipl) {}
720  virtual bool solution(const Assignment& x) const {
721  return std::max(std::max(x[0],x[1]), x[2]) == x[3];
722  }
724  virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) {
725  Gecode::IntVarArgs m(3);
726  m[0]=x[0]; m[1]=x[1]; m[2]=x[2];
727  Gecode::max(home, m, x[3], ipl);
728  }
729  };
730 
732  class MaxNaryShared : public Test {
733  public:
736  : Test("Arithmetic::Max::Nary::Shared::"+str(ipl),3,-4,4,false,ipl) {}
738  virtual bool solution(const Assignment& x) const {
739  return std::max(std::max(x[0],x[1]), x[2]) == x[1];
740  }
742  virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) {
743  Gecode::IntVarArgs m(3);
744  m[0]=x[0]; m[1]=x[1]; m[2]=x[2];
745  Gecode::max(home, m, x[1], ipl);
746  }
747  };
748 
750  class ArgMax : public Test {
751  protected:
753  int offset;
755  bool tiebreak;
756  public:
758  ArgMax(int n, int o, bool tb)
759  : Test("Arithmetic::ArgMax::"+str(o)+"::"+str(tb)+"::"+str(n),
760  n+1,0,n+1,
761  false,tb ? Gecode::IPL_DEF : Gecode::IPL_DOM),
762  offset(o), tiebreak(tb) {}
764  virtual bool solution(const Assignment& x) const {
765  int n=x.size()-1;
766  if ((x[n] < offset) || (x[n] >= n + offset))
767  return false;
768  int m=x[0]; int p=0;
769  for (int i=1; i<n; i++)
770  if (x[i] > m) {
771  p=i; m=x[i];
772  }
773  return tiebreak ? (p + offset == x[n]) : (m == x[x[n]-offset]);
774  }
776  virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) {
777  int n=x.size()-1;
778  Gecode::IntVarArgs m(n);
779  for (int i=0; i<n; i++)
780  m[i]=x[i];
781  Gecode::argmax(home, m, offset, x[n], tiebreak);
782  }
783  };
784 
786  class ArgMaxShared : public Test {
787  protected:
789  bool tiebreak;
790  public:
792  ArgMaxShared(int n, bool tb)
793  : Test("Arithmetic::ArgMax::Shared::"+str(tb)+"::"+str(n),n+1,0,n+1,
794  false),
795  tiebreak(tb) {
796  testfix=false;
797  }
799  virtual bool solution(const Assignment& x) const {
800  int n=x.size()-1;
801  if ((x[n] < 0) || (x[n] >= 2*n))
802  return false;
803  Gecode::IntArgs y(2*n);
804  for (int i=0; i<n; i++)
805  y[2*i+0]=y[2*i+1]=x[i];
806  int m=y[0]; int p=0;
807  for (int i=1; i<2*n; i++)
808  if (y[i] > m) {
809  p=i; m=y[i];
810  }
811  return tiebreak ? (p == x[n]) : (m == y[x[n]]);
812  }
814  virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) {
815  int n=x.size()-1;
816  Gecode::IntVarArgs m(2*n);
817  for (int i=0; i<n; i++)
818  m[2*i+0]=m[2*i+1]=x[i];
819  Gecode::argmax(home, m, x[n], tiebreak);
820  }
821  };
822 
824  class ArgMin : public Test {
825  protected:
827  int offset;
829  bool tiebreak;
830  public:
832  ArgMin(int n, int o, bool tb)
833  : Test("Arithmetic::ArgMin::"+str(o)+"::"+str(tb)+"::"+str(n),
834  n+1,0,n+1,
835  false,tb ? Gecode::IPL_DEF : Gecode::IPL_DOM),
836  offset(o), tiebreak(tb) {}
838  virtual bool solution(const Assignment& x) const {
839  int n=x.size()-1;
840  if ((x[n] < offset) || (x[n] >= n + offset))
841  return false;
842  int m=x[0]; int p=0;
843  for (int i=1; i<n; i++)
844  if (x[i] < m) {
845  p=i; m=x[i];
846  }
847  return tiebreak ? (p+offset == x[n]) : (m == x[x[n]-offset]);
848  }
850  virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) {
851  int n=x.size()-1;
852  Gecode::IntVarArgs m(n);
853  for (int i=0; i<n; i++)
854  m[i]=x[i];
855  Gecode::argmin(home, m, offset, x[n], tiebreak);
856  }
857  };
858 
860  class ArgMinShared : public Test {
861  protected:
863  bool tiebreak;
864  public:
866  ArgMinShared(int n, bool tb)
867  : Test("Arithmetic::ArgMin::Shared::"+str(tb)+"::"+str(n),n+1,0,n+1,
868  false),
869  tiebreak(tb) {
870  testfix=false;
871  }
873  virtual bool solution(const Assignment& x) const {
874  int n=x.size()-1;
875  if ((x[n] < 0) || (x[n] >= 2*n))
876  return false;
877  Gecode::IntArgs y(2*n);
878  for (int i=0; i<n; i++)
879  y[2*i+0]=y[2*i+1]=x[i];
880  int m=y[0]; int p=0;
881  for (int i=1; i<2*n; i++)
882  if (y[i] < m) {
883  p=i; m=y[i];
884  }
885  return tiebreak ? (p == x[n]) : (m == y[x[n]]);
886  }
888  virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) {
889  int n=x.size()-1;
890  Gecode::IntVarArgs m(2*n);
891  for (int i=0; i<n; i++)
892  m[2*i+0]=m[2*i+1]=x[i];
893  Gecode::argmin(home, m, x[n], tiebreak);
894  }
895  };
896 
897 
898 
900  class Create {
901  public:
903  Create(void) {
904 
905  const int va[7] = {
907  -1,0,1,
908  Gecode::Int::Limits::max-1, Gecode::Int::Limits::max
909  };
910  const int vb[9] = {
911  static_cast<int>(-sqrt(static_cast<double>
913  -4,-2,-1,0,1,2,4,
914  static_cast<int>(sqrt(static_cast<double>
915  (Gecode::Int::Limits::max)))
916  };
917 
918  Gecode::IntSet a(va,7);
919  Gecode::IntSet b(vb,9);
920  Gecode::IntSet c(-8,8);
921  Gecode::IntSet d(-70,70);
922 
923  (void) new DivMod("A",a);
924  (void) new DivMod("B",b);
925  (void) new DivMod("C",c);
926 
927  (void) new Div("A",a);
928  (void) new Div("B",b);
929  (void) new Div("C",c);
930 
931  (void) new Mod("A",a);
932  (void) new Mod("B",b);
933  (void) new Mod("C",c);
934 
935 
936  for (IntPropLevels ipls; ipls(); ++ipls) {
937  (void) new AbsXY("A",a,ipls.ipl());
938  (void) new AbsXY("B",b,ipls.ipl());
939  (void) new AbsXY("C",c,ipls.ipl());
940 
941  (void) new AbsXX("A",a,ipls.ipl());
942  (void) new AbsXX("B",b,ipls.ipl());
943  (void) new AbsXX("C",c,ipls.ipl());
944  if (ipls.ipl() != Gecode::IPL_VAL) {
945  (void) new MultXYZ("A",a,ipls.ipl());
946  (void) new MultXYZ("B",b,ipls.ipl());
947  (void) new MultXYZ("C",c,ipls.ipl());
948 
949  (void) new MultXXY("A",a,ipls.ipl());
950  (void) new MultXXY("B",b,ipls.ipl());
951  (void) new MultXXY("C",c,ipls.ipl());
952 
953  (void) new MultXYX("A",a,ipls.ipl());
954  (void) new MultXYX("B",b,ipls.ipl());
955  (void) new MultXYX("C",c,ipls.ipl());
956 
957  (void) new MultXYY("A",a,ipls.ipl());
958  (void) new MultXYY("B",b,ipls.ipl());
959  (void) new MultXYY("C",c,ipls.ipl());
960 
961  (void) new MultXXX("A",a,ipls.ipl());
962  (void) new MultXXX("B",b,ipls.ipl());
963  (void) new MultXXX("C",c,ipls.ipl());
964 
965  (void) new SqrXY("A",a,ipls.ipl());
966  (void) new SqrXY("B",b,ipls.ipl());
967  (void) new SqrXY("C",c,ipls.ipl());
968 
969  (void) new SqrXX("A",a,ipls.ipl());
970  (void) new SqrXX("B",b,ipls.ipl());
971  (void) new SqrXX("C",c,ipls.ipl());
972 
973  for (int n=0; n<=6; n++) {
974  (void) new PowXY("A",n,a,ipls.ipl());
975  (void) new PowXY("B",n,b,ipls.ipl());
976  (void) new PowXY("C",n,c,ipls.ipl());
977  (void) new PowXY("D",n,d,ipls.ipl());
978 
979  (void) new PowXX("A",n,a,ipls.ipl());
980  (void) new PowXX("B",n,b,ipls.ipl());
981  (void) new PowXX("C",n,c,ipls.ipl());
982  (void) new PowXX("D",n,d,ipls.ipl());
983  }
984 
985  for (int n=1; n<=6; n++) {
986  (void) new NrootXY("A",n,a,ipls.ipl());
987  (void) new NrootXY("B",n,b,ipls.ipl());
988  (void) new NrootXY("C",n,c,ipls.ipl());
989  (void) new NrootXY("D",n,d,ipls.ipl());
990 
991  (void) new NrootXX("A",n,a,ipls.ipl());
992  (void) new NrootXX("B",n,b,ipls.ipl());
993  (void) new NrootXX("C",n,c,ipls.ipl());
994  (void) new NrootXX("D",n,d,ipls.ipl());
995  }
996 
997  for (int n=30; n<=34; n++) {
998  (void) new PowXY("C",n,c,ipls.ipl());
999  (void) new PowXX("C",n,c,ipls.ipl());
1000  (void) new NrootXY("C",n,c,ipls.ipl());
1001  (void) new NrootXX("C",n,c,ipls.ipl());
1002  }
1003 
1004  (void) new SqrtXY("A",a,ipls.ipl());
1005  (void) new SqrtXY("B",b,ipls.ipl());
1006  (void) new SqrtXY("C",c,ipls.ipl());
1007 
1008  (void) new SqrtXX("A",a,ipls.ipl());
1009  (void) new SqrtXX("B",b,ipls.ipl());
1010  (void) new SqrtXX("C",c,ipls.ipl());
1011 
1012  (void) new MinXYZ("A",a,ipls.ipl());
1013  (void) new MinXYZ("B",b,ipls.ipl());
1014  (void) new MinXYZ("C",c,ipls.ipl());
1015 
1016  (void) new MinXXY("A",a,ipls.ipl());
1017  (void) new MinXXY("B",b,ipls.ipl());
1018  (void) new MinXXY("C",c,ipls.ipl());
1019 
1020  (void) new MinXYX("A",a,ipls.ipl());
1021  (void) new MinXYX("B",b,ipls.ipl());
1022  (void) new MinXYX("C",c,ipls.ipl());
1023 
1024  (void) new MinXYY("A",a,ipls.ipl());
1025  (void) new MinXYY("B",b,ipls.ipl());
1026  (void) new MinXYY("C",c,ipls.ipl());
1027 
1028  (void) new MinXXX("A",a,ipls.ipl());
1029  (void) new MinXXX("B",b,ipls.ipl());
1030  (void) new MinXXX("C",c,ipls.ipl());
1031 
1032  (void) new MaxXYZ("A",a,ipls.ipl());
1033  (void) new MaxXYZ("B",b,ipls.ipl());
1034  (void) new MaxXYZ("C",c,ipls.ipl());
1035 
1036  (void) new MaxXXY("A",a,ipls.ipl());
1037  (void) new MaxXXY("B",b,ipls.ipl());
1038  (void) new MaxXXY("C",c,ipls.ipl());
1039 
1040  (void) new MaxXYX("A",a,ipls.ipl());
1041  (void) new MaxXYX("B",b,ipls.ipl());
1042  (void) new MaxXYX("C",c,ipls.ipl());
1043 
1044  (void) new MaxXYY("A",a,ipls.ipl());
1045  (void) new MaxXYY("B",b,ipls.ipl());
1046  (void) new MaxXYY("C",c,ipls.ipl());
1047 
1048  (void) new MaxXXX("A",a,ipls.ipl());
1049  (void) new MaxXXX("B",b,ipls.ipl());
1050  (void) new MaxXXX("C",c,ipls.ipl());
1051 
1052  (void) new MinNary(ipls.ipl());
1053  (void) new MinNaryShared(ipls.ipl());
1054  (void) new MaxNary(ipls.ipl());
1055  (void) new MaxNaryShared(ipls.ipl());
1056  }
1057  }
1058 
1059  for (int i=1; i<5; i++) {
1060  (void) new ArgMax(i,0,true);
1061  (void) new ArgMax(i,1,true);
1062  (void) new ArgMaxShared(i,true);
1063  (void) new ArgMin(i,0,true);
1064  (void) new ArgMin(i,1,true);
1065  (void) new ArgMinShared(i,true);
1066  (void) new ArgMax(i,0,false);
1067  (void) new ArgMax(i,1,false);
1068  (void) new ArgMaxShared(i,false);
1069  (void) new ArgMin(i,0,false);
1070  (void) new ArgMin(i,1,false);
1071  (void) new ArgMinShared(i,false);
1072  }
1073  }
1074  };
1075 
1078 
1079  }
1080 }}
1081 
1082 // STATISTICS: test-int
Test for power constraint
Definition: arithmetic.cpp:226
Test for multiplication constraint
Definition: arithmetic.cpp:52
virtual bool solution(const Assignment &x) const
Test whether x is solution
Definition: arithmetic.cpp:738
void mod(Home home, IntVar x0, IntVar x1, IntVar x2, IntPropLevel ipl)
Post propagator for .
Definition: arithmetic.cpp:263
Test for argument maximum constraint with shared variables
Definition: arithmetic.cpp:786
static std::string str(Gecode::IntPropLevel ipl)
Map integer propagation level to string.
Definition: int.hpp:208
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
Definition: arithmetic.cpp:604
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
Definition: arithmetic.cpp:66
Test for binary minimum constraint with shared variables
Definition: arithmetic.cpp:557
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
Definition: arithmetic.cpp:776
Test for binary minimum constraint with shared variables
Definition: arithmetic.cpp:574
void min(Home home, const IntVarArgs &x, IntVar y, IntPropLevel ipl)
Post propagator for .
Definition: arithmetic.cpp:91
void mult(Home home, FloatVar x0, FloatVar x1, FloatVar x2)
Post propagator for .
Definition: arithmetic.cpp:88
bool tiebreak
Whether to use tie-breaking.
Definition: arithmetic.cpp:829
virtual bool solution(const Assignment &x) const
Test whether x is solution
Definition: arithmetic.cpp:79
NNF * l
Left subtree.
Definition: bool-expr.cpp:240
void sqrt(Home home, IntVar x0, IntVar x1, IntPropLevel ipl)
Post propagator for .
Definition: arithmetic.cpp:286
Test for binary maximum constraint with shared variables
Definition: arithmetic.cpp:644
SqrXX(const std::string &s, const Gecode::IntSet &d, Gecode::IntPropLevel ipl)
Create and register test.
Definition: arithmetic.cpp:174
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
Definition: arithmetic.cpp:362
Test for binary maximum constraint with shared variables
Definition: arithmetic.cpp:661
MaxXYZ(const std::string &s, const Gecode::IntSet &d, Gecode::IntPropLevel ipl)
Create and register test.
Definition: arithmetic.cpp:594
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
Definition: arithmetic.cpp:248
int size(void) const
Return size of array (number of elements)
Definition: array.hpp:908
PowXX(const std::string &s, int n0, const Gecode::IntSet &d, Gecode::IntPropLevel ipl)
Create and register test.
Definition: arithmetic.cpp:264
virtual bool solution(const Assignment &x) const
Test whether x is solution
Definition: arithmetic.cpp:269
MaxXYY(const std::string &s, const Gecode::IntSet &d, Gecode::IntPropLevel ipl)
Create and register test.
Definition: arithmetic.cpp:647
Test for argument minimum constraint with shared variables
Definition: arithmetic.cpp:860
int size(void) const
Return number of variables.
Definition: int.hpp:46
virtual bool solution(const Assignment &x) const
Test whether x is solution
Definition: arithmetic.cpp:720
Test for squaring constraint
Definition: arithmetic.cpp:152
Help class to create and register tests.
Definition: arithmetic.cpp:900
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
Definition: arithmetic.cpp:814
Test for argument maximum constraint
Definition: arithmetic.cpp:750
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
Definition: arithmetic.cpp:500
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
Definition: arithmetic.cpp:672
MultXXY(const std::string &s, const Gecode::IntSet &d, Gecode::IntPropLevel ipl)
Create and register test.
Definition: arithmetic.cpp:75
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
Definition: arithmetic.cpp:888
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
Definition: arithmetic.cpp:568
virtual bool solution(const Assignment &x) const
Test whether x is solution
Definition: arithmetic.cpp:838
MinXXY(const std::string &s, const Gecode::IntSet &d, Gecode::IntPropLevel ipl)
Create and register test.
Definition: arithmetic.cpp:526
void max(Home home, FloatVar x0, FloatVar x1, FloatVar x2)
Post propagator for .
Definition: arithmetic.cpp:49
void abs(Home home, FloatVar x0, FloatVar x1)
Post propagator for .
Definition: arithmetic.cpp:41
virtual bool solution(const Assignment &x) const
Test whether x is solution
Definition: arithmetic.cpp:799
void nroot(Home home, FloatVar x0, int n, FloatVar x1)
Post propagator for for $n 0$.
Definition: arithmetic.cpp:118
NrootXY(const std::string &s, int n0, const Gecode::IntSet &d, Gecode::IntPropLevel ipl)
Floor.
Definition: arithmetic.cpp:348
MultXYX(const std::string &s, const Gecode::IntSet &d, Gecode::IntPropLevel ipl)
Create and register test.
Definition: arithmetic.cpp:95
bool tiebreak
Whether to use tie-breaking.
Definition: arithmetic.cpp:755
virtual bool solution(const Assignment &x) const
Test whether x is solution
Definition: arithmetic.cpp:651
void pow(Home home, FloatVar x0, int n, FloatVar x1)
Post propagator for for $n 0$.
Definition: arithmetic.cpp:109
bool powle(int n, long long int r, int x)
Definition: arithmetic.cpp:312
void abs(Home home, IntVar x0, IntVar x1, IntPropLevel ipl)
Post propagator for .
Definition: arithmetic.cpp:39
MinXYY(const std::string &s, const Gecode::IntSet &d, Gecode::IntPropLevel ipl)
Create and register test.
Definition: arithmetic.cpp:560
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
Definition: arithmetic.cpp:183
Test for multiplication constraint with shared variables
Definition: arithmetic.cpp:112
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
Definition: arithmetic.cpp:126
SqrtXX(const std::string &s, const Gecode::IntSet &d, Gecode::IntPropLevel ipl)
Create and register test.
Definition: arithmetic.cpp:211
virtual bool solution(const Assignment &x) const
Test whether x is solution
Definition: arithmetic.cpp:196
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
Definition: arithmetic.cpp:106
Integer variable array.
Definition: int.hh:763
void argmin(Home home, const IntVarArgs &x, IntVar y, bool tiebreak, IntPropLevel)
Post propagator for .
Definition: arithmetic.cpp:163
virtual bool solution(const Assignment &x) const
Test whether x is solution
Definition: arithmetic.cpp:428
int offset
Offset to be used.
Definition: arithmetic.cpp:753
virtual bool solution(const Assignment &x) const
Test whether x is solution
Definition: arithmetic.cpp:494
Test for binary minimum constraint
Definition: arithmetic.cpp:506
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
Definition: arithmetic.cpp:534
ConTestLevel contest
Whether to test for certain consistency.
Definition: int.hh:236
const int max
Largest allowed integer value.
Definition: int.hh:116
Computation spaces.
Definition: core.hpp:1701
Test for binary maximum constraint
Definition: arithmetic.cpp:591
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:448
virtual bool solution(const Assignment &x) const
Test whether x is solution
Definition: arithmetic.cpp:159
MinNaryShared(Gecode::IntPropLevel ipl)
Create and register test.
Definition: arithmetic.cpp:699
Gecode::IntSet d1(v1, 7)
virtual bool solution(const Assignment &x) const
Test whether x is solution
Definition: arithmetic.cpp:600
Gecode::IntSet d(v, 7)
virtual bool solution(const Assignment &x) const
Test whether x is solution
Definition: arithmetic.cpp:668
Test for n-ary maximum constraint
Definition: arithmetic.cpp:714
virtual bool solution(const Assignment &x) const
Test whether x is solution
Definition: arithmetic.cpp:139
ArgMinShared(int n, bool tb)
Create and register test.
Definition: arithmetic.cpp:866
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
Definition: arithmetic.cpp:742
Test for n-ary minimmum constraint
Definition: arithmetic.cpp:678
MultXXX(const std::string &s, const Gecode::IntSet &d, Gecode::IntPropLevel ipl)
Create and register test.
Definition: arithmetic.cpp:135
MinXXX(const std::string &s, const Gecode::IntSet &d, Gecode::IntPropLevel ipl)
Create and register test.
Definition: arithmetic.cpp:577
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
Definition: arithmetic.cpp:280
int p
Number of positive literals for node type.
Definition: bool-expr.cpp:232
ArgMin(int n, int o, bool tb)
Create and register test.
Definition: arithmetic.cpp:832
Div(const std::string &s, const Gecode::IntSet &d)
Create and register test.
Definition: arithmetic.cpp:425
int n
Number of negative literals for node type.
Definition: bool-expr.cpp:234
Equality ( )
Definition: int.hh:926
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
Definition: arithmetic.cpp:517
AbsXX(const std::string &s, const Gecode::IntSet &d, Gecode::IntPropLevel ipl)
Create and register test.
Definition: arithmetic.cpp:490
Test for n-ary maximum constraint with shared variables
Definition: arithmetic.cpp:732
Test for binary minimum constraint with shared variables
Definition: arithmetic.cpp:523
Gecode::IntSet d2(v2, 9)
Gecode::IntArgs i({1, 2, 3, 4})
void divmod(Home home, IntVar x0, IntVar x1, IntVar x2, IntVar x3, IntPropLevel)
Post propagator for .
Definition: arithmetic.cpp:230
Test for absolute value constraint with shared variables
Definition: arithmetic.cpp:487
int fnroot(int n, int x)
Definition: arithmetic.cpp:297
Create(void)
Perform creation and registration.
Definition: arithmetic.cpp:903
Test for binary maximum constraint with shared variables
Definition: arithmetic.cpp:610
void sqr(Home home, FloatVar x0, FloatVar x1)
Post propagator for .
Definition: arithmetic.cpp:95
Simple propagation levels.
Definition: int.hh:976
virtual bool solution(const Assignment &x) const
Test whether x is solution
Definition: arithmetic.cpp:237
void sqrt(Home home, FloatVar x0, FloatVar x1)
Post propagator for .
Definition: arithmetic.cpp:102
Test for square root constraint with shared variables
Definition: arithmetic.cpp:208
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
Definition: arithmetic.cpp:165
Value propagation.
Definition: int.hh:977
MultXYZ(const std::string &s, const Gecode::IntSet &d, Gecode::IntPropLevel ipl)
Create and register test.
Definition: arithmetic.cpp:55
void argmax(Home home, const IntVarArgs &x, IntVar y, bool tiebreak, IntPropLevel)
Post propagator for .
Definition: arithmetic.cpp:110
Test for bounds(z)-consistency.
Definition: int.hh:143
virtual bool solution(const Assignment &x) const
Test whether x is solution
Definition: arithmetic.cpp:617
Test for modulo constraint
Definition: arithmetic.cpp:445
virtual bool solution(const Assignment &x) const
Test whether x is solution
Definition: arithmetic.cpp:634
NrootXX(const std::string &s, int n0, const Gecode::IntSet &d, Gecode::IntPropLevel ipl)
Create and register test.
Definition: arithmetic.cpp:378
virtual bool solution(const Assignment &x) const
Test whether x is solution
Definition: arithmetic.cpp:353
Integer sets.
Definition: int.hh:174
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
Definition: arithmetic.cpp:462
int cnroot(int n, int x)
Definition: arithmetic.cpp:325
MultXYY(const std::string &s, const Gecode::IntSet &d, Gecode::IntPropLevel ipl)
Create and register test.
Definition: arithmetic.cpp:115
Test for multiplication constraint with shared variables
Definition: arithmetic.cpp:92
ArgMax(int n, int o, bool tb)
Create and register test.
Definition: arithmetic.cpp:758
Test for multiplication constraint with shared variables
Definition: arithmetic.cpp:72
Gecode::IntPropLevel ipl
Propagation level.
Definition: int.hh:234
Passing integer variables.
Definition: int.hh:656
Passing integer arguments.
Definition: int.hh:628
void nroot(Home home, IntVar x0, int n, IntVar x1, IntPropLevel ipl)
Post propagator for .
Definition: arithmetic.cpp:319
virtual bool solution(const Assignment &x) const
Test whether x is solution
Definition: arithmetic.cpp:178
virtual bool solution(const Assignment &x) const
Test whether x is solution
Definition: arithmetic.cpp:215
BoolVar expr(Home home, const BoolExpr &e, IntPropLevel ipl)
Post Boolean expression and return its value.
Definition: bool-expr.cpp:627
MaxXXY(const std::string &s, const Gecode::IntSet &d, Gecode::IntPropLevel ipl)
Create and register test.
Definition: arithmetic.cpp:613
bool powgr(int n, long long int r, int x)
Definition: arithmetic.cpp:285
union Gecode::@593::NNF::@62 u
Union depending on nodetype t.
virtual bool solution(const Assignment &x) const
Test whether x is solution
Definition: arithmetic.cpp:581
bool testfix
Whether to perform fixpoint test.
Definition: int.hh:240
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
Definition: arithmetic.cpp:621
void min(Home home, FloatVar x0, FloatVar x1, FloatVar x2)
Post propagator for .
Definition: arithmetic.cpp:67
virtual bool solution(const Assignment &x) const
Test whether x is solution
Definition: arithmetic.cpp:873
AbsXY(const std::string &s, const Gecode::IntSet &d, Gecode::IntPropLevel ipl)
Create and register test.
Definition: arithmetic.cpp:471
General test support.
Definition: afc.cpp:39
IntPropLevel
Propagation levels for integer propagators.
Definition: int.hh:974
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
Definition: arithmetic.cpp:655
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
Definition: arithmetic.cpp:585
Test for power constraint with shared variables
Definition: arithmetic.cpp:258
Gecode::FloatVal b(9, 12)
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
Definition: arithmetic.cpp:481
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
Definition: arithmetic.cpp:439
bool tiebreak
Whether to use tie-breaking.
Definition: arithmetic.cpp:789
Post propagator for SetVar SetOpType SetVar y
Definition: set.hh:767
SqrXY(const std::string &s, const Gecode::IntSet &d, Gecode::IntPropLevel ipl)
Create and register test.
Definition: arithmetic.cpp:155
void div(Home home, FloatVar x0, FloatVar x1, FloatVar x2)
Post propagator for .
Definition: arithmetic.cpp:127
PowXY(const std::string &s, int n0, const Gecode::IntSet &d, Gecode::IntPropLevel ipl)
Create and register test.
Definition: arithmetic.cpp:232
MinXYZ(const std::string &s, const Gecode::IntSet &d, Gecode::IntPropLevel ipl)
Create and register test.
Definition: arithmetic.cpp:509
void max(Home home, const IntVarArgs &x, IntVar y, IntPropLevel ipl)
Post propagator for .
Definition: arithmetic.cpp:63
Node * x
Pointer to corresponding Boolean expression node.
Definition: bool-expr.cpp:249
Test for division constraint
Definition: arithmetic.cpp:422
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
Definition: arithmetic.cpp:393
virtual bool solution(const Assignment &x) const
Test whether x is solution
Definition: arithmetic.cpp:547
virtual bool solution(const Assignment &x) const
Test whether x is solution
Definition: arithmetic.cpp:684
Test for division/modulo constraint
Definition: arithmetic.cpp:399
Test for nroot constraint with shared variables
Definition: arithmetic.cpp:372
virtual bool solution(const Assignment &x) const
Test whether x is solution
Definition: arithmetic.cpp:702
MaxNary(Gecode::IntPropLevel ipl)
Create and register test.
Definition: arithmetic.cpp:717
virtual bool solution(const Assignment &x) const
Test whether x is solution
Definition: arithmetic.cpp:530
Test for binary minimum constraint with shared variables
Definition: arithmetic.cpp:540
Test for square root constraint
Definition: arithmetic.cpp:189
virtual bool solution(const Assignment &x) const
Test whether x is solution
Definition: arithmetic.cpp:451
Region r
Definition: region.cpp:65
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
Definition: arithmetic.cpp:416
Base class for assignments
Definition: int.hh:59
void pow(Home home, IntVar x0, int n, IntVar x1, IntPropLevel ipl)
Post propagator for .
Definition: arithmetic.cpp:300
Test for binary maximum constraint with shared variables
Definition: arithmetic.cpp:627
void rel(Home home, FloatVar x0, FloatRelType frt, FloatVal n)
Propagates .
Definition: rel.cpp:43
MinNary(Gecode::IntPropLevel ipl)
Create and register test.
Definition: arithmetic.cpp:681
MaxXXX(const std::string &s, const Gecode::IntSet &d, Gecode::IntPropLevel ipl)
Create and register test.
Definition: arithmetic.cpp:664
virtual bool solution(const Assignment &x) const
Test whether x is solution
Definition: arithmetic.cpp:383
Domain propagation Options: basic versus advanced propagation.
Definition: int.hh:979
Gecode::FloatVal a(-8, 5)
Test for squaring constraint with shared variables
Definition: arithmetic.cpp:171
Test for absolute value constraint
Definition: arithmetic.cpp:468
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
Definition: arithmetic.cpp:850
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
Definition: arithmetic.cpp:86
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
Definition: arithmetic.cpp:146
MaxXYX(const std::string &s, const Gecode::IntSet &d, Gecode::IntPropLevel ipl)
Create and register test.
Definition: arithmetic.cpp:630
Gecode toplevel namespace
virtual bool solution(const Assignment &x) const
Test whether x is solution
Definition: arithmetic.cpp:99
Test for argument minimum constraint
Definition: arithmetic.cpp:824
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
Definition: arithmetic.cpp:688
virtual bool solution(const Assignment &x) const
Test whether x is solution
Definition: arithmetic.cpp:410
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
Definition: arithmetic.cpp:706
ArgMaxShared(int n, bool tb)
Create and register test.
Definition: arithmetic.cpp:792
virtual bool solution(const Assignment &x) const
Test whether x is solution
Definition: arithmetic.cpp:119
MinXYX(const std::string &s, const Gecode::IntSet &d, Gecode::IntPropLevel ipl)
Create and register test.
Definition: arithmetic.cpp:543
virtual bool solution(const Assignment &x) const
Test whether x is solution
Definition: arithmetic.cpp:59
Test for nroot constraint
Definition: arithmetic.cpp:341
DivMod(const std::string &s, const Gecode::IntSet &d)
Create and register test.
Definition: arithmetic.cpp:407
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
Definition: arithmetic.cpp:638
Test for multiplication constraint with shared variables
Definition: arithmetic.cpp:132
virtual bool solution(const Assignment &x) const
Test whether x is solution
Definition: arithmetic.cpp:513
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
Definition: arithmetic.cpp:220
int offset
Which offset to use.
Definition: arithmetic.cpp:827
virtual bool solution(const Assignment &x) const
Test whether x is solution
Definition: arithmetic.cpp:564
virtual bool solution(const Assignment &x) const
Test whether x is solution
Definition: arithmetic.cpp:764
SqrtXY(const std::string &s, const Gecode::IntSet &d, Gecode::IntPropLevel ipl)
Create and register test.
Definition: arithmetic.cpp:192
Iterator for simple integer propagation levels.
Definition: int.hh:332
Test for n-ary minimmum constraint with shared variables
Definition: arithmetic.cpp:696
MaxNaryShared(Gecode::IntPropLevel ipl)
Create and register test.
Definition: arithmetic.cpp:735
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
Definition: arithmetic.cpp:551
bool tiebreak
Whether to use tie-breaking.
Definition: arithmetic.cpp:863
virtual bool solution(const Assignment &x) const
Test whether x is solution
Definition: arithmetic.cpp:475
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
Definition: arithmetic.cpp:202
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
Definition: arithmetic.cpp:724