Generated on Tue Feb 11 2025 17:33:26 for Gecode by doxygen 1.12.0
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
34namespace 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>
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 }
69 template<class Info, class Offset, PropCond pc>
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 }
78}}}
79
80// STATISTICS: int-prop
81
int p
Number of positive literals for node type.
int n
Number of negative literals for node type.
virtual size_t dispose(Space &home)
Delete actor and return its size.
Definition core.hpp:3252
Home class for posting propagators
Definition core.hpp:856
Base-class for channel propagators.
Definition channel.hh:55
Base(Space &home, Base< Info, Offset, pc > &p)
Constructor for cloning p.
Definition base.hpp:47
Offset oy
Offset transformation for y variables.
Definition channel.hh:64
int n
Number of views (actually twice as many for both x and y)
Definition channel.hh:58
Offset ox
Offset transformation for x variables.
Definition channel.hh:62
virtual size_t dispose(Space &home)
Delete propagator and return its size.
Definition base.hpp:71
virtual PropCost cost(const Space &home, const ModEventDelta &med) const
Propagation cost (defined as low quadratic)
Definition base.hpp:58
Info * xy
View and information for both x and y.
Definition channel.hh:66
virtual void reschedule(Space &home)
Schedule function.
Definition base.hpp:64
Converter with fixed offset.
Definition view.hpp:650
void update(const Offset &o)
Update during cloning.
Propagation cost.
Definition core.hpp:486
static PropCost quadratic(PropCost::Mod m, unsigned int n)
Quadratic complexity for modifier m and size measure n.
Definition core.hpp:4787
Base-class for propagators.
Definition core.hpp:1064
Computation spaces.
Definition core.hpp:1742
int ModEventDelta
Modification event deltas.
Definition core.hpp:89
Gecode toplevel namespace
#define forceinline
Definition config.hpp:187