Generated on Sat Jan 12 2019 20:58:51 for Gecode by doxygen 1.8.13
base.hpp
Go to the documentation of this file.
1 /* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
2 /*
3  * Main authors:
4  * Christian Schulte <schulte@gecode.org>
5  *
6  * Copyright:
7  * Christian Schulte, 2006
8  *
9  * This file is part of Gecode, the generic constraint
10  * development environment:
11  * http://www.gecode.org
12  *
13  * Permission is hereby granted, free of charge, to any person obtaining
14  * a copy of this software and associated documentation files (the
15  * "Software"), to deal in the Software without restriction, including
16  * without limitation the rights to use, copy, modify, merge, publish,
17  * distribute, sublicense, and/or sell copies of the Software, and to
18  * permit persons to whom the Software is furnished to do so, subject to
19  * the following conditions:
20  *
21  * The above copyright notice and this permission notice shall be
22  * included in all copies or substantial portions of the Software.
23  *
24  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
25  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
26  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
27  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
28  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
29  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
30  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
31  *
32  */
33 
34 namespace Gecode { namespace Int { namespace Channel {
35 
36  template<class Info, class Offset, PropCond pc>
38  Base<Info,Offset,pc>::Base(Home home, int n0, Info* xy0,
39  Offset& ox0, Offset& oy0)
40  : Propagator(home), n(n0), n_na(2*n), ox(ox0), oy(oy0), xy(xy0) {
41  for (int i=0; i<2*n; i++)
42  xy[i].view.subscribe(home,*this,pc);
43  }
44 
45  template<class Info, class Offset, PropCond pc>
48  : Propagator(home,p), n(p.n), n_na(p.n_na),
49  xy(home.alloc<Info>(2*n)) {
50  ox.update(p.ox);
51  oy.update(p.oy);
52  for (int i=0; i<2*n; i++)
53  xy[i].update(home,p.xy[i]);
54  }
55 
56  template<class Info, class Offset, PropCond pc>
57  PropCost
59  return PropCost::quadratic(PropCost::LO, 2*n);
60  }
61 
62  template<class Info, class Offset, PropCond pc>
63  void
65  for (int i=0; i<2*n; i++)
66  xy[i].view.reschedule(home,*this,pc);
67  }
68 
69  template<class Info, class Offset, PropCond pc>
70  forceinline size_t
72  for (int i=0; i<2*n; i++)
73  xy[i].view.cancel(home,*this,pc);
74  (void) Propagator::dispose(home);
75  return sizeof(*this);
76  }
77 
78 }}}
79 
80 // STATISTICS: int-prop
81 
Base(Space &home, Base< Info, Offset, pc > &p)
Constructor for cloning p.
Definition: base.hpp:47
Offset ox
Offset transformation for x variables.
Definition: channel.hh:62
Base-class for propagators.
Definition: core.hpp:1023
Info * xy
View and information for both x and y.
Definition: channel.hh:66
Offset oy
Offset transformation for y variables.
Definition: channel.hh:64
#define forceinline
Definition: config.hpp:185
Computation spaces.
Definition: core.hpp:1701
int p
Number of positive literals for node type.
Definition: bool-expr.cpp:232
int n
Number of negative literals for node type.
Definition: bool-expr.cpp:234
Gecode::IntArgs i({1, 2, 3, 4})
Converter with fixed offset.
Definition: view.hpp:650
Base-class for channel propagators.
Definition: channel.hh:55
Propagation cost.
Definition: core.hpp:485
Gecode toplevel namespace
void reschedule(Space &home, Propagator &p, IntSet &y)
Definition: rel.hpp:92
int ModEventDelta
Modification event deltas.
Definition: core.hpp:89
Home class for posting propagators
Definition: core.hpp:853
void update(IntSet &y, Space &home, IntSet &py)
Definition: rel.hpp:103