This file is indexed.

/usr/include/gecode/int/channel/val.hpp is in libgecode-dev 5.1.0-2build1.

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
/* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
/*
 *  Main authors:
 *     Christian Schulte <schulte@gecode.org>
 *
 *  Contributing authors:
 *     Mikael Lagerkvist <lagerkvist@gecode.org>
 *
 *  Copyright:
 *     Christian Schulte, 2006
 *     Mikael Lagerkvist, 2006
 *
 *  Last modified:
 *     $Date: 2016-04-19 17:19:45 +0200 (Tue, 19 Apr 2016) $ by $Author: schulte $
 *     $Revision: 14967 $
 *
 *  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.
 *
 */

namespace Gecode { namespace Int { namespace Channel {

  /**
   * \brief Combine view with information for value propagation
   *
   */
  template<class View>
  class ValInfo {
  public:
    /// The view
    View view;
    /// Whether it has been propagated that view is assigned
    bool a;
    /// Initialize
    void init(View x, int n);
    /// Update during cloning
    void update(Space& home, bool share, ValInfo<View>& vi);
    /// Check whether propagation for assignment is to be done
    bool doval(void) const;
    /// Check whether propagation for domain is to be done
    bool dodom(void) const;
    /// Record that view got assigned
    void assigned(void);
    /// Record that one value got removed
    void removed(int i);
    /// Update the cardinality and bounds information after pruning
    void done(void);
  };

  template<class View>
  forceinline void
  ValInfo<View>::init(View x, int) {
    view = x; a = false;
  }

  template<class View>
  forceinline void
  ValInfo<View>::update(Space& home, bool share, ValInfo<View>& vi) {
    view.update(home,share,vi.view); a = vi.a;
  }

  template<class View>
  forceinline bool
  ValInfo<View>::doval(void) const {
    return !a && view.assigned();
  }

  template<class View>
  forceinline bool
  ValInfo<View>::dodom(void) const {
    return false;
  }

  template<class View>
  forceinline void
  ValInfo<View>::assigned(void) {
    a = true;
  }

  template<class View>
  forceinline void
  ValInfo<View>::removed(int) {}

  template<class View>
  forceinline void
  ValInfo<View>::done(void) {}


  // Propagate assigned views for x
  template<class View, class Offset, class Info>
  ExecStatus
  doprop_val(Space& home, int n, Info* x, Offset& ox,
             Info* y, Offset& oy,
             int& n_na, ProcessStack& xa, ProcessStack& ya) {
    do {
      int i = xa.pop();
      int j = ox(x[i].view).val();
      // Assign the y variable to i (or test if already assigned!)
      {
        ModEvent me = oy(y[j].view).eq(home,i);
        if (me_failed(me)) {
          return ES_FAILED;
        }
        // Record that y[j] has been assigned and must be propagated
        if (me_modified(me))
          ya.push(j);
      }
      // Prune the value j from all x variables
      for (int k=i; k--; ) {
        ModEvent me = ox(x[k].view).nq(home,j);
        if (me_failed(me)) {
          return ES_FAILED;
        }
        if (me_modified(me)) {
          if (me == ME_INT_VAL) {
            // Record that x[k] has been assigned and must be propagated
            xa.push(k);
          } else {
            // One value has been removed and this removal does not need
            // to be propagated again: after all y[j] = i, so it holds
            // that y[j] != k.
            x[k].removed(j);
          }
        }
      }
      // The same for the other views
      for (int k=i+1; k<n; k++) {
        ModEvent me = ox(x[k].view).nq(home,j);
        if (me_failed(me)) {
          return ES_FAILED;
        }
        if (me_modified(me)) {
          if (me == ME_INT_VAL) {
            // Record that x[k] has been assigned and must be propagated
            xa.push(k);
          } else {
            // One value has been removed and this removal does not need
            // to be propagated again: after all y[j] = i, so it holds
            // that y[j] != k.
            x[k].removed(j);
          }
        }
      }
      x[i].assigned(); n_na--;
    } while (!xa.empty());
    return ES_OK;
  }

  // Just do a test whether a call to the routine is necessary
  template<class View, class Offset, class Info>
  forceinline ExecStatus
  prop_val(Space& home, int n, Info* x, Offset& ox, Info* y, Offset& oy,
           int& n_na, ProcessStack& xa, ProcessStack& ya) {
    if (xa.empty())
      return ES_OK;
    return doprop_val<View,Offset,Info>(home,n,x,ox,y,oy,n_na,xa,ya);
  }

  /*
   * The actual propagator
   *
   */
  template<class View, class Offset, bool shared>
  forceinline
  Val<View,Offset,shared>::Val(Home home, int n, ValInfo<View>* xy,
                               Offset& ox, Offset& oy)
    : Base<ValInfo<View>,Offset,PC_INT_VAL>(home,n,xy,ox,oy) {}

  template<class View, class Offset, bool shared>
  forceinline
  Val<View,Offset,shared>::Val(Space& home, bool share,
                               Val<View,Offset,shared>& p)
    : Base<ValInfo<View>,Offset,PC_INT_VAL>(home,share,p) {}

  template<class View, class Offset, bool shared>
  Actor*
  Val<View,Offset,shared>::copy(Space& home, bool share) {
    return new (home) Val<View,Offset,shared>(home,share,*this);
  }

  template<class View, class Offset, bool shared>
  ExecStatus
  Val<View,Offset,shared>::propagate(Space& home, const ModEventDelta&) {
    Region r(home);
    ProcessStack xa(r,n);
    ProcessStack ya(r,n);

    ValInfo<View>* x = xy;
    ValInfo<View>* y = xy+n;

    // Scan x and y for assigned but not yet propagated views
    for (int i = n; i--; ) {
      if (x[i].doval()) xa.push(i);
      if (y[i].doval()) ya.push(i);
    }

    do {
      // Propagate assigned views for x
      GECODE_ES_CHECK((prop_val<View,Offset,ValInfo<View> >
                       (home,n,x,ox,y,oy,n_na,xa,ya)));
      // Propagate assigned views for y
      GECODE_ES_CHECK((prop_val<View,Offset,ValInfo<View> >
                       (home,n,y,oy,x,ox,n_na,ya,xa)));
      assert(ya.empty());
    } while (!xa.empty());

    if (n_na == 0)
      return home.ES_SUBSUMED(*this);
    return shared ? ES_NOFIX : ES_FIX;
  }

  template<class View, class Offset, bool shared>
  ExecStatus
  Val<View,Offset,shared>::post(Home home, int n, ValInfo<View>* xy,
                                Offset& ox, Offset& oy) {
    assert(n > 0);
    if (n == 1) {
      GECODE_ME_CHECK(ox(xy[0].view).eq(home,0));
      GECODE_ME_CHECK(oy(xy[1].view).eq(home,0));
      return ES_OK;
    }
    for (int i=n; i--; ) {
      GECODE_ME_CHECK(ox(xy[i  ].view).gq(home,0));
      GECODE_ME_CHECK(ox(xy[i  ].view).le(home,n));
      GECODE_ME_CHECK(oy(xy[i+n].view).gq(home,0));
      GECODE_ME_CHECK(oy(xy[i+n].view).le(home,n));
    }
    (void) new (home) Val<View,Offset,shared>(home,n,xy,ox,oy);
    return ES_OK;
  }

}}}

// STATISTICS: int-prop