dep_selector 0.0.7 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- data/ext/dep_gecode/dep_selector_swig.i +1 -1
- data/ext/dep_gecode/dep_selector_swig_wrap.cxx +11 -3
- data/ext/dep_gecode/dep_selector_to_gecode.cpp +107 -102
- data/ext/dep_gecode/dep_selector_to_gecode.h +2 -1
- data/ext/dep_gecode/dep_selector_to_gecode_interface.cpp +2 -2
- data/ext/dep_gecode/dep_selector_to_gecode_interface.h +1 -1
- data/lib/dep_selector/dep_selector_version.rb +1 -1
- data/lib/dep_selector/gecode_wrapper.rb +3 -1
- metadata +3 -3
@@ -27,7 +27,7 @@
|
|
27
27
|
|
28
28
|
class VersionProblem;
|
29
29
|
|
30
|
-
VersionProblem * VersionProblemCreate(int packageCount, bool dumpStats);
|
30
|
+
VersionProblem * VersionProblemCreate(int packageCount, bool dumpStats, bool debug);
|
31
31
|
void VersionProblemDestroy(VersionProblem * vp);
|
32
32
|
|
33
33
|
int VersionProblemSize(VersionProblem *p);
|
@@ -1673,15 +1673,18 @@ SWIGINTERN VALUE
|
|
1673
1673
|
_wrap_VersionProblemCreate(int argc, VALUE *argv, VALUE self) {
|
1674
1674
|
int arg1 ;
|
1675
1675
|
bool arg2 ;
|
1676
|
+
bool arg3 ;
|
1676
1677
|
VersionProblem *result = 0 ;
|
1677
1678
|
int val1 ;
|
1678
1679
|
int ecode1 = 0 ;
|
1679
1680
|
bool val2 ;
|
1680
1681
|
int ecode2 = 0 ;
|
1682
|
+
bool val3 ;
|
1683
|
+
int ecode3 = 0 ;
|
1681
1684
|
VALUE vresult = Qnil;
|
1682
1685
|
|
1683
|
-
if ((argc <
|
1684
|
-
rb_raise(rb_eArgError, "wrong # of arguments(%d for
|
1686
|
+
if ((argc < 3) || (argc > 3)) {
|
1687
|
+
rb_raise(rb_eArgError, "wrong # of arguments(%d for 3)",argc); SWIG_fail;
|
1685
1688
|
}
|
1686
1689
|
ecode1 = SWIG_AsVal_int(argv[0], &val1);
|
1687
1690
|
if (!SWIG_IsOK(ecode1)) {
|
@@ -1693,7 +1696,12 @@ _wrap_VersionProblemCreate(int argc, VALUE *argv, VALUE self) {
|
|
1693
1696
|
SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "VersionProblemCreate" "', argument " "2"" of type '" "bool""'");
|
1694
1697
|
}
|
1695
1698
|
arg2 = static_cast< bool >(val2);
|
1696
|
-
|
1699
|
+
ecode3 = SWIG_AsVal_bool(argv[2], &val3);
|
1700
|
+
if (!SWIG_IsOK(ecode3)) {
|
1701
|
+
SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "VersionProblemCreate" "', argument " "3"" of type '" "bool""'");
|
1702
|
+
}
|
1703
|
+
arg3 = static_cast< bool >(val3);
|
1704
|
+
result = (VersionProblem *)VersionProblemCreate(arg1,arg2,arg3);
|
1697
1705
|
vresult = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_VersionProblem, 0 | 0 );
|
1698
1706
|
return vresult;
|
1699
1707
|
fail:
|
@@ -32,6 +32,7 @@
|
|
32
32
|
|
33
33
|
//#define MEMORY_DEBUG
|
34
34
|
//#define DEBUG
|
35
|
+
#define DEBUG_STREAM std::cerr
|
35
36
|
//#define USE_DUMB_BRANCHING
|
36
37
|
#define VECTOR_CONSTRAIN
|
37
38
|
|
@@ -52,7 +53,7 @@ void VersionProblemPool::Add(VersionProblem * vp)
|
|
52
53
|
{
|
53
54
|
vp->pool = this;
|
54
55
|
#ifdef MEMORY_DEBUG
|
55
|
-
|
56
|
+
DEBUG_STREAM << "Pool add\t" << vp << std::endl << std::flush;
|
56
57
|
#endif // MEMORY_DEBUG
|
57
58
|
elems.insert(vp);
|
58
59
|
}
|
@@ -61,7 +62,7 @@ void VersionProblemPool::Delete(VersionProblem *vp)
|
|
61
62
|
if (vp->pool != 0)
|
62
63
|
{
|
63
64
|
#ifdef MEMORY_DEBUG
|
64
|
-
|
65
|
+
DEBUG_STREAM << "Pool del\t" << vp << std::endl << std::flush;
|
65
66
|
#endif // MEMORY_DEBUG
|
66
67
|
elems.erase(vp);
|
67
68
|
vp->pool = 0;
|
@@ -69,14 +70,14 @@ void VersionProblemPool::Delete(VersionProblem *vp)
|
|
69
70
|
}
|
70
71
|
void VersionProblemPool::ShowAll()
|
71
72
|
{
|
72
|
-
|
73
|
+
DEBUG_STREAM << "ShowAll =====================================================" << std::endl << std::flush;
|
73
74
|
std::set<VersionProblem *>::iterator i;
|
74
75
|
for(i = elems.begin(); i != elems.end(); i++) {
|
75
76
|
#ifdef MEMORY_DEBUG
|
76
|
-
|
77
|
+
DEBUG_STREAM << "ShowAll has\t\t\t" << *i << std::endl << std::flush;
|
77
78
|
#endif // MEMORY_DEBUG
|
78
79
|
}
|
79
|
-
|
80
|
+
DEBUG_STREAM << "ShowAll =====================================================" << std::endl << std::flush;
|
80
81
|
}
|
81
82
|
|
82
83
|
void VersionProblemPool::DeleteAll()
|
@@ -92,15 +93,15 @@ void VersionProblemPool::DeleteAll()
|
|
92
93
|
}
|
93
94
|
elems.clear();
|
94
95
|
#ifdef MEMORY_DEBUG
|
95
|
-
|
96
|
+
DEBUG_STREAM << "DeleteAll ===================================================" << std::endl << std::flush;
|
96
97
|
#endif
|
97
98
|
}
|
98
99
|
|
99
100
|
|
100
101
|
|
101
102
|
|
102
|
-
VersionProblem::VersionProblem(int packageCount, bool dumpStats)
|
103
|
-
|
103
|
+
VersionProblem::VersionProblem(int packageCount, bool dumpStats, bool debug)
|
104
|
+
: size(packageCount), version_constraint_count(0), dump_stats(dumpStats), debug_logging(debug),
|
104
105
|
finalized(false), cur_package(0), package_versions(*this, packageCount),
|
105
106
|
disabled_package_variables(*this, packageCount, 0, 1), total_disabled(*this, 0, packageCount*MAX_TRUST_LEVEL),
|
106
107
|
total_required_disabled(*this, 0, packageCount), total_induced_disabled(*this, 0, packageCount),
|
@@ -120,7 +121,10 @@ VersionProblem::VersionProblem(int packageCount, bool dumpStats)
|
|
120
121
|
is_required[i] = 0;
|
121
122
|
is_suspicious[i] = 0;
|
122
123
|
}
|
123
|
-
|
124
|
+
if (debug_logging) {
|
125
|
+
DEBUG_STREAM << "Creating VersionProblem with args" << packageCount <<" "<< dumpStats <<" "<< debug << std::endl;
|
126
|
+
DEBUG_STREAM.flush();
|
127
|
+
}
|
124
128
|
}
|
125
129
|
|
126
130
|
VersionProblem::VersionProblem(bool share, VersionProblem & s)
|
@@ -149,7 +153,7 @@ VersionProblem::VersionProblem(bool share, VersionProblem & s)
|
|
149
153
|
|
150
154
|
pool->Add(this);
|
151
155
|
#ifdef MEMORY_DEBUG
|
152
|
-
|
156
|
+
DEBUG_STREAM << "C VersionProblem(bool, VP)\t" << this << std::endl << std::flush;
|
153
157
|
#endif
|
154
158
|
}
|
155
159
|
|
@@ -168,7 +172,7 @@ VersionProblem::~VersionProblem()
|
|
168
172
|
pool->Delete(this);
|
169
173
|
}
|
170
174
|
#ifdef MEMORY_DEBUG
|
171
|
-
|
175
|
+
DEBUG_STREAM << "D VersionProblem\t\t" << this << std::endl << std::flush;
|
172
176
|
#endif
|
173
177
|
}
|
174
178
|
|
@@ -189,10 +193,10 @@ VersionProblem::AddPackage(int minVersion, int maxVersion, int currentVersion)
|
|
189
193
|
return -1;
|
190
194
|
}
|
191
195
|
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
+
if (debug_logging) {
|
197
|
+
DEBUG_STREAM << "Adding package id " << cur_package << '/' << size << ": min = " << minVersion << ", max = " << maxVersion << ", current version " << currentVersion << std::endl;
|
198
|
+
DEBUG_STREAM.flush();
|
199
|
+
}
|
196
200
|
int index = cur_package;
|
197
201
|
cur_package++;
|
198
202
|
// IntVar version(*this, minVersion, maxVersion);
|
@@ -213,11 +217,11 @@ VersionProblem::AddVersionConstraint(int packageId, int version,
|
|
213
217
|
BoolVar predicated_depend_match(*this, 0, 1);
|
214
218
|
|
215
219
|
version_constraint_count++;
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
220
|
+
if (debug_logging) {
|
221
|
+
DEBUG_STREAM << "Add VC for " << packageId << " @ " << version << " depPkg " << dependentPackageId;
|
222
|
+
DEBUG_STREAM << " [ " << minDependentVersion << ", " << maxDependentVersion << " ]" << std::endl;
|
223
|
+
DEBUG_STREAM.flush();
|
224
|
+
}
|
221
225
|
|
222
226
|
|
223
227
|
//version_flags << version_match;
|
@@ -255,56 +259,58 @@ VersionProblem::MarkPackagePreferredToBeAtLatest(int packageId, int weight)
|
|
255
259
|
|
256
260
|
void VersionProblem::Finalize()
|
257
261
|
{
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
+
if (debug_logging) {
|
263
|
+
DEBUG_STREAM << "Finalization Started" << std::endl;
|
264
|
+
DEBUG_STREAM.flush();
|
265
|
+
}
|
262
266
|
finalized = true;
|
263
267
|
|
264
268
|
// Setup constraint for cost
|
265
269
|
// We wish to minimize the total number of disabled packages, by priority ranks
|
266
270
|
IntArgs disabled_required_weights(size, is_required);
|
267
271
|
linear(*this, disabled_required_weights, disabled_package_variables, IRT_EQ, total_required_disabled);
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
+
if (debug_logging) {
|
273
|
+
DEBUG_STREAM << "disabled_required_weights: " << disabled_required_weights << std::endl;
|
274
|
+
DEBUG_STREAM << "total_required_disabled: " << total_required_disabled << std::endl;
|
275
|
+
}
|
272
276
|
|
273
277
|
IntArgs disabled_induced_weights(size);
|
274
278
|
for (int i = 0; i < size; i++) {
|
275
279
|
disabled_induced_weights[i] = !(is_required[i] || is_suspicious[i]);
|
276
280
|
}
|
277
281
|
linear(*this, disabled_induced_weights, disabled_package_variables, IRT_EQ, total_induced_disabled);
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
+
|
283
|
+
if (debug_logging) {
|
284
|
+
DEBUG_STREAM << " disabled_induced_weights: " << disabled_induced_weights << std::endl;
|
285
|
+
DEBUG_STREAM << "total_induce d_disabled: " << total_induced_disabled << std::endl;
|
286
|
+
}
|
282
287
|
|
283
288
|
IntArgs disabled_suspicious_weights(size, is_suspicious);
|
284
289
|
linear(*this, disabled_suspicious_weights, disabled_package_variables, IRT_EQ, total_suspicious_disabled);
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
+
|
291
|
+
if (debug_logging) {
|
292
|
+
DEBUG_STREAM << "disabled_suspicious_weights: " << disabled_suspicious_weights << std::endl;
|
293
|
+
DEBUG_STREAM << "total_suspicious_disabled: " << total_suspicious_disabled << std::endl;
|
294
|
+
}
|
295
|
+
|
290
296
|
linear(*this, disabled_package_variables, IRT_EQ, total_disabled);
|
291
|
-
|
292
|
-
|
293
|
-
|
297
|
+
if (debug_logging) {
|
298
|
+
DEBUG_STREAM << "total_disabled: " << total_disabled << std::endl;
|
299
|
+
}
|
294
300
|
|
295
301
|
// Setup computation for total_preferred_at_latest
|
296
302
|
// We wish to maximize the total number of packages at their latest versions in the preferred tier of packages
|
297
303
|
// We negate the weights in the cost function to make it fit into the context of a minimization problem.
|
298
304
|
for (int i = 0; i < size; i++) {
|
299
|
-
|
305
|
+
preferred_at_latest_weights[i] = -preferred_at_latest_weights[i];
|
300
306
|
}
|
301
307
|
IntArgs preferred_at_latest_weights_args(size, preferred_at_latest_weights);
|
302
308
|
linear(*this, preferred_at_latest_weights_args, at_latest, IRT_EQ, total_preferred_at_latest);
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
309
|
+
if (debug_logging) {
|
310
|
+
DEBUG_STREAM << " preferred_at_latest_weights_args: " << preferred_at_latest_weights_args << std::endl;
|
311
|
+
DEBUG_STREAM << "total_prefer red_at_latest: " << total_preferred_at_latest << std::endl;
|
312
|
+
}
|
313
|
+
|
308
314
|
// Setup computation for remaining variables
|
309
315
|
// We wish to maximize the total number of packages at their latest version in the non-preferred tier of packages
|
310
316
|
// We negate the weights in the cost function to make it fit into the context of a minimization problem.
|
@@ -315,23 +321,24 @@ void VersionProblem::Finalize()
|
|
315
321
|
}
|
316
322
|
}
|
317
323
|
linear(*this, not_preferred_at_latest_weights_args, at_latest, IRT_EQ, total_not_preferred_at_latest);
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
324
|
+
if (debug_logging) {
|
325
|
+
DEBUG_STREAM << " not_preferred_at_latest_weights_args: " << not_preferred_at_latest_weights_args << std::endl;
|
326
|
+
DEBUG_STREAM << "total_not_preferred_at_latest: " << total_not_preferred_at_latest << std::endl;
|
327
|
+
}
|
328
|
+
|
322
329
|
|
323
330
|
// Cleanup
|
324
331
|
// Assign a dummy variable to elements greater than actually used.
|
325
332
|
for (int i = cur_package; i < size; i++) {
|
326
|
-
|
327
|
-
|
333
|
+
package_versions[i] = IntVar(*this, -1, -1);
|
334
|
+
disabled_package_variables[i] = BoolVar(*this, 1, 1);
|
328
335
|
}
|
329
336
|
|
330
337
|
#ifdef USE_DUMB_BRANCHING
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
338
|
+
if (debug_logging) {
|
339
|
+
DEBUG_STREAM << "Adding branching (POOR)" << std::endl;
|
340
|
+
DEBUG_STREAM.flush();
|
341
|
+
}
|
335
342
|
// This branching starts as far as possible from the solution, in order to exercise the optimization functions.
|
336
343
|
branch(*this, disabled_package_variables, INT_VAR_SIZE_MIN, INT_VAL_MAX);
|
337
344
|
branch(*this, package_versions, INT_VAR_SIZE_MIN, INT_VAL_MIN);
|
@@ -343,10 +350,10 @@ void VersionProblem::Finalize()
|
|
343
350
|
branch(*this, total_preferred_at_latest, INT_VAL_MIN);
|
344
351
|
branch(*this, total_not_preferred_at_latest, INT_VAL_MIN);
|
345
352
|
#else // USE_DUMB_BRANCHING
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
353
|
+
if (debug_logging) {
|
354
|
+
DEBUG_STREAM << "Adding branching (BEST)" << std::endl;
|
355
|
+
DEBUG_STREAM.flush();
|
356
|
+
}
|
350
357
|
// This branching is meant to start with most probable solution
|
351
358
|
branch(*this, disabled_package_variables, INT_VAR_SIZE_MIN, INT_VAL_MIN);
|
352
359
|
branch(*this, package_versions, INT_VAR_SIZE_MIN, INT_VAL_MAX);
|
@@ -359,10 +366,10 @@ void VersionProblem::Finalize()
|
|
359
366
|
branch(*this, total_not_preferred_at_latest, INT_VAL_MAX);
|
360
367
|
#endif // USE_DUMB_BRANCHING
|
361
368
|
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
369
|
+
if (debug_logging) {
|
370
|
+
DEBUG_STREAM << " Finalization Done" << std::endl;
|
371
|
+
DEBUG_STREAM.flush();
|
372
|
+
}
|
366
373
|
}
|
367
374
|
|
368
375
|
////////////////////////////////////////////////////////////////////////
|
@@ -388,7 +395,9 @@ void VersionProblem::constrain(const Space & _best_known_solution)
|
|
388
395
|
// new constraint: total_disabled < best_known_total_disabled_value)
|
389
396
|
int best_known_total_disabled_value = best_known_solution.total_disabled.val();
|
390
397
|
rel(*this, total_disabled, IRT_LE, best_known_total_disabled_value);
|
391
|
-
|
398
|
+
if (debug_logging) {
|
399
|
+
PrintVarAligned("Con strain: total_disabled: ", total_disabled);
|
400
|
+
}
|
392
401
|
}
|
393
402
|
#endif // TOTAL_DISABLED_COST
|
394
403
|
|
@@ -453,11 +462,11 @@ IntVar & VersionProblem::GetPackageVersionVar(int packageId)
|
|
453
462
|
if (packageId < cur_package) {
|
454
463
|
return package_versions[packageId];
|
455
464
|
} else {
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
|
465
|
+
if (debug_logging) {
|
466
|
+
DEBUG_STREAM << "Bad package Id " << packageId << " >= " << cur_package << std::endl;
|
467
|
+
DEBUG_STREAM.flush();
|
468
|
+
}
|
469
|
+
// return 0;
|
461
470
|
}
|
462
471
|
}
|
463
472
|
|
@@ -542,10 +551,10 @@ void VersionProblem::ConstrainVectorLessThanBest(IntVarArgs & current, IntVarArg
|
|
542
551
|
IntVar delta = expr(*this, current[i] - best_val - borrow[i]);
|
543
552
|
// (delta < 0) <=> borrow[i+1]
|
544
553
|
rel(*this, delta, IRT_LE, 0, borrow[i+1]);
|
545
|
-
|
546
|
-
|
547
|
-
|
548
|
-
|
554
|
+
if (debug_logging) {
|
555
|
+
DEBUG_STREAM << " ConstrainVector: borrow[" << i+1 << "] " << borrow[i+1] << ",\tdelta " << delta << std::endl;
|
556
|
+
DEBUG_STREAM << "ConstrainV ector: current[" << i << "] " << current[i] << ",\tbest_val " << best_val << std::endl;
|
557
|
+
}
|
549
558
|
}
|
550
559
|
|
551
560
|
// must borrow off past the most significant element.
|
@@ -558,19 +567,19 @@ VersionProblem * VersionProblem::InnerSolve(VersionProblem * problem, int &iterc
|
|
558
567
|
timer.start();
|
559
568
|
|
560
569
|
#ifdef MEMORY_DEBUG
|
561
|
-
|
570
|
+
DEBUG_STREAM << "Creating solver" << std::endl << std::flush;
|
562
571
|
#endif
|
563
572
|
VersionProblem *best_solution = NULL;
|
564
573
|
Restart<VersionProblem> solver(problem);
|
565
574
|
|
566
575
|
#ifdef MEMORY_DEBUG
|
567
|
-
|
576
|
+
DEBUG_STREAM << "Starting Solve" << std::endl << std::flush;
|
568
577
|
#endif
|
569
578
|
|
570
579
|
while (VersionProblem *solution = solver.next())
|
571
580
|
{
|
572
581
|
#ifdef MEMORY_DEBUG
|
573
|
-
|
582
|
+
DEBUG_STREAM << "Solver Next " << solution << std::endl << std::flush;
|
574
583
|
#endif
|
575
584
|
if (best_solution != NULL)
|
576
585
|
{
|
@@ -578,15 +587,15 @@ VersionProblem * VersionProblem::InnerSolve(VersionProblem * problem, int &iterc
|
|
578
587
|
}
|
579
588
|
best_solution = solution;
|
580
589
|
++itercount;
|
581
|
-
|
582
|
-
|
583
|
-
|
584
|
-
|
585
|
-
|
586
|
-
|
587
|
-
|
590
|
+
if (problem->debug_logging) {
|
591
|
+
DEBUG_STREAM << "Trial Solution #" << itercount << "===============================" << std::endl;
|
592
|
+
const Search::Statistics & stats = solver.statistics();
|
593
|
+
DEBUG_STREAM << "Solver stats: Prop:" << stats.propagate << " Fail:" << stats.fail << " Node:" << stats.node;
|
594
|
+
DEBUG_STREAM << " Depth:" << stats.depth << " memory:" << stats.memory << std::endl;
|
595
|
+
solution->Print(DEBUG_STREAM);
|
596
|
+
}
|
588
597
|
}
|
589
|
-
|
598
|
+
|
590
599
|
double elapsed_time = timer.stop();
|
591
600
|
|
592
601
|
if (problem->dump_stats) {
|
@@ -613,17 +622,17 @@ VersionProblem * VersionProblem::Solve(VersionProblem * problem)
|
|
613
622
|
VersionProblemPool *pool = new VersionProblemPool();
|
614
623
|
problem->pool = pool;
|
615
624
|
|
616
|
-
|
617
|
-
|
618
|
-
|
619
|
-
|
625
|
+
if (problem->debug_logging) {
|
626
|
+
DEBUG_STREAM << " Before solve" << std::endl;
|
627
|
+
problem->Print(DEBUG_STREAM);
|
628
|
+
}
|
620
629
|
int itercount = 0;
|
621
630
|
|
622
631
|
VersionProblem *best_solution = InnerSolve(problem, itercount);
|
623
632
|
|
624
|
-
|
625
|
-
|
626
|
-
|
633
|
+
if (problem->debug_logging) {
|
634
|
+
DEBUG_STREAM << "Solver Best Solution " << best_solution << std::endl << std::flush;
|
635
|
+
}
|
627
636
|
|
628
637
|
pool->Delete(best_solution);
|
629
638
|
problem->pool = 0;
|
@@ -639,19 +648,15 @@ VersionProblem * VersionProblem::Solve(VersionProblem * problem)
|
|
639
648
|
//
|
640
649
|
template <class T> void PrintVarAligned(const char * message, T & var)
|
641
650
|
{
|
642
|
-
|
643
|
-
|
644
|
-
|
645
|
-
std::cout.width(0);
|
646
|
-
#endif
|
651
|
+
DEBUG_STREAM.width(40);
|
652
|
+
DEBUG_STREAM << std::left << message << var << std::endl;
|
653
|
+
DEBUG_STREAM.width(0);
|
647
654
|
}
|
648
655
|
template <class S, class T> void PrintVarAligned(const char * message, S & var1, T & var2)
|
649
656
|
{
|
650
|
-
|
651
|
-
|
652
|
-
|
653
|
-
std::cout.width(0);
|
654
|
-
#endif
|
657
|
+
DEBUG_STREAM.width(40);
|
658
|
+
DEBUG_STREAM << std::left << message << var1 << " " << var2 << std::endl;
|
659
|
+
DEBUG_STREAM.width(0);
|
655
660
|
}
|
656
661
|
|
657
662
|
//template void PrintVarAligned<int>(const char * message, int & var);
|
@@ -62,7 +62,7 @@ public:
|
|
62
62
|
static const int MAX_TRUST_LEVEL;
|
63
63
|
static const int MAX_PREFERRED_WEIGHT;
|
64
64
|
|
65
|
-
VersionProblem(int packageCount, bool dumpStats = true);
|
65
|
+
VersionProblem(int packageCount, bool dumpStats = true, bool debug = false);
|
66
66
|
// Clone constructor; check gecode rules for this...
|
67
67
|
VersionProblem(bool share, VersionProblem & s);
|
68
68
|
virtual ~VersionProblem();
|
@@ -113,6 +113,7 @@ public:
|
|
113
113
|
int version_constraint_count;
|
114
114
|
int cur_package;
|
115
115
|
bool dump_stats;
|
116
|
+
bool debug_logging;
|
116
117
|
bool finalized;
|
117
118
|
|
118
119
|
BoolVarArgs version_flags;
|
@@ -29,9 +29,9 @@
|
|
29
29
|
// insure proper memory behaviour
|
30
30
|
|
31
31
|
// FFI friendly
|
32
|
-
VersionProblem * VersionProblemCreate(int packageCount, bool dump_stats)
|
32
|
+
VersionProblem * VersionProblemCreate(int packageCount, bool dump_stats, bool debug)
|
33
33
|
{
|
34
|
-
|
34
|
+
return new VersionProblem(packageCount, dump_stats, debug);
|
35
35
|
}
|
36
36
|
|
37
37
|
void VersionProblemDestroy(VersionProblem * p)
|
@@ -31,7 +31,7 @@ extern "C" {
|
|
31
31
|
typedef struct VersionProblem VersionProblem;
|
32
32
|
#endif // __cplusplus
|
33
33
|
|
34
|
-
VersionProblem * VersionProblemCreate(int packageCount, bool dumpStats);
|
34
|
+
VersionProblem * VersionProblemCreate(int packageCount, bool dumpStats, bool debug);
|
35
35
|
void VersionProblemDestroy(VersionProblem * vp);
|
36
36
|
|
37
37
|
|
@@ -25,12 +25,14 @@ module DepSelector
|
|
25
25
|
attr_reader :gecode_problem
|
26
26
|
DontCareConstraint = -1
|
27
27
|
NoMatchConstraint = -2
|
28
|
+
DumpStatistics = true
|
29
|
+
DebugLogsOn = false
|
28
30
|
|
29
31
|
# This insures that we properly deallocate the c++ class at the heart of dep_gecode.
|
30
32
|
# modeled after http://www.mikeperham.com/2010/02/24/the-trouble-with-ruby-finalizers/
|
31
33
|
def initialize(problem_or_package_count)
|
32
34
|
if (problem_or_package_count.is_a?(Numeric))
|
33
|
-
@gecode_problem = Dep_gecode.VersionProblemCreate(problem_or_package_count,
|
35
|
+
@gecode_problem = Dep_gecode.VersionProblemCreate(problem_or_package_count, DumpStatistics, DebugLogsOn)
|
34
36
|
else
|
35
37
|
@gecode_problem = problem_or_package_count
|
36
38
|
end
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: 0.0.
|
8
|
+
- 8
|
9
|
+
version: 0.0.8
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Christopher Walters
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-
|
18
|
+
date: 2011-05-06 00:00:00 -07:00
|
19
19
|
default_executable:
|
20
20
|
dependencies: []
|
21
21
|
|