extensional.cpp
Go to the documentation of this file.
/* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
/*
* Main authors:
* Mikael Lagerkvist <lagerkvist@gecode.org>
* Linnea Ingmar <linnea.ingmar@hotmail.com>
* Christian Schulte <schulte@gecode.org>
*
* Copyright:
* Linnea Ingmar, 2017
* Mikael Lagerkvist, 2007
* 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 <gecode/minimodel.hh>
#include <climits>
namespace Test { namespace Int {
namespace Extensional {
class RegSimpleA : public Test {
public:
RegSimpleA(void) : Test("Extensional::Reg::Simple::A",4,2,2) {}
virtual bool solution(const Assignment& x) const {
return (((x[0] == 0) || (x[0] == 2)) &&
((x[1] == -1) || (x[1] == 1)) &&
((x[2] == 0) || (x[2] == 1)) &&
((x[3] == 0) || (x[3] == 1)));
}
virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) {
using namespace Gecode;
extensional(home, x,
(REG(0) | REG(2)) +
(REG(-1) | REG(1)) +
(REG(7) | REG(0) | REG(1)) +
(REG(0) | REG(1)));
}
};
class RegSimpleB : public Test {
public:
RegSimpleB(void) : Test("Extensional::Reg::Simple::B",4,2,2) {}
virtual bool solution(const Assignment& x) const {
return (x[0]<x[1]) && (x[1]<x[2]) && (x[2]<x[3]);
}
virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) {
using namespace Gecode;
extensional(home, x,
(REG(-2) + REG(-1) + REG(0) + REG(1)) |
(REG(-2) + REG(-1) + REG(0) + REG(2)) |
(REG(-2) + REG(-1) + REG(1) + REG(2)) |
(REG(-2) + REG(0) + REG(1) + REG(2)) |
(REG(-1) + REG(0) + REG(1) + REG(2)));
}
};
class RegSimpleC : public Test {
public:
RegSimpleC(void) : Test("Extensional::Reg::Simple::C",6,0,1) {}
virtual bool solution(const Assignment& x) const {
int pos = 0;
int s = x.size();
while (pos < s && x[pos] == 0) ++pos;
if (pos + 4 > s) return false;
for (int i = 0; i < 2; ++i, ++pos)
if (x[pos] != 1) return false;
if (pos + 2 > s) return false;
for (int i = 0; i < 1; ++i, ++pos)
if (x[pos] != 0) return false;
while (pos < s && x[pos] == 0) ++pos;
if (pos + 1 > s) return false;
for (int i = 0; i < 1; ++i, ++pos)
if (x[pos] != 1) return false;
while (pos < s) if (x[pos++] != 0) return false;
return true;
}
virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) {
using namespace Gecode;
extensional(home, x,
*REG(0) + REG(1)(2,2) + +REG(0) + REG(1)(1,1) + *REG(0));
}
};
class RegDistinct : public Test {
public:
RegDistinct(void) : Test("Extensional::Reg::Distinct",4,-1,4) {}
virtual bool solution(const Assignment& x) const {
for (int i=0; i<x.size(); i++) {
if ((x[i] < 0) || (x[i] > 3))
return false;
for (int j=i+1; j<x.size(); j++)
if (x[i]==x[j])
return false;
}
return true;
}
virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) {
using namespace Gecode;
extensional(home, x,
(REG(0)+REG(1)+REG(2)+REG(3)) |
(REG(0)+REG(1)+REG(3)+REG(2)) |
(REG(0)+REG(2)+REG(1)+REG(3)) |
(REG(0)+REG(2)+REG(3)+REG(1)) |
(REG(0)+REG(3)+REG(1)+REG(2)) |
(REG(0)+REG(3)+REG(2)+REG(1)) |
(REG(1)+REG(0)+REG(2)+REG(3)) |
(REG(1)+REG(0)+REG(3)+REG(2)) |
(REG(1)+REG(2)+REG(0)+REG(3)) |
(REG(1)+REG(2)+REG(3)+REG(0)) |
(REG(1)+REG(3)+REG(0)+REG(2)) |
(REG(1)+REG(3)+REG(2)+REG(0)) |
(REG(2)+REG(0)+REG(1)+REG(3)) |
(REG(2)+REG(0)+REG(3)+REG(1)) |
(REG(2)+REG(1)+REG(0)+REG(3)) |
(REG(2)+REG(1)+REG(3)+REG(0)) |
(REG(2)+REG(3)+REG(0)+REG(1)) |
(REG(2)+REG(3)+REG(1)+REG(0)) |
(REG(3)+REG(0)+REG(1)+REG(2)) |
(REG(3)+REG(0)+REG(2)+REG(1)) |
(REG(3)+REG(1)+REG(0)+REG(2)) |
(REG(3)+REG(1)+REG(2)+REG(0)) |
(REG(3)+REG(2)+REG(0)+REG(1)) |
(REG(3)+REG(2)+REG(1)+REG(0)));
}
};
class RegRoland : public Test {
public:
RegRoland(int n)
: Test("Extensional::Reg::Roland::"+str(n),n,0,1) {}
virtual bool solution(const Assignment& x) const {
int n = x.size();
return
((n > 1) && (x[n-2] == 0)) ||
((n > 0) && (x[n-1] == 0));
}
virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) {
using namespace Gecode;
REG r0(0), r1(1);
REG r01 = r0 | r1;
extensional(home, x, *r01 + r0 + r01(0,1));
}
};
class RegSharedA : public Test {
public:
RegSharedA(void) : Test("Extensional::Reg::Shared::A",4,2,2) {}
virtual bool solution(const Assignment& x) const {
return (((x[0] == 0) || (x[0] == 2)) &&
((x[1] == -1) || (x[1] == 1)) &&
((x[2] == 0) || (x[2] == 1)) &&
((x[3] == 0) || (x[3] == 1)));
}
virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) {
using namespace Gecode;
IntVarArgs y(8);
for (int i=0; i<4; i++)
y[i]=y[i+4]=x[i];
unshare(home,y);
extensional(home, y,
((REG(0) | REG(2)) +
(REG(-1) | REG(1)) +
(REG(7) | REG(0) | REG(1)) +
(REG(0) | REG(1)))(2,2));
}
};
class RegSharedB : public Test {
public:
RegSharedB(void) : Test("Extensional::Reg::Shared::B",4,2,2) {}
virtual bool solution(const Assignment& x) const {
return (((x[0] == 0) || (x[0] == 2)) &&
((x[1] == -1) || (x[1] == 1)) &&
((x[2] == 0) || (x[2] == 1)) &&
((x[3] == 0) || (x[3] == 1)));
}
virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) {
using namespace Gecode;
IntVarArgs y(12);
for (int i=0; i<4; i++)
y[i]=y[i+4]=y[i+8]=x[i];
unshare(home,y);
extensional(home, y,
((REG(0) | REG(2)) +
(REG(-1) | REG(1)) +
(REG(7) | REG(0) | REG(1)) +
(REG(0) | REG(1)))(3,3));
}
};
class RegSharedC : public Test {
public:
RegSharedC(void) : Test("Extensional::Reg::Shared::C",4,0,1) {}
virtual bool solution(const Assignment& x) const {
return (x[1]==1) && (x[2]==0) && (x[3]==1);
}
virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) {
using namespace Gecode;
Gecode::BoolVarArgs y(8);
for (int i=0; i<4; i++)
y[i]=y[i+4]=channel(home,x[i]);
unshare(home,y);
extensional(home,y,
((REG(0) | REG(1)) + REG(1) + REG(0) + REG(1))(2,2));
}
};
class RegSharedD : public Test {
public:
RegSharedD(void) : Test("Extensional::Reg::Shared::D",4,0,1) {}
virtual bool solution(const Assignment& x) const {
return (x[1]==1) && (x[2]==0) && (x[3]==1);
}
virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) {
using namespace Gecode;
Gecode::BoolVarArgs y(12);
for (int i=0; i<4; i++)
y[i]=y[i+4]=y[i+8]=channel(home,x[i]);
unshare(home, y);
extensional(home, y,
((REG(0) | REG(1)) + REG(1) + REG(0) + REG(1))(3,3));
}
};
class RegEmptyDFA : public Test {
public:
RegEmptyDFA(void) : Test("Extensional::Reg::Empty::DFA",1,0,0) {
testsearch = false;
}
virtual bool solution(const Assignment& x) const {
(void)x;
return false;
}
virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) {
Gecode::DFA d;
Gecode::extensional(home, x, d);
}
};
class RegEmptyREG : public Test {
public:
RegEmptyREG(void) : Test("Extensional::Reg::Empty::REG",1,0,0) {
testsearch = false;
}
virtual bool solution(const Assignment& x) const {
(void)x;
return false;
}
virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) {
Gecode::REG r;
Gecode::extensional(home, x, r);
}
};
class RegOpt : public Test {
protected:
int n;
public:
RegOpt(int n0)
: Test("Extensional::Reg::Opt::"+str(n0),1,0,15), n(n0) {}
virtual bool solution(const Assignment& x) const {
return (x[0] < n) && ((x[0] & 1) == 0);
}
virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) {
using namespace Gecode;
DFA::Transition* t = new DFA::Transition[n+1];
DFA::Transition* ti = t;
int* f = new int[n+1];
int* fi = f;
for (int i=0; i<n; i++) {
ti->i_state = 0;
ti->symbol = i;
ti->o_state = i+1;
ti++;
if ((i & 1) == 0) {
*fi = i+1; fi++;
}
}
ti->i_state = -1;
*fi = -1;
DFA d(0, t, f, false);
delete [] t;
delete [] f;
extensional(home, x, d);
}
};
Gecode::DFA tupleset2dfa(Gecode::TupleSet ts) {
using namespace Gecode;
REG expression;
for (int i = 0; i<ts.tuples(); i++) {
REG r;
for (int j = 0; j<ts.arity(); j++) {
r += REG(ts[i][j]);
}
expression |= r;
}
DFA dfa(expression);
return dfa;
}
class TupleSetBase : public Test {
protected:
Gecode::TupleSet t;
bool pos;
public:
TupleSetBase(bool p)
: Test("Extensional::TupleSet::" + str(p) + "::Base",
4,1,5,true,Gecode::IPL_DOM), t(4), pos(p) {
using namespace Gecode;
IntArgs t1({2, 1, 2, 4});
IntArgs t2({2, 2, 1, 4});
IntArgs t3({4, 3, 4, 1});
IntArgs t4({1, 3, 2, 3});
IntArgs t5({3, 3, 3, 2});
t.add(t1).add(t1).add(t2).add(t2)
.add(t3).add(t3).add(t4).add(t4)
.add(t5).add(t5).add(t5).add(t5)
.add(t5).add(t5).add(t5).add(t5)
.add(t1).add(t1).add(t2).add(t2)
.add(t3).add(t3).add(t4).add(t4)
.add(t5).add(t5).add(t5).add(t5)
.add(t5).add(t5).add(t5).add(t5)
.finalize();
}
virtual bool solution(const Assignment& x) const {
return pos == ((x[0] == 1 && x[1] == 3 && x[2] == 2 && x[3] == 3) ||
(x[0] == 2 && x[1] == 1 && x[2] == 2 && x[3] == 4) ||
(x[0] == 2 && x[1] == 2 && x[2] == 1 && x[3] == 4) ||
(x[0] == 3 && x[1] == 3 && x[2] == 3 && x[3] == 2) ||
(x[0] == 4 && x[1] == 3 && x[2] == 4 && x[3] == 1));
}
virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) {
using namespace Gecode;
TupleSet ts = TupleSet(t.arity(),tupleset2dfa(t));
assert(t == ts);
extensional(home, x, t, pos, ipl);
}
virtual void post(Gecode::Space& home, Gecode::IntVarArray& x,
Gecode::Reify r) {
extensional(home, x, t, pos, r, ipl);
}
};
class TupleSetTest : public Test {
protected:
bool pos;
Gecode::TupleSet ts;
bool toDFA;
public:
TupleSetTest(const std::string& s, bool p,
Gecode::IntSet d0, Gecode::TupleSet ts0, bool td)
: Test("Extensional::TupleSet::" + str(p) + "::" + s,
ts0.arity(),d0,true,Gecode::IPL_DOM),
pos(p), ts(ts0), toDFA(td) {
}
virtual bool solution(const Assignment& x) const {
using namespace Gecode;
for (int i=ts.tuples(); i--; ) {
TupleSet::Tuple t = ts[i];
bool same = true;
for (int j=0; (j < ts.arity()) && same; j++)
if (t[j] != x[j])
same = false;
if (same)
return pos;
}
return !pos;
}
virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) {
using namespace Gecode;
if (toDFA) {
TupleSet t = TupleSet(ts.arity(),tupleset2dfa(ts));
assert(ts == t);
}
extensional(home, x, ts, pos, ipl);
}
virtual void post(Gecode::Space& home, Gecode::IntVarArray& x,
Gecode::Reify r) {
using namespace Gecode;
extensional(home, x, ts, pos, r, ipl);
}
};
class RandomTupleSetTest : public TupleSetTest {
public:
RandomTupleSetTest(const std::string& s, bool p,
Gecode::IntSet d0, Gecode::TupleSet ts0)
: TupleSetTest(s,p,d0,ts0,false) {
testsearch = false;
}
virtual Assignment* assignment(void) const {
using namespace Gecode;
return new RandomAssignment(arity,dom,1000);
}
};
class TupleSetLarge : public Test {
protected:
bool pos;
mutable Gecode::TupleSet t;
public:
TupleSetLarge(double prob, bool p)
: Test("Extensional::TupleSet::" + str(p) + "::Large",
5,1,5,true,Gecode::IPL_DOM), pos(p), t(5) {
using namespace Gecode;
CpltAssignment ass(5, IntSet(1, 5));
while (ass()) {
if (Base::rand(100) <= prob*100) {
IntArgs tuple(5);
for (int i = 5; i--; ) tuple[i] = ass[i];
t.add(tuple);
}
++ass;
}
t.finalize();
}
virtual bool solution(const Assignment& x) const {
using namespace Gecode;
for (int i = 0; i < t.tuples(); ++i) {
TupleSet::Tuple l = t[i];
bool same = true;
for (int j = 0; j < t.arity() && same; ++j)
if (l[j] != x[j]) same = false;
if (same)
return pos;
}
return !pos;
}
virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) {
using namespace Gecode;
extensional(home, x, t, pos, ipl);
}
virtual void post(Gecode::Space& home, Gecode::IntVarArray& x,
Gecode::Reify r) {
using namespace Gecode;
extensional(home, x, t, pos, r, ipl);
}
};
class TupleSetBool : public Test {
protected:
bool pos;
mutable Gecode::TupleSet t;
public:
TupleSetBool(double prob, bool p)
: Test("Extensional::TupleSet::" + str(p) + "::Bool",
5,0,1,true), pos(p), t(5) {
using namespace Gecode;
CpltAssignment ass(5, IntSet(0, 1));
while (ass()) {
if (Base::rand(100) <= prob*100) {
IntArgs tuple(5);
for (int i = 5; i--; ) tuple[i] = ass[i];
t.add(tuple);
}
++ass;
}
t.finalize();
}
virtual bool solution(const Assignment& x) const {
using namespace Gecode;
for (int i = 0; i < t.tuples(); ++i) {
TupleSet::Tuple l = t[i];
bool same = true;
for (int j = 0; j < t.arity() && same; ++j)
if (l[j] != x[j])
same = false;
if (same)
return pos;
}
return !pos;
}
virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) {
using namespace Gecode;
BoolVarArgs y(x.size());
for (int i = x.size(); i--; )
y[i] = channel(home, x[i]);
extensional(home, y, t, pos, ipl);
}
virtual void post(Gecode::Space& home, Gecode::IntVarArray& x,
Gecode::Reify r) {
using namespace Gecode;
BoolVarArgs y(x.size());
for (int i = x.size(); i--; )
y[i] = channel(home, x[i]);
extensional(home, y, t, pos, r, ipl);
}
};
class TupleSetTestSize {
public:
TupleSetTestSize(int size, bool pos) {
using namespace Gecode;
int arity = 2;
int n_tuples = 5*5;
while (n_tuples < size) {
arity++;
n_tuples*=5;
}
TupleSet ts(arity);
CpltAssignment ass(arity, IntSet(0, 4));
for (int i = size; i--; ) {
assert(ass());
IntArgs tuple(arity);
for (int j = arity; j--; ) tuple[j] = ass[j];
ts.add(tuple);
++ass;
}
ts.finalize();
assert(ts.tuples() == size);
// Create and register test
(void) new TupleSetTest(std::to_string(size),pos,IntSet(0,4),ts,
size <= 128);
}
};
Gecode::TupleSet randomTupleSet(int n, int min, int max, double prob) {
using namespace Gecode;
TupleSet t(n);
CpltAssignment ass(n, IntSet(min, max));
while (ass()) {
if (Base::rand(100) <= prob*100) {
IntArgs tuple(n);
for (int i = n; i--; ) tuple[i] = ass[i];
t.add(tuple);
}
++ass;
}
t.finalize();
return t;
}
class Create {
public:
Create(void) {
using namespace Gecode;
for (bool pos : { false, true }) {
{
TupleSet ts(4);
ts.add({2, 1, 2, 4}).add({2, 2, 1, 4})
.add({4, 3, 4, 1}).add({1, 3, 2, 3})
.add({3, 3, 3, 2}).add({5, 1, 4, 4})
.add({2, 5, 1, 5}).add({4, 3, 5, 1})
.add({1, 5, 2, 5}).add({5, 3, 3, 2})
.finalize();
(void) new TupleSetTest("A",pos,IntSet(0,6),ts,true);
}
{
TupleSet ts(4);
ts.finalize();
(void) new TupleSetTest("Empty",pos,IntSet(1,2),ts,true);
}
{
TupleSet ts(4);
for (int n=1024*16; n--; )
ts.add({1,2,3,4});
ts.finalize();
(void) new TupleSetTest("Assigned",pos,IntSet(1,4),ts,true);
}
{
TupleSet ts(1);
ts.add({1}).add({2}).add({3}).finalize();
(void) new TupleSetTest("Single",pos,IntSet(-4,4),ts,true);
}
{
int m = Gecode::Int::Limits::min;
TupleSet ts(3);
ts.add({m+0,m+1,m+2}).add({m+4,m+1,m+3})
.add({m+2,m+3,m+0}).add({m+2,m+3,m+0})
.add({m+1,m+2,m+5}).add({m+2,m+3,m+0})
.add({m+3,m+6,m+5}).finalize();
(void) new TupleSetTest("Min",pos,IntSet(m,m+7),ts,true);
}
{
int M = Gecode::Int::Limits::max;
TupleSet ts(3);
ts.add({M-0,M-1,M-2}).add({M-4,M-1,M-3})
.add({M-2,M-3,M-0}).add({M-2,M-3,M-0})
.add({M-1,M-2,M-5}).add({M-2,M-3,M-0})
.add({M-3,M-6,M-5}).finalize();
(void) new TupleSetTest("Max",pos,IntSet(M-7,M),ts,true);
}
{
int m = Gecode::Int::Limits::min;
int M = Gecode::Int::Limits::max;
TupleSet ts(3);
ts.add({M-0,m+1,M-2}).add({m+4,M-1,M-3})
.add({m+2,M-3,m+0}).add({M-2,M-3,M-0})
.finalize();
(void) new TupleSetTest("MinMax",pos,
IntSet(IntArgs({m,m+1,m+4,M-3,M-2,M})),
ts,true);
}
{
TupleSet ts(7);
for (int i = 0; i < 10000; i++) {
IntArgs tuple(7);
for (int j = 0; j < 7; j++) {
tuple[j] = Base::rand(j+1);
}
ts.add(tuple);
}
ts.finalize();
(void) new RandomTupleSetTest("Triangle",pos,IntSet(0,6),ts);
}
{
for (int i = 0; i <= 64*6; i+=32)
(void) new TupleSetTestSize(i,pos);
}
{
(void) new RandomTupleSetTest("Rand(10,-1,2)", pos,
IntSet(-1,2),
randomTupleSet(10,-1,2,0.05));
(void) new RandomTupleSetTest("Rand(5,-10,10)", pos,
IntSet(-10,10),
randomTupleSet(5,-10,10,0.05));
}
{
TupleSet t(5);
CpltAssignment ass(4, IntSet(1, 4));
while (ass()) {
IntArgs tuple(5);
tuple[4] = 1;
for (int i = 4; i--; ) tuple[i] = ass[i];
t.add(tuple);
++ass;
}
t.add({2,2,4,3,4});
t.finalize();
(void) new TupleSetTest("FewLast",pos,IntSet(1,4),t,false);
}
{
TupleSet t(4);
CpltAssignment ass(4, IntSet(1, 6));
while (ass()) {
t.add({ass[0],0,ass[1],ass[2]});
++ass;
}
t.add({2,-1,3,4});
t.finalize();
(void) new TupleSetTest("FewMiddle",pos,IntSet(-1,6),t,false);
}
{
TupleSet t(10);
CpltAssignment ass(9, IntSet(1, 4));
while (ass()) {
if (Base::rand(100) <= 0.25*100) {
IntArgs tuple(10);
tuple[0] = 2;
for (int i = 9; i--; ) tuple[i+1] = ass[i];
t.add(tuple);
}
++ass;
}
t.add({1,1,1,1,1,1,1,1,1,1});
t.add({1,2,3,4,4,2,1,2,3,3});
t.finalize();
(void) new RandomTupleSetTest("FewHuge",pos,IntSet(1,4),t);
}
(void) new TupleSetBase(pos);
(void) new TupleSetLarge(0.05,pos);
(void) new TupleSetBool(0.3,pos);
}
}
};
Create c;
RegSimpleA ra;
RegSimpleB rb;
RegSimpleC rc;
RegDistinct rd;
RegRoland rr1(1);
RegRoland rr2(2);
RegRoland rr3(3);
RegRoland rr4(4);
RegSharedA rsa;
RegSharedB rsb;
RegSharedC rsc;
RegSharedD rsd;
RegEmptyDFA redfa;
RegEmptyREG rereg;
RegOpt ro0(CHAR_MAX-1);
RegOpt ro1(CHAR_MAX);
RegOpt ro2(static_cast<int>(UCHAR_MAX-1));
RegOpt ro3(static_cast<int>(UCHAR_MAX));
RegOpt ro4(SHRT_MAX-1);
RegOpt ro5(SHRT_MAX);
RegOpt ro6(static_cast<int>(USHRT_MAX-1));
RegOpt ro7(static_cast<int>(USHRT_MAX));
}
}}
// STATISTICS: test-int
Gecode::BoolVarArgs
Passing Boolean variables.
Definition int.hh:712
Gecode::DFA::Transition
Specification of a DFA transition.
Definition int.hh:2058
Gecode::DFA::Transition::i_state
int i_state
input state
Definition int.hh:2060
Gecode::DFA::Transition::o_state
int o_state
output state Default constructor
Definition int.hh:2062
Gecode::DFA::Transition::symbol
int symbol
symbol
Definition int.hh:2061
Gecode::DFA
Deterministic finite automaton (DFA).
Definition int.hh:2049
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::REG
Regular expressions over integer values.
Definition minimodel.hh:1625
Gecode::Reify
Reification specification.
Definition int.hh:876
Gecode::Space
Computation spaces.
Definition core.hpp:1742
Gecode::TupleSet
Class represeting a set of tuples.
Definition int.hh:2191
Gecode::TupleSet::tuples
int tuples(void) const
Number of tuples.
Definition tuple-set.hpp:185
Gecode::TupleSet::add
TupleSet & add(const IntArgs &t)
Add tuple t to tuple set.
Definition tuple-set.hpp:142
Gecode::TupleSet::Tuple
int * Tuple
Type of a tuple.
Definition int.hh:2197
Gecode::TupleSet::finalize
void finalize(void)
Finalize tuple set.
Definition tuple-set.hpp:155
Gecode::TupleSet::arity
int arity(void) const
Arity of tuple set.
Definition tuple-set.hpp:181
Gecode::VarArray::size
int size(void) const
Return size of array (number of elements).
Definition array.hpp:926
Test::Base::rand
static Gecode::Support::RandomGenerator rand
Random number generator.
Definition test.hh:134
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::CpltAssignment
Generate all assignments.
Definition int.hh:79
Test::Int::Extensional::Create
Help class to create and register tests.
Definition extensional.cpp:660
Test::Int::Extensional::Create::Create
Create(void)
Perform creation and registration.
Definition extensional.cpp:663
Test::Int::Extensional::RandomTupleSetTest
Definition extensional.cpp:488
Test::Int::Extensional::RandomTupleSetTest::RandomTupleSetTest
RandomTupleSetTest(const std::string &s, bool p, Gecode::IntSet d0, Gecode::TupleSet ts0)
Create and register test.
Definition extensional.cpp:491
Test::Int::Extensional::RandomTupleSetTest::assignment
virtual Assignment * assignment(void) const
Create and register initial assignment.
Definition extensional.cpp:497
Test::Int::Extensional::RegDistinct
Test with regular expression for distinct constraint
Definition extensional.cpp:134
Test::Int::Extensional::RegDistinct::post
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
Definition extensional.cpp:150
Test::Int::Extensional::RegDistinct::RegDistinct
RegDistinct(void)
Create and register test.
Definition extensional.cpp:137
Test::Int::Extensional::RegDistinct::solution
virtual bool solution(const Assignment &x) const
Test whether x is solution
Definition extensional.cpp:139
Test::Int::Extensional::RegEmptyDFA
Test for empty DFA
Definition extensional.cpp:299
Test::Int::Extensional::RegEmptyDFA::RegEmptyDFA
RegEmptyDFA(void)
Create and register test.
Definition extensional.cpp:302
Test::Int::Extensional::RegEmptyDFA::post
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
Definition extensional.cpp:311
Test::Int::Extensional::RegEmptyDFA::solution
virtual bool solution(const Assignment &x) const
Test whether x is solution
Definition extensional.cpp:306
Test::Int::Extensional::RegEmptyREG
Test for empty regular expression
Definition extensional.cpp:318
Test::Int::Extensional::RegEmptyREG::post
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
Definition extensional.cpp:330
Test::Int::Extensional::RegEmptyREG::RegEmptyREG
RegEmptyREG(void)
Create and register test.
Definition extensional.cpp:321
Test::Int::Extensional::RegEmptyREG::solution
virtual bool solution(const Assignment &x) const
Test whether x is solution
Definition extensional.cpp:325
Test::Int::Extensional::RegOpt
Test for optimizations
Definition extensional.cpp:337
Test::Int::Extensional::RegOpt::post
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
Definition extensional.cpp:350
Test::Int::Extensional::RegOpt::solution
virtual bool solution(const Assignment &x) const
Test whether x is solution
Definition extensional.cpp:346
Test::Int::Extensional::RegOpt::RegOpt
RegOpt(int n0)
Create and register test.
Definition extensional.cpp:343
Test::Int::Extensional::RegOpt::n
int n
DFA size characteristic.
Definition extensional.cpp:340
Test::Int::Extensional::RegRoland
Test with simple regular expression from Roland Yap
Definition extensional.cpp:181
Test::Int::Extensional::RegRoland::solution
virtual bool solution(const Assignment &x) const
Test whether x is solution
Definition extensional.cpp:187
Test::Int::Extensional::RegRoland::post
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
Definition extensional.cpp:194
Test::Int::Extensional::RegRoland::RegRoland
RegRoland(int n)
Create and register test.
Definition extensional.cpp:184
Test::Int::Extensional::RegSharedA
Test with simple regular expression and shared variables (uses unsharing)
Definition extensional.cpp:203
Test::Int::Extensional::RegSharedA::solution
virtual bool solution(const Assignment &x) const
Test whether x is solution
Definition extensional.cpp:208
Test::Int::Extensional::RegSharedA::RegSharedA
RegSharedA(void)
Create and register test.
Definition extensional.cpp:206
Test::Int::Extensional::RegSharedA::post
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
Definition extensional.cpp:215
Test::Int::Extensional::RegSharedB
Test with simple regular expression and shared variables (uses unsharing)
Definition extensional.cpp:230
Test::Int::Extensional::RegSharedB::RegSharedB
RegSharedB(void)
Create and register test.
Definition extensional.cpp:233
Test::Int::Extensional::RegSharedB::post
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
Definition extensional.cpp:242
Test::Int::Extensional::RegSharedB::solution
virtual bool solution(const Assignment &x) const
Test whether x is solution
Definition extensional.cpp:235
Test::Int::Extensional::RegSharedC
Test with simple regular expression and shared variables (uses unsharing)
Definition extensional.cpp:257
Test::Int::Extensional::RegSharedC::solution
virtual bool solution(const Assignment &x) const
Test whether x is solution
Definition extensional.cpp:262
Test::Int::Extensional::RegSharedC::RegSharedC
RegSharedC(void)
Create and register test.
Definition extensional.cpp:260
Test::Int::Extensional::RegSharedC::post
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
Definition extensional.cpp:266
Test::Int::Extensional::RegSharedD
Test with simple regular expression and shared variables (uses unsharing)
Definition extensional.cpp:278
Test::Int::Extensional::RegSharedD::post
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
Definition extensional.cpp:287
Test::Int::Extensional::RegSharedD::RegSharedD
RegSharedD(void)
Create and register test.
Definition extensional.cpp:281
Test::Int::Extensional::RegSharedD::solution
virtual bool solution(const Assignment &x) const
Test whether x is solution
Definition extensional.cpp:283
Test::Int::Extensional::RegSimpleA
Test with simple regular expression
Definition extensional.cpp:54
Test::Int::Extensional::RegSimpleA::solution
virtual bool solution(const Assignment &x) const
Test whether x is solution
Definition extensional.cpp:59
Test::Int::Extensional::RegSimpleA::post
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
Definition extensional.cpp:66
Test::Int::Extensional::RegSimpleA::RegSimpleA
RegSimpleA(void)
Create and register test.
Definition extensional.cpp:57
Test::Int::Extensional::RegSimpleB
Test with simple regular expression
Definition extensional.cpp:77
Test::Int::Extensional::RegSimpleB::solution
virtual bool solution(const Assignment &x) const
Test whether x is solution
Definition extensional.cpp:82
Test::Int::Extensional::RegSimpleB::RegSimpleB
RegSimpleB(void)
Create and register test.
Definition extensional.cpp:80
Test::Int::Extensional::RegSimpleB::post
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
Definition extensional.cpp:86
Test::Int::Extensional::RegSimpleC
Test with simple regular expression
Definition extensional.cpp:98
Test::Int::Extensional::RegSimpleC::post
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
Definition extensional.cpp:126
Test::Int::Extensional::RegSimpleC::RegSimpleC
RegSimpleC(void)
Create and register test.
Definition extensional.cpp:101
Test::Int::Extensional::RegSimpleC::solution
virtual bool solution(const Assignment &x) const
Test whether x is solution
Definition extensional.cpp:103
Test::Int::Extensional::TupleSetBase
Test with tuple set
Definition extensional.cpp:391
Test::Int::Extensional::TupleSetBase::pos
bool pos
Whether the table is positive or negative.
Definition extensional.cpp:396
Test::Int::Extensional::TupleSetBase::solution
virtual bool solution(const Assignment &x) const
Test whether x is solution
Definition extensional.cpp:419
Test::Int::Extensional::TupleSetBase::TupleSetBase
TupleSetBase(bool p)
Create and register test.
Definition extensional.cpp:399
Test::Int::Extensional::TupleSetBase::post
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x, Gecode::Reify r)
Post reified constraint on x for r.
Definition extensional.cpp:434
Test::Int::Extensional::TupleSetBase::t
Gecode::TupleSet t
Simple test tupleset.
Definition extensional.cpp:394
Test::Int::Extensional::TupleSetBase::post
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
Definition extensional.cpp:427
Test::Int::Extensional::TupleSetBool
Test with bool tuple set
Definition extensional.cpp:555
Test::Int::Extensional::TupleSetBool::t
Gecode::TupleSet t
Tupleset used for testing.
Definition extensional.cpp:560
Test::Int::Extensional::TupleSetBool::post
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
Definition extensional.cpp:594
Test::Int::Extensional::TupleSetBool::solution
virtual bool solution(const Assignment &x) const
Test whether x is solution
Definition extensional.cpp:580
Test::Int::Extensional::TupleSetBool::pos
bool pos
Whether the table is positive or negative.
Definition extensional.cpp:558
Test::Int::Extensional::TupleSetBool::TupleSetBool
TupleSetBool(double prob, bool p)
Create and register test.
Definition extensional.cpp:563
Test::Int::Extensional::TupleSetBool::post
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x, Gecode::Reify r)
Post reified constraint on x for r.
Definition extensional.cpp:602
Test::Int::Extensional::TupleSetLarge
Test with large tuple set
Definition extensional.cpp:504
Test::Int::Extensional::TupleSetLarge::pos
bool pos
Whether the table is positive or negative.
Definition extensional.cpp:507
Test::Int::Extensional::TupleSetLarge::post
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x, Gecode::Reify r)
Post reified constraint on x for r.
Definition extensional.cpp:547
Test::Int::Extensional::TupleSetLarge::post
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
Definition extensional.cpp:542
Test::Int::Extensional::TupleSetLarge::t
Gecode::TupleSet t
Tupleset used for testing.
Definition extensional.cpp:509
Test::Int::Extensional::TupleSetLarge::solution
virtual bool solution(const Assignment &x) const
Test whether x is solution
Definition extensional.cpp:529
Test::Int::Extensional::TupleSetLarge::TupleSetLarge
TupleSetLarge(double prob, bool p)
Create and register test.
Definition extensional.cpp:512
Test::Int::Extensional::TupleSetTestSize
Help class to create and register tests with a fixed table size.
Definition extensional.cpp:613
Test::Int::Extensional::TupleSetTestSize::TupleSetTestSize
TupleSetTestSize(int size, bool pos)
Perform creation and registration.
Definition extensional.cpp:616
Test::Int::Extensional::TupleSetTest
Test with tuple set
Definition extensional.cpp:441
Test::Int::Extensional::TupleSetTest::solution
virtual bool solution(const Assignment &x) const
Test whether x is solution
Definition extensional.cpp:458
Test::Int::Extensional::TupleSetTest::toDFA
bool toDFA
Whether to validate dfa2tupleset.
Definition extensional.cpp:448
Test::Int::Extensional::TupleSetTest::post
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x, Gecode::Reify r)
Post reified constraint on x for r.
Definition extensional.cpp:481
Test::Int::Extensional::TupleSetTest::ts
Gecode::TupleSet ts
The tuple set to use.
Definition extensional.cpp:446
Test::Int::Extensional::TupleSetTest::pos
bool pos
Whether the table is positive or negative.
Definition extensional.cpp:444
Test::Int::Extensional::TupleSetTest::TupleSetTest
TupleSetTest(const std::string &s, bool p, Gecode::IntSet d0, Gecode::TupleSet ts0, bool td)
Create and register test.
Definition extensional.cpp:451
Test::Int::Extensional::TupleSetTest::post
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
Definition extensional.cpp:472
Test::Int::RandomAssignment
Generate random selection of assignments.
Definition int.hh:96
Test::Int::Test::testsearch
bool testsearch
Whether to perform search test.
Definition int.hh:238
Test::Int::Test::ipl
Gecode::IntPropLevel ipl
Propagation level.
Definition int.hh:234
Test::Int::Test::arity
int arity
Number of variables.
Definition int.hh:226
Test::Int::Test::str
static std::string str(Gecode::IntPropLevel ipl)
Map integer propagation level to string.
Definition int.hpp:209
Test::Int::Test::dom
Gecode::IntSet dom
Domain of variables.
Definition int.hh:228
Gecode::extensional
void extensional(Home home, const IntVarArgs &x, DFA d, IntPropLevel ipl=IPL_DEF)
Post domain consistent propagator for extensional constraint described by a DFA.
Definition extensional-regular.cpp:39
Gecode::IPL_DOM
@ IPL_DOM
Domain propagation Options: basic versus advanced propagation.
Definition int.hh:979
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::min
void min(Home home, FloatVar x0, FloatVar x1, FloatVar x2)
Post propagator for .
Definition arithmetic.cpp:67
Gecode::same
bool same(VarArgArray< Var > x, VarArgArray< Var > y)
Definition array.hpp:1937
Gecode::unshare
void unshare(Home home, IntVarArgs &x, IntPropLevel ipl=IPL_DEF)
Replace multiple variable occurences in x by fresh variables.
Definition unshare.cpp:136
Gecode::max
void max(Home home, FloatVar x0, FloatVar x1, FloatVar x2)
Post propagator for .
Definition arithmetic.cpp:49
Test::Int::Extensional
Tests for extensional (relation) constraints
Definition extensional.cpp:46
Test::Int::Extensional::rsb
RegSharedB rsb
Definition extensional.cpp:809
Test::Int::Extensional::ro0
RegOpt ro0(CHAR_MAX-1)
Test::Int::Extensional::rb
RegSimpleB rb
Definition extensional.cpp:798
Test::Int::Extensional::rsa
RegSharedA rsa
Definition extensional.cpp:808
Test::Int::Extensional::rereg
RegEmptyREG rereg
Definition extensional.cpp:814
Test::Int::Extensional::c
Create c
Definition extensional.cpp:795
Test::Int::Extensional::rsc
RegSharedC rsc
Definition extensional.cpp:810
Test::Int::Extensional::rd
RegDistinct rd
Definition extensional.cpp:801
Test::Int::Extensional::redfa
RegEmptyDFA redfa
Definition extensional.cpp:813
Test::Int::Extensional::tupleset2dfa
Gecode::DFA tupleset2dfa(Gecode::TupleSet ts)
% Transform a TupleSet into a DFA
Definition extensional.cpp:376
Test::Int::Extensional::ro7
RegOpt ro7(static_cast< int >(USHRT_MAX))
Test::Int::Extensional::rsd
RegSharedD rsd
Definition extensional.cpp:811
Test::Int::Extensional::ro2
RegOpt ro2(static_cast< int >(UCHAR_MAX-1))
Test::Int::Extensional::randomTupleSet
Gecode::TupleSet randomTupleSet(int n, int min, int max, double prob)
Definition extensional.cpp:643
Test::Int::Extensional::ro6
RegOpt ro6(static_cast< int >(USHRT_MAX-1))
Test::Int::Extensional::rr2
RegRoland rr2(2)
Test::Int::Extensional::rr4
RegRoland rr4(4)
Test::Int::Extensional::rr1
RegRoland rr1(1)
Test::Int::Extensional::ro4
RegOpt ro4(SHRT_MAX-1)
Test::Int::Extensional::rr3
RegRoland rr3(3)
Test::Int::Extensional::ro1
RegOpt ro1(CHAR_MAX)
Test::Int::Extensional::ra
RegSimpleA ra
Definition extensional.cpp:797
Test::Int::Extensional::rc
RegSimpleC rc
Definition extensional.cpp:799
Test::Int::Extensional::ro3
RegOpt ro3(static_cast< int >(UCHAR_MAX))
Test::Int::Extensional::ro5
RegOpt ro5(SHRT_MAX)
Test::Int
Testing finite domain integers.
Definition int.cpp:40
Test
General test support.
Definition afc.cpp:39
Test::r
Region r
Definition region.cpp:65
int.hh