post.hpp
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.hh>
#include <gecode/set/rel.hh>
#include <gecode/set/rel-op.hh>
namespace Gecode { namespace Set { namespace RelOp {
template<class View0, class View1, class Res>
forceinline void
rel_eq(Home home, View0 x0, SetOpType op, View1 x1, Res x2) {
switch(op) {
case SOT_DUNION:
{
EmptyView emptyset;
GECODE_ES_FAIL((SuperOfInter<View0,View1,EmptyView>
::post(home, x0, x1, emptyset)));
// fall through to SOT_UNION
}
case SOT_UNION:
{
GECODE_ES_FAIL(
(Union<View0,View1,Res>
::post(home, x0, x1, x2)));
}
break;
case SOT_INTER:
{
GECODE_ES_FAIL((Intersection<View0,View1,Res>
::post(home, x0,x1,x2)));
}
break;
case SOT_MINUS:
{
ComplementView<View1> cx1(x1);
GECODE_ES_FAIL(
(Intersection<View0,
ComplementView<View1>,Res>
::post(home,x0,cx1,x2)));
}
break;
}
}
template<class View0, class View1, class View2>
forceinline void
rel_sub(Home home, View0 x0, SetOpType op, View1 x1, View2 x2) {
switch(op) {
case SOT_DUNION:
{
EmptyView emptyset;
GECODE_ES_FAIL((SuperOfInter<View0,View1,EmptyView>
::post(home, x0, x1, emptyset)));
// fall through to SOT_UNION
}
case SOT_UNION:
{
SetVar tmp(home);
GECODE_ES_FAIL(
(Rel::Subset<SetView,View2>::post(home,tmp,x2)));
GECODE_ES_FAIL(
(Union<View0,View1,SetView>
::post(home, x0, x1, tmp)));
}
break;
case SOT_INTER:
{
GECODE_ES_FAIL((SuperOfInter<View0,View1,View2>
::post(home, x0,x1,x2)));
}
break;
case SOT_MINUS:
{
ComplementView<View1> cx1(x1);
GECODE_ES_FAIL(
(SuperOfInter<View0,
ComplementView<View1>,View2>
::post(home,x0,cx1,x2)));
}
break;
}
}
template<class View0, class View1, class View2>
forceinline void
rel_sup(Home home, View0 x0, SetOpType op, View1 x1, View2 x2) {
switch(op) {
case SOT_DUNION:
{
EmptyView emptyset;
GECODE_ES_FAIL((SuperOfInter<View0,View1,EmptyView>
::post(home, x0, x1, emptyset)));
// fall through to SOT_UNION
}
case SOT_UNION:
{
GECODE_ES_FAIL(
(SubOfUnion<View0,View1,View2>
::post(home, x0, x1, x2)));
}
break;
case SOT_INTER:
{
SetVar tmp(home);
GECODE_ES_FAIL(
(Rel::Subset<View2,SetView>::post(home,x2,tmp)));
GECODE_ES_FAIL((Intersection<View0,View1,SetView>
::post(home, x0,x1,tmp)));
}
break;
case SOT_MINUS:
{
SetVar tmp(home);
GECODE_ES_FAIL(
(Rel::Subset<View2,SetView>::post(home,x2,tmp)));
ComplementView<View1> cx1(x1);
GECODE_ES_FAIL(
(Intersection<View0,
ComplementView<View1>,SetView>
::post(home,x0,cx1,tmp)));
}
break;
}
}
template<class View>
forceinline void
rel_op_post_lex(Home home, SetView x0, SetRelType r, View x1) {
switch (r) {
case SRT_LQ:
GECODE_ES_FAIL((Rel::Lq<SetView,View,false>::post(home,x0,x1)));
break;
case SRT_LE:
GECODE_ES_FAIL((Rel::Lq<SetView,View,true>::post(home,x0,x1)));
break;
case SRT_GQ:
GECODE_ES_FAIL((Rel::Lq<View,SetView,false>::post(home,x1,x0)));
break;
case SRT_GR:
GECODE_ES_FAIL((Rel::Lq<View,SetView,true>::post(home,x1,x0)));
break;
default:
throw UnknownRelation("Set::rel");
}
}
template<class View0, class View1, class View2>
forceinline void
rel_op_post_nocompl(Home home, View0 x, SetOpType op, View1 y,
SetRelType r, View2 z) {
if (home.failed()) return;
switch(r) {
case SRT_EQ:
rel_eq<View0,View1,View2>(home, x, op, y, z);
break;
case SRT_LQ: case SRT_LE: case SRT_GQ: case SRT_GR:
{
SetVar tmp(home,IntSet::empty,Set::Limits::min,Set::Limits::max);
rel_eq<View0,View1,SetView>(home, x, op, y, tmp);
rel_op_post_lex<View2>(home,tmp,r,z);
}
break;
case SRT_NQ:
{
SetVar tmp(home);
GECODE_ES_FAIL(
(Rel::Distinct<SetView,View2>
::post(home,tmp,z)));
rel_eq<View0,View1,SetView>(home, x, op, y, tmp);
}
break;
case SRT_SUB:
rel_sub<View0,View1,View2>(home, x, op, y, z);
break;
case SRT_SUP:
rel_sup<View0,View1,View2>(home, x, op, y, z);
break;
case SRT_DISJ:
{
SetVar tmp(home);
EmptyView emptyset;
GECODE_ES_FAIL((SuperOfInter<View2,SetView,EmptyView>
::post(home, z, tmp, emptyset)));
rel_eq<View0,View1,SetView>(home, x, op, y, tmp);
}
break;
default:
GECODE_NEVER;
}
}
GECODE_SET_EXPORT void
post_nocompl(Home home, SetView x, SetOpType op, SetView y,
SetRelType r, SetView z);
GECODE_SET_EXPORT void
post_nocompl(Home home, ConstSetView x, SetOpType op, SetView y,
SetRelType r, SetView z);
GECODE_SET_EXPORT void
post_nocompl(Home home, SetView x, SetOpType op, SetView y,
SetRelType r, ConstSetView z);
GECODE_SET_EXPORT void
post_nocompl(Home home, ConstSetView x, SetOpType op, SetView y,
SetRelType r, ConstSetView z);
GECODE_SET_EXPORT void
post_compl(Home home, SetView x, SetOpType op, SetView y, SetView z);
GECODE_SET_EXPORT void
post_compl(Home home, ConstSetView x, SetOpType op, SetView y, SetView z);
GECODE_SET_EXPORT void
post_compl(Home home, SetView x, SetOpType op, SetView y, ConstSetView z);
GECODE_SET_EXPORT void
post_compl(Home home, ConstSetView x, SetOpType op, SetView y,
ConstSetView z);
}}}
// STATISTICS: set-prop
Gecode::Home
Home class for posting propagators
Definition core.hpp:856
Gecode::Home::failed
bool failed(void) const
Check whether corresponding space is failed.
Definition core.hpp:4048
Gecode::IntSet::empty
static const IntSet empty
Empty set.
Definition int.hh:283
Gecode::Int::UnknownRelation
Exception: Unknown relation passed as argument
Definition exception.hpp:87
Gecode::SetVar
Set variables
Definition set.hh:127
Gecode::Set::ComplementView
Complement set view.
Definition view.hpp:769
Gecode::Set::ConstSetView
Constant view.
Definition view.hpp:186
Gecode::Set::EmptyView
Constant view for the empty set.
Definition view.hpp:336
Gecode::Set::RelOp::Intersection
Propagator for ternary intersection
Definition rel-op.hh:124
Gecode::Set::RelOp::SubOfUnion
Propagator for the subset of union
Definition rel-op.hh:93
Gecode::Set::RelOp::SuperOfInter
Propagator for the superset of intersection
Definition rel-op.hh:63
Gecode::Set::RelOp::Union
Propagator for ternary union
Definition rel-op.hh:154
Gecode::Set::Rel::Distinct
Propagator for negated equality
Definition rel.hh:268
Gecode::Set::Rel::Lq::post
static ExecStatus post(Home home, View0 x, View1 y)
Post propagator .
Definition lq.hpp:325
Gecode::Set::Rel::Subset::post
static ExecStatus post(Home home, View0 x, View1 y)
Post propagator .
Definition subset.hpp:55
Gecode::Set::SetView
Set view for set variables
Definition view.hpp:56
Gecode::View
set.hh
GECODE_SET_EXPORT
#define GECODE_SET_EXPORT
Definition set.hh:67
GECODE_ES_FAIL
#define GECODE_ES_FAIL(es)
Check whether execution status es is failed, and fail space home.
Definition macros.hpp:103
Gecode::SetOpType
SetOpType
Common operations for sets.
Definition set.hh:660
Gecode::SetRelType
SetRelType
Common relation types for sets.
Definition set.hh:643
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::SRT_GQ
@ SRT_GQ
Greater or equal ( ).
Definition set.hh:652
Gecode::SRT_GR
@ SRT_GR
Greater ( ).
Definition set.hh:653
Gecode::SRT_LQ
@ SRT_LQ
Less or equal ( ).
Definition set.hh:650
Gecode::SRT_NQ
@ SRT_NQ
Disequality ( ).
Definition set.hh:645
Gecode::SRT_LE
@ SRT_LE
Less ( ).
Definition set.hh:651
Gecode::SRT_EQ
@ SRT_EQ
Equality ( ).
Definition set.hh:644
Gecode::SRT_SUP
@ SRT_SUP
Superset ( ).
Definition set.hh:647
Gecode::SRT_DISJ
@ SRT_DISJ
Disjoint ( ).
Definition set.hh:648
Gecode::SRT_SUB
@ SRT_SUB
Subset ( ).
Definition set.hh:646
Gecode::Set::Limits::min
const int min
Smallest allowed integer in integer set.
Definition set.hh:99
Gecode::Set::Limits::max
const int max
Largest allowed integer in integer set.
Definition set.hh:97
Gecode::Set::RelOp
Standard set operation propagators.
Definition rel-op.hh:46
Gecode::Set::RelOp::post_compl
void post_compl(Home home, ConstSetView x, SetOpType op, SetView y, ConstSetView z)
Definition post-compl-cvc.cpp:43
Gecode::Set::RelOp::post_nocompl
void post_nocompl(Home home, ConstSetView x, SetOpType op, SetView y, SetRelType r, ConstSetView z)
Definition post-nocompl-cvc.cpp:43
Gecode::Set::RelOp::rel_op_post_nocompl
void rel_op_post_nocompl(Home home, View0 x, SetOpType op, View1 y, SetRelType r, View2 z)
Definition post.hpp:188
Gecode::Set::RelOp::rel_eq
void rel_eq(Home home, View0 x0, SetOpType op, View1 x1, Res x2)
Definition post.hpp:45
Gecode::Set::RelOp::rel_sup
void rel_sup(Home home, View0 x0, SetOpType op, View1 x1, View2 x2)
Definition post.hpp:122
Gecode::Set::RelOp::rel_op_post_lex
void rel_op_post_lex(Home home, SetView x0, SetRelType r, View x1)
Definition post.hpp:167
Gecode::Set::RelOp::rel_sub
void rel_sub(Home home, View0 x0, SetOpType op, View1 x1, View2 x2)
Definition post.hpp:81
Gecode::Set
Finite integer sets.
Definition var-imp.hpp:137
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
rel.hh
forceinline
#define forceinline
Definition config.hpp:187
GECODE_NEVER
#define GECODE_NEVER
Assert that this command is never executed.
Definition macros.hpp:56