Generated on Sat Jun 2 2018 07:17:44 for Gecode by doxygen 1.8.13
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  * 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 
38 #include <gecode/set.hh>
39 #include <gecode/int.hh>
40 
41 namespace Gecode { namespace Set { namespace Int {
42 
43  template<class View>
47  Gecode::Int::IntView,Gecode::Int::PC_INT_BND> (home, y0, y1) {}
48 
49  template<class View>
52  GECODE_ME_CHECK(x1.gq(home,0));
53  GECODE_ME_CHECK(x0.cardMax(home, Gecode::Int::Limits::max));
54  (void) new (home) Card(home,x0,x1);
55  return ES_OK;
56  }
57 
58  template<class View>
62  Gecode::Int::IntView,Gecode::Int::PC_INT_BND> (home, p) {}
63 
64  template<class View>
65  Actor*
67  return new (home) Card(home,*this);
68  }
69 
70  template<class View>
73  int x1min, x1max;
74  do {
75  x1min = x1.min();
76  x1max = x1.max();
77  GECODE_ME_CHECK(x0.cardMin(home,static_cast<unsigned int>(x1min)));
78  GECODE_ME_CHECK(x0.cardMax(home,static_cast<unsigned int>(x1max)));
79  GECODE_ME_CHECK(x1.gq(home,static_cast<int>(x0.cardMin())));
80  GECODE_ME_CHECK(x1.lq(home,static_cast<int>(x0.cardMax())));
81  } while (x1.min() > x1min || x1.max() < x1max);
82  if (x1.assigned())
83  return home.ES_SUBSUMED(*this);
84  return ES_FIX;
85  }
86 
87 }}}
88 
89 // STATISTICS: set-prop
virtual Actor * copy(Space &home)
Copy propagator during cloning.
Definition: card.hpp:66
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:3482
#define forceinline
Definition: config.hpp:185
Propagation has computed fixpoint.
Definition: core.hpp:476
const int max
Largest allowed integer value.
Definition: int.hh:112
Computation spaces.
Definition: core.hpp:1701
Base-class for both propagators and branchers.
Definition: core.hpp:627
static ExecStatus post(Home home, View s, Gecode::Int::IntView x)
Post propagator for .
Definition: card.hpp:51
Card(Space &home, Card &p)
Constructor for cloning p.
Definition: card.hpp:60
int p
Number of positive literals for node type.
Definition: bool-expr.cpp:232
ModEvent lq(Space &home, int n)
Restrict domain values to be less or equal than n.
Definition: int.hpp:121
const Gecode::PropCond PC_INT_BND
Propagate when minimum or maximum of a view changes.
Definition: var-type.hpp:91
int min(void) const
Return minimum of domain.
Definition: int.hpp:58
#define GECODE_ME_CHECK(me)
Check whether modification event me is failed, and forward failure.
Definition: macros.hpp:52
Integer view for integer variables.
Definition: view.hpp:129
bool assigned(void) const
Test whether view is assigned.
Definition: view.hpp:504
Mixed binary propagator.
Definition: pattern.hpp:204
ExecStatus
Definition: core.hpp:471
ModEvent gq(Space &home, int n)
Restrict domain values to be greater or equal than n.
Definition: int.hpp:139
Execution is okay.
Definition: core.hpp:475
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
Definition: card.hpp:72
Gecode toplevel namespace
int max(void) const
Return maximum of domain.
Definition: int.hpp:62
int ModEventDelta
Modification event deltas.
Definition: core.hpp:89
Home class for posting propagators
Definition: core.hpp:853
Propagator for cardinality
Definition: int.hh:229