/usr/include/gecode/int/element.hh is in libgecode-dev 4.4.0-5.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 | /* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
/*
* Main authors:
* Christian Schulte <schulte@gecode.org>
* Guido Tack <tack@gecode.org>
*
* Copyright:
* Christian Schulte, 2004
* Guido Tack, 2004
*
* Last modified:
* $Date: 2015-01-16 14:10:48 +0100 (Fri, 16 Jan 2015) $ by $Author: schulte $
* $Revision: 14362 $
*
* This file is part of Gecode, the generic constraint
* development environment:
* http://www.gecode.org
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/
#ifndef __GECODE_INT_ELEMENT_HH__
#define __GECODE_INT_ELEMENT_HH__
#include <gecode/int.hh>
#include <gecode/int/rel.hh>
#include <gecode/int/idx-view.hh>
/**
* \namespace Gecode::Int::Element
* \brief %Element propagators
*/
namespace Gecode { namespace Int { namespace Element {
/**
* \brief %Element propagator for array of integers
*
* Requires \code #include <gecode/int/element.hh> \endcode
* \ingroup FuncIntProp
*/
template<class V0, class V1, class Idx, class Val>
class Int : public Propagator {
protected:
/**
* \brief Linked index-value pairs
*
* Data structure linking pairs of index and value (index,value)
* where pairs are linked in order of both index and
* value (to allow for easy removal while keeping both index and
* value sorted).
*/
class IdxVal {
public:
Idx idx_next; ///< The position of the next pair in index order
Idx val_next; ///< The position of the next pair in value order
Idx idx; ///< The index
Val val; ///< The value
/// Mark that this pair should be removed
void mark(void);
/// Return whether this pair is marked for removal
bool marked(void) const;
};
/**
* \brief Value iterator for indices in index-value map
*
* The iterator also removes marked index-value pairs.
*
*/
class IterIdxUnmark {
private:
IdxVal* iv; ///< The index value data structure
Idx i; ///< Current index value pair
public:
/// Initialize with start
IterIdxUnmark(IdxVal* iv);
/// Test whether more pairs to be iterated
bool operator ()(void) const;
/// Move to next index value pair (next index)
void operator ++(void);
/// Return index of current index value pair
Idx val(void) const;
};
/**
* \brief Value iterator for values in index-value map
*
* Note that the iterated value sequence is not strictly
* increasing (might contain duplicates).
*/
class IterVal {
private:
IdxVal* iv; ///< The index value data structure
Idx i; ///< Current index value pair
public:
/// Initialize with start
IterVal(IdxVal* iv);
/// Test whether more pairs to be iterated
bool operator ()(void) const;
/// Move to next index value pair (next value)
void operator ++(void);
/// Return value of current index value pair
Val val(void) const;
};
/**
* \brief Value iterator for values in index-value map
*
* Note that the iterated value sequence is not strictly
* increasing (might contain duplicates).
*
* The iterator also removes marked index-value pairs.
*/
class IterValUnmark {
private:
IdxVal* iv; ///< The index value data structure
Idx i; ///< Current index value pair
public:
/// Initialize with start
IterValUnmark(IdxVal* iv);
/// Test whether more pairs to be iterated
bool operator ()(void) const;
/// Move to next index value pair (next value)
void operator ++(void);
/// Return value of current index value pair
Val val(void) const;
};
/// Sorting pointers to (index,value) pairs in value order
class ByVal {
protected:
const IdxVal* iv; ///< Index-value pairs
public:
/// Initialize with index value pairs
ByVal(const IdxVal* iv);
/// Compare pairs at positions \a i and \a j
bool operator ()(Idx& i, Idx& j);
};
/// View for index
V0 x0;
/// Type for index size
typedef typename Gecode::Support::IntTypeTraits<Idx>::utype IdxSize;
/// Size of \a x0 at last execution
IdxSize s0;
/// View for result
V1 x1;
/// Type for value size
typedef typename Gecode::Support::IntTypeTraits<Val>::utype ValSize;
/// Size of \a x1 at last execution
ValSize s1;
/// Shared array of integer values
IntSharedArray c;
/// The index-value data structure
IdxVal* iv;
/// Prune index according to \a x0
void prune_idx(void);
/// Prune values according to \a x1
void prune_val(void);
/// Prune when \a x1 is assigned
static ExecStatus assigned_val(Space& home, IntSharedArray& c,
V0 x0, V1 x1);
/// Constructor for cloning \a p
Int(Space& home, bool shared, Int& p);
/// Constructor for creation
Int(Home home, IntSharedArray& i, V0 x0, V1 x1);
public:
/// Perform copying during cloning
virtual Actor* copy(Space& home, bool share);
/// Const function (defined as high binary)
virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
/// Perform propagation
virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
/// Post propagator for \f$i_{x_0}=x_1\f$
static ExecStatus post(Home home, IntSharedArray& i, V0 x0, V1 x1);
/// Delete propagator and return its size
virtual size_t dispose(Space& home);
};
/// Post propagator with apropriate index and value types
template<class V0, class V1>
ExecStatus post_int(Home home, IntSharedArray& c, V0 x0, V1 x1);
/**
* \brief Base-class for element propagator for array of views
*
*/
template<class VA, class VB, class VC, PropCond pc_ac>
class View : public Propagator {
protected:
/// Current index-view map
IdxViewArray<VA> iv;
/// View for index
VB x0;
/// View for result
VC x1;
/// Constructor for cloning \a p
View(Space& home, bool share, View& p);
/// Constructor for creation
View(Home home, IdxViewArray<VA>& iv, VB x0, VC x1);
public:
// Cost function (defined as low linear)
virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
/// Delete propagator and return its size
virtual size_t dispose(Space& home);
};
/**
* \brief Bounds consistent element propagator for array of views
*
* Requires \code #include <gecode/int/element.hh> \endcode
* \ingroup FuncIntProp
*/
template<class VA, class VB, class VC>
class ViewBnd : public View<VA,VB,VC,PC_INT_BND> {
protected:
using View<VA,VB,VC,PC_INT_BND>::iv;
using View<VA,VB,VC,PC_INT_BND>::x0;
using View<VA,VB,VC,PC_INT_BND>::x1;
/// Constructor for cloning \a p
ViewBnd(Space& home, bool share, ViewBnd& p);
/// Constructor for creation
ViewBnd(Home home, IdxViewArray<VA>& iv, VB x0, VC x1);
public:
/// Perform copying during cloning
virtual Actor* copy(Space& home, bool share);
/// Perform propagation
virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
/// Post propagator for \f$iv_{x_0}=x_1\f$
static ExecStatus post(Home home, IdxViewArray<VA>& iv, VB x0, VC x1);
};
/**
* \brief Domain consistent element propagator for array of views
*
* The propagator uses staging: first it uses
* bounds-propagation on the array of views and the uses
* domain-propagation on the array of views.
*
* Requires \code #include <gecode/int/element.hh> \endcode
* \ingroup FuncIntProp
*/
template<class VA, class VB, class VC>
class ViewDom : public View<VA,VB,VC,PC_INT_DOM> {
protected:
using View<VA,VB,VC,PC_INT_DOM>::iv;
using View<VA,VB,VC,PC_INT_DOM>::x0;
using View<VA,VB,VC,PC_INT_DOM>::x1;
/// Constructor for cloning \a p
ViewDom(Space& home, bool share, ViewDom& p);
/// Constructor for creation
ViewDom(Home home, IdxViewArray<VA>& iv, VB x0, VC x1);
public:
/// Perform copying during cloning
virtual Actor* copy(Space& home, bool share);
/**
* \brief Cost function
*
* If in stage for bounds-propagation defined as low linear,
* otherwise as high linear.
*
*/
virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
/// Perform propagation
virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
/// Post propagator for \f$iv_{x_0}=x_1\f$
static ExecStatus post(Home home, IdxViewArray<VA>& iv,
VB x0, VC x1);
};
/**
* \brief Domain consistent pair propagator
*
* Requires \code #include <gecode/int/element.hh> \endcode
*
* \ingroup FuncIntProp
*/
class GECODE_VTABLE_EXPORT Pair
: public TernaryPropagator<IntView,PC_INT_DOM> {
protected:
using TernaryPropagator<IntView,PC_INT_DOM>::x0;
using TernaryPropagator<IntView,PC_INT_DOM>::x1;
using TernaryPropagator<IntView,PC_INT_DOM>::x2;
/// Width
int w;
/// Constructor for cloning \a p
Pair(Space& home, bool share, Pair& p);
public:
/// Constructor for posting
Pair(Home home, IntView x0, IntView x1, IntView x2, int w);
/// Post propagator \f$x_0+x_1\cdot w=x_2\f$
static ExecStatus post(Home home, IntView x0, IntView x1, IntView x2,
int w, int h);
/// Copy propagator during cloning
GECODE_INT_EXPORT virtual Actor* copy(Space& home, bool share);
/// Perform propagation
GECODE_INT_EXPORT virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
};
}}}
#include <gecode/int/element/int.hpp>
#include <gecode/int/element/view.hpp>
#include <gecode/int/element/pair.hpp>
#endif
// STATISTICS: int-prop
|