/* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */ /* * Main authors: * Christian Schulte * Mikael Lagerkvist * * Copyright: * Christian Schulte, 2005 * Mikael Lagerkvist, 2006 * * 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 namespace Test { namespace Int { /// %Tests for distinct constraints namespace Distinct { /** * \defgroup TaskTestIntDistinct Distinct constraints * \ingroup TaskTestInt */ //@{ /// Simple test for distinct constraint template class Distinct : public Test { public: /// Create and register test Distinct(const Gecode::IntSet& d0, Gecode::IntPropLevel ipl, int n=6) : Test(std::string(useCount ? "Count::Distinct::" : "Distinct::")+ str(ipl)+"::Sparse::"+str(n),n,d0,false,ipl) {} /// Create and register test Distinct(int min, int max, Gecode::IntPropLevel ipl) : Test(std::string(useCount ? "Count::Distinct::" : "Distinct::")+ str(ipl)+"::Dense",6,min,max,false,ipl) {} /// Check whether \a x is solution virtual bool solution(const Assignment& x) const { for (int i=0; i 1)) return false; for (int i=0; istatus() == SS_FAILED) { delete s; return false; } for (int i=0; istatus() == SS_FAILED) { delete s; return false; } for (int i=0; i dom_d(-3,3,Gecode::IPL_DOM); Distinct bnd_d(-3,3,Gecode::IPL_BND); Distinct val_d(-3,3,Gecode::IPL_VAL); Distinct dom_s(d,Gecode::IPL_DOM); Distinct bnd_s(d,Gecode::IPL_BND); Distinct val_s(d,Gecode::IPL_VAL); Distinct dom_l(dl,Gecode::IPL_DOM,5); Distinct bnd_l(dl,Gecode::IPL_BND,5); Distinct val_l(dl,Gecode::IPL_VAL,5); Distinct count_dom_d(-3,3,Gecode::IPL_DOM); Distinct count_bnd_d(-3,3,Gecode::IPL_BND); Distinct count_val_d(-3,3,Gecode::IPL_VAL); Distinct count_dom_s(d,Gecode::IPL_DOM); Distinct count_bnd_s(d,Gecode::IPL_BND); Distinct count_val_s(d,Gecode::IPL_VAL); Offset dom_od(-3,3,Gecode::IPL_DOM); Offset bnd_od(-3,3,Gecode::IPL_BND); Offset val_od(-3,3,Gecode::IPL_VAL); Offset dom_os(d,Gecode::IPL_DOM); Offset bnd_os(d,Gecode::IPL_BND); Offset val_os(d,Gecode::IPL_VAL); Gecode::IntArgs v1({Gecode::Int::Limits::min+4, 0,1, Gecode::Int::Limits::max}); Gecode::IntArgs v2({Gecode::Int::Limits::min, 0,1, Gecode::Int::Limits::max-4}); Gecode::IntArgs v3({0,1,2,3}); Gecode::IntArgs v4({0,1,2}); Gecode::IntArgs v5({0,1}); Optional od1(v1,Gecode::IPL_DOM); Optional ob1(v1,Gecode::IPL_BND); Optional ov1(v1,Gecode::IPL_VAL); Optional od2(v2,Gecode::IPL_DOM); Optional ob2(v2,Gecode::IPL_BND); Optional ov2(v2,Gecode::IPL_VAL); Optional od3(v3,Gecode::IPL_DOM); Optional ob3(v3,Gecode::IPL_BND); Optional ov3(v3,Gecode::IPL_VAL); Optional od4(v4,Gecode::IPL_DOM); Optional ob4(v4,Gecode::IPL_BND); Optional ov4(v4,Gecode::IPL_VAL); Optional od5(v5,Gecode::IPL_DOM); Optional ob5(v5,Gecode::IPL_BND); Optional ov5(v5,Gecode::IPL_VAL); Except ed1(v1,Gecode::IPL_DOM); Except eb1(v1,Gecode::IPL_BND); Except ev1(v1,Gecode::IPL_VAL); Except ed2(v2,Gecode::IPL_DOM); Except eb2(v2,Gecode::IPL_BND); Except ev2(v2,Gecode::IPL_VAL); Except ed5(v5,Gecode::IPL_DOM); Except eb5(v5,Gecode::IPL_BND); Except ev5(v5,Gecode::IPL_VAL); Random dom_r(20,-50,50,Gecode::IPL_DOM); Random bnd_r(50,-500,500,Gecode::IPL_BND); Random val_r(50,-500,500,Gecode::IPL_VAL); Pathological p_16_v(16,Gecode::IPL_VAL); Pathological p_16_b(16,Gecode::IPL_BND); Pathological p_16_d(16,Gecode::IPL_DOM); Pathological p_32_v(32,Gecode::IPL_VAL); Pathological p_32_b(32,Gecode::IPL_BND); Pathological p_32_d(32,Gecode::IPL_DOM); //@} } }} // STATISTICS: test-int