Generated on Sat Feb 7 2015 02:01:30 for Gecode by doxygen 1.8.9.1
card.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-30 15:34:12 +0200 (Tue, 30 Mar 2010) $ by $Author: tack $
15  * $Revision: 10603 $
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 #include <gecode/set.hh>
43 #include <gecode/int.hh>
44 
45 namespace Gecode { namespace Set { namespace Int {
46 
47  template<class View>
51  Gecode::Int::IntView,Gecode::Int::PC_INT_BND> (home, y0, y1) {}
52 
53  template<class View>
56  GECODE_ME_CHECK(x1.gq(home,0));
57  GECODE_ME_CHECK(x0.cardMax(home, Gecode::Int::Limits::max));
58  (void) new (home) Card(home,x0,x1);
59  return ES_OK;
60  }
61 
62  template<class View>
64  Card<View>::Card(Space& home, bool share, Card& p)
66  Gecode::Int::IntView,Gecode::Int::PC_INT_BND> (home, share, p) {}
67 
68  template<class View>
69  Actor*
70  Card<View>::copy(Space& home, bool share) {
71  return new (home) Card(home,share,*this);
72  }
73 
74  template<class View>
77  int x1min, x1max;
78  do {
79  x1min = x1.min();
80  x1max = x1.max();
81  GECODE_ME_CHECK(x0.cardMin(home,static_cast<unsigned int>(x1min)));
82  GECODE_ME_CHECK(x0.cardMax(home,static_cast<unsigned int>(x1max)));
83  GECODE_ME_CHECK(x1.gq(home,static_cast<int>(x0.cardMin())));
84  GECODE_ME_CHECK(x1.lq(home,static_cast<int>(x0.cardMax())));
85  } while (x1.min() > x1min || x1.max() < x1max);
86  if (x1.assigned())
87  return home.ES_SUBSUMED(*this);
88  return ES_FIX;
89  }
90 
91 }}}
92 
93 // STATISTICS: set-prop
const Gecode::PropCond PC_SET_CARD
Propagate when the cardinality of a view changes.
Definition: var-type.hpp:216
ExecStatus ES_SUBSUMED(Propagator &p)
Definition: core.hpp:2973
Propagation has computed fixpoint.
Definition: core.hpp:528
const int max
Largest allowed integer value.
Definition: int.hh:113
Computation spaces.
Definition: core.hpp:1362
Base-class for both propagators and branchers.
Definition: core.hpp:666
static ExecStatus post(Home home, View s, Gecode::Int::IntView x)
Post propagator for .
Definition: card.hpp:55
int p
Number of positive literals for node type.
Definition: bool-expr.cpp:236
const Gecode::PropCond PC_INT_BND
Propagate when minimum or maximum of a view changes.
Definition: var-type.hpp:91
#define GECODE_ME_CHECK(me)
Check whether modification event me is failed, and forward failure.
Definition: macros.hpp:45
Integer view for integer variables.
Definition: view.hpp:129
Card(Space &home, bool share, Card &p)
Constructor for cloning p.
Definition: card.hpp:64
Mixed binary propagator.
Definition: propagator.hpp:203
virtual Actor * copy(Space &home, bool)
Copy propagator during cloning.
Definition: card.hpp:70
ExecStatus
Definition: core.hpp:523
#define forceinline
Definition: config.hpp:132
ModEvent gq(Space &home, int n)
Restrict domain values to be greater or equal than n.
Definition: int.hpp:133
Execution is okay.
Definition: core.hpp:527
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
Definition: card.hpp:76
Gecode toplevel namespace
int ModEventDelta
Modification event deltas.
Definition: core.hpp:173
Home class for posting propagators
Definition: core.hpp:717
Propagator for cardinality
Definition: int.hh:233