Generated on Thu Jan 16 2025 00:00:00 for Gecode by doxygen 1.14.0
nosubset.hpp
Go to the documentation of this file.
1/* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
2/*
3 * Main authors:
4 * Guido Tack <tack@gecode.org>
5 * Christian Schulte <schulte@gecode.org>
6 * Gabor Szokoli <szokoli@gecode.org>
7 *
8 * Copyright:
9 * Guido Tack, 2004
10 * Christian Schulte, 2004
11 * Gabor Szokoli, 2004
12 *
13 * This file is part of Gecode, the generic constraint
14 * development environment:
15 * http://www.gecode.org
16 *
17 * Permission is hereby granted, free of charge, to any person obtaining
18 * a copy of this software and associated documentation files (the
19 * "Software"), to deal in the Software without restriction, including
20 * without limitation the rights to use, copy, modify, merge, publish,
21 * distribute, sublicense, and/or sell copies of the Software, and to
22 * permit persons to whom the Software is furnished to do so, subject to
23 * the following conditions:
24 *
25 * The above copyright notice and this permission notice shall be
26 * included in all copies or substantial portions of the Software.
27 *
28 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
29 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
30 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
31 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
32 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
33 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
34 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
35 *
36 */
37
38namespace Gecode { namespace Set { namespace Rel {
39
40 /*
41 * "No Subset" propagator
42 *
43 */
44
45 template<class View0, class View1>
47 NoSubset<View0,View1>::NoSubset(Home home, View0 y0, View1 y1)
49 View1,PC_SET_CGLB>(home,y0,y1) {}
50
51 template<class View0, class View1>
56
57 template<class View0, class View1>
59 NoSubset<View0,View1>::post(Home home, View0 x, View1 y) {
60 if (same(x,y))
61 return ES_FAILED;
62 if (me_failed(x.cardMin(home,1)))
63 return ES_FAILED;
64 (void) new (home) NoSubset<View0,View1>(home,x,y);
65 return ES_OK;
66 }
67
68 template<class View0, class View1>
69 Actor*
71 return new (home) NoSubset<View0,View1>(home,*this);
72 }
73
74 template<class View0, class View1>
77 GlbRanges<View0> x0lb(x0);
78 LubRanges<View1> x1ub(x1);
79 if (!Iter::Ranges::subset(x0lb, x1ub))
80 return home.ES_SUBSUMED(*this);
81 if (x0.cardMin()>x1.cardMax()) { return home.ES_SUBSUMED(*this); }
82 LubRanges<View0> x0ub(x0);
83 GlbRanges<View1> x1lb(x1);
85 breakers(x0ub,x1lb);
86 if (!breakers()) { return ES_FAILED; }
87 if (breakers.min() == breakers.max()) {
88 int b1 = breakers.min();
89 ++breakers;
90 if (breakers()) { return ES_FIX; }
91 //Only one subsetness-breaker element left:
92 GECODE_ME_CHECK( x0.include(home,b1) );
93 GECODE_ME_CHECK( x1.exclude(home,b1) );
94 return home.ES_SUBSUMED(*this);
95 }
96 return ES_FIX;
97 }
98
99}}}
100
101// STATISTICS: set-prop
Base-class for both propagators and branchers.
Definition core.hpp:628
Home class for posting propagators
Definition core.hpp:856
Range iterator for computing set difference.
int min(void) const
Return smallest value of range.
int max(void) const
Return largest value of range.
friend class Space
Definition core.hpp:1068
Range iterator for the greatest lower bound.
Definition var-imp.hpp:359
Range iterator for the least upper bound.
Definition var-imp.hpp:317
static ExecStatus post(Home home, View0 x, View1 y)
Post propagator .
Definition nosubset.hpp:59
NoSubset(Space &home, NoSubset &p)
Constructor for cloning p.
Definition nosubset.hpp:53
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
Definition nosubset.hpp:76
virtual Actor * copy(Space &home)
Copy propagator during cloning.
Definition nosubset.hpp:70
ExecStatus ES_SUBSUMED(Propagator &p)
Propagator p is subsumed
Definition core.hpp:3570
int ModEventDelta
Modification event deltas.
Definition core.hpp:89
#define GECODE_ME_CHECK(me)
Check whether modification event me is failed, and forward failure.
Definition macros.hpp:52
bool me_failed(ModEvent me)
Check whether modification event me is failed.
Definition modevent.hpp:54
bool subset(I &i, J &j)
Check whether range iterator i is subset of range iterator j.
Standard set relation propagators.
Definition rel.hh:45
Finite integer sets.
Definition var-imp.hpp:137
const Gecode::PropCond PC_SET_CLUB
Propagate when the cardinality or the least upper bound of a view changes.
Definition var-type.hpp:227
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 toplevel namespace
bool same(VarArgArray< Var > x, VarArgArray< Var > y)
Definition array.hpp:1943
Post propagator for SetVar SetOpType SetVar y
Definition set.hh:773
ExecStatus
Definition core.hpp:472
@ ES_OK
Execution is okay.
Definition core.hpp:476
@ ES_FIX
Propagation has computed fixpoint.
Definition core.hpp:477
@ ES_FAILED
Execution has resulted in failure.
Definition core.hpp:474
Post propagator for SetVar x
Definition set.hh:773
#define forceinline
Definition config.hpp:194