arithmetic.cpp
Go to the documentation of this file.
/* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
/*
* Main authors:
* Christian Schulte <schulte@gecode.org>
*
* Copyright:
* Christian Schulte, 2005
*
* This file is part of Gecode, the generic constraint
* development environment:
* http://www.gecode.org
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/
#include "test/int.hh"
#include <cmath>
#include <algorithm>
#include <gecode/minimodel.hh>
namespace Test { namespace Int {
namespace Arithmetic {
class MultXYZ : public Test {
public:
MultXYZ(const std::string& s, const Gecode::IntSet& d,
Gecode::IntPropLevel ipl)
: Test("Arithmetic::Mult::XYZ::"+str(ipl)+"::"+s,3,d,false,ipl) {}
virtual bool solution(const Assignment& x) const {
double d0 = static_cast<double>(x[0]);
double d1 = static_cast<double>(x[1]);
double d2 = static_cast<double>(x[2]);
return d0*d1 == d2;
}
virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) {
Gecode::mult(home, x[0], x[1], x[2], ipl);
}
};
class MultXXY : public Test {
public:
MultXXY(const std::string& s, const Gecode::IntSet& d,
Gecode::IntPropLevel ipl)
: Test("Arithmetic::Mult::XXY::"+str(ipl)+"::"+s,2,d,false,ipl) {}
virtual bool solution(const Assignment& x) const {
double d0 = static_cast<double>(x[0]);
double d1 = static_cast<double>(x[0]);
double d2 = static_cast<double>(x[1]);
return d0*d1 == d2;
}
virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) {
Gecode::mult(home, x[0], x[0], x[1], ipl);
}
};
class MultXYX : public Test {
public:
MultXYX(const std::string& s, const Gecode::IntSet& d,
Gecode::IntPropLevel ipl)
: Test("Arithmetic::Mult::XYX::"+str(ipl)+"::"+s,2,d,false,ipl) {}
virtual bool solution(const Assignment& x) const {
double d0 = static_cast<double>(x[0]);
double d1 = static_cast<double>(x[1]);
double d2 = static_cast<double>(x[0]);
return d0*d1 == d2;
}
virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) {
Gecode::mult(home, x[0], x[1], x[0], ipl);
}
};
class MultXYY : public Test {
public:
MultXYY(const std::string& s, const Gecode::IntSet& d,
Gecode::IntPropLevel ipl)
: Test("Arithmetic::Mult::XYY::"+str(ipl)+"::"+s,2,d,false,ipl) {}
virtual bool solution(const Assignment& x) const {
double d0 = static_cast<double>(x[0]);
double d1 = static_cast<double>(x[1]);
double d2 = static_cast<double>(x[1]);
return d0*d1 == d2;
}
virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) {
Gecode::mult(home, x[0], x[1], x[1], ipl);
}
};
class MultXXX : public Test {
public:
MultXXX(const std::string& s, const Gecode::IntSet& d,
Gecode::IntPropLevel ipl)
: Test("Arithmetic::Mult::XXX::"+str(ipl)+"::"+s,1,d,false,ipl) {}
virtual bool solution(const Assignment& x) const {
double d0 = static_cast<double>(x[0]);
double d1 = static_cast<double>(x[0]);
double d2 = static_cast<double>(x[0]);
return d0*d1 == d2;
}
virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) {
Gecode::mult(home, x[0], x[0], x[0], ipl);
}
};
class SqrXY : public Test {
public:
SqrXY(const std::string& s, const Gecode::IntSet& d,
Gecode::IntPropLevel ipl)
: Test("Arithmetic::Sqr::XY::"+str(ipl)+"::"+s,2,d,false,ipl) {}
virtual bool solution(const Assignment& x) const {
double d0 = static_cast<double>(x[0]);
double d1 = static_cast<double>(x[1]);
return d0*d0 == d1;
}
virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) {
Gecode::sqr(home, x[0], x[1], ipl);
}
};
class SqrXX : public Test {
public:
SqrXX(const std::string& s, const Gecode::IntSet& d,
Gecode::IntPropLevel ipl)
: Test("Arithmetic::Sqr::XX::"+str(ipl)+"::"+s,1,d,false,ipl) {}
virtual bool solution(const Assignment& x) const {
double d0 = static_cast<double>(x[0]);
return d0*d0 == d0;
}
virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) {
Gecode::sqr(home, x[0], x[0], ipl);
}
};
class SqrtXY : public Test {
public:
SqrtXY(const std::string& s, const Gecode::IntSet& d,
Gecode::IntPropLevel ipl)
: Test("Arithmetic::Sqrt::XY::"+str(ipl)+"::"+s,2,d,false,ipl) {}
virtual bool solution(const Assignment& x) const {
double d0 = static_cast<double>(x[0]);
double d1 = static_cast<double>(x[1]);
return (d0 >= 0) && (d0 >= d1*d1) && (d0 < (d1+1)*(d1+1));
}
virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) {
Gecode::sqrt(home, x[0], x[1], ipl);
}
};
class SqrtXX : public Test {
public:
SqrtXX(const std::string& s, const Gecode::IntSet& d,
Gecode::IntPropLevel ipl)
: Test("Arithmetic::Sqrt::XX::"+str(ipl)+"::"+s,1,d,false,ipl) {}
virtual bool solution(const Assignment& x) const {
double d0 = static_cast<double>(x[0]);
return (d0 >= 0) && (d0 >= d0*d0) && (d0 < (d0+1)*(d0+1));
}
virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) {
Gecode::sqrt(home, x[0], x[0], ipl);
}
};
class PowXY : public Test {
protected:
int n;
public:
PowXY(const std::string& s, int n0, const Gecode::IntSet& d,
Gecode::IntPropLevel ipl)
: Test("Arithmetic::Pow::XY::"+str(n0)+"::"+str(ipl)+"::"+s,
2,d,false,ipl), n(n0) {}
virtual bool solution(const Assignment& x) const {
long long int p = 1;
for (int i=0; i<n; i++) {
p *= x[0];
if ((p < Gecode::Int::Limits::min) ||
(p > Gecode::Int::Limits::max))
return false;
}
return p == x[1];
}
virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) {
using namespace Gecode;
if (n > 4)
pow(home, x[0], n, x[1], ipl);
else
rel(home, expr(home, pow(x[0],n), ipl), IRT_EQ, x[1], ipl);
}
};
class PowXX : public Test {
protected:
int n;
public:
PowXX(const std::string& s, int n0, const Gecode::IntSet& d,
Gecode::IntPropLevel ipl)
: Test("Arithmetic::Pow::XX::"+str(n0)+"::"+str(ipl)+"::"+s,
1,d,false,ipl), n(n0) {}
virtual bool solution(const Assignment& x) const {
long long int p = 1;
for (int i=0; i<n; i++) {
p *= x[0];
if ((p < Gecode::Int::Limits::min) ||
(p > Gecode::Int::Limits::max))
return false;
}
return p == x[0];
}
virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) {
Gecode::pow(home, x[0], n, x[0], ipl);
}
};
bool powgr(int n, long long int r, int x) {
assert(r >= 0);
long long int y = r;
long long int p = 1;
do {
p *= y; n--;
if (p > x)
return true;
} while (n > 0);
return false;
}
int fnroot(int n, int x) {
if (x < 2)
return x;
/*
* We look for l such that: l^n <= x < (l+1)^n
*/
long long int l = 1;
long long int u = x;
do {
long long int m = (l + u) >> 1;
if (powgr(n,m,x)) u=m; else l=m;
} while (l+1 < u);
return static_cast<int>(l);
}
bool powle(int n, long long int r, int x) {
assert(r >= 0);
long long int y = r;
long long int p = 1;
do {
p *= y; n--;
if (p >= x)
return false;
} while (n > 0);
assert(y < x);
return true;
}
int cnroot(int n, int x) {
if (x < 2)
return x;
/*
* We look for u such that: (u-1)^n < x <= u^n
*/
long long int l = 1;
long long int u = x;
do {
long long int m = (l + u) >> 1;
if (powle(n,m,x)) l=m; else u=m;
} while (l+1 < u);
return static_cast<int>(u);
}
class NrootXY : public Test {
protected:
int n;
public:
NrootXY(const std::string& s, int n0, const Gecode::IntSet& d,
Gecode::IntPropLevel ipl)
: Test("Arithmetic::Nroot::XY::"+str(n0)+"::"+str(ipl)+"::"+s,
2,d,false,ipl), n(n0) {}
virtual bool solution(const Assignment& x) const {
if (n == 1)
return x[0] == x[1];
if ((n % 2 == 0) && ((x[0] < 0) || (x[1] < 0)))
return false;
int r = (x[0] < 0) ? -cnroot(n,-x[0]) : fnroot(n,x[0]);
return r == x[1];
}
virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) {
using namespace Gecode;
if (n > 4)
nroot(home, x[0], n, x[1], ipl);
else
rel(home, expr(home, nroot(x[0],n), ipl), IRT_EQ, x[1], ipl);
}
};
class NrootXX : public Test {
protected:
int n;
public:
NrootXX(const std::string& s, int n0, const Gecode::IntSet& d,
Gecode::IntPropLevel ipl)
: Test("Arithmetic::Nroot::XX::"+str(n0)+"::"+str(ipl)+"::"+s,
1,d,false,ipl), n(n0) {}
virtual bool solution(const Assignment& x) const {
if (n == 1)
return true;
if (n % 2 == 0) {
return (x[0] >= 0) && (x[0] <= 1);
} else {
return (x[0] >= -2) && (x[0] <= 1);
}
}
virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) {
Gecode::nroot(home, x[0], n, x[0], ipl);
}
};
class DivMod : public Test {
private:
static int abs(int a) { return a<0 ? -a:a; }
static int sgn(int a) { return a<0 ? -1:1; }
public:
DivMod(const std::string& s, const Gecode::IntSet& d)
: Test("Arithmetic::DivMod::"+s,4,d) {}
virtual bool solution(const Assignment& x) const {
return x[0] == x[1]*x[2]+x[3] &&
abs(x[3]) < abs(x[1]) &&
(x[3] == 0 || sgn(x[3]) == sgn(x[0]));
}
virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) {
Gecode::divmod(home, x[0], x[1], x[2], x[3]);
}
};
class Div : public Test {
public:
Div(const std::string& s, const Gecode::IntSet& d)
: Test("Arithmetic::Div::"+s,3,d) {}
virtual bool solution(const Assignment& x) const {
if (x[1] == 0)
return false;
int divsign = (x[0] / x[1] < 0) ? -1 : 1;
int divresult =
divsign *
static_cast<int>(floor(static_cast<double>(std::abs(x[0]))/
static_cast<double>(std::abs(x[1]))));
return x[2] == divresult;
}
virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) {
Gecode::div(home, x[0], x[1], x[2]);
}
};
class Mod : public Test {
public:
Mod(const std::string& s, const Gecode::IntSet& d)
: Test("Arithmetic::Mod::"+s,3,d) {}
virtual bool solution(const Assignment& x) const {
if (x[1] == 0)
return false;
int divsign = (x[0] / x[1] < 0) ? -1 : 1;
int divresult =
divsign *
static_cast<int>(floor(static_cast<double>(std::abs(x[0]))/
static_cast<double>(std::abs(x[1]))));
return x[0] == x[1]*divresult+x[2];
}
virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) {
Gecode::mod(home, x[0], x[1], x[2]);
}
};
class AbsXY : public Test {
public:
AbsXY(const std::string& s, const Gecode::IntSet& d,
Gecode::IntPropLevel ipl)
: Test("Arithmetic::Abs::XY::"+str(ipl)+"::"+s,2,d,false,ipl) {}
virtual bool solution(const Assignment& x) const {
double d0 = static_cast<double>(x[0]);
double d1 = static_cast<double>(x[1]);
return (d0<0 ? -d0 : d0) == d1;
}
virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) {
Gecode::abs(home, x[0], x[1], ipl);
}
};
class AbsXX : public Test {
public:
AbsXX(const std::string& s, const Gecode::IntSet& d,
Gecode::IntPropLevel ipl)
: Test("Arithmetic::Abs::XX::"+str(ipl)+"::"+s,1,d,false,ipl) {}
virtual bool solution(const Assignment& x) const {
double d0 = static_cast<double>(x[0]);
double d1 = static_cast<double>(x[0]);
return (d0<0 ? -d0 : d0) == d1;
}
virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) {
Gecode::abs(home, x[0], x[0], ipl);
}
};
class MinXYZ : public Test {
public:
MinXYZ(const std::string& s, const Gecode::IntSet& d,
Gecode::IntPropLevel ipl)
: Test("Arithmetic::Min::Bin::XYZ::"+str(ipl)+"::"+s,3,d,false,ipl) {}
virtual bool solution(const Assignment& x) const {
return std::min(x[0],x[1]) == x[2];
}
virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) {
Gecode::min(home, x[0], x[1], x[2], ipl);
}
};
class MinXXY : public Test {
public:
MinXXY(const std::string& s, const Gecode::IntSet& d,
Gecode::IntPropLevel ipl)
: Test("Arithmetic::Min::Bin::XYX::"+str(ipl)+"::"+s,2,d) {}
virtual bool solution(const Assignment& x) const {
return std::min(x[0],x[0]) == x[1];
}
virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) {
Gecode::min(home, x[0], x[0], x[1], ipl);
}
};
class MinXYX : public Test {
public:
MinXYX(const std::string& s, const Gecode::IntSet& d,
Gecode::IntPropLevel ipl)
: Test("Arithmetic::Min::Bin::XYX::"+str(ipl)+"::"+s,2,d) {}
virtual bool solution(const Assignment& x) const {
return std::min(x[0],x[1]) == x[0];
}
virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) {
Gecode::min(home, x[0], x[1], x[0], ipl);
}
};
class MinXYY : public Test {
public:
MinXYY(const std::string& s, const Gecode::IntSet& d,
Gecode::IntPropLevel ipl)
: Test("Arithmetic::Min::Bin::XYY::"+str(ipl)+"::"+s,2,d) {}
virtual bool solution(const Assignment& x) const {
return std::min(x[0],x[1]) == x[1];
}
virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) {
Gecode::min(home, x[0], x[1], x[1], ipl);
}
};
class MinXXX : public Test {
public:
MinXXX(const std::string& s, const Gecode::IntSet& d,
Gecode::IntPropLevel ipl)
: Test("Arithmetic::Min::Bin::XXX::"+str(ipl)+"::"+s,1,d) {}
virtual bool solution(const Assignment& x) const {
return std::min(x[0],x[0]) == x[0];
}
virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) {
Gecode::min(home, x[0], x[0], x[0], ipl);
}
};
class MaxXYZ : public Test {
public:
MaxXYZ(const std::string& s, const Gecode::IntSet& d,
Gecode::IntPropLevel ipl)
: Test("Arithmetic::Max::Bin::XYZ::"+str(ipl)+"::"+s,3,d) {
contest = CTL_BOUNDS_Z;
}
virtual bool solution(const Assignment& x) const {
return std::max(x[0],x[1]) == x[2];
}
virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) {
Gecode::max(home, x[0], x[1], x[2], ipl);
}
};
class MaxXXY : public Test {
public:
MaxXXY(const std::string& s, const Gecode::IntSet& d,
Gecode::IntPropLevel ipl)
: Test("Arithmetic::Max::Bin::XXY::"+str(ipl)+"::"+s,2,d) {}
virtual bool solution(const Assignment& x) const {
return std::max(x[0],x[0]) == x[1];
}
virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) {
Gecode::max(home, x[0], x[0], x[1], ipl);
}
};
class MaxXYX : public Test {
public:
MaxXYX(const std::string& s, const Gecode::IntSet& d,
Gecode::IntPropLevel ipl)
: Test("Arithmetic::Max::Bin::XYX::"+str(ipl)+"::"+s,2,d) {}
virtual bool solution(const Assignment& x) const {
return std::max(x[0],x[1]) == x[0];
}
virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) {
Gecode::max(home, x[0], x[1], x[0], ipl);
}
};
class MaxXYY : public Test {
public:
MaxXYY(const std::string& s, const Gecode::IntSet& d,
Gecode::IntPropLevel ipl)
: Test("Arithmetic::Max::Bin::XYY::"+str(ipl)+"::"+s,2,d) {}
virtual bool solution(const Assignment& x) const {
return std::max(x[0],x[1]) == x[1];
}
virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) {
Gecode::max(home, x[0], x[1], x[1], ipl);
}
};
class MaxXXX : public Test {
public:
MaxXXX(const std::string& s, const Gecode::IntSet& d,
Gecode::IntPropLevel ipl)
: Test("Arithmetic::Max::Bin::XXX::"+str(ipl)+"::"+s,1,d) {}
virtual bool solution(const Assignment& x) const {
return std::max(x[0],x[0]) == x[0];
}
virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) {
Gecode::max(home, x[0], x[0], x[0], ipl);
}
};
class MinNary : public Test {
public:
MinNary(Gecode::IntPropLevel ipl)
: Test("Arithmetic::Min::Nary::"+str(ipl),4,-4,4,false,ipl) {}
virtual bool solution(const Assignment& x) const {
return std::min(std::min(x[0],x[1]), x[2]) == x[3];
}
virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) {
Gecode::IntVarArgs m(3);
m[0]=x[0]; m[1]=x[1]; m[2]=x[2];
Gecode::min(home, m, x[3], ipl);
}
};
class MinNaryShared : public Test {
public:
MinNaryShared(Gecode::IntPropLevel ipl)
: Test("Arithmetic::Min::Nary::Shared::"+str(ipl),3,-4,4,false,ipl) {}
virtual bool solution(const Assignment& x) const {
return std::min(std::min(x[0],x[1]), x[2]) == x[1];
}
virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) {
Gecode::IntVarArgs m(3);
m[0]=x[0]; m[1]=x[1]; m[2]=x[2];
Gecode::min(home, m, x[1], ipl);
}
};
class MaxNary : public Test {
public:
MaxNary(Gecode::IntPropLevel ipl)
: Test("Arithmetic::Max::Nary::"+str(ipl),4,-4,4,false,ipl) {}
virtual bool solution(const Assignment& x) const {
return std::max(std::max(x[0],x[1]), x[2]) == x[3];
}
virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) {
Gecode::IntVarArgs m(3);
m[0]=x[0]; m[1]=x[1]; m[2]=x[2];
Gecode::max(home, m, x[3], ipl);
}
};
class MaxNaryShared : public Test {
public:
MaxNaryShared(Gecode::IntPropLevel ipl)
: Test("Arithmetic::Max::Nary::Shared::"+str(ipl),3,-4,4,false,ipl) {}
virtual bool solution(const Assignment& x) const {
return std::max(std::max(x[0],x[1]), x[2]) == x[1];
}
virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) {
Gecode::IntVarArgs m(3);
m[0]=x[0]; m[1]=x[1]; m[2]=x[2];
Gecode::max(home, m, x[1], ipl);
}
};
class ArgMax : public Test {
protected:
int offset;
bool tiebreak;
public:
ArgMax(int n, int o, bool tb)
: Test("Arithmetic::ArgMax::"+str(o)+"::"+str(tb)+"::"+str(n),
n+1,0,n+1,
false,tb ? Gecode::IPL_DEF : Gecode::IPL_DOM),
offset(o), tiebreak(tb) {}
virtual bool solution(const Assignment& x) const {
int n=x.size()-1;
if ((x[n] < offset) || (x[n] >= n + offset))
return false;
int m=x[0]; int p=0;
for (int i=1; i<n; i++)
if (x[i] > m) {
p=i; m=x[i];
}
return tiebreak ? (p + offset == x[n]) : (m == x[x[n]-offset]);
}
virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) {
int n=x.size()-1;
Gecode::IntVarArgs m(n);
for (int i=0; i<n; i++)
m[i]=x[i];
Gecode::argmax(home, m, offset, x[n], tiebreak);
}
};
class ArgMaxShared : public Test {
protected:
bool tiebreak;
public:
ArgMaxShared(int n, bool tb)
: Test("Arithmetic::ArgMax::Shared::"+str(tb)+"::"+str(n),n+1,0,n+1,
false),
tiebreak(tb) {
testfix=false;
}
virtual bool solution(const Assignment& x) const {
int n=x.size()-1;
if ((x[n] < 0) || (x[n] >= 2*n))
return false;
Gecode::IntArgs y(2*n);
for (int i=0; i<n; i++)
y[2*i+0]=y[2*i+1]=x[i];
int m=y[0]; int p=0;
for (int i=1; i<2*n; i++)
if (y[i] > m) {
p=i; m=y[i];
}
return tiebreak ? (p == x[n]) : (m == y[x[n]]);
}
virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) {
int n=x.size()-1;
Gecode::IntVarArgs m(2*n);
for (int i=0; i<n; i++)
m[2*i+0]=m[2*i+1]=x[i];
Gecode::argmax(home, m, x[n], tiebreak);
}
};
class ArgMin : public Test {
protected:
int offset;
bool tiebreak;
public:
ArgMin(int n, int o, bool tb)
: Test("Arithmetic::ArgMin::"+str(o)+"::"+str(tb)+"::"+str(n),
n+1,0,n+1,
false,tb ? Gecode::IPL_DEF : Gecode::IPL_DOM),
offset(o), tiebreak(tb) {}
virtual bool solution(const Assignment& x) const {
int n=x.size()-1;
if ((x[n] < offset) || (x[n] >= n + offset))
return false;
int m=x[0]; int p=0;
for (int i=1; i<n; i++)
if (x[i] < m) {
p=i; m=x[i];
}
return tiebreak ? (p+offset == x[n]) : (m == x[x[n]-offset]);
}
virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) {
int n=x.size()-1;
Gecode::IntVarArgs m(n);
for (int i=0; i<n; i++)
m[i]=x[i];
Gecode::argmin(home, m, offset, x[n], tiebreak);
}
};
class ArgMinShared : public Test {
protected:
bool tiebreak;
public:
ArgMinShared(int n, bool tb)
: Test("Arithmetic::ArgMin::Shared::"+str(tb)+"::"+str(n),n+1,0,n+1,
false),
tiebreak(tb) {
testfix=false;
}
virtual bool solution(const Assignment& x) const {
int n=x.size()-1;
if ((x[n] < 0) || (x[n] >= 2*n))
return false;
Gecode::IntArgs y(2*n);
for (int i=0; i<n; i++)
y[2*i+0]=y[2*i+1]=x[i];
int m=y[0]; int p=0;
for (int i=1; i<2*n; i++)
if (y[i] < m) {
p=i; m=y[i];
}
return tiebreak ? (p == x[n]) : (m == y[x[n]]);
}
virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) {
int n=x.size()-1;
Gecode::IntVarArgs m(2*n);
for (int i=0; i<n; i++)
m[2*i+0]=m[2*i+1]=x[i];
Gecode::argmin(home, m, x[n], tiebreak);
}
};
class ArgMaxBool : public Test {
protected:
int offset;
bool tiebreak;
public:
ArgMaxBool(int n, int o, bool tb)
: Test("Arithmetic::ArgMaxBool::"+str(o)+"::"+str(tb)+"::"+str(n),
n+1,0,n+1,
false,tb ? Gecode::IPL_DEF : Gecode::IPL_DOM),
offset(o), tiebreak(tb) {}
virtual bool solution(const Assignment& x) const {
int n=x.size()-1;
if ((x[n] < offset) || (x[n] >= n + offset))
return false;
int m=x[0]; int p=0;
if (x[0] > 1)
return false;
for (int i=1; i<n; i++) {
if (x[i] > 1)
return false;
if (x[i] > m) {
p=i; m=x[i];
}
}
return tiebreak ? (p + offset == x[n]) : (m == x[x[n]-offset]);
}
virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) {
int n=x.size()-1;
Gecode::BoolVarArgs m(n);
for (int i=0; i<n; i++)
m[i]=channel(home,x[i]);
Gecode::argmax(home, m, offset, x[n], tiebreak);
}
};
class ArgMaxBoolShared : public Test {
protected:
bool tiebreak;
public:
ArgMaxBoolShared(int n, bool tb)
: Test("Arithmetic::ArgMaxBool::Shared::"+str(tb)+"::"+str(n),n+1,0,n+1,
false),
tiebreak(tb) {
testfix=false;
}
virtual bool solution(const Assignment& x) const {
int n=x.size()-1;
if ((x[n] < 0) || (x[n] >= 2*n))
return false;
Gecode::IntArgs y(2*n);
for (int i=0; i<n; i++)
y[2*i+0]=y[2*i+1]=x[i];
int m=y[0]; int p=0;
if (y[0] > 1)
return false;
for (int i=1; i<2*n; i++) {
if (y[i] > 1)
return false;
if (y[i] > m) {
p=i; m=y[i];
}
}
return tiebreak ? (p == x[n]) : (m == y[x[n]]);
}
virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) {
int n=x.size()-1;
Gecode::BoolVarArgs m(2*n);
for (int i=0; i<n; i++)
m[2*i+0]=m[2*i+1]=channel(home,x[i]);
Gecode::argmax(home, m, x[n], tiebreak);
}
};
class ArgMinBool : public Test {
protected:
int offset;
bool tiebreak;
public:
ArgMinBool(int n, int o, bool tb)
: Test("Arithmetic::ArgMinBool::"+str(o)+"::"+str(tb)+"::"+str(n),
n+1,0,n+1,
false,tb ? Gecode::IPL_DEF : Gecode::IPL_DOM),
offset(o), tiebreak(tb) {}
virtual bool solution(const Assignment& x) const {
int n=x.size()-1;
if ((x[n] < offset) || (x[n] >= n + offset))
return false;
int m=x[0]; int p=0;
if (x[0] < 0 || x[0] > 1)
return false;
for (int i=1; i<n; i++) {
if (x[i] < 0 || x[i] > 1)
return false;
if (x[i] < m) {
p=i; m=x[i];
}
}
return tiebreak ? (p+offset == x[n]) : (m == x[x[n]-offset]);
}
virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) {
int n=x.size()-1;
Gecode::BoolVarArgs m(n);
for (int i=0; i<n; i++)
m[i]=channel(home,x[i]);
Gecode::argmin(home, m, offset, x[n], tiebreak);
}
};
class ArgMinBoolShared : public Test {
protected:
bool tiebreak;
public:
ArgMinBoolShared(int n, bool tb)
: Test("Arithmetic::ArgMinBool::Shared::"+str(tb)+"::"+str(n),n+1,0,n+1,
false),
tiebreak(tb) {
testfix=false;
}
virtual bool solution(const Assignment& x) const {
int n=x.size()-1;
if ((x[n] < 0) || (x[n] >= 2*n))
return false;
Gecode::IntArgs y(2*n);
for (int i=0; i<n; i++)
y[2*i+0]=y[2*i+1]=x[i];
int m=y[0]; int p=0;
if (y[0] > 1)
return false;
for (int i=1; i<2*n; i++) {
if (y[i] > 1)
return false;
if (y[i] < m) {
p=i; m=y[i];
}
}
return tiebreak ? (p == x[n]) : (m == y[x[n]]);
}
virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) {
int n=x.size()-1;
Gecode::BoolVarArgs m(2*n);
for (int i=0; i<n; i++)
m[2*i+0]=m[2*i+1]=channel(home,x[i]);
Gecode::argmin(home, m, x[n], tiebreak);
}
};
class Create {
public:
Create(void) {
const int va[7] = {
Gecode::Int::Limits::min, Gecode::Int::Limits::min+1,
-1,0,1,
Gecode::Int::Limits::max-1, Gecode::Int::Limits::max
};
const int vb[9] = {
static_cast<int>(-sqrt(static_cast<double>
(-Gecode::Int::Limits::min))),
-4,-2,-1,0,1,2,4,
static_cast<int>(sqrt(static_cast<double>
(Gecode::Int::Limits::max)))
};
Gecode::IntSet a(va,7);
Gecode::IntSet b(vb,9);
Gecode::IntSet c(-8,8);
Gecode::IntSet d(-70,70);
(void) new DivMod("A",a);
(void) new DivMod("B",b);
(void) new DivMod("C",c);
(void) new Div("A",a);
(void) new Div("B",b);
(void) new Div("C",c);
(void) new Mod("A",a);
(void) new Mod("B",b);
(void) new Mod("C",c);
for (IntPropLevels ipls; ipls(); ++ipls) {
(void) new AbsXY("A",a,ipls.ipl());
(void) new AbsXY("B",b,ipls.ipl());
(void) new AbsXY("C",c,ipls.ipl());
(void) new AbsXX("A",a,ipls.ipl());
(void) new AbsXX("B",b,ipls.ipl());
(void) new AbsXX("C",c,ipls.ipl());
if (ipls.ipl() != Gecode::IPL_VAL) {
(void) new MultXYZ("A",a,ipls.ipl());
(void) new MultXYZ("B",b,ipls.ipl());
(void) new MultXYZ("C",c,ipls.ipl());
(void) new MultXXY("A",a,ipls.ipl());
(void) new MultXXY("B",b,ipls.ipl());
(void) new MultXXY("C",c,ipls.ipl());
(void) new MultXYX("A",a,ipls.ipl());
(void) new MultXYX("B",b,ipls.ipl());
(void) new MultXYX("C",c,ipls.ipl());
(void) new MultXYY("A",a,ipls.ipl());
(void) new MultXYY("B",b,ipls.ipl());
(void) new MultXYY("C",c,ipls.ipl());
(void) new MultXXX("A",a,ipls.ipl());
(void) new MultXXX("B",b,ipls.ipl());
(void) new MultXXX("C",c,ipls.ipl());
(void) new SqrXY("A",a,ipls.ipl());
(void) new SqrXY("B",b,ipls.ipl());
(void) new SqrXY("C",c,ipls.ipl());
(void) new SqrXX("A",a,ipls.ipl());
(void) new SqrXX("B",b,ipls.ipl());
(void) new SqrXX("C",c,ipls.ipl());
for (int n=0; n<=6; n++) {
(void) new PowXY("A",n,a,ipls.ipl());
(void) new PowXY("B",n,b,ipls.ipl());
(void) new PowXY("C",n,c,ipls.ipl());
(void) new PowXY("D",n,d,ipls.ipl());
(void) new PowXX("A",n,a,ipls.ipl());
(void) new PowXX("B",n,b,ipls.ipl());
(void) new PowXX("C",n,c,ipls.ipl());
(void) new PowXX("D",n,d,ipls.ipl());
}
for (int n=1; n<=6; n++) {
(void) new NrootXY("A",n,a,ipls.ipl());
(void) new NrootXY("B",n,b,ipls.ipl());
(void) new NrootXY("C",n,c,ipls.ipl());
(void) new NrootXY("D",n,d,ipls.ipl());
(void) new NrootXX("A",n,a,ipls.ipl());
(void) new NrootXX("B",n,b,ipls.ipl());
(void) new NrootXX("C",n,c,ipls.ipl());
(void) new NrootXX("D",n,d,ipls.ipl());
}
for (int n=30; n<=34; n++) {
(void) new PowXY("C",n,c,ipls.ipl());
(void) new PowXX("C",n,c,ipls.ipl());
(void) new NrootXY("C",n,c,ipls.ipl());
(void) new NrootXX("C",n,c,ipls.ipl());
}
(void) new SqrtXY("A",a,ipls.ipl());
(void) new SqrtXY("B",b,ipls.ipl());
(void) new SqrtXY("C",c,ipls.ipl());
(void) new SqrtXX("A",a,ipls.ipl());
(void) new SqrtXX("B",b,ipls.ipl());
(void) new SqrtXX("C",c,ipls.ipl());
(void) new MinXYZ("A",a,ipls.ipl());
(void) new MinXYZ("B",b,ipls.ipl());
(void) new MinXYZ("C",c,ipls.ipl());
(void) new MinXXY("A",a,ipls.ipl());
(void) new MinXXY("B",b,ipls.ipl());
(void) new MinXXY("C",c,ipls.ipl());
(void) new MinXYX("A",a,ipls.ipl());
(void) new MinXYX("B",b,ipls.ipl());
(void) new MinXYX("C",c,ipls.ipl());
(void) new MinXYY("A",a,ipls.ipl());
(void) new MinXYY("B",b,ipls.ipl());
(void) new MinXYY("C",c,ipls.ipl());
(void) new MinXXX("A",a,ipls.ipl());
(void) new MinXXX("B",b,ipls.ipl());
(void) new MinXXX("C",c,ipls.ipl());
(void) new MaxXYZ("A",a,ipls.ipl());
(void) new MaxXYZ("B",b,ipls.ipl());
(void) new MaxXYZ("C",c,ipls.ipl());
(void) new MaxXXY("A",a,ipls.ipl());
(void) new MaxXXY("B",b,ipls.ipl());
(void) new MaxXXY("C",c,ipls.ipl());
(void) new MaxXYX("A",a,ipls.ipl());
(void) new MaxXYX("B",b,ipls.ipl());
(void) new MaxXYX("C",c,ipls.ipl());
(void) new MaxXYY("A",a,ipls.ipl());
(void) new MaxXYY("B",b,ipls.ipl());
(void) new MaxXYY("C",c,ipls.ipl());
(void) new MaxXXX("A",a,ipls.ipl());
(void) new MaxXXX("B",b,ipls.ipl());
(void) new MaxXXX("C",c,ipls.ipl());
(void) new MinNary(ipls.ipl());
(void) new MinNaryShared(ipls.ipl());
(void) new MaxNary(ipls.ipl());
(void) new MaxNaryShared(ipls.ipl());
}
}
for (int i=1; i<5; i++) {
(void) new ArgMax(i,0,true);
(void) new ArgMax(i,1,true);
(void) new ArgMaxShared(i,true);
(void) new ArgMin(i,0,true);
(void) new ArgMin(i,1,true);
(void) new ArgMinShared(i,true);
(void) new ArgMax(i,0,false);
(void) new ArgMax(i,1,false);
(void) new ArgMaxShared(i,false);
(void) new ArgMin(i,0,false);
(void) new ArgMin(i,1,false);
(void) new ArgMinShared(i,false);
(void) new ArgMaxBool(i,0,true);
(void) new ArgMaxBool(i,1,true);
(void) new ArgMaxBoolShared(i,true);
(void) new ArgMinBool(i,0,true);
(void) new ArgMinBool(i,1,true);
(void) new ArgMinBoolShared(i,true);
(void) new ArgMaxBool(i,0,false);
(void) new ArgMaxBool(i,1,false);
(void) new ArgMaxBoolShared(i,false);
(void) new ArgMinBool(i,0,false);
(void) new ArgMinBool(i,1,false);
(void) new ArgMinBoolShared(i,false);
}
}
};
Create c;
}
}}
// STATISTICS: test-int
Gecode::BoolVarArgs
Passing Boolean variables.
Definition int.hh:712
Gecode::IntArgs
Passing integer arguments.
Definition int.hh:628
Gecode::IntSet
Integer sets.
Definition int.hh:174
Gecode::IntVarArgs
Passing integer variables.
Definition int.hh:656
Gecode::IntVarArray
Integer variable array.
Definition int.hh:763
Gecode::Space
Computation spaces.
Definition core.hpp:1742
Gecode::VarArray::size
int size(void) const
Return size of array (number of elements).
Definition array.hpp:926
Test::Int::Arithmetic::AbsXX
Test for absolute value constraint with shared variables
Definition arithmetic.cpp:487
Test::Int::Arithmetic::AbsXX::solution
virtual bool solution(const Assignment &x) const
Test whether x is solution
Definition arithmetic.cpp:494
Test::Int::Arithmetic::AbsXX::AbsXX
AbsXX(const std::string &s, const Gecode::IntSet &d, Gecode::IntPropLevel ipl)
Create and register test.
Definition arithmetic.cpp:490
Test::Int::Arithmetic::AbsXX::post
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
Definition arithmetic.cpp:500
Test::Int::Arithmetic::AbsXY
Test for absolute value constraint
Definition arithmetic.cpp:468
Test::Int::Arithmetic::AbsXY::solution
virtual bool solution(const Assignment &x) const
Test whether x is solution
Definition arithmetic.cpp:475
Test::Int::Arithmetic::AbsXY::AbsXY
AbsXY(const std::string &s, const Gecode::IntSet &d, Gecode::IntPropLevel ipl)
Create and register test.
Definition arithmetic.cpp:471
Test::Int::Arithmetic::AbsXY::post
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
Definition arithmetic.cpp:481
Test::Int::Arithmetic::ArgMaxBoolShared
Test for argument maximum constraint with shared variables
Definition arithmetic.cpp:939
Test::Int::Arithmetic::ArgMaxBoolShared::solution
virtual bool solution(const Assignment &x) const
Test whether x is solution
Definition arithmetic.cpp:952
Test::Int::Arithmetic::ArgMaxBoolShared::ArgMaxBoolShared
ArgMaxBoolShared(int n, bool tb)
Create and register test.
Definition arithmetic.cpp:945
Test::Int::Arithmetic::ArgMaxBoolShared::post
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
Definition arithmetic.cpp:972
Test::Int::Arithmetic::ArgMaxBoolShared::tiebreak
bool tiebreak
Whether to use tie-breaking.
Definition arithmetic.cpp:942
Test::Int::Arithmetic::ArgMaxBool
Test for Boolean argument maximum constraint
Definition arithmetic.cpp:898
Test::Int::Arithmetic::ArgMaxBool::post
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
Definition arithmetic.cpp:929
Test::Int::Arithmetic::ArgMaxBool::tiebreak
bool tiebreak
Whether to use tie-breaking.
Definition arithmetic.cpp:903
Test::Int::Arithmetic::ArgMaxBool::offset
int offset
Offset to be used.
Definition arithmetic.cpp:901
Test::Int::Arithmetic::ArgMaxBool::solution
virtual bool solution(const Assignment &x) const
Test whether x is solution
Definition arithmetic.cpp:912
Test::Int::Arithmetic::ArgMaxBool::ArgMaxBool
ArgMaxBool(int n, int o, bool tb)
Create and register test.
Definition arithmetic.cpp:906
Test::Int::Arithmetic::ArgMaxShared
Test for argument maximum constraint with shared variables
Definition arithmetic.cpp:786
Test::Int::Arithmetic::ArgMaxShared::ArgMaxShared
ArgMaxShared(int n, bool tb)
Create and register test.
Definition arithmetic.cpp:792
Test::Int::Arithmetic::ArgMaxShared::post
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
Definition arithmetic.cpp:814
Test::Int::Arithmetic::ArgMaxShared::solution
virtual bool solution(const Assignment &x) const
Test whether x is solution
Definition arithmetic.cpp:799
Test::Int::Arithmetic::ArgMaxShared::tiebreak
bool tiebreak
Whether to use tie-breaking.
Definition arithmetic.cpp:789
Test::Int::Arithmetic::ArgMax
Test for argument maximum constraint
Definition arithmetic.cpp:750
Test::Int::Arithmetic::ArgMax::solution
virtual bool solution(const Assignment &x) const
Test whether x is solution
Definition arithmetic.cpp:764
Test::Int::Arithmetic::ArgMax::post
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
Definition arithmetic.cpp:776
Test::Int::Arithmetic::ArgMax::offset
int offset
Offset to be used.
Definition arithmetic.cpp:753
Test::Int::Arithmetic::ArgMax::tiebreak
bool tiebreak
Whether to use tie-breaking.
Definition arithmetic.cpp:755
Test::Int::Arithmetic::ArgMax::ArgMax
ArgMax(int n, int o, bool tb)
Create and register test.
Definition arithmetic.cpp:758
Test::Int::Arithmetic::ArgMinBoolShared
Test for argument minimum constraint with shared variables
Definition arithmetic.cpp:1023
Test::Int::Arithmetic::ArgMinBoolShared::post
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
Definition arithmetic.cpp:1056
Test::Int::Arithmetic::ArgMinBoolShared::tiebreak
bool tiebreak
Whether to use tie-breaking.
Definition arithmetic.cpp:1026
Test::Int::Arithmetic::ArgMinBoolShared::ArgMinBoolShared
ArgMinBoolShared(int n, bool tb)
Create and register test.
Definition arithmetic.cpp:1029
Test::Int::Arithmetic::ArgMinBoolShared::solution
virtual bool solution(const Assignment &x) const
Test whether x is solution
Definition arithmetic.cpp:1036
Test::Int::Arithmetic::ArgMinBool
Test for argument minimum constraint
Definition arithmetic.cpp:982
Test::Int::Arithmetic::ArgMinBool::offset
int offset
Which offset to use.
Definition arithmetic.cpp:985
Test::Int::Arithmetic::ArgMinBool::tiebreak
bool tiebreak
Whether to use tie-breaking.
Definition arithmetic.cpp:987
Test::Int::Arithmetic::ArgMinBool::post
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
Definition arithmetic.cpp:1013
Test::Int::Arithmetic::ArgMinBool::ArgMinBool
ArgMinBool(int n, int o, bool tb)
Create and register test.
Definition arithmetic.cpp:990
Test::Int::Arithmetic::ArgMinBool::solution
virtual bool solution(const Assignment &x) const
Test whether x is solution
Definition arithmetic.cpp:996
Test::Int::Arithmetic::ArgMinShared
Test for argument minimum constraint with shared variables
Definition arithmetic.cpp:860
Test::Int::Arithmetic::ArgMinShared::tiebreak
bool tiebreak
Whether to use tie-breaking.
Definition arithmetic.cpp:863
Test::Int::Arithmetic::ArgMinShared::post
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
Definition arithmetic.cpp:888
Test::Int::Arithmetic::ArgMinShared::ArgMinShared
ArgMinShared(int n, bool tb)
Create and register test.
Definition arithmetic.cpp:866
Test::Int::Arithmetic::ArgMinShared::solution
virtual bool solution(const Assignment &x) const
Test whether x is solution
Definition arithmetic.cpp:873
Test::Int::Arithmetic::ArgMin
Test for argument minimum constraint
Definition arithmetic.cpp:824
Test::Int::Arithmetic::ArgMin::solution
virtual bool solution(const Assignment &x) const
Test whether x is solution
Definition arithmetic.cpp:838
Test::Int::Arithmetic::ArgMin::post
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
Definition arithmetic.cpp:850
Test::Int::Arithmetic::ArgMin::ArgMin
ArgMin(int n, int o, bool tb)
Create and register test.
Definition arithmetic.cpp:832
Test::Int::Arithmetic::ArgMin::tiebreak
bool tiebreak
Whether to use tie-breaking.
Definition arithmetic.cpp:829
Test::Int::Arithmetic::ArgMin::offset
int offset
Which offset to use.
Definition arithmetic.cpp:827
Test::Int::Arithmetic::Create
Help class to create and register tests.
Definition arithmetic.cpp:1066
Test::Int::Arithmetic::Create::Create
Create(void)
Perform creation and registration.
Definition arithmetic.cpp:1069
Test::Int::Arithmetic::DivMod
Test for division/modulo constraint
Definition arithmetic.cpp:399
Test::Int::Arithmetic::DivMod::post
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
Definition arithmetic.cpp:416
Test::Int::Arithmetic::DivMod::DivMod
DivMod(const std::string &s, const Gecode::IntSet &d)
Create and register test.
Definition arithmetic.cpp:407
Test::Int::Arithmetic::DivMod::solution
virtual bool solution(const Assignment &x) const
Test whether x is solution
Definition arithmetic.cpp:410
Test::Int::Arithmetic::Div
Test for division constraint
Definition arithmetic.cpp:422
Test::Int::Arithmetic::Div::solution
virtual bool solution(const Assignment &x) const
Test whether x is solution
Definition arithmetic.cpp:428
Test::Int::Arithmetic::Div::post
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
Definition arithmetic.cpp:439
Test::Int::Arithmetic::Div::Div
Div(const std::string &s, const Gecode::IntSet &d)
Create and register test.
Definition arithmetic.cpp:425
Test::Int::Arithmetic::MaxNaryShared
Test for n-ary maximum constraint with shared variables
Definition arithmetic.cpp:732
Test::Int::Arithmetic::MaxNaryShared::post
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
Definition arithmetic.cpp:742
Test::Int::Arithmetic::MaxNaryShared::MaxNaryShared
MaxNaryShared(Gecode::IntPropLevel ipl)
Create and register test.
Definition arithmetic.cpp:735
Test::Int::Arithmetic::MaxNaryShared::solution
virtual bool solution(const Assignment &x) const
Test whether x is solution
Definition arithmetic.cpp:738
Test::Int::Arithmetic::MaxNary
Test for n-ary maximum constraint
Definition arithmetic.cpp:714
Test::Int::Arithmetic::MaxNary::post
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
Definition arithmetic.cpp:724
Test::Int::Arithmetic::MaxNary::solution
virtual bool solution(const Assignment &x) const
Test whether x is solution
Definition arithmetic.cpp:720
Test::Int::Arithmetic::MaxNary::MaxNary
MaxNary(Gecode::IntPropLevel ipl)
Create and register test.
Definition arithmetic.cpp:717
Test::Int::Arithmetic::MaxXXX
Test for binary maximum constraint with shared variables
Definition arithmetic.cpp:661
Test::Int::Arithmetic::MaxXXX::MaxXXX
MaxXXX(const std::string &s, const Gecode::IntSet &d, Gecode::IntPropLevel ipl)
Create and register test.
Definition arithmetic.cpp:664
Test::Int::Arithmetic::MaxXXX::solution
virtual bool solution(const Assignment &x) const
Test whether x is solution
Definition arithmetic.cpp:668
Test::Int::Arithmetic::MaxXXX::post
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
Definition arithmetic.cpp:672
Test::Int::Arithmetic::MaxXXY
Test for binary maximum constraint with shared variables
Definition arithmetic.cpp:610
Test::Int::Arithmetic::MaxXXY::post
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
Definition arithmetic.cpp:621
Test::Int::Arithmetic::MaxXXY::MaxXXY
MaxXXY(const std::string &s, const Gecode::IntSet &d, Gecode::IntPropLevel ipl)
Create and register test.
Definition arithmetic.cpp:613
Test::Int::Arithmetic::MaxXXY::solution
virtual bool solution(const Assignment &x) const
Test whether x is solution
Definition arithmetic.cpp:617
Test::Int::Arithmetic::MaxXYX
Test for binary maximum constraint with shared variables
Definition arithmetic.cpp:627
Test::Int::Arithmetic::MaxXYX::solution
virtual bool solution(const Assignment &x) const
Test whether x is solution
Definition arithmetic.cpp:634
Test::Int::Arithmetic::MaxXYX::MaxXYX
MaxXYX(const std::string &s, const Gecode::IntSet &d, Gecode::IntPropLevel ipl)
Create and register test.
Definition arithmetic.cpp:630
Test::Int::Arithmetic::MaxXYX::post
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
Definition arithmetic.cpp:638
Test::Int::Arithmetic::MaxXYY
Test for binary maximum constraint with shared variables
Definition arithmetic.cpp:644
Test::Int::Arithmetic::MaxXYY::solution
virtual bool solution(const Assignment &x) const
Test whether x is solution
Definition arithmetic.cpp:651
Test::Int::Arithmetic::MaxXYY::post
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
Definition arithmetic.cpp:655
Test::Int::Arithmetic::MaxXYY::MaxXYY
MaxXYY(const std::string &s, const Gecode::IntSet &d, Gecode::IntPropLevel ipl)
Create and register test.
Definition arithmetic.cpp:647
Test::Int::Arithmetic::MaxXYZ
Test for binary maximum constraint
Definition arithmetic.cpp:591
Test::Int::Arithmetic::MaxXYZ::solution
virtual bool solution(const Assignment &x) const
Test whether x is solution
Definition arithmetic.cpp:600
Test::Int::Arithmetic::MaxXYZ::MaxXYZ
MaxXYZ(const std::string &s, const Gecode::IntSet &d, Gecode::IntPropLevel ipl)
Create and register test.
Definition arithmetic.cpp:594
Test::Int::Arithmetic::MaxXYZ::post
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
Definition arithmetic.cpp:604
Test::Int::Arithmetic::MinNaryShared
Test for n-ary minimmum constraint with shared variables
Definition arithmetic.cpp:696
Test::Int::Arithmetic::MinNaryShared::post
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
Definition arithmetic.cpp:706
Test::Int::Arithmetic::MinNaryShared::solution
virtual bool solution(const Assignment &x) const
Test whether x is solution
Definition arithmetic.cpp:702
Test::Int::Arithmetic::MinNaryShared::MinNaryShared
MinNaryShared(Gecode::IntPropLevel ipl)
Create and register test.
Definition arithmetic.cpp:699
Test::Int::Arithmetic::MinNary
Test for n-ary minimmum constraint
Definition arithmetic.cpp:678
Test::Int::Arithmetic::MinNary::solution
virtual bool solution(const Assignment &x) const
Test whether x is solution
Definition arithmetic.cpp:684
Test::Int::Arithmetic::MinNary::post
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
Definition arithmetic.cpp:688
Test::Int::Arithmetic::MinNary::MinNary
MinNary(Gecode::IntPropLevel ipl)
Create and register test.
Definition arithmetic.cpp:681
Test::Int::Arithmetic::MinXXX
Test for binary minimum constraint with shared variables
Definition arithmetic.cpp:574
Test::Int::Arithmetic::MinXXX::MinXXX
MinXXX(const std::string &s, const Gecode::IntSet &d, Gecode::IntPropLevel ipl)
Create and register test.
Definition arithmetic.cpp:577
Test::Int::Arithmetic::MinXXX::solution
virtual bool solution(const Assignment &x) const
Test whether x is solution
Definition arithmetic.cpp:581
Test::Int::Arithmetic::MinXXX::post
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
Definition arithmetic.cpp:585
Test::Int::Arithmetic::MinXXY
Test for binary minimum constraint with shared variables
Definition arithmetic.cpp:523
Test::Int::Arithmetic::MinXXY::solution
virtual bool solution(const Assignment &x) const
Test whether x is solution
Definition arithmetic.cpp:530
Test::Int::Arithmetic::MinXXY::MinXXY
MinXXY(const std::string &s, const Gecode::IntSet &d, Gecode::IntPropLevel ipl)
Create and register test.
Definition arithmetic.cpp:526
Test::Int::Arithmetic::MinXXY::post
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
Definition arithmetic.cpp:534
Test::Int::Arithmetic::MinXYX
Test for binary minimum constraint with shared variables
Definition arithmetic.cpp:540
Test::Int::Arithmetic::MinXYX::solution
virtual bool solution(const Assignment &x) const
Test whether x is solution
Definition arithmetic.cpp:547
Test::Int::Arithmetic::MinXYX::post
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
Definition arithmetic.cpp:551
Test::Int::Arithmetic::MinXYX::MinXYX
MinXYX(const std::string &s, const Gecode::IntSet &d, Gecode::IntPropLevel ipl)
Create and register test.
Definition arithmetic.cpp:543
Test::Int::Arithmetic::MinXYY
Test for binary minimum constraint with shared variables
Definition arithmetic.cpp:557
Test::Int::Arithmetic::MinXYY::post
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
Definition arithmetic.cpp:568
Test::Int::Arithmetic::MinXYY::solution
virtual bool solution(const Assignment &x) const
Test whether x is solution
Definition arithmetic.cpp:564
Test::Int::Arithmetic::MinXYY::MinXYY
MinXYY(const std::string &s, const Gecode::IntSet &d, Gecode::IntPropLevel ipl)
Create and register test.
Definition arithmetic.cpp:560
Test::Int::Arithmetic::MinXYZ
Test for binary minimum constraint
Definition arithmetic.cpp:506
Test::Int::Arithmetic::MinXYZ::post
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
Definition arithmetic.cpp:517
Test::Int::Arithmetic::MinXYZ::solution
virtual bool solution(const Assignment &x) const
Test whether x is solution
Definition arithmetic.cpp:513
Test::Int::Arithmetic::MinXYZ::MinXYZ
MinXYZ(const std::string &s, const Gecode::IntSet &d, Gecode::IntPropLevel ipl)
Create and register test.
Definition arithmetic.cpp:509
Test::Int::Arithmetic::Mod
Test for modulo constraint
Definition arithmetic.cpp:445
Test::Int::Arithmetic::Mod::Mod
Mod(const std::string &s, const Gecode::IntSet &d)
Create and register test.
Definition arithmetic.cpp:448
Test::Int::Arithmetic::Mod::solution
virtual bool solution(const Assignment &x) const
Test whether x is solution
Definition arithmetic.cpp:451
Test::Int::Arithmetic::Mod::post
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
Definition arithmetic.cpp:462
Test::Int::Arithmetic::MultXXX
Test for multiplication constraint with shared variables
Definition arithmetic.cpp:132
Test::Int::Arithmetic::MultXXX::solution
virtual bool solution(const Assignment &x) const
Test whether x is solution
Definition arithmetic.cpp:139
Test::Int::Arithmetic::MultXXX::MultXXX
MultXXX(const std::string &s, const Gecode::IntSet &d, Gecode::IntPropLevel ipl)
Create and register test.
Definition arithmetic.cpp:135
Test::Int::Arithmetic::MultXXX::post
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
Definition arithmetic.cpp:146
Test::Int::Arithmetic::MultXXY
Test for multiplication constraint with shared variables
Definition arithmetic.cpp:72
Test::Int::Arithmetic::MultXXY::post
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
Definition arithmetic.cpp:86
Test::Int::Arithmetic::MultXXY::solution
virtual bool solution(const Assignment &x) const
Test whether x is solution
Definition arithmetic.cpp:79
Test::Int::Arithmetic::MultXXY::MultXXY
MultXXY(const std::string &s, const Gecode::IntSet &d, Gecode::IntPropLevel ipl)
Create and register test.
Definition arithmetic.cpp:75
Test::Int::Arithmetic::MultXYX
Test for multiplication constraint with shared variables
Definition arithmetic.cpp:92
Test::Int::Arithmetic::MultXYX::MultXYX
MultXYX(const std::string &s, const Gecode::IntSet &d, Gecode::IntPropLevel ipl)
Create and register test.
Definition arithmetic.cpp:95
Test::Int::Arithmetic::MultXYX::solution
virtual bool solution(const Assignment &x) const
Test whether x is solution
Definition arithmetic.cpp:99
Test::Int::Arithmetic::MultXYX::post
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
Definition arithmetic.cpp:106
Test::Int::Arithmetic::MultXYY
Test for multiplication constraint with shared variables
Definition arithmetic.cpp:112
Test::Int::Arithmetic::MultXYY::solution
virtual bool solution(const Assignment &x) const
Test whether x is solution
Definition arithmetic.cpp:119
Test::Int::Arithmetic::MultXYY::MultXYY
MultXYY(const std::string &s, const Gecode::IntSet &d, Gecode::IntPropLevel ipl)
Create and register test.
Definition arithmetic.cpp:115
Test::Int::Arithmetic::MultXYY::post
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
Definition arithmetic.cpp:126
Test::Int::Arithmetic::MultXYZ
Test for multiplication constraint
Definition arithmetic.cpp:52
Test::Int::Arithmetic::MultXYZ::solution
virtual bool solution(const Assignment &x) const
Test whether x is solution
Definition arithmetic.cpp:59
Test::Int::Arithmetic::MultXYZ::post
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
Definition arithmetic.cpp:66
Test::Int::Arithmetic::MultXYZ::MultXYZ
MultXYZ(const std::string &s, const Gecode::IntSet &d, Gecode::IntPropLevel ipl)
Create and register test.
Definition arithmetic.cpp:55
Test::Int::Arithmetic::NrootXX
Test for nroot constraint with shared variables
Definition arithmetic.cpp:372
Test::Int::Arithmetic::NrootXX::solution
virtual bool solution(const Assignment &x) const
Test whether x is solution
Definition arithmetic.cpp:383
Test::Int::Arithmetic::NrootXX::NrootXX
NrootXX(const std::string &s, int n0, const Gecode::IntSet &d, Gecode::IntPropLevel ipl)
Create and register test.
Definition arithmetic.cpp:378
Test::Int::Arithmetic::NrootXX::post
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
Definition arithmetic.cpp:393
Test::Int::Arithmetic::NrootXX::n
int n
The root index.
Definition arithmetic.cpp:375
Test::Int::Arithmetic::NrootXY
Test for nroot constraint
Definition arithmetic.cpp:341
Test::Int::Arithmetic::NrootXY::n
int n
The root index.
Definition arithmetic.cpp:344
Test::Int::Arithmetic::NrootXY::post
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
Definition arithmetic.cpp:362
Test::Int::Arithmetic::NrootXY::NrootXY
NrootXY(const std::string &s, int n0, const Gecode::IntSet &d, Gecode::IntPropLevel ipl)
Floor.
Definition arithmetic.cpp:348
Test::Int::Arithmetic::NrootXY::solution
virtual bool solution(const Assignment &x) const
Test whether x is solution
Definition arithmetic.cpp:353
Test::Int::Arithmetic::PowXX
Test for power constraint with shared variables
Definition arithmetic.cpp:258
Test::Int::Arithmetic::PowXX::n
int n
The exponent.
Definition arithmetic.cpp:261
Test::Int::Arithmetic::PowXX::solution
virtual bool solution(const Assignment &x) const
Test whether x is solution
Definition arithmetic.cpp:269
Test::Int::Arithmetic::PowXX::post
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
Definition arithmetic.cpp:280
Test::Int::Arithmetic::PowXX::PowXX
PowXX(const std::string &s, int n0, const Gecode::IntSet &d, Gecode::IntPropLevel ipl)
Create and register test.
Definition arithmetic.cpp:264
Test::Int::Arithmetic::PowXY
Test for power constraint
Definition arithmetic.cpp:226
Test::Int::Arithmetic::PowXY::post
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
Definition arithmetic.cpp:248
Test::Int::Arithmetic::PowXY::PowXY
PowXY(const std::string &s, int n0, const Gecode::IntSet &d, Gecode::IntPropLevel ipl)
Create and register test.
Definition arithmetic.cpp:232
Test::Int::Arithmetic::PowXY::n
int n
The exponent.
Definition arithmetic.cpp:229
Test::Int::Arithmetic::PowXY::solution
virtual bool solution(const Assignment &x) const
Test whether x is solution
Definition arithmetic.cpp:237
Test::Int::Arithmetic::SqrXX
Test for squaring constraint with shared variables
Definition arithmetic.cpp:171
Test::Int::Arithmetic::SqrXX::post
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
Definition arithmetic.cpp:183
Test::Int::Arithmetic::SqrXX::solution
virtual bool solution(const Assignment &x) const
Test whether x is solution
Definition arithmetic.cpp:178
Test::Int::Arithmetic::SqrXX::SqrXX
SqrXX(const std::string &s, const Gecode::IntSet &d, Gecode::IntPropLevel ipl)
Create and register test.
Definition arithmetic.cpp:174
Test::Int::Arithmetic::SqrXY
Test for squaring constraint
Definition arithmetic.cpp:152
Test::Int::Arithmetic::SqrXY::post
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
Definition arithmetic.cpp:165
Test::Int::Arithmetic::SqrXY::SqrXY
SqrXY(const std::string &s, const Gecode::IntSet &d, Gecode::IntPropLevel ipl)
Create and register test.
Definition arithmetic.cpp:155
Test::Int::Arithmetic::SqrXY::solution
virtual bool solution(const Assignment &x) const
Test whether x is solution
Definition arithmetic.cpp:159
Test::Int::Arithmetic::SqrtXX
Test for square root constraint with shared variables
Definition arithmetic.cpp:208
Test::Int::Arithmetic::SqrtXX::post
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
Definition arithmetic.cpp:220
Test::Int::Arithmetic::SqrtXX::solution
virtual bool solution(const Assignment &x) const
Test whether x is solution
Definition arithmetic.cpp:215
Test::Int::Arithmetic::SqrtXX::SqrtXX
SqrtXX(const std::string &s, const Gecode::IntSet &d, Gecode::IntPropLevel ipl)
Create and register test.
Definition arithmetic.cpp:211
Test::Int::Arithmetic::SqrtXY
Test for square root constraint
Definition arithmetic.cpp:189
Test::Int::Arithmetic::SqrtXY::post
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
Definition arithmetic.cpp:202
Test::Int::Arithmetic::SqrtXY::solution
virtual bool solution(const Assignment &x) const
Test whether x is solution
Definition arithmetic.cpp:196
Test::Int::Arithmetic::SqrtXY::SqrtXY
SqrtXY(const std::string &s, const Gecode::IntSet &d, Gecode::IntPropLevel ipl)
Create and register test.
Definition arithmetic.cpp:192
Test::Int::Assignment
Base class for assignments
Definition int.hh:59
Test::Int::Assignment::size
int size(void) const
Return number of variables.
Definition int.hpp:46
Test::Int::IntPropLevels
Iterator for simple integer propagation levels.
Definition int.hh:332
Test::Int::Test::testfix
bool testfix
Whether to perform fixpoint test.
Definition int.hh:240
Test::Int::Test::ipl
Gecode::IntPropLevel ipl
Propagation level.
Definition int.hh:234
Test::Int::Test::str
static std::string str(Gecode::IntPropLevel ipl)
Map integer propagation level to string.
Definition int.hpp:209
Test::Int::Test::contest
ConTestLevel contest
Whether to test for certain consistency.
Definition int.hh:236
Gecode::rel
void rel(Home home, FloatVar x0, FloatRelType frt, FloatVar x1)
Post propagator for .
Definition rel.cpp:68
Gecode::IntPropLevel
IntPropLevel
Propagation levels for integer propagators.
Definition int.hh:974
Gecode::IRT_EQ
@ IRT_EQ
Equality ( ).
Definition int.hh:926
Gecode::IPL_DOM
@ IPL_DOM
Domain propagation Options: basic versus advanced propagation.
Definition int.hh:979
Gecode::IPL_VAL
@ IPL_VAL
Value propagation.
Definition int.hh:977
Gecode::IPL_DEF
@ IPL_DEF
Simple propagation levels.
Definition int.hh:976
minimodel.hh
Gecode::Int::Limits::min
const int min
Smallest allowed integer value.
Definition int.hh:118
Gecode::Int::Limits::max
const int max
Largest allowed integer value.
Definition int.hh:116
Gecode
Gecode toplevel namespace
Gecode::channel
void channel(Home home, FloatVar x0, IntVar x1)
Post propagator for channeling a float and an integer variable .
Definition channel.cpp:41
Gecode::mod
void mod(Home home, IntVar x0, IntVar x1, IntVar x2, IntPropLevel ipl=IPL_DEF)
Post propagator for .
Definition arithmetic.cpp:360
Gecode::sqr
void sqr(Home home, FloatVar x0, FloatVar x1)
Post propagator for .
Definition arithmetic.cpp:95
Gecode::expr
IntVar expr(Home home, const LinIntExpr &e, const IntPropLevels &ipls=IntPropLevels::def)
Post linear expression and return its value.
Definition int-expr.cpp:915
Gecode::min
void min(Home home, FloatVar x0, FloatVar x1, FloatVar x2)
Post propagator for .
Definition arithmetic.cpp:67
Gecode::abs
void abs(Home home, FloatVar x0, FloatVar x1)
Post propagator for .
Definition arithmetic.cpp:41
Gecode::div
void div(Home home, FloatVar x0, FloatVar x1, FloatVar x2)
Post propagator for .
Definition arithmetic.cpp:127
Gecode::argmax
void argmax(Home home, const IntVarArgs &x, IntVar y, bool tiebreak=true, IntPropLevel ipl=IPL_DEF)
Post propagator for .
Definition arithmetic.cpp:110
Gecode::mult
void mult(Home home, FloatVar x0, FloatVar x1, FloatVar x2)
Post propagator for .
Definition arithmetic.cpp:88
Gecode::divmod
void divmod(Home home, IntVar x0, IntVar x1, IntVar x2, IntVar x3, IntPropLevel ipl=IPL_DEF)
Post propagator for .
Definition arithmetic.cpp:327
Gecode::sqrt
void sqrt(Home home, FloatVar x0, FloatVar x1)
Post propagator for .
Definition arithmetic.cpp:102
Gecode::max
void max(Home home, FloatVar x0, FloatVar x1, FloatVar x2)
Post propagator for .
Definition arithmetic.cpp:49
Gecode::argmin
void argmin(Home home, const IntVarArgs &x, IntVar y, bool tiebreak=true, IntPropLevel ipl=IPL_DEF)
Post propagator for .
Definition arithmetic.cpp:163
Gecode::pow
void pow(Home home, FloatVar x0, int n, FloatVar x1)
Post propagator for for $n\geq 0$.
Definition arithmetic.cpp:109
Gecode::nroot
void nroot(Home home, FloatVar x0, int n, FloatVar x1)
Post propagator for for $n\geq 0$.
Definition arithmetic.cpp:118
Test::Int::Arithmetic
Tests for arithmetic constraints
Definition arithmetic.cpp:44
Test::Int::Arithmetic::powgr
bool powgr(int n, long long int r, int x)
Definition arithmetic.cpp:285
Test::Int::Arithmetic::cnroot
int cnroot(int n, int x)
Definition arithmetic.cpp:325
Test::Int::Arithmetic::fnroot
int fnroot(int n, int x)
Definition arithmetic.cpp:297
Test::Int::Arithmetic::c
Create c
Definition arithmetic.cpp:1255
Test::Int::Arithmetic::powle
bool powle(int n, long long int r, int x)
Definition arithmetic.cpp:312
Test::Int
Testing finite domain integers.
Definition int.cpp:40
Test::Int::CTL_BOUNDS_Z
@ CTL_BOUNDS_Z
Test for bounds(z)-consistency.
Definition int.hh:143
Test
General test support.
Definition afc.cpp:39
Test::r
Region r
Definition region.cpp:65
int.hh