nosubset.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>
* Christian Schulte <schulte@gecode.org>
* Gabor Szokoli <szokoli@gecode.org>
*
* Copyright:
* Guido Tack, 2004
* Christian Schulte, 2004
* Gabor Szokoli, 2004
*
* 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.
*
*/
namespace Gecode { namespace Set { namespace Rel {
/*
* "No Subset" propagator
*
*/
template<class View0, class View1>
forceinline
NoSubset<View0,View1>::NoSubset(Home home, View0 y0, View1 y1)
: MixBinaryPropagator<View0,PC_SET_CLUB,
View1,PC_SET_CGLB>(home,y0,y1) {}
template<class View0, class View1>
forceinline
NoSubset<View0,View1>::NoSubset(Space& home, NoSubset<View0,View1>& p)
: MixBinaryPropagator<View0,PC_SET_CLUB,
View1,PC_SET_CGLB>(home,p) {}
template<class View0, class View1>
ExecStatus
NoSubset<View0,View1>::post(Home home, View0 x, View1 y) {
if (same(x,y))
return ES_FAILED;
if (me_failed(x.cardMin(home,1)))
return ES_FAILED;
(void) new (home) NoSubset<View0,View1>(home,x,y);
return ES_OK;
}
template<class View0, class View1>
Actor*
NoSubset<View0,View1>::copy(Space& home) {
return new (home) NoSubset<View0,View1>(home,*this);
}
template<class View0, class View1>
ExecStatus
NoSubset<View0,View1>::propagate(Space& home, const ModEventDelta&) {
GlbRanges<View0> x0lb(x0);
LubRanges<View1> x1ub(x1);
if (!Iter::Ranges::subset(x0lb, x1ub))
return home.ES_SUBSUMED(*this);
if (x0.cardMin()>x1.cardMax()) { return home.ES_SUBSUMED(*this); }
LubRanges<View0> x0ub(x0);
GlbRanges<View1> x1lb(x1);
Iter::Ranges::Diff<LubRanges<View0>,GlbRanges<View1> >
breakers(x0ub,x1lb);
if (!breakers()) { return ES_FAILED; }
if (breakers.min() == breakers.max()) {
int b1 = breakers.min();
++breakers;
if (breakers()) { return ES_FIX; }
//Only one subsetness-breaker element left:
GECODE_ME_CHECK( x0.include(home,b1) );
GECODE_ME_CHECK( x1.exclude(home,b1) );
return home.ES_SUBSUMED(*this);
}
return ES_FIX;
}
}}}
// STATISTICS: set-prop
Gecode::Actor
Base-class for both propagators and branchers.
Definition core.hpp:628
Gecode::Home
Home class for posting propagators
Definition core.hpp:856
Gecode::Iter::Ranges::Diff
Range iterator for computing set difference.
Definition ranges-diff.hpp:43
Gecode::Iter::Ranges::MinMax::min
int min(void) const
Return smallest value of range.
Definition ranges-minmax.hpp:99
Gecode::Iter::Ranges::MinMax::max
int max(void) const
Return largest value of range.
Definition ranges-minmax.hpp:103
Gecode::MixBinaryPropagator< View0, PC_SET_CLUB, View1, PC_SET_CGLB >::x1
View1 x1
Definition pattern.hpp:209
Gecode::MixBinaryPropagator< View0, PC_SET_CLUB, View1, PC_SET_CGLB >::MixBinaryPropagator
MixBinaryPropagator(Space &home, MixBinaryPropagator &p)
Definition pattern.hpp:597
Gecode::MixBinaryPropagator< View0, PC_SET_CLUB, View1, PC_SET_CGLB >::x0
View0 x0
Definition pattern.hpp:207
Gecode::Propagator::Space
friend class Space
Definition core.hpp:1066
Gecode::Set::GlbRanges
Range iterator for the greatest lower bound.
Definition var-imp.hpp:359
Gecode::Set::LubRanges
Range iterator for the least upper bound.
Definition var-imp.hpp:317
Gecode::Set::Rel::NoSubset::post
static ExecStatus post(Home home, View0 x, View1 y)
Post propagator .
Definition nosubset.hpp:59
Gecode::Set::Rel::NoSubset::NoSubset
NoSubset(Space &home, NoSubset &p)
Constructor for cloning p.
Definition nosubset.hpp:53
Gecode::Set::Rel::NoSubset::propagate
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
Definition nosubset.hpp:76
Gecode::Set::Rel::NoSubset::copy
virtual Actor * copy(Space &home)
Copy propagator during cloning.
Definition nosubset.hpp:70
Gecode::Space::ES_SUBSUMED
ExecStatus ES_SUBSUMED(Propagator &p)
Definition core.hpp:3563
Gecode::ModEventDelta
int ModEventDelta
Modification event deltas.
Definition core.hpp:89
GECODE_ME_CHECK
#define GECODE_ME_CHECK(me)
Check whether modification event me is failed, and forward failure.
Definition macros.hpp:52
Gecode::me_failed
bool me_failed(ModEvent me)
Check whether modification event me is failed.
Definition modevent.hpp:54
Gecode::Iter::Ranges::subset
bool subset(I &i, J &j)
Check whether range iterator i is subset of range iterator j.
Definition ranges-operations.hpp:97
Gecode::Set::Rel
Standard set relation propagators.
Definition rel.hh:45
Gecode::Set
Finite integer sets.
Definition var-imp.hpp:137
Gecode::Set::PC_SET_CLUB
const Gecode::PropCond PC_SET_CLUB
Propagate when the cardinality or the least upper bound of a view changes.
Definition var-type.hpp:227
Gecode::Set::PC_SET_CGLB
const Gecode::PropCond PC_SET_CGLB
Propagate when the cardinality or the greatest lower bound of a view changes.
Definition var-type.hpp:238
Gecode
Gecode toplevel namespace
Gecode::same
bool same(VarArgArray< Var > x, VarArgArray< Var > y)
Definition array.hpp:1937
Gecode::ExecStatus
ExecStatus
Definition core.hpp:472
Gecode::ES_OK
@ ES_OK
Execution is okay.
Definition core.hpp:476
Gecode::ES_FIX
@ ES_FIX
Propagation has computed fixpoint.
Definition core.hpp:477
Gecode::ES_FAILED
@ ES_FAILED
Execution has resulted in failure.
Definition core.hpp:474
forceinline
#define forceinline
Definition config.hpp:187