rel-op-singleton.cpp
Go to the documentation of this file.
/* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
/*
* Main authors:
* Guido Tack <tack@gecode.org>
*
* Contributing authors:
* Gabor Szokoli <szokoli@gecode.org>
*
* Copyright:
* Guido Tack, 2004, 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 <gecode/set/rel-op.hh>
namespace Gecode {
using namespace Gecode::Set;
using namespace Gecode::Set::Rel;
using namespace Gecode::Set::RelOp;
void
rel(Home home, SetOpType op, const IntVarArgs& x, SetVar y) {
GECODE_POST;
ViewArray<SingletonView> xa(home,x.size());
for (int i=x.size(); i--;) {
Int::IntView iv(x[i]);
SingletonView sv(iv);
xa[i] = sv;
}
switch (op) {
case SOT_UNION:
GECODE_ES_FAIL((RelOp::UnionN<SingletonView,SetView>
::post(home, xa, y)));
break;
case SOT_DUNION:
GECODE_ES_FAIL((RelOp::PartitionN<SingletonView,SetView>
::post(home, xa, y)));
break;
case SOT_INTER:
GECODE_ES_FAIL(
(RelOp::IntersectionN<SingletonView,SetView>
::post(home, xa, y)));
break;
case SOT_MINUS:
throw IllegalOperation("Set::rel");
break;
default:
throw UnknownOperation("Set::rel");
}
}
void
rel(Home home, SetOpType op, const IntVarArgs& x, const IntSet& z,
SetVar y) {
GECODE_POST;
Set::Limits::check(z, "Set::rel");
ViewArray<SingletonView> xa(home,x.size());
for (int i=x.size(); i--;) {
Int::IntView iv(x[i]);
SingletonView sv(iv);
xa[i] = sv;
}
switch (op) {
case SOT_UNION:
GECODE_ES_FAIL((RelOp::UnionN<SingletonView,SetView>
::post(home, xa, z, y)));
break;
case SOT_DUNION:
GECODE_ES_FAIL((RelOp::PartitionN<SingletonView,SetView>
::post(home, xa, z, y)));
break;
case SOT_INTER:
GECODE_ES_FAIL(
(RelOp::IntersectionN<SingletonView,SetView>
::post(home, xa, z, y)));
break;
case SOT_MINUS:
throw IllegalOperation("set::rel");
break;
default:
throw UnknownOperation("Set::rel");
}
}
}
// STATISTICS: set-post
Gecode::ArgArrayBase::size
int size(void) const
Return size of array (number of elements).
Definition array.hpp:1607
Gecode::Home
Home class for posting propagators
Definition core.hpp:856
Gecode::IntSet
Integer sets.
Definition int.hh:174
Gecode::IntVarArgs
Passing integer variables.
Definition int.hh:656
Gecode::Int::IllegalOperation
Exception: Illegal operation passed as argument
Definition exception.hpp:101
Gecode::Int::IntView
Integer view for integer variables.
Definition view.hpp:129
Gecode::Int::UnknownOperation
Exception: Unknown operation passed as argument
Definition exception.hpp:94
Gecode::SetVar
Set variables
Definition set.hh:127
Gecode::Set::RelOp::IntersectionN
Propagator for nary intersection
Definition rel-op.hh:183
Gecode::Set::RelOp::PartitionN
Propagator for nary partition
Definition rel-op.hh:256
Gecode::Set::RelOp::UnionN
Propagator for nary union
Definition rel-op.hh:219
Gecode::Set::SingletonView
Singleton set view.
Definition view.hpp:594
Gecode::ViewArray
View arrays.
Definition array.hpp:253
GECODE_POST
#define GECODE_POST
Check for failure in a constraint post function.
Definition macros.hpp:40
GECODE_ES_FAIL
#define GECODE_ES_FAIL(es)
Check whether execution status es is failed, and fail space home.
Definition macros.hpp:103
Gecode::rel
void rel(Home home, FloatVar x0, FloatRelType frt, FloatVar x1)
Post propagator for .
Definition rel.cpp:68
Gecode::SetOpType
SetOpType
Common operations for sets.
Definition set.hh:660
Gecode::SOT_MINUS
@ SOT_MINUS
Difference.
Definition set.hh:664
Gecode::SOT_DUNION
@ SOT_DUNION
Disjoint union.
Definition set.hh:662
Gecode::SOT_UNION
@ SOT_UNION
Union.
Definition set.hh:661
Gecode::SOT_INTER
@ SOT_INTER
Intersection
Definition set.hh:663
Gecode::Set::Limits::check
void check(int n, const char *l)
Check whether integer n is in range, otherwise throw overflow exception with information l.
Definition limits.hpp:37
Gecode
Gecode toplevel namespace
Gecode::post
TFE post(PropagatorGroup g)
Only post functions (but not propagators) from g are considered.
Definition filter.cpp:138
rel-op.hh