MCPcopy Create free account
hub / github.com/Gecode/gecode / ExecStatus edgefinding

Function ExecStatus edgefinding

gecode/int/cumulative/edge-finding.hpp:67–174  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

65
66 template<class TaskView>
67 forceinline ExecStatus
68 edgefinding(Space& home, int c, TaskViewArray<TaskView>& t) {
69 sort<TaskView,STO_LCT,false>(t);
70
71 Region r;
72
73 ///////////////////////
74 // Detection
75
76 int* prec = r.alloc<int>(t.size());
77 for (int i=0; i<t.size(); i++)
78 prec[i] = t[i].ect();
79
80 OmegaLambdaTree<TaskView> ol(r,c,t);
81
82 for (int j=0; j<t.size(); j++) {
83 while (!ol.lempty() &&
84 (ol.lenv() > static_cast<long long int>(c)*t[j].lct())) {
85 int i = ol.responsible();
86 prec[i] = std::max(prec[i], t[j].lct());
87 ol.lremove(i);
88 }
89 ol.shift(j);
90 }
91
92 ///////////////////////
93 // Propagation
94
95 // Compute array of unique capacities and a mapping
96 // from the task array to the corresponding entry in
97 // the capacity array
98
99 int* cap = r.alloc<int>(t.size());
100 for (int i=0; i<t.size(); i++)
101 cap[i] = i;
102 SortMap<TaskView,StoCap,true> o(t);
103 Support::quicksort(cap, t.size(), o);
104
105 int* capacities = r.alloc<int>(t.size());
106 int* capInv = r.alloc<int>(t.size());
107 for (int i=t.size(); i--;) {
108 capacities[cap[i]] = t[i].c();
109 capInv[cap[i]] = i;
110 }
111
112 int n_c = 0;
113 for (int i=0, cur_c=INT_MIN; i<t.size(); i++) {
114 if (capacities[i] != cur_c)
115 capacities[n_c++] = cur_c = capacities[i];
116 cap[capInv[i]] = n_c-1;
117 }
118 r.free<int>(capInv, t.size());
119
120 // Compute update values for each capacity and LCut
121
122 int* update = r.alloc<int>(t.size()*n_c);
123 for (int i=0; i<t.size()*n_c; i++)
124 update[i] = -Limits::infinity;

Callers

nothing calls this directly

Calls 15

quicksortFunction · 0.85
plusFunction · 0.85
ceil_div_xxFunction · 0.85
lenvMethod · 0.80
envMethod · 0.80
maxFunction · 0.50
sizeMethod · 0.45
ectMethod · 0.45
lemptyMethod · 0.45
lctMethod · 0.45
responsibleMethod · 0.45
lremoveMethod · 0.45

Tested by

no test coverage detected