main page
modules
namespaces
classes
files
Gecode home
Generated on Tue Jan 28 2020 00:00:00 for Gecode by
doxygen
1.8.17
gecode
set
rel
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
* Last modified:
14
* $Date: 2010-03-03 17:32:21 +0100 (Wed, 03 Mar 2010) $ by $Author: schulte $
15
* $Revision: 10364 $
16
*
17
* This file is part of Gecode, the generic constraint
18
* development environment:
19
* http://www.gecode.org
20
*
21
* Permission is hereby granted, free of charge, to any person obtaining
22
* a copy of this software and associated documentation files (the
23
* "Software"), to deal in the Software without restriction, including
24
* without limitation the rights to use, copy, modify, merge, publish,
25
* distribute, sublicense, and/or sell copies of the Software, and to
26
* permit persons to whom the Software is furnished to do so, subject to
27
* the following conditions:
28
*
29
* The above copyright notice and this permission notice shall be
30
* included in all copies or substantial portions of the Software.
31
*
32
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
33
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
34
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
35
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
36
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
37
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
38
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
39
*
40
*/
41
42
namespace
Gecode
{
namespace
Set {
namespace
Rel {
43
44
/*
45
* "No Subset" propagator
46
*
47
*/
48
49
template
<
class
View0,
class
View1>
50
forceinline
51
NoSubset<View0,View1>::NoSubset
(
Home
home, View0 y0, View1 y1)
52
:
MixBinaryPropagator
<View0,
PC_SET_CLUB
,
53
View1,
PC_SET_CGLB
>(home,y0,y1) {}
54
55
template
<
class
View0,
class
View1>
56
forceinline
57
NoSubset<View0,View1>::NoSubset
(
Space
& home,
bool
share,
58
NoSubset<View0,View1>
&
p
)
59
:
MixBinaryPropagator
<View0,
PC_SET_CLUB
,
60
View1,
PC_SET_CGLB
>(home,share,
p
) {}
61
62
template
<
class
View0,
class
View1>
63
ExecStatus
64
NoSubset<View0,View1>::post
(
Home
home, View0
x
, View1
y
) {
65
if
(
me_failed
(
x
.
cardMin
(home,1)))
66
return
ES_FAILED
;
67
(void)
new
(home)
NoSubset<View0,View1>
(home,
x
,
y
);
68
return
ES_OK
;
69
}
70
71
template
<
class
View0,
class
View1>
72
Actor
*
73
NoSubset<View0,View1>::copy
(
Space
& home,
bool
share) {
74
return
new
(home)
NoSubset<View0,View1>
(home,share,*
this
);
75
}
76
77
template
<
class
View0,
class
View1>
78
ExecStatus
79
NoSubset<View0,View1>::propagate
(
Space
& home,
const
ModEventDelta
&) {
80
GlbRanges<View0>
x0lb(x0);
81
LubRanges<View1>
x1ub(x1);
82
if
(!
Iter::Ranges::subset
(x0lb, x1ub))
83
return
home.
ES_SUBSUMED
(*
this
);
84
if
(x0.cardMin()>x1.cardMax()) {
return
home.
ES_SUBSUMED
(*
this
); }
85
LubRanges<View0>
x0ub(x0);
86
GlbRanges<View1>
x1lb(x1);
87
Iter::Ranges::Diff<LubRanges<View0>
,
GlbRanges<View1>
>
88
breakers(x0ub,x1lb);
89
if
(!breakers()) {
return
ES_FAILED
; }
90
if
(breakers.
min
() == breakers.
max
()) {
91
int
b1
= breakers.
min
();
92
++breakers;
93
if
(breakers()) {
return
ES_FIX
; }
94
//Only one subsetness-breaker element left:
95
GECODE_ME_CHECK
( x0.include(home,
b1
) );
96
GECODE_ME_CHECK
( x1.exclude(home,
b1
) );
97
return
home.
ES_SUBSUMED
(*
this
);
98
}
99
return
ES_FIX
;
100
}
101
102
}}}
103
104
// STATISTICS: set-prop
Gecode::x
Post propagator for SetVar x
Definition:
set.hh:784
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::y
Post propagator for SetVar SetOpType SetVar y
Definition:
set.hh:784
Gecode::Set::Rel::NoSubset::propagate
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
Definition:
nosubset.hpp:79
forceinline
#define forceinline
Definition:
config.hpp:173
Gecode::me_failed
bool me_failed(ModEvent me)
Check whether modification event me is failed.
Definition:
modevent.hpp:58
Gecode::Space::ES_SUBSUMED
ExecStatus ES_SUBSUMED(Propagator &p)
Definition:
core.hpp:3614
Gecode::SetVar::cardMin
unsigned int cardMin(void) const
Return cardinality minimum.
Definition:
set.hpp:82
Gecode::Space
Computation spaces.
Definition:
core.hpp:1748
Gecode::Actor
Base-class for both propagators and branchers.
Definition:
core.hpp:696
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:101
Gecode::Set::Rel::NoSubset::post
static ExecStatus post(Home home, View0 x, View1 y)
Post propagator .
Definition:
nosubset.hpp:64
Gecode
Gecode toplevel namespace
Gecode::MixBinaryPropagator
Mixed binary propagator.
Definition:
propagator.hpp:213
Gecode::Set::Rel::NoSubset::NoSubset
NoSubset(Space &home, bool share, NoSubset &p)
Constructor for cloning p.
Definition:
nosubset.hpp:57
Gecode::Iter::Ranges::MinMax::min
int min(void) const
Return smallest value of range.
Definition:
ranges-minmax.hpp:103
Test::Int::Basic::b1
Basic b1(3)
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::Home
Home class for posting propagators
Definition:
core.hpp:922
Gecode::Iter::Ranges::Diff
Range iterator for computing set difference.
Definition:
ranges-diff.hpp:47
Gecode::Set::GlbRanges
Range iterator for the greatest lower bound.
Definition:
var-imp.hpp:363
Gecode::Set::Rel::NoSubset::copy
virtual Actor * copy(Space &home, bool share)
Copy propagator during cloning.
Definition:
nosubset.hpp:73
Gecode::ES_FIX
@ ES_FIX
Propagation has computed fixpoint.
Definition:
core.hpp:545
Gecode::Set::LubRanges
Range iterator for the least upper bound.
Definition:
var-imp.hpp:321
Gecode::Iter::Ranges::MinMax::max
int max(void) const
Return largest value of range.
Definition:
ranges-minmax.hpp:107
GECODE_ME_CHECK
#define GECODE_ME_CHECK(me)
Check whether modification event me is failed, and forward failure.
Definition:
macros.hpp:56
Gecode::Set::Rel::NoSubset
Propagator for the negated subset constraint
Definition:
rel.hh:90
Gecode::ES_FAILED
@ ES_FAILED
Execution has resulted in failure.
Definition:
core.hpp:542
Gecode::ModEventDelta
int ModEventDelta
Modification event deltas.
Definition:
core.hpp:169
Gecode::ES_OK
@ ES_OK
Execution is okay.
Definition:
core.hpp:544
p
int p
Number of positive literals for node type.
Definition:
bool-expr.cpp:236
Gecode::ExecStatus
ExecStatus
Definition:
core.hpp:540