33
33
34
34
#ifdef GECODE_HAS_CBS
35
35
36
- #include < vector>
37
36
#include < limits>
38
37
#include < algorithm>
39
38
@@ -75,14 +74,18 @@ class ValToUpdate {
75
74
private:
76
75
const size_t width;
77
76
const int minVal;
78
- std::vector<double > mincUpdate;
79
- std::vector<double > liangUpdate;
77
+ Region r;
78
+ double * mincUpdate;
79
+ double * liangUpdate;
80
80
public:
81
81
template <class View >
82
82
ValToUpdate (const ViewArray<View>& x, int minDomVal, int maxDomVal)
83
- : width(maxDomVal - minDomVal + 1 ), minVal(minDomVal),
84
- mincUpdate (width, 1.0 ),
85
- liangUpdate(width, 1.0 ) {
83
+ : width(maxDomVal - minDomVal + 1 ),
84
+ minVal (minDomVal) {
85
+ mincUpdate = r.alloc <double >(width);
86
+ std::fill (mincUpdate, mincUpdate + width, 1 );
87
+ liangUpdate = r.alloc <double >(width);
88
+ std::fill (liangUpdate, liangUpdate + width, 1 );
86
89
87
90
for (int i=0 ; i<x.size (); i++) {
88
91
if (x[i].assigned ()) continue ;
@@ -120,7 +123,7 @@ void cbsdistinct(Space&, unsigned int prop_id, const ViewArray<View>& x,
120
123
UB ub{1 ,1 };
121
124
for (int i=0 ; i<x.size (); i++) {
122
125
unsigned int s = x[i].size ();
123
- if (s >= MAX_MINC_FACTORS || s >= WIDTH_LIANG_BAI_FACTORS)
126
+ if (( s >= MAX_MINC_FACTORS) || ( s >= WIDTH_LIANG_BAI_FACTORS) )
124
127
throw Gecode::Exception (" Int::Distinct::cbsdistinct" ,
125
128
" Variable cardinality too big for using counting-based"
126
129
" search with distinct constraints" );
@@ -143,7 +146,8 @@ void cbsdistinct(Space&, unsigned int prop_id, const ViewArray<View>& x,
143
146
144
147
// Preallocated memory for holding solution counts for all values of a
145
148
// variable during computation
146
- std::vector<double > solCounts (maxVal - minVal + 1 );
149
+ Region r;
150
+ double * solCounts = r.alloc <double >(maxVal - minVal + 1 );
147
151
148
152
for (int i=0 ; i<x.size (); i++) {
149
153
if (x[i].assigned ()) continue ;
0 commit comments