ldsb.cpp
Go to the documentation of this file.
/* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
/*
* Main authors:
* Christopher Mears <chris.mears@monash.edu>
*
* Copyright:
* Christopher Mears, 2012
*
* 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 <gecode/kernel.hh>
#include <gecode/int.hh>
#include <gecode/int/branch.hh>
#ifdef GECODE_HAS_SET_VARS
#include <gecode/set.hh>
#include <gecode/set/branch.hh>
#include <stdarg.h>
#endif
#include <gecode/minimodel.hh>
#include "test/test.hh"
#include <vector>
namespace Test { namespace LDSB {
using namespace Gecode;
bool
equal(const IntArgs& a, const IntArgs& b) {
if (a.size() != b.size()) return false;
for (int i = 0 ; i < a.size() ; ++i)
if (a[i] != b[i])
return false;
return true;
}
#ifdef GECODE_HAS_SET_VARS
bool
equal(const IntSetArgs& a, const IntSetArgs& b) {
if (a.size() != b.size()) return false;
for (int i = 0 ; i < a.size() ; ++i) {
// Compare the two sets a[i] and b[i].
// Perhaps TODO: use Iter::Ranges::equal instead.
if (a[i].size() != b[i].size()) return false;
IntSetValues x(a[i]);
IntSetValues y(b[i]);
while (x() && y()) {
if (x.val() != y.val()) return false;
++x;
++y;
}
}
return true;
}
#endif
template <class T, class VarArgsType>
bool
check(DFS<T>& e, std::vector<VarArgsType> expected) {
int nexpected = expected.size();
for (int i = 0 ; i < nexpected ; ++i) {
T* s = e.next();
if (s == NULL) {
if (opt.log) {
olog << "Expected a solution but there are no more solutions." << std::endl;
olog << "(Expected " << nexpected << " but only found " << i << ")" << std::endl;
olog << "Expected: " << expected[i] << std::endl;
}
return false;
}
if (!equal(s->solution(), expected[i])) {
if (opt.log) {
olog << "Solution does not match expected." << std::endl;
olog << "Solution: " << s->solution() << std::endl;
olog << "Expected: " << expected[i] << std::endl;
}
return false;
}
delete s;
}
T* s = e.next();
if (s != NULL) {
if (opt.log) {
olog << "More solutions than expected:" << std::endl;
olog << "(Expected only " << nexpected << ")" << std::endl;
olog << s->solution() << std::endl;
}
return false;
}
// Nothing went wrong.
return true;
}
class OneArray : public Space {
public:
IntVarArray xs;
OneArray(int n, int l, int u) : xs(*this,n,l,u) {
}
OneArray(OneArray& s) : Space(s) {
xs.update(*this,s.xs);
}
virtual Space* copy(void) {
return new OneArray(*this);
}
IntArgs solution(void) {
IntArgs a(xs.size());
for (int i = 0 ; i < a.size() ; ++i)
a[i] = xs[i].val();
return a;
}
virtual IntArgs* expectedSolutions(void) { return NULL; }
};
#ifdef GECODE_HAS_SET_VARS
class OneArraySet : public Space {
public:
SetVarArray xs;
OneArraySet(int n, int l, int u) : xs(*this,n, IntSet::empty, l,u) {
}
OneArraySet(OneArraySet& s) : Space(s) {
xs.update(*this,s.xs);
}
virtual Space* copy(void) {
return new OneArraySet(*this);
}
IntSetArgs solution(void) {
IntSetArgs a(xs.size());
for (int i = 0 ; i < a.size() ; ++i) {
SetVarGlbRanges glbranges(xs[i]);
a[i] = IntSet(glbranges);
}
return a;
}
virtual IntSetArgs* expectedSolutions(void) { return NULL; }
};
#endif
template <class T>
class LDSB : public Base {
public:
unsigned int c_d;
unsigned int a_d;
LDSB(std::string label, unsigned int c=0, unsigned int a=0)
: Test::Base("LDSB::" + label),
c_d(c), a_d(a) {}
bool run(void) {
OneArray *s = new OneArray(T::n, T::l, T::u);
T::setup(*s, s->xs);
Search::Options o = Search::Options::def;
if (c_d != 0) o.c_d = c_d;
if (a_d != 0) o.a_d = a_d;
DFS<OneArray> e(s,o);
bool r = check(e, T::expectedSolutions());
delete s;
return r;
}
};
#ifdef GECODE_HAS_SET_VARS
template <class T>
class LDSBSet : public Base {
public:
unsigned int c_d;
unsigned int a_d;
LDSBSet(std::string label, unsigned int c=0, unsigned int a=0)
: Test::Base("LDSB::" + label),
c_d(c), a_d(a) {}
bool run(void) {
OneArraySet *s = new OneArraySet(T::n, T::l, T::u);
T::setup(*s, s->xs);
Search::Options o = Search::Options::def;
if (c_d != 0) o.c_d = c_d;
if (a_d != 0) o.a_d = a_d;
DFS<OneArraySet> e(s,o);
bool r = check(e, T::expectedSolutions());
delete s;
return r;
}
};
#endif
// Test cases
class VarSym1 {
public:
static const int n = 4;
static const int l = 0;
static const int u = 3;
static void setup(Home home, IntVarArray& xs) {
Symmetries syms;
IntArgs indices({0,1,2,3});
syms << VariableSymmetry(xs, indices);
distinct(home, xs);
branch(home, xs, INT_VAR_NONE(), INT_VAL_MIN(), syms);
}
static std::vector<IntArgs> expectedSolutions(void) {
static std::vector<IntArgs> expected;
expected.clear();
expected.push_back(IntArgs({0,1,2,3}));
return expected;
}
};
class VarSym1b {
public:
static const int n = 4;
static const int l = 0;
static const int u = 3;
static void setup(Home home, IntVarArray& xs) {
distinct(home, xs);
Symmetries syms;
syms << VariableSymmetry(xs);
branch(home, xs, INT_VAR_NONE(), INT_VAL_MIN(), syms);
}
static std::vector<IntArgs> expectedSolutions(void) {
static std::vector<IntArgs> expected;
expected.clear();
expected.push_back(IntArgs({0,1,2,3}));
return expected;
}
};
class VarSym2 {
public:
static const int n = 4;
static const int l = 0;
static const int u = 3;
static void setup(Home home, IntVarArray& xs) {
Symmetries syms;
IntArgs indices({0,1,2,3});
syms << VariableSymmetry(xs);
branch(home, xs, INT_VAR_NONE(), INT_VAL_MIN(), syms);
}
static std::vector<IntArgs> expectedSolutions(void) {
static std::vector<IntArgs> expected;
expected.clear();
expected.push_back(IntArgs({0,0,0,0}));
expected.push_back(IntArgs({0,0,0,1}));
expected.push_back(IntArgs({0,0,0,2}));
expected.push_back(IntArgs({0,0,0,3}));
expected.push_back(IntArgs({0,0,1,1}));
expected.push_back(IntArgs({0,0,1,2}));
expected.push_back(IntArgs({0,0,1,3}));
expected.push_back(IntArgs({0,0,2,2}));
expected.push_back(IntArgs({0,0,2,3}));
expected.push_back(IntArgs({0,0,3,3}));
expected.push_back(IntArgs({0,1,1,1}));
expected.push_back(IntArgs({0,1,1,2}));
expected.push_back(IntArgs({0,1,1,3}));
expected.push_back(IntArgs({0,1,2,2}));
expected.push_back(IntArgs({0,1,2,3}));
expected.push_back(IntArgs({0,1,3,3}));
expected.push_back(IntArgs({0,2,2,2}));
expected.push_back(IntArgs({0,2,2,3}));
expected.push_back(IntArgs({0,2,3,3}));
expected.push_back(IntArgs({0,3,3,3}));
expected.push_back(IntArgs({1,1,1,1}));
expected.push_back(IntArgs({1,1,1,2}));
expected.push_back(IntArgs({1,1,1,3}));
expected.push_back(IntArgs({1,1,2,2}));
expected.push_back(IntArgs({1,1,2,3}));
expected.push_back(IntArgs({1,1,3,3}));
expected.push_back(IntArgs({1,2,2,2}));
expected.push_back(IntArgs({1,2,2,3}));
expected.push_back(IntArgs({1,2,3,3}));
expected.push_back(IntArgs({1,3,3,3}));
expected.push_back(IntArgs({2,2,2,2}));
expected.push_back(IntArgs({2,2,2,3}));
expected.push_back(IntArgs({2,2,3,3}));
expected.push_back(IntArgs({2,3,3,3}));
expected.push_back(IntArgs({3,3,3,3}));
return expected;
}
};
class VarSym3 {
public:
static const int n = 4;
static const int l = 0;
static const int u = 3;
static void setup(Home home, IntVarArray& xs) {
Symmetries syms;
distinct(home, xs);
syms << VariableSymmetry(IntVarArgs() << xs[0] << xs[1]);
branch(home, xs, INT_VAR_NONE(), INT_VAL_MIN(), syms);
}
static std::vector<IntArgs> expectedSolutions(void) {
static std::vector<IntArgs> expected;
expected.clear();
expected.push_back(IntArgs({0,1,2,3}));
expected.push_back(IntArgs({0,1,3,2}));
expected.push_back(IntArgs({0,2,1,3}));
expected.push_back(IntArgs({0,2,3,1}));
expected.push_back(IntArgs({0,3,1,2}));
expected.push_back(IntArgs({0,3,2,1}));
expected.push_back(IntArgs({1,2,0,3}));
expected.push_back(IntArgs({1,2,3,0}));
expected.push_back(IntArgs({1,3,0,2}));
expected.push_back(IntArgs({1,3,2,0}));
expected.push_back(IntArgs({2,3,0,1}));
expected.push_back(IntArgs({2,3,1,0}));
return expected;
}
};
class VarSym4 {
public:
static const int n = 3;
static const int l = 0;
static const int u = 2;
static void setup(Home home, IntVarArray& xs) {
distinct(home, xs);
Symmetries s;
IntVarArgs symvars;
symvars << xs[0];
s << VariableSymmetry(symvars);
branch(home, xs, INT_VAR_NONE(), INT_VAL_MIN(), s);
}
static std::vector<IntArgs> expectedSolutions(void) {
static std::vector<IntArgs> expected;
expected.clear();
expected.push_back(IntArgs({0,1,2}));
expected.push_back(IntArgs({0,2,1}));
expected.push_back(IntArgs({1,0,2}));
expected.push_back(IntArgs({1,2,0}));
expected.push_back(IntArgs({2,0,1}));
expected.push_back(IntArgs({2,1,0}));
return expected;
}
};
class VarSym5 {
public:
static const int n = 4;
static const int l = 0;
static const int u = 3;
static void setup(Home home, IntVarArray& xs) {
distinct(home, xs);
Matrix<IntVarArray> m(xs, 4, 1);
Symmetries s;
s << VariableSymmetry(m.slice(0,2, 0,1));
s << VariableSymmetry(m.slice(2,4, 0,1));
branch(home, xs, INT_VAR_NONE(), INT_VAL_MIN(), s);
}
static std::vector<IntArgs> expectedSolutions(void) {
static std::vector<IntArgs> expected;
expected.clear();
expected.push_back(IntArgs({0,1,2,3}));
expected.push_back(IntArgs({0,2,1,3}));
expected.push_back(IntArgs({0,3,1,2}));
expected.push_back(IntArgs({1,2,0,3}));
expected.push_back(IntArgs({1,3,0,2}));
expected.push_back(IntArgs({2,3,0,1}));
return expected;
}
};
class MatSym1 {
public:
static const int n = 6;
static const int l = 0;
static const int u = 1;
static void setup(Home home, IntVarArray& xs) {
Matrix<IntVarArray> m(xs, 2, 3);
Symmetries s;
s << rows_interchange(m);
branch(home, xs, INT_VAR_NONE(), INT_VAL_MIN(), s);
}
static std::vector<IntArgs> expectedSolutions(void) {
static std::vector<IntArgs> expected;
expected.clear();
expected.push_back(IntArgs({0,0, 0,0, 0,0}));
expected.push_back(IntArgs({0,0, 0,0, 0,1}));
expected.push_back(IntArgs({0,0, 0,0, 1,0}));
expected.push_back(IntArgs({0,0, 0,0, 1,1}));
expected.push_back(IntArgs({0,0, 0,1, 0,0}));
expected.push_back(IntArgs({0,0, 0,1, 0,1}));
expected.push_back(IntArgs({0,0, 0,1, 1,0}));
expected.push_back(IntArgs({0,0, 0,1, 1,1}));
expected.push_back(IntArgs({0,0, 1,0, 1,0}));
expected.push_back(IntArgs({0,0, 1,0, 1,1}));
expected.push_back(IntArgs({0,0, 1,1, 1,1}));
expected.push_back(IntArgs({0,1, 0,0, 0,0}));
expected.push_back(IntArgs({0,1, 0,0, 0,1}));
expected.push_back(IntArgs({0,1, 0,0, 1,0}));
expected.push_back(IntArgs({0,1, 0,0, 1,1}));
expected.push_back(IntArgs({0,1, 0,1, 0,0}));
expected.push_back(IntArgs({0,1, 0,1, 0,1}));
expected.push_back(IntArgs({0,1, 0,1, 1,0}));
expected.push_back(IntArgs({0,1, 0,1, 1,1}));
expected.push_back(IntArgs({0,1, 1,0, 1,0}));
expected.push_back(IntArgs({0,1, 1,0, 1,1}));
expected.push_back(IntArgs({0,1, 1,1, 1,1}));
expected.push_back(IntArgs({1,0, 1,0, 1,0}));
expected.push_back(IntArgs({1,0, 1,0, 1,1}));
expected.push_back(IntArgs({1,0, 1,1, 1,1}));
expected.push_back(IntArgs({1,1, 1,1, 1,1}));
return expected;
}
};
class MatSym2 {
public:
static const int n = 6;
static const int l = 0;
static const int u = 1;
static void setup(Home home, IntVarArray& xs) {
Matrix<IntVarArray> m(xs, 2, 3);
Symmetries s;
s << columns_interchange(m);
branch(home, xs, INT_VAR_NONE(), INT_VAL_MIN(), s);
}
static std::vector<IntArgs> expectedSolutions(void) {
static std::vector<IntArgs> expected;
expected.clear();
expected.push_back(IntArgs({0,0, 0,0, 0,0}));
expected.push_back(IntArgs({0,0, 0,0, 0,1}));
expected.push_back(IntArgs({0,0, 0,0, 1,1}));
expected.push_back(IntArgs({0,0, 0,1, 0,0}));
expected.push_back(IntArgs({0,0, 0,1, 0,1}));
expected.push_back(IntArgs({0,0, 0,1, 1,0}));
expected.push_back(IntArgs({0,0, 0,1, 1,1}));
expected.push_back(IntArgs({0,0, 1,1, 0,0}));
expected.push_back(IntArgs({0,0, 1,1, 0,1}));
expected.push_back(IntArgs({0,0, 1,1, 1,1}));
expected.push_back(IntArgs({0,1, 0,0, 0,0}));
expected.push_back(IntArgs({0,1, 0,0, 0,1}));
expected.push_back(IntArgs({0,1, 0,0, 1,0}));
expected.push_back(IntArgs({0,1, 0,0, 1,1}));
expected.push_back(IntArgs({0,1, 0,1, 0,0}));
expected.push_back(IntArgs({0,1, 0,1, 0,1}));
expected.push_back(IntArgs({0,1, 0,1, 1,0}));
expected.push_back(IntArgs({0,1, 0,1, 1,1}));
expected.push_back(IntArgs({0,1, 1,0, 0,0}));
expected.push_back(IntArgs({0,1, 1,0, 0,1}));
expected.push_back(IntArgs({0,1, 1,0, 1,0}));
expected.push_back(IntArgs({0,1, 1,0, 1,1}));
expected.push_back(IntArgs({0,1, 1,1, 0,0}));
expected.push_back(IntArgs({0,1, 1,1, 0,1}));
expected.push_back(IntArgs({0,1, 1,1, 1,0}));
expected.push_back(IntArgs({0,1, 1,1, 1,1}));
expected.push_back(IntArgs({1,1, 0,0, 0,0}));
expected.push_back(IntArgs({1,1, 0,0, 0,1}));
expected.push_back(IntArgs({1,1, 0,0, 1,1}));
expected.push_back(IntArgs({1,1, 0,1, 0,0}));
expected.push_back(IntArgs({1,1, 0,1, 0,1}));
expected.push_back(IntArgs({1,1, 0,1, 1,0}));
expected.push_back(IntArgs({1,1, 0,1, 1,1}));
expected.push_back(IntArgs({1,1, 1,1, 0,0}));
expected.push_back(IntArgs({1,1, 1,1, 0,1}));
expected.push_back(IntArgs({1,1, 1,1, 1,1}));
return expected;
}
};
class MatSym3 {
public:
static const int n = 6;
static const int l = 0;
static const int u = 1;
static void setup(Home home, IntVarArray& xs) {
Matrix<IntVarArray> m(xs, 2, 3);
Symmetries s;
s << rows_interchange(m);
s << columns_interchange(m);
branch(home, xs, INT_VAR_NONE(), INT_VAL_MIN(), s);
}
static std::vector<IntArgs> expectedSolutions(void) {
static std::vector<IntArgs> expected;
expected.clear();
expected.push_back(IntArgs({0,0, 0,0, 0,0}));
expected.push_back(IntArgs({0,0, 0,0, 0,1}));
expected.push_back(IntArgs({0,0, 0,0, 1,1}));
expected.push_back(IntArgs({0,0, 0,1, 0,0}));
expected.push_back(IntArgs({0,0, 0,1, 0,1}));
expected.push_back(IntArgs({0,0, 0,1, 1,0}));
expected.push_back(IntArgs({0,0, 0,1, 1,1}));
expected.push_back(IntArgs({0,0, 1,1, 1,1}));
expected.push_back(IntArgs({0,1, 0,0, 0,0}));
expected.push_back(IntArgs({0,1, 0,0, 0,1}));
expected.push_back(IntArgs({0,1, 0,0, 1,0}));
expected.push_back(IntArgs({0,1, 0,0, 1,1}));
expected.push_back(IntArgs({0,1, 0,1, 0,0}));
expected.push_back(IntArgs({0,1, 0,1, 0,1}));
expected.push_back(IntArgs({0,1, 0,1, 1,0}));
expected.push_back(IntArgs({0,1, 0,1, 1,1}));
expected.push_back(IntArgs({0,1, 1,0, 1,0}));
expected.push_back(IntArgs({0,1, 1,0, 1,1}));
expected.push_back(IntArgs({0,1, 1,1, 1,1}));
expected.push_back(IntArgs({1,1, 1,1, 1,1}));
return expected;
}
};
class MatSym4 {
public:
static const int n = 4;
static const int l = 0;
static const int u = 1;
static void setup(Home home, IntVarArray& xs) {
Matrix<IntVarArray> m(xs, 1, 4);
Symmetries s;
s << rows_reflect(m);
branch(home, xs, INT_VAR_NONE(), INT_VAL_MIN(), s);
}
static std::vector<IntArgs> expectedSolutions(void) {
static std::vector<IntArgs> expected;
expected.clear();
expected.push_back(IntArgs({0, 0, 0, 0}));
expected.push_back(IntArgs({0, 0, 0, 1}));
expected.push_back(IntArgs({0, 0, 1, 0}));
expected.push_back(IntArgs({0, 0, 1, 1}));
expected.push_back(IntArgs({0, 1, 0, 0}));
expected.push_back(IntArgs({0, 1, 0, 1}));
expected.push_back(IntArgs({0, 1, 1, 0}));
expected.push_back(IntArgs({0, 1, 1, 1}));
expected.push_back(IntArgs({1, 0, 0, 1}));
expected.push_back(IntArgs({1, 0, 1, 1}));
expected.push_back(IntArgs({1, 1, 1, 1}));
return expected;
}
};
class SimIntVarSym1 {
public:
static const int n = 12;
static const int l = 0;
static const int u = 3;
static void setup(Home home, IntVarArray& xs) {
Matrix<IntVarArray> m(xs, 3, 4);
// The values in the first column are distinct.
distinct(home, m.col(0));
// Each row sums to 3.
for (int i = 0 ; i < 4 ; ++i)
linear(home, m.row(i), IRT_EQ, 3);
// Rows are interchangeable.
Symmetries s;
s << VariableSequenceSymmetry(xs, 3);
branch(home, xs, INT_VAR_NONE(), INT_VAL_MIN(), s);
}
static std::vector<IntArgs> expectedSolutions(void) {
static std::vector<IntArgs> expected;
expected.clear();
expected.push_back(IntArgs({0,0,3, 1,0,2, 2,0,1, 3,0,0}));
expected.push_back(IntArgs({0,0,3, 1,0,2, 2,1,0, 3,0,0}));
expected.push_back(IntArgs({0,0,3, 1,1,1, 2,0,1, 3,0,0}));
expected.push_back(IntArgs({0,0,3, 1,1,1, 2,1,0, 3,0,0}));
expected.push_back(IntArgs({0,0,3, 1,2,0, 2,0,1, 3,0,0}));
expected.push_back(IntArgs({0,0,3, 1,2,0, 2,1,0, 3,0,0}));
expected.push_back(IntArgs({0,1,2, 1,0,2, 2,0,1, 3,0,0}));
expected.push_back(IntArgs({0,1,2, 1,0,2, 2,1,0, 3,0,0}));
expected.push_back(IntArgs({0,1,2, 1,1,1, 2,0,1, 3,0,0}));
expected.push_back(IntArgs({0,1,2, 1,1,1, 2,1,0, 3,0,0}));
expected.push_back(IntArgs({0,1,2, 1,2,0, 2,0,1, 3,0,0}));
expected.push_back(IntArgs({0,1,2, 1,2,0, 2,1,0, 3,0,0}));
expected.push_back(IntArgs({0,2,1, 1,0,2, 2,0,1, 3,0,0}));
expected.push_back(IntArgs({0,2,1, 1,0,2, 2,1,0, 3,0,0}));
expected.push_back(IntArgs({0,2,1, 1,1,1, 2,0,1, 3,0,0}));
expected.push_back(IntArgs({0,2,1, 1,1,1, 2,1,0, 3,0,0}));
expected.push_back(IntArgs({0,2,1, 1,2,0, 2,0,1, 3,0,0}));
expected.push_back(IntArgs({0,2,1, 1,2,0, 2,1,0, 3,0,0}));
expected.push_back(IntArgs({0,3,0, 1,0,2, 2,0,1, 3,0,0}));
expected.push_back(IntArgs({0,3,0, 1,0,2, 2,1,0, 3,0,0}));
expected.push_back(IntArgs({0,3,0, 1,1,1, 2,0,1, 3,0,0}));
expected.push_back(IntArgs({0,3,0, 1,1,1, 2,1,0, 3,0,0}));
expected.push_back(IntArgs({0,3,0, 1,2,0, 2,0,1, 3,0,0}));
expected.push_back(IntArgs({0,3,0, 1,2,0, 2,1,0, 3,0,0}));
return expected;
}
};
class SimIntVarSym2 {
static const int nrows = 4;
static const int ncols = 3;
public:
static const int n = nrows*ncols;
static const int l = 0;
static const int u = 3;
static void setup(Home home, IntVarArray& xs) {
Matrix<IntVarArray> m(xs, 3, 4);
// The values in the first column are distinct.
distinct(home, m.col(0));
// Each row sums to 3.
for (int i = 0 ; i < nrows ; ++i)
linear(home, m.row(i), IRT_EQ, 3);
Symmetries s;
IntArgs a = IntArgs::create(n, 0);
// Rows are interchangeable.
s << VariableSequenceSymmetry(xs, 3);
// Elements (i,1) and (i,2) in row i are interchangeable,
// separately for each row.
for (int i = 0 ; i < nrows ; i++) {
IntVarArgs symvars;
symvars << m(1,i) << m(2,i);
s << VariableSymmetry(symvars);
}
branch(home, xs, INT_VAR_NONE(), INT_VAL_MIN(), s);
}
static std::vector<IntArgs> expectedSolutions(void) {
static std::vector<IntArgs> expected;
expected.clear();
expected.push_back(IntArgs({0,0,3, 1,0,2, 2,0,1, 3,0,0}));
expected.push_back(IntArgs({0,0,3, 1,1,1, 2,0,1, 3,0,0}));
expected.push_back(IntArgs({0,1,2, 1,0,2, 2,0,1, 3,0,0}));
expected.push_back(IntArgs({0,1,2, 1,1,1, 2,0,1, 3,0,0}));
return expected;
}
};
class SimIntValSym1 {
public:
static const int n = 2;
static const int l = 0;
static const int u = 6;
static void setup(Home home, IntVarArray& xs) {
rel(home, xs[0] + xs[1] == 6);
// Values 0,1,2 are symmetric with 6,5,4.
IntArgs values({0,1,2, 6,5,4});
Symmetries s;
s << ValueSequenceSymmetry(values, 3);
branch(home, xs, INT_VAR_NONE(), INT_VAL_MIN(), s);
}
static std::vector<IntArgs> expectedSolutions(void) {
static std::vector<IntArgs> expected;
expected.clear();
expected.push_back(IntArgs({0,6}));
expected.push_back(IntArgs({1,5}));
expected.push_back(IntArgs({2,4}));
expected.push_back(IntArgs({3,3}));
return expected;
}
};
class SimIntValSym2 {
public:
static const int n = 3;
static const int l = 0;
static const int u = 8;
static void setup(Home home, IntVarArray& xs) {
TupleSet tuples(3);
tuples.add({1,1,1}).add({4,4,4}).add({7,7,7})
.add({0,1,5}).add({0,1,8}).add({3,4,2})
.add({3,4,8}).add({6,7,2}).add({6,7,5})
.finalize();
extensional(home, xs, tuples);
// Values 0,1,2 are symmetric with 3,4,5, and with 6,7,8.
IntArgs values({0,1,2, 3,4,5, 6,7,8});
Symmetries s;
s << ValueSequenceSymmetry(values, 3);
branch(home, xs, INT_VAR_NONE(), INT_VAL_MIN(), s);
}
static std::vector<IntArgs> expectedSolutions(void) {
static std::vector<IntArgs> expected;
expected.clear();
expected.push_back(IntArgs({0,1,5}));
expected.push_back(IntArgs({1,1,1}));
return expected;
}
};
class SimIntValSym3 {
public:
static const int n = 2;
static const int l = 0;
static const int u = 6;
static void setup(Home home, IntVarArray& xs) {
rel(home, xs[0] + xs[1] == 6);
Symmetries s;
// Values 0,1,2 are symmetric with 6,5,4.
s << values_reflect(0,6);
branch(home, xs, INT_VAR_NONE(), INT_VAL_MED(), s);
}
static std::vector<IntArgs> expectedSolutions(void) {
static std::vector<IntArgs> expected;
expected.clear();
expected.push_back(IntArgs({3,3}));
expected.push_back(IntArgs({2,4}));
expected.push_back(IntArgs({1,5}));
expected.push_back(IntArgs({0,6}));
return expected;
}
};
class ValSym1 {
public:
static const int n = 4;
static const int l = 0;
static const int u = 3;
static void setup(Home home, IntVarArray& xs) {
distinct(home, xs);
Symmetries s;
IntArgs indices({0,1,2,3});
s << ValueSymmetry(indices);
branch(home, xs, INT_VAR_NONE(), INT_VAL_MIN(), s);
}
static std::vector<IntArgs> expectedSolutions(void) {
static std::vector<IntArgs> expected;
expected.clear();
expected.push_back(IntArgs({0,1,2,3}));
return expected;
}
};
class ValSym1b {
public:
static const int n = 4;
static const int l = 0;
static const int u = 3;
static void setup(Home home, IntVarArray& xs) {
distinct(home, xs);
Symmetries s;
s << ValueSymmetry(xs[0]);
branch(home, xs, INT_VAR_NONE(), INT_VAL_MIN(), s);
}
static std::vector<IntArgs> expectedSolutions(void) {
static std::vector<IntArgs> expected;
expected.clear();
expected.push_back(IntArgs({0,1,2,3}));
return expected;
}
};
class ValSym1c {
public:
static const int n = 4;
static const int l = 0;
static const int u = 3;
static void setup(Home home, IntVarArray& xs) {
distinct(home, xs);
Symmetries s;
s << ValueSymmetry(xs[0]);
branch(home, xs, INT_VAR_NONE(), INT_VAL_MAX(), s);
}
static std::vector<IntArgs> expectedSolutions(void) {
static std::vector<IntArgs> expected;
expected.clear();
expected.push_back(IntArgs({3,2,1,0}));
return expected;
}
};
class ValSym2 {
public:
static const int n = 4;
static const int l = 0;
static const int u = 3;
static void setup(Home home, IntVarArray& xs) {
Symmetries s;
IntArgs indices({0,1,2,3});
s << ValueSymmetry(indices);
branch(home, xs, INT_VAR_NONE(), INT_VAL_MIN(), s);
}
static std::vector<IntArgs> expectedSolutions(void) {
static std::vector<IntArgs> expected;
expected.clear();
expected.push_back(IntArgs({0,0,0,0}));
expected.push_back(IntArgs({0,0,0,1}));
expected.push_back(IntArgs({0,0,1,0}));
expected.push_back(IntArgs({0,0,1,1}));
expected.push_back(IntArgs({0,0,1,2}));
expected.push_back(IntArgs({0,1,0,0}));
expected.push_back(IntArgs({0,1,0,1}));
expected.push_back(IntArgs({0,1,0,2}));
expected.push_back(IntArgs({0,1,1,0}));
expected.push_back(IntArgs({0,1,1,1}));
expected.push_back(IntArgs({0,1,1,2}));
expected.push_back(IntArgs({0,1,2,0}));
expected.push_back(IntArgs({0,1,2,1}));
expected.push_back(IntArgs({0,1,2,2}));
expected.push_back(IntArgs({0,1,2,3}));
return expected;
}
};
class ValSym2b {
public:
static const int n = 4;
static const int l = 0;
static const int u = 3;
static void setup(Home home, IntVarArray& xs) {
Symmetries s;
s << ValueSymmetry(xs[0]);
branch(home, xs, INT_VAR_NONE(), INT_VAL_MIN(), s);
}
static std::vector<IntArgs> expectedSolutions(void) {
static std::vector<IntArgs> expected;
expected.clear();
expected.push_back(IntArgs({0,0,0,0}));
expected.push_back(IntArgs({0,0,0,1}));
expected.push_back(IntArgs({0,0,1,0}));
expected.push_back(IntArgs({0,0,1,1}));
expected.push_back(IntArgs({0,0,1,2}));
expected.push_back(IntArgs({0,1,0,0}));
expected.push_back(IntArgs({0,1,0,1}));
expected.push_back(IntArgs({0,1,0,2}));
expected.push_back(IntArgs({0,1,1,0}));
expected.push_back(IntArgs({0,1,1,1}));
expected.push_back(IntArgs({0,1,1,2}));
expected.push_back(IntArgs({0,1,2,0}));
expected.push_back(IntArgs({0,1,2,1}));
expected.push_back(IntArgs({0,1,2,2}));
expected.push_back(IntArgs({0,1,2,3}));
return expected;
}
};
class ValSym3 {
public:
static const int n = 4;
static const int l = 0;
static const int u = 3;
static void setup(Home home, IntVarArray& xs) {
distinct(home, xs);
Symmetries s;
IntArgs indices({0,1});
s << ValueSymmetry(indices);
branch(home, xs, INT_VAR_NONE(), INT_VAL_MIN(), s);
}
static std::vector<IntArgs> expectedSolutions(void) {
static std::vector<IntArgs> expected;
expected.clear();
expected.push_back(IntArgs({0,1,2,3}));
expected.push_back(IntArgs({0,1,3,2}));
expected.push_back(IntArgs({0,2,1,3}));
expected.push_back(IntArgs({0,2,3,1}));
expected.push_back(IntArgs({0,3,1,2}));
expected.push_back(IntArgs({0,3,2,1}));
expected.push_back(IntArgs({2,0,1,3}));
expected.push_back(IntArgs({2,0,3,1}));
expected.push_back(IntArgs({2,3,0,1}));
expected.push_back(IntArgs({3,0,1,2}));
expected.push_back(IntArgs({3,0,2,1}));
expected.push_back(IntArgs({3,2,0,1}));
return expected;
}
};
class ValSym4 {
public:
static const int n = 3;
static const int l = 0;
static const int u = 2;
static void setup(Home home, IntVarArray& xs) {
distinct(home, xs);
Symmetries s;
IntArgs indices({0});
s << ValueSymmetry(indices);
branch(home, xs, INT_VAR_NONE(), INT_VAL_MIN(), s);
}
static std::vector<IntArgs> expectedSolutions(void) {
static std::vector<IntArgs> expected;
expected.clear();
expected.push_back(IntArgs({0,1,2}));
expected.push_back(IntArgs({0,2,1}));
expected.push_back(IntArgs({1,0,2}));
expected.push_back(IntArgs({1,2,0}));
expected.push_back(IntArgs({2,0,1}));
expected.push_back(IntArgs({2,1,0}));
return expected;
}
};
class ValSym5 {
public:
static const int n = 4;
static const int l = 0;
static const int u = 3;
static void setup(Home home, IntVarArray& xs) {
distinct(home, xs);
Symmetries s;
IntArgs indices0({0,1});
IntArgs indices1({2,3});
s << ValueSymmetry(indices0);
s << ValueSymmetry(indices1);
branch(home, xs, INT_VAR_NONE(), INT_VAL_MIN(), s);
}
static std::vector<IntArgs> expectedSolutions(void) {
static std::vector<IntArgs> expected;
expected.clear();
expected.push_back(IntArgs({0,1,2,3}));
expected.push_back(IntArgs({0,2,1,3}));
expected.push_back(IntArgs({0,2,3,1}));
expected.push_back(IntArgs({2,0,1,3}));
expected.push_back(IntArgs({2,0,3,1}));
expected.push_back(IntArgs({2,3,0,1}));
return expected;
}
};
class VarValSym1 {
public:
static const int n = 4;
static const int l = 0;
static const int u = 3;
static void setup(Home home, IntVarArray& xs) {
Symmetries s;
s << VariableSymmetry(xs);
s << ValueSymmetry(IntArgs::create(4,0));
branch(home, xs, INT_VAR_NONE(), INT_VAL_MIN(), s);
}
static std::vector<IntArgs> expectedSolutions(void) {
static std::vector<IntArgs> expected;
expected.clear();
expected.push_back(IntArgs({0,0,0,0}));
expected.push_back(IntArgs({0,0,0,1}));
expected.push_back(IntArgs({0,0,1,1}));
expected.push_back(IntArgs({0,0,1,2}));
expected.push_back(IntArgs({0,1,1,1}));
expected.push_back(IntArgs({0,1,1,2}));
expected.push_back(IntArgs({0,1,2,2})); // This solution is symmetric to the previous one.
expected.push_back(IntArgs({0,1,2,3}));
return expected;
}
};
class LDSBLatin : public Base {
public:
class Latin : public Space {
public:
IntVarArray xs;
Latin(int n = 4) : xs(*this, n*n, 1, n)
{
Matrix<IntVarArray> m(xs, n, n);
for (int i = 0 ; i < n ; i++) {
distinct(*this, m.col(i));
distinct(*this, m.row(i));
}
Symmetries s;
s << rows_interchange(m);
s << columns_interchange(m);
s << ValueSymmetry(IntSet(1,n));
branch(*this, xs, INT_VAR_NONE(), INT_VAL_MIN(), s);
}
// Search support.
Latin(Latin& s) : Space(s)
{ xs.update(*this, s.xs); }
virtual Space* copy(void)
{ return new Latin(*this); }
IntArgs solution(void) {
IntArgs a(xs.size());
for (int i = 0 ; i < a.size() ; ++i)
a[i] = xs[i].val();
return a;
}
static std::vector<IntArgs> expectedSolutions(void) {
static std::vector<IntArgs> expected;
expected.clear();
expected.push_back(IntArgs({1,2,3,4, 2,1,4,3, 3,4,1,2, 4,3,2,1}));
expected.push_back(IntArgs({1,2,3,4, 2,1,4,3, 3,4,2,1, 4,3,1,2}));
expected.push_back(IntArgs({1,2,3,4, 2,3,4,1, 3,4,1,2, 4,1,2,3}));
expected.push_back(IntArgs({1,2,3,4, 2,4,1,3, 3,1,4,2, 4,3,2,1}));
return expected;
}
};
LDSBLatin(std::string label) : Test::Base("LDSB::" + label) {}
bool run(void) {
Latin *s = new Latin();
DFS<Latin> e(s);
bool r = check(e, Latin::expectedSolutions());
delete s;
return r;
}
};
/* This test should fail if the recomputation-handling does not work
* properly.
*
* Why recomputation can be a problem
* ==================================
*
* Every branch point in LDSB is binary, with a left and a right
* branch. Whenever backtracking happens -- when a right branch is
* explored -- LDSB computes a set of symmetric literals to
* exclude.
*
* !!! This calculation may depend on the current domains of the
* !!! variables.
*
* During recomputation, parts of the search tree are replayed. To
* be specific, the branching constraints are posted, but no
* propagation happens. This means that at a given branch point,
* the domains during recomputation may be different (weaker) than
* they were the first time during search.
*
* !!! This *cannot* cause solutions to be missed --- LDSB will not
* !!! be incorrect --- but it *does* change what will be pruned.
*
* If recomputation is not handled properly, the difference in
* domains will cause extra solutions to be found. This is a result
* of symmetries failing to be broken.
*
*/
class Recomputation {
public:
static const int n = 4;
static const int l = 0;
static const int u = 1;
static void setup(Home home, IntVarArray& xs) {
TupleSet t(2);
t.add({0,0}).add({1,1}).finalize();
IntVarArgs va;
va << xs[0] << xs[2];
extensional(home, va, t);
Symmetries syms;
syms << VariableSequenceSymmetry(xs, 2);
branch(home, xs, INT_VAR_NONE(), INT_VAL_MIN(), syms);
}
static std::vector<IntArgs> expectedSolutions(void) {
static std::vector<IntArgs> expected;
expected.clear();
expected.push_back(IntArgs({0,0,0,0}));
expected.push_back(IntArgs({0,0,0,1}));
// This is the solution that will be found if recomputation is
// not handled. After branching on x[0]=0, we try x[1]=0. When
// x[1]=0 backtracks, the symmetry [x[0],x[1]] <-> [x[2],x[3]]
// is active --- but only after propagation! (Without
// propagation, we do not have x[2]=0.) If propagation happens,
// we know that symmetry is active and we can post x[3]!=0. If
// it doesn't, we don't use the symmetry and we find a solution
// where x[3]=0.
// expected.push_back(IntArgs({0,1,0,0}));
expected.push_back(IntArgs({0,1,0,1}));
expected.push_back(IntArgs({1,0,1,0}));
expected.push_back(IntArgs({1,0,1,1}));
expected.push_back(IntArgs({1,1,1,1}));
return expected;
}
};
double position(const Space& home, IntVar x, int i) {
(void) home;
(void) x;
return i;
}
class TieBreak {
public:
static const int n = 4;
static const int l = 0;
static const int u = 3;
static void setup(Home home, IntVarArray& xs) {
Symmetries syms;
IntArgs indices({0,1,2,3});
syms << VariableSymmetry(xs, indices);
distinct(home, xs);
// This redundant constraint is to trick the variable
// heuristic.
rel(home, xs[1] != xs[2]);
// xs[1] and xs[2] have higher degree than the others, so they
// are considered first. xs[2] is higher than x[1] by the merit
// function, so it is assigned first. Now all remaining
// variables have the same degree, so they are searched in
// reverse order (according to the merit function). So, the
// solution found is {3, 2, 0, 1}.
branch(home, xs, tiebreak(INT_VAR_DEGREE_MAX(), INT_VAR_MERIT_MAX(position)), INT_VAL_MIN(), syms);
}
static std::vector<IntArgs> expectedSolutions(void) {
static std::vector<IntArgs> expected;
expected.clear();
expected.push_back(IntArgs({3,2,0,1}));
return expected;
}
};
#ifdef GECODE_HAS_SET_VARS
IntSetArgs ISA(int n, ...) {
IntSetArgs sets;
va_list args;
va_start(args, n);
int i = 0;
IntArgs a;
while (i < n) {
int x = va_arg(args,int);
if (x == -1) {
i++;
sets << IntSet(a);
a = IntArgs();
} else {
a << x;
}
}
va_end(args);
return sets;
}
class SetVarSym1 {
public:
static const int n = 2;
static const int l = 0;
static const int u = 1;
static void setup(Home home, SetVarArray& xs) {
Symmetries syms;
syms << VariableSymmetry(xs);
branch(home, xs, SET_VAR_NONE(), SET_VAL_MIN_INC(), syms);
}
static std::vector<IntSetArgs> expectedSolutions(void) {
static std::vector<IntSetArgs> expected;
expected.clear();
expected.push_back(ISA(2, 0,1,-1, 0,1,-1));
expected.push_back(ISA(2, 0,1,-1, 0, -1));
expected.push_back(ISA(2, 0,1,-1, 1,-1));
expected.push_back(ISA(2, 0,1,-1, -1));
expected.push_back(ISA(2, 0, -1, 0,1,-1));
expected.push_back(ISA(2, 0, -1, 0, -1));
expected.push_back(ISA(2, 0, -1, 1,-1));
expected.push_back(ISA(2, 0, -1, -1));
// expected.push_back(ISA(2, 1,-1, 0,1,-1));
// expected.push_back(ISA(2, 1,-1, 0, -1));
expected.push_back(ISA(2, 1,-1, 1,-1));
expected.push_back(ISA(2, 1,-1, -1));
// expected.push_back(ISA(2, -1, 0,1,-1));
// expected.push_back(ISA(2, -1, 0, -1));
// expected.push_back(ISA(2, -1, 1,-1));
expected.push_back(ISA(2, -1, -1));
return expected;
}
};
/*
* This tests the special handling of value symmetries on set
* values. Look at the third solution (commented out) below. The
* first variable has been assigned to {0,1}. If the value symmetry
* is not handled specially, then we will consider the value
* symmetry broken because the search has touched each value.
* However, because both values have been assigned to the same
* variable, 0 and 1 are still symmetric. Therefore, the third
* solution is symmetric to the second one and should be excluded.
*/
class SetValSym1 {
public:
static const int n = 2;
static const int l = 0;
static const int u = 1;
static void setup(Home home, SetVarArray& xs) {
Symmetries syms;
syms << ValueSymmetry(IntArgs({0,1}));
branch(home, xs, SET_VAR_NONE(), SET_VAL_MIN_INC(), syms);
}
static std::vector<IntSetArgs> expectedSolutions(void) {
static std::vector<IntSetArgs> expected;
expected.clear();
expected.push_back(ISA(2, 0,1,-1, 0,1,-1));
expected.push_back(ISA(2, 0,1,-1, 0, -1));
// expected.push_back(ISA(2, 0,1,-1, 1,-1)); // XXXXX bad solution
expected.push_back(ISA(2, 0,1,-1, -1));
expected.push_back(ISA(2, 0, -1, 0,1,-1));
expected.push_back(ISA(2, 0, -1, 0, -1));
expected.push_back(ISA(2, 0, -1, 1,-1));
expected.push_back(ISA(2, 0, -1, -1));
// expected.push_back(ISA(2, 1,-1, 0,1,-1));
// expected.push_back(ISA(2, 1,-1, 0, -1));
// expected.push_back(ISA(2, 1,-1, 1,-1));
// expected.push_back(ISA(2, 1,-1, -1));
expected.push_back(ISA(2, -1, 0,1,-1));
expected.push_back(ISA(2, -1, 0, -1));
// expected.push_back(ISA(2, -1, 1,-1));
expected.push_back(ISA(2, -1, -1));
return expected;
}
};
class SetValSym2 {
public:
static const int n = 3;
static const int l = 1;
static const int u = 4;
static void setup(Home home, SetVarArray& xs) {
Symmetries syms;
syms << ValueSymmetry(IntArgs({1,2,3,4}));
for (int i = 0 ; i < 3 ; i++)
cardinality(home, xs[i], 1, 1);
branch(home, xs, SET_VAR_NONE(), SET_VAL_MIN_INC(), syms);
}
static std::vector<IntSetArgs> expectedSolutions(void) {
static std::vector<IntSetArgs> expected;
expected.clear();
expected.push_back(ISA(3, 1,-1, 1,-1, 1,-1));
expected.push_back(ISA(3, 1,-1, 1,-1, 2,-1));
expected.push_back(ISA(3, 1,-1, 2,-1, 1,-1));
expected.push_back(ISA(3, 1,-1, 2,-1, 2,-1));
expected.push_back(ISA(3, 1,-1, 2,-1, 3,-1));
return expected;
}
};
class SetVarSeqSym1 {
public:
static const int n = 4;
static const int l = 0;
static const int u = 1;
static void setup(Home home, SetVarArray& xs) {
Symmetries syms;
syms << VariableSequenceSymmetry(xs,2);
rel(home, xs[0], SOT_INTER, xs[1], SRT_EQ, IntSet::empty);
rel(home, xs[2], SOT_INTER, xs[3], SRT_EQ, IntSet::empty);
for (int i = 0 ; i < 4 ; i++)
cardinality(home, xs[i], 1, 1);
branch(home, xs, SET_VAR_NONE(), SET_VAL_MIN_INC(), syms);
}
static std::vector<IntSetArgs> expectedSolutions(void) {
static std::vector<IntSetArgs> expected;
expected.clear();
expected.push_back(ISA(4, 0,-1, 1,-1, 0,-1, 1,-1));
expected.push_back(ISA(4, 0,-1, 1,-1, 1,-1, 0,-1));
// expected.push_back(ISA(4, 1,-1, 0,-1, 0,-1, 1,-1));
expected.push_back(ISA(4, 1,-1, 0,-1, 1,-1, 0,-1));
return expected;
}
};
class SetVarSeqSym2 {
public:
static const int n = 4;
static const int l = 0;
static const int u = 0;
static void setup(Home home, SetVarArray& xs) {
Symmetries syms;
syms << VariableSequenceSymmetry(xs,2);
rel(home, xs[0], SRT_EQ, xs[2]);
branch(home, xs, SET_VAR_NONE(), SET_VAL_MIN_INC(), syms);
}
static std::vector<IntSetArgs> expectedSolutions(void) {
static std::vector<IntSetArgs> expected;
expected.clear();
// Symmetric solutions are commented out.
expected.push_back(ISA(4, 0, -1,0,-1,0,-1,0,-1));
expected.push_back(ISA(4, 0, -1,0,-1,0,-1, -1));
// expected.push_back(ISA(4, 0, -1,0,-1, -1,0,-1));
// expected.push_back(ISA(4, 0, -1,0,-1, -1, -1));
// expected.push_back(ISA(4, 0, -1, -1,0,-1,0,-1));
expected.push_back(ISA(4, 0, -1, -1,0,-1, -1));
// expected.push_back(ISA(4, 0, -1, -1, -1,0,-1));
// expected.push_back(ISA(4, 0, -1, -1, -1, -1));
// expected.push_back(ISA(4, -1,0,-1,0,-1,0,-1));
// expected.push_back(ISA(4, -1,0,-1,0,-1, -1));
expected.push_back(ISA(4, -1,0,-1, -1,0,-1));
expected.push_back(ISA(4, -1,0,-1, -1, -1));
// expected.push_back(ISA(4, -1, -1,0,-1,0,-1));
// expected.push_back(ISA(4, -1, -1,0,-1, -1));
// expected.push_back(ISA(4, -1, -1, -1,0,-1));
expected.push_back(ISA(4, -1, -1, -1, -1));
return expected;
}
};
class ReflectSym1 {
public:
static const int n = 6;
static const int l = 0;
static const int u = 6;
static void setup(Home home, IntVarArray& xs) {
Matrix<IntVarArray> m(xs, 3, 2);
distinct(home, xs);
rel(home, abs(m(0,0)-m(1,0))==1);
rel(home, abs(m(0,1)-m(1,1))==1);
rel(home, abs(m(1,0)-m(2,0))==1);
rel(home, abs(m(1,1)-m(2,1))==1);
Symmetries s;
s << values_reflect(l, u);
s << rows_interchange(m);
s << columns_reflect(m);
branch(home, xs, INT_VAR_NONE(), INT_VAL_MIN(), s);
}
static std::vector<IntArgs> expectedSolutions(void) {
static std::vector<IntArgs> expected;
expected.clear();
expected.push_back(IntArgs({0,1,2,3,4,5}));
expected.push_back(IntArgs({0,1,2,4,5,6}));
expected.push_back(IntArgs({0,1,2,5,4,3}));
expected.push_back(IntArgs({0,1,2,6,5,4}));
return expected;
}
};
class ReflectSym2 {
public:
static const int n = 2;
static const int l = 0;
static const int u = 3;
static void setup(Home home, IntVarArray& xs) {
Symmetries s;
s << values_reflect(l, u);
branch(home, xs, INT_VAR_NONE(), INT_VAL_MIN(), s);
}
static std::vector<IntArgs> expectedSolutions(void) {
static std::vector<IntArgs> expected;
expected.clear();
expected.push_back(IntArgs({0,0}));
expected.push_back(IntArgs({0,1}));
expected.push_back(IntArgs({0,2}));
expected.push_back(IntArgs({0,3}));
expected.push_back(IntArgs({1,0}));
expected.push_back(IntArgs({1,1}));
expected.push_back(IntArgs({1,2}));
expected.push_back(IntArgs({1,3}));
return expected;
}
};
class Action1 {
public:
static const int n = 4;
static const int l = 0;
static const int u = 3;
static void setup(Home home, IntVarArray& xs) {
distinct(home, xs);
Symmetries s;
s << VariableSymmetry(xs);
s << ValueSymmetry(IntArgs::create(4,0));
branch(home, xs, INT_VAR_ACTION_MIN(0.8), INT_VAL_MIN(), s);
}
static std::vector<IntArgs> expectedSolutions(void) {
static std::vector<IntArgs> expected;
expected.clear();
expected.push_back(IntArgs({0,1,2,3}));
return expected;
}
};
#endif
LDSB<VarSym1> varsym1("VarSym1");
LDSB<VarSym1b> varsym1b("VarSym1b");
LDSB<VarSym2> varsym2("VarSym2");
LDSB<VarSym3> varsym3("VarSym3");
LDSB<VarSym4> varsym4("VarSym4");
LDSB<VarSym5> varsym5("VarSym5");
LDSB<MatSym1> matsym1("MatSym1");
LDSB<MatSym2> matsym2("MatSym2");
LDSB<MatSym3> matsym3("MatSym3");
LDSB<MatSym4> matsym4("MatSym4");
LDSB<SimIntVarSym1> simintvarsym1("SimIntVarSym1");
LDSB<SimIntVarSym2> simintvarsym2("SimIntVarSym2");
LDSB<SimIntValSym1> simintvalsym1("SimIntValSym1");
LDSB<SimIntValSym2> simintvalsym2("SimIntValSym2");
LDSB<SimIntValSym3> simintvalsym3("SimIntValSym3");
LDSB<ValSym1> valsym1("ValSym1");
LDSB<ValSym1b> valsym1b("ValSym1b");
LDSB<ValSym1c> valsym1c("ValSym1c");
LDSB<ValSym2> valsym2("ValSym2");
LDSB<ValSym2b> valsym2b("ValSym2b");
LDSB<ValSym3> valsym3("ValSym3");
LDSB<ValSym4> valsym4("ValSym4");
LDSB<ValSym5> valsym5("ValSym5");
LDSB<VarValSym1> varvalsym1("VarValSym1");
LDSBLatin latin("Latin");
LDSB<Recomputation> recomp("Recomputation", 999,999);
LDSB<TieBreak> tiebreak("TieBreak");
#ifdef GECODE_HAS_SET_VARS
LDSB<ReflectSym1> reflectsym1("ReflectSym1");
LDSB<ReflectSym2> reflectsym2("ReflectSym2");
LDSB<Action1> action1("Action1");
LDSBSet<SetVarSym1> setvarsym1("SetVarSym1");
LDSBSet<SetValSym1> setvalsym1("SetValSym1");
LDSBSet<SetValSym2> setvalsym2("SetValSym2", 0, 1);
LDSBSet<SetVarSeqSym1> setvarseqsym1("SetVarSeqSym1");
LDSBSet<SetVarSeqSym2> setvarseqsym2("SetVarSeqSym2");
#endif
}}
// STATISTICS: test-core
Gecode::DFS
Depth-first search engine.
Definition search.hh:1036
Gecode::FloatVal::size
FloatNum size(void) const
Return size of float value (distance between maximum and minimum).
Definition val.hpp:78
Gecode::Home
Home class for posting propagators
Definition core.hpp:856
Gecode::IntArgs
Passing integer arguments.
Definition int.hh:628
Gecode::IntArgs::create
static IntArgs create(int n, int start, int inc=1)
Allocate array with n elements such that for all .
Definition array.hpp:76
Gecode::IntSetValues
Value iterator for integer sets.
Definition int.hh:333
Gecode::IntSet
Integer sets.
Definition int.hh:174
Gecode::IntSet::empty
static const IntSet empty
Empty set.
Definition int.hh:283
Gecode::IntVarArgs
Passing integer variables.
Definition int.hh:656
Gecode::IntVarArray
Integer variable array.
Definition int.hh:763
Gecode::IntVar
Integer variables.
Definition int.hh:371
Gecode::Iter::Ranges::ToValues::val
int val(void) const
Return current value.
Definition ranges-values.hpp:129
Gecode::Matrix
Matrix-interface for arrays.
Definition minimodel.hh:2161
Gecode::Matrix::slice
Slice< A > slice(int fc, int tc, int fr, int tr) const
Access slice of the matrix.
Definition matrix.hpp:171
Gecode::Matrix::col
Slice< A > col(int c) const
Access column c.
Definition matrix.hpp:183
Gecode::Matrix::row
Slice< A > row(int r) const
Access row r.
Definition matrix.hpp:177
Gecode::Search::Base::next
virtual T * next(void)
Return next solution (NULL, if none exists or search has been stopped).
Definition base.hpp:46
Gecode::Search::Options
Search engine options
Definition search.hh:746
Gecode::Search::Options::def
static const Options def
Default options.
Definition search.hh:771
Gecode::Search::Options::c_d
unsigned int c_d
Create a clone after every c_d commits (commit distance).
Definition search.hh:753
Gecode::Search::Options::a_d
unsigned int a_d
Create a clone during recomputation if distance is greater than a_d (adaptive distance).
Definition search.hh:755
Gecode::SetVarArray
Set variable array
Definition set.hh:570
Gecode::SetVarGlbRanges
Iterator for the greatest lower bound ranges of a set variable.
Definition set.hh:270
Gecode::Space
Computation spaces.
Definition core.hpp:1742
Gecode::Symmetries
Collection of symmetries.
Definition int.hh:5292
Gecode::TieBreak
Combine variable selection criteria for tie-breaking.
Definition tiebreak.hpp:38
Gecode::TupleSet
Class represeting a set of tuples.
Definition int.hh:2191
Gecode::TupleSet::add
TupleSet & add(const IntArgs &t)
Add tuple t to tuple set.
Definition tuple-set.hpp:142
Test::Base::Base
Base(const std::string &s)
Create and register test with name s.
Definition test.cpp:59
Test::LDSB::Action1
Test with action
Definition ldsb.cpp:1591
Test::LDSB::Action1::u
static const int u
Upper bound of values.
Definition ldsb.cpp:1598
Test::LDSB::Action1::expectedSolutions
static std::vector< IntArgs > expectedSolutions(void)
Compute list of expected solutions.
Definition ldsb.cpp:1608
Test::LDSB::Action1::setup
static void setup(Home home, IntVarArray &xs)
Setup problem constraints and symmetries.
Definition ldsb.cpp:1600
Test::LDSB::Action1::l
static const int l
Lower bound of values.
Definition ldsb.cpp:1596
Test::LDSB::Action1::n
static const int n
Number of variables.
Definition ldsb.cpp:1594
Test::LDSB::LDSBLatin::Latin
Latin square space
Definition ldsb.cpp:1139
Test::LDSB::LDSBLatin::Latin::xs
IntVarArray xs
Definition ldsb.cpp:1141
Test::LDSB::LDSBLatin::Latin::expectedSolutions
static std::vector< IntArgs > expectedSolutions(void)
Compute list of expected solutions.
Definition ldsb.cpp:1168
Test::LDSB::LDSBLatin::Latin::Latin
Latin(int n=4)
Definition ldsb.cpp:1142
Test::LDSB::LDSBLatin::Latin::Latin
Latin(Latin &s)
Definition ldsb.cpp:1156
Test::LDSB::LDSBLatin::Latin::solution
IntArgs solution(void)
Definition ldsb.cpp:1160
Test::LDSB::LDSBLatin::Latin::copy
virtual Space * copy(void)
Copying member function.
Definition ldsb.cpp:1158
Test::LDSB::LDSBLatin
Test for LDSB infrastructure with Latin square problem
Definition ldsb.cpp:1136
Test::LDSB::LDSBLatin::run
bool run(void)
Perform actual tests.
Definition ldsb.cpp:1181
Test::LDSB::LDSBLatin::LDSBLatin
LDSBLatin(std::string label)
Initialize test.
Definition ldsb.cpp:1179
Test::LDSB::LDSBSet
Test for LDSB infrastructure
Definition ldsb.cpp:226
Test::LDSB::LDSBSet::LDSBSet
LDSBSet(std::string label, unsigned int c=0, unsigned int a=0)
Initialize test.
Definition ldsb.cpp:233
Test::LDSB::LDSBSet::run
bool run(void)
Perform actual tests.
Definition ldsb.cpp:237
Test::LDSB::LDSBSet::a_d
unsigned int a_d
Adaptation distance.
Definition ldsb.cpp:231
Test::LDSB::LDSBSet::c_d
unsigned int c_d
Recomputation distance.
Definition ldsb.cpp:229
Test::LDSB::LDSB::run
bool run(void)
Perform actual tests.
Definition ldsb.cpp:210
Test::LDSB::LDSB::LDSB
LDSB(std::string label, unsigned int c=0, unsigned int a=0)
Initialize test.
Definition ldsb.cpp:206
Test::LDSB::LDSB::c_d
unsigned int c_d
Recomputation distance.
Definition ldsb.cpp:202
Test::LDSB::LDSB::a_d
unsigned int a_d
Adaptation distance.
Definition ldsb.cpp:204
Test::LDSB::MatSym1
Test for matrix symmetry
Definition ldsb.cpp:464
Test::LDSB::MatSym1::n
static const int n
Number of variables.
Definition ldsb.cpp:467
Test::LDSB::MatSym1::expectedSolutions
static std::vector< IntArgs > expectedSolutions(void)
Compute list of expected solutions.
Definition ldsb.cpp:480
Test::LDSB::MatSym1::l
static const int l
Lower bound of values.
Definition ldsb.cpp:469
Test::LDSB::MatSym1::u
static const int u
Upper bound of values.
Definition ldsb.cpp:471
Test::LDSB::MatSym1::setup
static void setup(Home home, IntVarArray &xs)
Setup problem constraints and symmetries.
Definition ldsb.cpp:473
Test::LDSB::MatSym2
Test for matrix symmetry
Definition ldsb.cpp:514
Test::LDSB::MatSym2::n
static const int n
Number of variables.
Definition ldsb.cpp:517
Test::LDSB::MatSym2::l
static const int l
Lower bound of values.
Definition ldsb.cpp:519
Test::LDSB::MatSym2::u
static const int u
Upper bound of values.
Definition ldsb.cpp:521
Test::LDSB::MatSym2::setup
static void setup(Home home, IntVarArray &xs)
Setup problem constraints and symmetries.
Definition ldsb.cpp:523
Test::LDSB::MatSym2::expectedSolutions
static std::vector< IntArgs > expectedSolutions(void)
Compute list of expected solutions.
Definition ldsb.cpp:530
Test::LDSB::MatSym3
Test for matrix symmetry
Definition ldsb.cpp:574
Test::LDSB::MatSym3::u
static const int u
Upper bound of values.
Definition ldsb.cpp:581
Test::LDSB::MatSym3::n
static const int n
Number of variables.
Definition ldsb.cpp:577
Test::LDSB::MatSym3::l
static const int l
Lower bound of values.
Definition ldsb.cpp:579
Test::LDSB::MatSym3::expectedSolutions
static std::vector< IntArgs > expectedSolutions(void)
Compute list of expected solutions.
Definition ldsb.cpp:591
Test::LDSB::MatSym3::setup
static void setup(Home home, IntVarArray &xs)
Setup problem constraints and symmetries.
Definition ldsb.cpp:583
Test::LDSB::MatSym4
Test for matrix symmetry
Definition ldsb.cpp:619
Test::LDSB::MatSym4::n
static const int n
Number of variables.
Definition ldsb.cpp:622
Test::LDSB::MatSym4::setup
static void setup(Home home, IntVarArray &xs)
Setup problem constraints and symmetries.
Definition ldsb.cpp:628
Test::LDSB::MatSym4::expectedSolutions
static std::vector< IntArgs > expectedSolutions(void)
Compute list of expected solutions.
Definition ldsb.cpp:635
Test::LDSB::MatSym4::l
static const int l
Lower bound of values.
Definition ldsb.cpp:624
Test::LDSB::MatSym4::u
static const int u
Upper bound of values.
Definition ldsb.cpp:626
Test::LDSB::OneArraySet
Test space (set version)
Definition ldsb.cpp:168
Test::LDSB::OneArraySet::solution
IntSetArgs solution(void)
Return the solution as IntSetArgs.
Definition ldsb.cpp:184
Test::LDSB::OneArraySet::copy
virtual Space * copy(void)
Copy during cloning.
Definition ldsb.cpp:180
Test::LDSB::OneArraySet::xs
SetVarArray xs
Variables.
Definition ldsb.cpp:171
Test::LDSB::OneArraySet::OneArraySet
OneArraySet(int n, int l, int u)
Constructor for creation.
Definition ldsb.cpp:173
Test::LDSB::OneArraySet::OneArraySet
OneArraySet(OneArraySet &s)
Constructor for cloning s.
Definition ldsb.cpp:176
Test::LDSB::OneArraySet::expectedSolutions
virtual IntSetArgs * expectedSolutions(void)
Expected solutions.
Definition ldsb.cpp:193
Test::LDSB::OneArray
Test space
Definition ldsb.cpp:140
Test::LDSB::OneArray::copy
virtual Space * copy(void)
Copy during cloning.
Definition ldsb.cpp:152
Test::LDSB::OneArray::OneArray
OneArray(int n, int l, int u)
Constructor for creation.
Definition ldsb.cpp:145
Test::LDSB::OneArray::expectedSolutions
virtual IntArgs * expectedSolutions(void)
Expected solutions.
Definition ldsb.cpp:163
Test::LDSB::OneArray::OneArray
OneArray(OneArray &s)
Constructor for cloning s.
Definition ldsb.cpp:148
Test::LDSB::OneArray::xs
IntVarArray xs
Variables.
Definition ldsb.cpp:143
Test::LDSB::OneArray::solution
IntArgs solution(void)
Return the solution as IntArgs.
Definition ldsb.cpp:156
Test::LDSB::Recomputation
Test for handling of recomputation
Definition ldsb.cpp:1220
Test::LDSB::Recomputation::u
static const int u
Upper bound of values.
Definition ldsb.cpp:1227
Test::LDSB::Recomputation::setup
static void setup(Home home, IntVarArray &xs)
Setup problem constraints and symmetries.
Definition ldsb.cpp:1229
Test::LDSB::Recomputation::expectedSolutions
static std::vector< IntArgs > expectedSolutions(void)
Compute list of expected solutions.
Definition ldsb.cpp:1240
Test::LDSB::Recomputation::n
static const int n
Number of variables.
Definition ldsb.cpp:1223
Test::LDSB::Recomputation::l
static const int l
Lower bound of values.
Definition ldsb.cpp:1225
Test::LDSB::ReflectSym1
Test for reflection symmetry
Definition ldsb.cpp:1523
Test::LDSB::ReflectSym1::expectedSolutions
static std::vector< IntArgs > expectedSolutions(void)
Compute list of expected solutions.
Definition ldsb.cpp:1548
Test::LDSB::ReflectSym1::n
static const int n
Number of variables.
Definition ldsb.cpp:1526
Test::LDSB::ReflectSym1::l
static const int l
Lower bound of values.
Definition ldsb.cpp:1528
Test::LDSB::ReflectSym1::setup
static void setup(Home home, IntVarArray &xs)
Setup problem constraints and symmetries.
Definition ldsb.cpp:1532
Test::LDSB::ReflectSym1::u
static const int u
Upper bound of values.
Definition ldsb.cpp:1530
Test::LDSB::ReflectSym2
Test for reflection symmetry
Definition ldsb.cpp:1560
Test::LDSB::ReflectSym2::u
static const int u
Upper bound of values.
Definition ldsb.cpp:1567
Test::LDSB::ReflectSym2::n
static const int n
Number of variables.
Definition ldsb.cpp:1563
Test::LDSB::ReflectSym2::expectedSolutions
static std::vector< IntArgs > expectedSolutions(void)
Compute list of expected solutions.
Definition ldsb.cpp:1575
Test::LDSB::ReflectSym2::l
static const int l
Lower bound of values.
Definition ldsb.cpp:1565
Test::LDSB::ReflectSym2::setup
static void setup(Home home, IntVarArray &xs)
Setup problem constraints and symmetries.
Definition ldsb.cpp:1569
Test::LDSB::SetValSym1
Test for set value symmetry
Definition ldsb.cpp:1380
Test::LDSB::SetValSym1::setup
static void setup(Home home, SetVarArray &xs)
Setup problem constraints and symmetries.
Definition ldsb.cpp:1389
Test::LDSB::SetValSym1::l
static const int l
Lower bound of values.
Definition ldsb.cpp:1385
Test::LDSB::SetValSym1::n
static const int n
Number of variables.
Definition ldsb.cpp:1383
Test::LDSB::SetValSym1::expectedSolutions
static std::vector< IntSetArgs > expectedSolutions(void)
Compute list of expected solutions.
Definition ldsb.cpp:1395
Test::LDSB::SetValSym1::u
static const int u
Upper bound of values.
Definition ldsb.cpp:1387
Test::LDSB::SetValSym2
Test for set value symmetry
Definition ldsb.cpp:1419
Test::LDSB::SetValSym2::l
static const int l
Lower bound of values.
Definition ldsb.cpp:1424
Test::LDSB::SetValSym2::expectedSolutions
static std::vector< IntSetArgs > expectedSolutions(void)
Compute list of expected solutions.
Definition ldsb.cpp:1436
Test::LDSB::SetValSym2::setup
static void setup(Home home, SetVarArray &xs)
Setup problem constraints and symmetries.
Definition ldsb.cpp:1428
Test::LDSB::SetValSym2::u
static const int u
Upper bound of values.
Definition ldsb.cpp:1426
Test::LDSB::SetValSym2::n
static const int n
Number of variables.
Definition ldsb.cpp:1422
Test::LDSB::SetVarSeqSym1
Test for set variable sequence symmetry
Definition ldsb.cpp:1449
Test::LDSB::SetVarSeqSym1::n
static const int n
Number of variables.
Definition ldsb.cpp:1452
Test::LDSB::SetVarSeqSym1::l
static const int l
Lower bound of values.
Definition ldsb.cpp:1454
Test::LDSB::SetVarSeqSym1::u
static const int u
Upper bound of values.
Definition ldsb.cpp:1456
Test::LDSB::SetVarSeqSym1::setup
static void setup(Home home, SetVarArray &xs)
Setup problem constraints and symmetries.
Definition ldsb.cpp:1458
Test::LDSB::SetVarSeqSym1::expectedSolutions
static std::vector< IntSetArgs > expectedSolutions(void)
Compute list of expected solutions.
Definition ldsb.cpp:1468
Test::LDSB::SetVarSeqSym2
Test for set variable sequence symmetry
Definition ldsb.cpp:1480
Test::LDSB::SetVarSeqSym2::n
static const int n
Number of variables.
Definition ldsb.cpp:1483
Test::LDSB::SetVarSeqSym2::u
static const int u
Upper bound of values.
Definition ldsb.cpp:1487
Test::LDSB::SetVarSeqSym2::setup
static void setup(Home home, SetVarArray &xs)
Setup problem constraints and symmetries.
Definition ldsb.cpp:1489
Test::LDSB::SetVarSeqSym2::l
static const int l
Lower bound of values.
Definition ldsb.cpp:1485
Test::LDSB::SetVarSeqSym2::expectedSolutions
static std::vector< IntSetArgs > expectedSolutions(void)
Compute list of expected solutions.
Definition ldsb.cpp:1496
Test::LDSB::SetVarSym1
Test for set variable symmetry
Definition ldsb.cpp:1330
Test::LDSB::SetVarSym1::u
static const int u
Upper bound of values.
Definition ldsb.cpp:1337
Test::LDSB::SetVarSym1::setup
static void setup(Home home, SetVarArray &xs)
Setup problem constraints and symmetries.
Definition ldsb.cpp:1339
Test::LDSB::SetVarSym1::l
static const int l
Lower bound of values.
Definition ldsb.cpp:1335
Test::LDSB::SetVarSym1::n
static const int n
Number of variables.
Definition ldsb.cpp:1333
Test::LDSB::SetVarSym1::expectedSolutions
static std::vector< IntSetArgs > expectedSolutions(void)
Compute list of expected solutions.
Definition ldsb.cpp:1345
Test::LDSB::SimIntValSym1
Test for value sequence symmetry
Definition ldsb.cpp:757
Test::LDSB::SimIntValSym1::n
static const int n
Number of variables.
Definition ldsb.cpp:760
Test::LDSB::SimIntValSym1::expectedSolutions
static std::vector< IntArgs > expectedSolutions(void)
Compute list of expected solutions.
Definition ldsb.cpp:775
Test::LDSB::SimIntValSym1::l
static const int l
Lower bound of values.
Definition ldsb.cpp:762
Test::LDSB::SimIntValSym1::u
static const int u
Upper bound of values.
Definition ldsb.cpp:764
Test::LDSB::SimIntValSym1::setup
static void setup(Home home, IntVarArray &xs)
Setup problem constraints and symmetries.
Definition ldsb.cpp:766
Test::LDSB::SimIntValSym2
Test for value sequence symmetry
Definition ldsb.cpp:787
Test::LDSB::SimIntValSym2::setup
static void setup(Home home, IntVarArray &xs)
Setup problem constraints and symmetries.
Definition ldsb.cpp:796
Test::LDSB::SimIntValSym2::u
static const int u
Upper bound of values.
Definition ldsb.cpp:794
Test::LDSB::SimIntValSym2::expectedSolutions
static std::vector< IntArgs > expectedSolutions(void)
Compute list of expected solutions.
Definition ldsb.cpp:811
Test::LDSB::SimIntValSym2::l
static const int l
Lower bound of values.
Definition ldsb.cpp:792
Test::LDSB::SimIntValSym2::n
static const int n
Number of variables.
Definition ldsb.cpp:790
Test::LDSB::SimIntValSym3
Test for value sequence symmetry
Definition ldsb.cpp:821
Test::LDSB::SimIntValSym3::n
static const int n
Number of variables.
Definition ldsb.cpp:824
Test::LDSB::SimIntValSym3::u
static const int u
Upper bound of values.
Definition ldsb.cpp:828
Test::LDSB::SimIntValSym3::l
static const int l
Lower bound of values.
Definition ldsb.cpp:826
Test::LDSB::SimIntValSym3::expectedSolutions
static std::vector< IntArgs > expectedSolutions(void)
Compute list of expected solutions.
Definition ldsb.cpp:838
Test::LDSB::SimIntValSym3::setup
static void setup(Home home, IntVarArray &xs)
Setup problem constraints and symmetries.
Definition ldsb.cpp:830
Test::LDSB::SimIntVarSym1
Test for variable sequence symmetry
Definition ldsb.cpp:654
Test::LDSB::SimIntVarSym1::l
static const int l
Lower bound of values.
Definition ldsb.cpp:659
Test::LDSB::SimIntVarSym1::setup
static void setup(Home home, IntVarArray &xs)
Setup problem constraints and symmetries.
Definition ldsb.cpp:663
Test::LDSB::SimIntVarSym1::expectedSolutions
static std::vector< IntArgs > expectedSolutions(void)
Compute list of expected solutions.
Definition ldsb.cpp:677
Test::LDSB::SimIntVarSym1::n
static const int n
Number of variables.
Definition ldsb.cpp:657
Test::LDSB::SimIntVarSym1::u
static const int u
Upper bound of values.
Definition ldsb.cpp:661
Test::LDSB::SimIntVarSym2
Test for variable sequence symmetry
Definition ldsb.cpp:709
Test::LDSB::SimIntVarSym2::l
static const int l
Lower bound of values.
Definition ldsb.cpp:718
Test::LDSB::SimIntVarSym2::u
static const int u
Upper bound of values.
Definition ldsb.cpp:720
Test::LDSB::SimIntVarSym2::expectedSolutions
static std::vector< IntArgs > expectedSolutions(void)
Compute list of expected solutions.
Definition ldsb.cpp:745
Test::LDSB::SimIntVarSym2::setup
static void setup(Home home, IntVarArray &xs)
Setup problem constraints and symmetries.
Definition ldsb.cpp:722
Test::LDSB::SimIntVarSym2::n
static const int n
Number of variables.
Definition ldsb.cpp:716
Test::LDSB::TieBreak::l
static const int l
Lower bound of values.
Definition ldsb.cpp:1278
Test::LDSB::TieBreak::u
static const int u
Upper bound of values.
Definition ldsb.cpp:1280
Test::LDSB::TieBreak::expectedSolutions
static std::vector< IntArgs > expectedSolutions(void)
Compute list of expected solutions.
Definition ldsb.cpp:1299
Test::LDSB::TieBreak::n
static const int n
Number of variables.
Definition ldsb.cpp:1276
Test::LDSB::TieBreak::setup
static void setup(Home home, IntVarArray &xs)
Setup problem constraints and symmetries.
Definition ldsb.cpp:1282
Test::LDSB::ValSym1
Test for value symmetry
Definition ldsb.cpp:850
Test::LDSB::ValSym1::n
static const int n
Number of variables.
Definition ldsb.cpp:853
Test::LDSB::ValSym1::setup
static void setup(Home home, IntVarArray &xs)
Setup problem constraints and symmetries.
Definition ldsb.cpp:859
Test::LDSB::ValSym1::l
static const int l
Lower bound of values.
Definition ldsb.cpp:855
Test::LDSB::ValSym1::u
static const int u
Upper bound of values.
Definition ldsb.cpp:857
Test::LDSB::ValSym1::expectedSolutions
static std::vector< IntArgs > expectedSolutions(void)
Compute list of expected solutions.
Definition ldsb.cpp:867
Test::LDSB::ValSym1b
Test for value symmetry
Definition ldsb.cpp:876
Test::LDSB::ValSym1b::u
static const int u
Upper bound of values.
Definition ldsb.cpp:883
Test::LDSB::ValSym1b::setup
static void setup(Home home, IntVarArray &xs)
Setup problem constraints and symmetries.
Definition ldsb.cpp:885
Test::LDSB::ValSym1b::expectedSolutions
static std::vector< IntArgs > expectedSolutions(void)
Compute list of expected solutions.
Definition ldsb.cpp:892
Test::LDSB::ValSym1b::l
static const int l
Lower bound of values.
Definition ldsb.cpp:881
Test::LDSB::ValSym1b::n
static const int n
Number of variables.
Definition ldsb.cpp:879
Test::LDSB::ValSym1c
Test for value symmetry
Definition ldsb.cpp:901
Test::LDSB::ValSym1c::setup
static void setup(Home home, IntVarArray &xs)
Setup problem constraints and symmetries.
Definition ldsb.cpp:910
Test::LDSB::ValSym1c::u
static const int u
Upper bound of values.
Definition ldsb.cpp:908
Test::LDSB::ValSym1c::l
static const int l
Lower bound of values.
Definition ldsb.cpp:906
Test::LDSB::ValSym1c::n
static const int n
Number of variables.
Definition ldsb.cpp:904
Test::LDSB::ValSym1c::expectedSolutions
static std::vector< IntArgs > expectedSolutions(void)
Compute list of expected solutions.
Definition ldsb.cpp:917
Test::LDSB::ValSym2
Test for value symmetry
Definition ldsb.cpp:926
Test::LDSB::ValSym2::n
static const int n
Number of variables.
Definition ldsb.cpp:929
Test::LDSB::ValSym2::expectedSolutions
static std::vector< IntArgs > expectedSolutions(void)
Compute list of expected solutions.
Definition ldsb.cpp:942
Test::LDSB::ValSym2::l
static const int l
Lower bound of values.
Definition ldsb.cpp:931
Test::LDSB::ValSym2::setup
static void setup(Home home, IntVarArray &xs)
Setup problem constraints and symmetries.
Definition ldsb.cpp:935
Test::LDSB::ValSym2::u
static const int u
Upper bound of values.
Definition ldsb.cpp:933
Test::LDSB::ValSym2b
Test for value symmetry
Definition ldsb.cpp:965
Test::LDSB::ValSym2b::l
static const int l
Lower bound of values.
Definition ldsb.cpp:970
Test::LDSB::ValSym2b::expectedSolutions
static std::vector< IntArgs > expectedSolutions(void)
Compute list of expected solutions.
Definition ldsb.cpp:980
Test::LDSB::ValSym2b::setup
static void setup(Home home, IntVarArray &xs)
Setup problem constraints and symmetries.
Definition ldsb.cpp:974
Test::LDSB::ValSym2b::u
static const int u
Upper bound of values.
Definition ldsb.cpp:972
Test::LDSB::ValSym2b::n
static const int n
Number of variables.
Definition ldsb.cpp:968
Test::LDSB::ValSym3
Test for value symmetry
Definition ldsb.cpp:1003
Test::LDSB::ValSym3::u
static const int u
Upper bound of values.
Definition ldsb.cpp:1010
Test::LDSB::ValSym3::n
static const int n
Number of variables.
Definition ldsb.cpp:1006
Test::LDSB::ValSym3::setup
static void setup(Home home, IntVarArray &xs)
Setup problem constraints and symmetries.
Definition ldsb.cpp:1012
Test::LDSB::ValSym3::l
static const int l
Lower bound of values.
Definition ldsb.cpp:1008
Test::LDSB::ValSym3::expectedSolutions
static std::vector< IntArgs > expectedSolutions(void)
Compute list of expected solutions.
Definition ldsb.cpp:1020
Test::LDSB::ValSym4
Test for value symmetry
Definition ldsb.cpp:1040
Test::LDSB::ValSym4::n
static const int n
Number of variables.
Definition ldsb.cpp:1043
Test::LDSB::ValSym4::expectedSolutions
static std::vector< IntArgs > expectedSolutions(void)
Compute list of expected solutions.
Definition ldsb.cpp:1057
Test::LDSB::ValSym4::l
static const int l
Lower bound of values.
Definition ldsb.cpp:1045
Test::LDSB::ValSym4::u
static const int u
Upper bound of values.
Definition ldsb.cpp:1047
Test::LDSB::ValSym4::setup
static void setup(Home home, IntVarArray &xs)
Setup problem constraints and symmetries.
Definition ldsb.cpp:1049
Test::LDSB::ValSym5
Test for value symmetry
Definition ldsb.cpp:1071
Test::LDSB::ValSym5::setup
static void setup(Home home, IntVarArray &xs)
Setup problem constraints and symmetries.
Definition ldsb.cpp:1080
Test::LDSB::ValSym5::n
static const int n
Number of variables.
Definition ldsb.cpp:1074
Test::LDSB::ValSym5::expectedSolutions
static std::vector< IntArgs > expectedSolutions(void)
Compute list of expected solutions.
Definition ldsb.cpp:1090
Test::LDSB::ValSym5::l
static const int l
Lower bound of values.
Definition ldsb.cpp:1076
Test::LDSB::ValSym5::u
static const int u
Upper bound of values.
Definition ldsb.cpp:1078
Test::LDSB::VarSym1
Test for variable symmetry
Definition ldsb.cpp:254
Test::LDSB::VarSym1::n
static const int n
Number of variables.
Definition ldsb.cpp:257
Test::LDSB::VarSym1::u
static const int u
Upper bound of values.
Definition ldsb.cpp:261
Test::LDSB::VarSym1::l
static const int l
Lower bound of values.
Definition ldsb.cpp:259
Test::LDSB::VarSym1::expectedSolutions
static std::vector< IntArgs > expectedSolutions(void)
Compute list of expected solutions.
Definition ldsb.cpp:271
Test::LDSB::VarSym1::setup
static void setup(Home home, IntVarArray &xs)
Setup problem constraints and symmetries.
Definition ldsb.cpp:263
Test::LDSB::VarSym1b
Test for variable symmetry
Definition ldsb.cpp:280
Test::LDSB::VarSym1b::expectedSolutions
static std::vector< IntArgs > expectedSolutions(void)
Compute list of expected solutions.
Definition ldsb.cpp:296
Test::LDSB::VarSym1b::u
static const int u
Upper bound of values.
Definition ldsb.cpp:287
Test::LDSB::VarSym1b::l
static const int l
Lower bound of values.
Definition ldsb.cpp:285
Test::LDSB::VarSym1b::setup
static void setup(Home home, IntVarArray &xs)
Setup problem constraints and symmetries.
Definition ldsb.cpp:289
Test::LDSB::VarSym1b::n
static const int n
Number of variables.
Definition ldsb.cpp:283
Test::LDSB::VarSym2
Test for variable symmetry
Definition ldsb.cpp:305
Test::LDSB::VarSym2::expectedSolutions
static std::vector< IntArgs > expectedSolutions(void)
Compute list of expected solutions.
Definition ldsb.cpp:321
Test::LDSB::VarSym2::setup
static void setup(Home home, IntVarArray &xs)
Setup problem constraints and symmetries.
Definition ldsb.cpp:314
Test::LDSB::VarSym2::l
static const int l
Lower bound of values.
Definition ldsb.cpp:310
Test::LDSB::VarSym2::u
static const int u
Upper bound of values.
Definition ldsb.cpp:312
Test::LDSB::VarSym2::n
static const int n
Number of variables.
Definition ldsb.cpp:308
Test::LDSB::VarSym3
Test for variable symmetry
Definition ldsb.cpp:364
Test::LDSB::VarSym3::n
static const int n
Number of variables.
Definition ldsb.cpp:367
Test::LDSB::VarSym3::setup
static void setup(Home home, IntVarArray &xs)
Setup problem constraints and symmetries.
Definition ldsb.cpp:373
Test::LDSB::VarSym3::l
static const int l
Lower bound of values.
Definition ldsb.cpp:369
Test::LDSB::VarSym3::u
static const int u
Upper bound of values.
Definition ldsb.cpp:371
Test::LDSB::VarSym3::expectedSolutions
static std::vector< IntArgs > expectedSolutions(void)
Compute list of expected solutions.
Definition ldsb.cpp:380
Test::LDSB::VarSym4
Test for variable symmetry
Definition ldsb.cpp:400
Test::LDSB::VarSym4::u
static const int u
Upper bound of values.
Definition ldsb.cpp:407
Test::LDSB::VarSym4::n
static const int n
Number of variables.
Definition ldsb.cpp:403
Test::LDSB::VarSym4::setup
static void setup(Home home, IntVarArray &xs)
Setup problem constraints and symmetries.
Definition ldsb.cpp:409
Test::LDSB::VarSym4::expectedSolutions
static std::vector< IntArgs > expectedSolutions(void)
Compute list of expected solutions.
Definition ldsb.cpp:418
Test::LDSB::VarSym4::l
static const int l
Lower bound of values.
Definition ldsb.cpp:405
Test::LDSB::VarSym5
Test for variable symmetry
Definition ldsb.cpp:432
Test::LDSB::VarSym5::expectedSolutions
static std::vector< IntArgs > expectedSolutions(void)
Compute list of expected solutions.
Definition ldsb.cpp:450
Test::LDSB::VarSym5::setup
static void setup(Home home, IntVarArray &xs)
Setup problem constraints and symmetries.
Definition ldsb.cpp:441
Test::LDSB::VarSym5::l
static const int l
Lower bound of values.
Definition ldsb.cpp:437
Test::LDSB::VarSym5::u
static const int u
Upper bound of values.
Definition ldsb.cpp:439
Test::LDSB::VarSym5::n
static const int n
Number of variables.
Definition ldsb.cpp:435
Test::LDSB::VarValSym1
Test for variable and value symmetry
Definition ldsb.cpp:1104
Test::LDSB::VarValSym1::l
static const int l
Lower bound of values.
Definition ldsb.cpp:1109
Test::LDSB::VarValSym1::n
static const int n
Number of variables.
Definition ldsb.cpp:1107
Test::LDSB::VarValSym1::expectedSolutions
static std::vector< IntArgs > expectedSolutions(void)
Compute list of expected solutions.
Definition ldsb.cpp:1120
Test::LDSB::VarValSym1::setup
static void setup(Home home, IntVarArray &xs)
Setup problem constraints and symmetries.
Definition ldsb.cpp:1113
Test::LDSB::VarValSym1::u
static const int u
Upper bound of values.
Definition ldsb.cpp:1111
branch.hh
int.hh
branch.hh
set.hh
Gecode::branch
void branch(Home home, const FloatVarArgs &x, FloatVarBranch vars, FloatValBranch vals, FloatBranchFilter bf=nullptr, FloatVarValPrint vvp=nullptr)
Branch over x with variable selection vars and value selection vals.
Definition branch.cpp:39
Gecode::linear
void linear(Home home, const FloatVarArgs &x, FloatRelType frt, FloatVal c)
Post propagator for .
Definition linear.cpp:41
Gecode::rel
void rel(Home home, FloatVar x0, FloatRelType frt, FloatVar x1)
Post propagator for .
Definition rel.cpp:68
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::IRT_EQ
@ IRT_EQ
Equality ( ).
Definition int.hh:926
Gecode::Space::Space
Space(void)
Default constructor.
Definition core.cpp:115
Gecode::SOT_INTER
@ SOT_INTER
Intersection
Definition set.hh:663
Gecode::SRT_EQ
@ SRT_EQ
Equality ( ).
Definition set.hh:644
kernel.hh
minimodel.hh
Gecode::Int::LDSB
Symmetry breaking for integer variables.
Definition int.hh:5246
Gecode
Gecode toplevel namespace
Gecode::IntSetArgs
ArgArray< IntSet > IntSetArgs
Passing set arguments.
Definition int.hh:619
Gecode::ValueSymmetry
SymmetryHandle ValueSymmetry(const IntArgs &v)
Values in v are interchangeable.
Definition ldsb.cpp:81
Gecode::ValueSequenceSymmetry
SymmetryHandle ValueSequenceSymmetry(const IntArgs &v, int ss)
Value sequences in v of size ss are interchangeable.
Definition ldsb.cpp:102
Gecode::values_reflect
SymmetryHandle values_reflect(int lower, int upper)
The values from lower to upper (inclusive) can be reflected.
Definition ldsb.cpp:106
Gecode::rows_reflect
SymmetryHandle rows_reflect(const Matrix< A > &m)
Reflect rows symmetry specification.
Definition ldsb.hpp:62
Gecode::SET_VAR_NONE
SetVarBranch SET_VAR_NONE(void)
Select first unassigned variable.
Definition var.hpp:96
Gecode::INT_VAR_DEGREE_MAX
IntVarBranch INT_VAR_DEGREE_MAX(BranchTbl tbl=nullptr)
Select variable with largest degree.
Definition var.hpp:121
Gecode::INT_VAL_MED
IntValBranch INT_VAL_MED(void)
Select greatest value not greater than the median.
Definition val.hpp:60
Gecode::tiebreak
TieBreak< VarBranch > tiebreak(VarBranch a, VarBranch b)
Combine variable selection criteria a and b for tie-breaking.
Definition tiebreak.hpp:80
Gecode::distinct
void distinct(Home home, const IntVarArgs &x, IntPropLevel ipl=IPL_DEF)
Post propagator for for all .
Definition distinct.cpp:46
Gecode::INT_VAR_NONE
IntVarBranch INT_VAR_NONE(void)
Select first unassigned variable.
Definition var.hpp:96
Gecode::abs
void abs(Home home, FloatVar x0, FloatVar x1)
Post propagator for .
Definition arithmetic.cpp:41
Gecode::INT_VAL_MAX
IntValBranch INT_VAL_MAX(void)
Select largest value.
Definition val.hpp:65
Gecode::values
void values(Home home, const IntVarArgs &x, IntSet y, IntPropLevel ipl=IPL_DEF)
Post constraint .
Definition aliases.hpp:143
Gecode::columns_reflect
SymmetryHandle columns_reflect(const Matrix< A > &m)
Reflect columns symmetry specification.
Definition ldsb.hpp:85
Gecode::rows_interchange
SymmetryHandle rows_interchange(const Matrix< A > &m)
Interchangeable rows symmetry specification.
Definition ldsb.hpp:40
Gecode::INT_VAL_MIN
IntValBranch INT_VAL_MIN(void)
Select smallest value.
Definition val.hpp:55
Gecode::VariableSymmetry
SymmetryHandle VariableSymmetry(const IntVarArgs &x)
Variables in x are interchangeable.
Definition ldsb.cpp:62
Gecode::INT_VAR_ACTION_MIN
IntVarBranch INT_VAR_ACTION_MIN(double d=1.0, BranchTbl tbl=nullptr)
Select variable with lowest action with decay factor d.
Definition var.hpp:146
Gecode::SET_VAL_MIN_INC
SetValBranch SET_VAL_MIN_INC(void)
Include smallest element.
Definition val.hpp:55
Gecode::VariableSequenceSymmetry
SymmetryHandle VariableSequenceSymmetry(const IntVarArgs &x, int ss)
Variable sequences in x of size ss are interchangeable.
Definition ldsb.cpp:90
Gecode::cardinality
LinIntExpr cardinality(const SetExpr &)
Cardinality of set expression.
Definition set-expr.cpp:817
Gecode::INT_VAR_MERIT_MAX
IntVarBranch INT_VAR_MERIT_MAX(IntBranchMerit bm, BranchTbl tbl=nullptr)
Select variable with highest merit according to branch merit function bm.
Definition var.hpp:111
Gecode::columns_interchange
SymmetryHandle columns_interchange(const Matrix< A > &m)
Interchangeable columns symmetry specification.
Definition ldsb.hpp:51
Test::LDSB::valsym4
LDSB< ValSym4 > valsym4("ValSym4")
Test::LDSB::action1
LDSB< Action1 > action1("Action1")
Test::LDSB::position
double position(const Space &home, IntVar x, int i)
Definition ldsb.cpp:1266
Test::LDSB::matsym1
LDSB< MatSym1 > matsym1("MatSym1")
Test::LDSB::varsym1
LDSB< VarSym1 > varsym1("VarSym1")
Test::LDSB::simintvalsym3
LDSB< SimIntValSym3 > simintvalsym3("SimIntValSym3")
Test::LDSB::varsym3
LDSB< VarSym3 > varsym3("VarSym3")
Test::LDSB::matsym3
LDSB< MatSym3 > matsym3("MatSym3")
Test::LDSB::varsym2
LDSB< VarSym2 > varsym2("VarSym2")
Test::LDSB::valsym1c
LDSB< ValSym1c > valsym1c("ValSym1c")
Test::LDSB::simintvarsym1
LDSB< SimIntVarSym1 > simintvarsym1("SimIntVarSym1")
Test::LDSB::varsym4
LDSB< VarSym4 > varsym4("VarSym4")
Test::LDSB::tiebreak
LDSB< TieBreak > tiebreak("TieBreak")
Test::LDSB::simintvalsym1
LDSB< SimIntValSym1 > simintvalsym1("SimIntValSym1")
Test::LDSB::valsym5
LDSB< ValSym5 > valsym5("ValSym5")
Test::LDSB::reflectsym2
LDSB< ReflectSym2 > reflectsym2("ReflectSym2")
Test::LDSB::matsym2
LDSB< MatSym2 > matsym2("MatSym2")
Test::LDSB::matsym4
LDSB< MatSym4 > matsym4("MatSym4")
Test::LDSB::latin
LDSBLatin latin("Latin")
Test::LDSB::recomp
LDSB< Recomputation > recomp("Recomputation", 999, 999)
Test::LDSB::simintvarsym2
LDSB< SimIntVarSym2 > simintvarsym2("SimIntVarSym2")
Test::LDSB::valsym2
LDSB< ValSym2 > valsym2("ValSym2")
Test::LDSB::setvarsym1
LDSBSet< SetVarSym1 > setvarsym1("SetVarSym1")
Test::LDSB::ISA
IntSetArgs ISA(int n,...)
Convenient way to make IntSetArgs.
Definition ldsb.cpp:1309
Test::LDSB::setvarseqsym1
LDSBSet< SetVarSeqSym1 > setvarseqsym1("SetVarSeqSym1")
Test::LDSB::valsym1b
LDSB< ValSym1b > valsym1b("ValSym1b")
Test::LDSB::valsym1
LDSB< ValSym1 > valsym1("ValSym1")
Test::LDSB::simintvalsym2
LDSB< SimIntValSym2 > simintvalsym2("SimIntValSym2")
Test::LDSB::valsym3
LDSB< ValSym3 > valsym3("ValSym3")
Test::LDSB::setvalsym1
LDSBSet< SetValSym1 > setvalsym1("SetValSym1")
Test::LDSB::check
bool check(DFS< T > &e, std::vector< VarArgsType > expected)
Checks found solutions against expected solutions.
Definition ldsb.cpp:102
Test::LDSB::valsym2b
LDSB< ValSym2b > valsym2b("ValSym2b")
Test::LDSB::setvarseqsym2
LDSBSet< SetVarSeqSym2 > setvarseqsym2("SetVarSeqSym2")
Test::LDSB::reflectsym1
LDSB< ReflectSym1 > reflectsym1("ReflectSym1")
Test::LDSB::varsym5
LDSB< VarSym5 > varsym5("VarSym5")
Test::LDSB::varsym1b
LDSB< VarSym1b > varsym1b("VarSym1b")
Test::LDSB::setvalsym2
LDSBSet< SetValSym2 > setvalsym2("SetValSym2", 0, 1)
Test::LDSB::varvalsym1
LDSB< VarValSym1 > varvalsym1("VarValSym1")
Test::LDSB::equal
bool equal(const IntArgs &a, const IntArgs &b)
Returns true iff a and b are equal (they have the same size and the same elements in the same positio...
Definition ldsb.cpp:61
Test
General test support.
Definition afc.cpp:39
Test::olog
std::ostringstream olog
Stream used for logging.
Definition test.cpp:53
Test::r
Region r
Definition region.cpp:65
Test::opt
Options opt
The options.
Definition test.cpp:97
test.hh