This file is indexed.

/usr/include/gecode/int/cumulative/edge-finding.hpp is in libgecode-dev 3.7.1-3.

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
/* -*- 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, 2009
 *     Guido Tack, 2010
 *
 *  Last modified:
 *     $Date: 2011-05-25 16:56:41 +0200 (Wed, 25 May 2011) $ by $Author: schulte $
 *     $Revision: 12022 $
 *
 *  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.
 *
 */

#include <algorithm>

namespace Gecode { namespace Int { namespace Cumulative {

  /// Sort by capacity
  template<class TaskView, bool inc>
  class StoCap {
  public:
    /// Sort order
    bool operator ()(const TaskView& t1, const TaskView& t2) const {
      return inc ? (t1.c() < t2.c()) : (t2.c() < t1.c());
    }
  };

  /// Sort by prec array
  class PrecOrder {
  public:
    int* prec;
    /// Constructor
    PrecOrder(int* prec0) : prec(prec0) {}
    /// Sort order
    bool operator ()(int i, int j) const {
      return prec[i] > prec[j];
    }
  };

  template<class TaskView>
  forceinline ExecStatus
  edgefinding(Space& home, int c, TaskViewArray<TaskView>& t) {
    sort<TaskView,STO_LCT,false>(t);

    Region r(home);

    ///////////////////////
    // Detection

    int* prec = r.alloc<int>(t.size());
    for (int i=t.size(); i--; )
      prec[i] = t[i].ect();

    OmegaLambdaTree<TaskView> ol(r,c,t);

    for (int j=0; j<t.size(); j++) {
      while (!ol.lempty() && 
             (ol.lenv() > static_cast<double>(c)*t[j].lct())) {
        int i = ol.responsible();
        prec[i] = std::max(prec[i], t[j].lct());
        ol.lremove(i);
      }
      ol.shift(j);
    }      

    ///////////////////////
    // Propagation
    
    // Compute array of unique capacities and a mapping
    // from the task array to the corresponding entry in
    // the capacity array
    
    int* cap = r.alloc<int>(t.size());
    for (int i=t.size(); i--;)
      cap[i] = i;
    SortMap<TaskView,StoCap,true> o(t);
    Support::quicksort(cap, t.size(), o);

    int* capacities = r.alloc<int>(t.size());
    int* capInv = r.alloc<int>(t.size());
    for (int i=t.size(); i--;) {
      capacities[cap[i]] = t[i].c();
      capInv[cap[i]] = i;
    }
    
    int n_c = 0;
    for (int i=0, cur_c=INT_MIN; i<t.size(); i++) {
      if (capacities[i] != cur_c)
        capacities[n_c++] = cur_c = capacities[i];
      cap[capInv[i]] = n_c-1;
    }
    r.free<int>(capInv, t.size());

    // Compute update values for each capacity and LCut

    int* update = r.alloc<int>(t.size()*n_c);
    for (int i=t.size()*n_c; i--;)
      update[i] = -Int::Limits::infinity;

    ExtOmegaTree<TaskView> eo(r,c,ol);
    for (int i=0; i<n_c; i++) {
      eo.init(capacities[i]);
      int u = -Int::Limits::infinity;
      for (int j=t.size(); j--;) {
        double lctj = static_cast<double>(c-capacities[i])*t[j].lct();
        double diff_d = ceil(div(plus(eo.env(j), -lctj),capacities[i]));
        int diff = (diff_d == -Int::Limits::double_infinity) ? 
          -Int::Limits::infinity : static_cast<int>(diff_d);
        u = std::max(u,diff);
        update[i*t.size()+j] = u;
      }
    }

    // Update est by iterating in parallel over the prec array
    // and the task array, both sorted by lct

    int* precMap = r.alloc<int>(t.size());
    for (int i=t.size(); i--;)
      precMap[i] = i;
    PrecOrder po(prec);
    Support::quicksort(precMap, t.size(), po);
    
    int curJ = 0;
    for (int i=0; i<t.size(); i++) {
      while (curJ < t.size() && t[curJ].lct() > prec[precMap[i]])
        curJ++;
      while (curJ < t.size() && t[curJ].lct() == prec[precMap[i]]) {
        if (t[curJ].lct() != t[precMap[i]].lct()) {
          GECODE_ME_CHECK(
            t[precMap[i]].est(home,update[cap[precMap[i]]*t.size()+curJ]));
        }
        curJ++;
      }
    }

    return ES_OK;
  }

  template<class Task>
  ExecStatus
  edgefinding(Space& home, int c, TaskArray<Task>& t) {
    TaskViewArray<typename TaskTraits<Task>::TaskViewFwd> f(t);
    GECODE_ES_CHECK(edgefinding(home,c,f));
    TaskViewArray<typename TaskTraits<Task>::TaskViewBwd> b(t);
    GECODE_ES_CHECK(edgefinding(home,c,b));
    return ES_OK;
  }
    
}}}

// STATISTICS: int-prop