diff --git a/gtsam/discrete/DiscreteConditional.cpp b/gtsam/discrete/DiscreteConditional.cpp index df21e47b0..7f5dde3e5 100644 --- a/gtsam/discrete/DiscreteConditional.cpp +++ b/gtsam/discrete/DiscreteConditional.cpp @@ -94,7 +94,8 @@ Potentials::ADT DiscreteConditional::choose(const Values& parentsValues) const { pFS = pFS.choose(j, value); } catch (exception&) { cout << "Key: " << j << " Value: " << value << endl; - pFS.print("pFS: "); + parentsValues.print("parentsValues: "); +// pFS.print("pFS: "); throw runtime_error("DiscreteConditional::choose: parent value missing"); }; return pFS; diff --git a/gtsam_unstable/discrete/Scheduler.cpp b/gtsam_unstable/discrete/Scheduler.cpp index 293f249e7..34532e488 100644 --- a/gtsam_unstable/discrete/Scheduler.cpp +++ b/gtsam_unstable/discrete/Scheduler.cpp @@ -257,7 +257,12 @@ namespace gtsam { /** Eliminate, return a Bayes net */ DiscreteBayesNet::shared_ptr Scheduler::eliminate() const { gttic(my_eliminate); - DiscreteBayesNet::shared_ptr chordal = this->eliminateSequential(); + // TODO: fix this!! + size_t maxKey = keys().size(); + Ordering defaultKeyOrdering; + for (size_t i = 0; ieliminateSequential(defaultKeyOrdering); gttoc(my_eliminate); return chordal; } diff --git a/gtsam_unstable/discrete/examples/schedulingExample.cpp b/gtsam_unstable/discrete/examples/schedulingExample.cpp index 9c22586fd..3de997b0f 100644 --- a/gtsam_unstable/discrete/examples/schedulingExample.cpp +++ b/gtsam_unstable/discrete/examples/schedulingExample.cpp @@ -53,6 +53,17 @@ void addStudent(Scheduler& s, size_t i) { } /* ************************************************************************* */ Scheduler largeExample(size_t nrStudents = 7) { + char cCurrentPath[FILENAME_MAX]; + + if (!getcwd(cCurrentPath, sizeof(cCurrentPath))) + { + return errno; + } + + cCurrentPath[sizeof(cCurrentPath) - 1] = '\0'; /* not really required */ + + printf ("The current working directory is %s", cCurrentPath); + string path("../../../gtsam_unstable/discrete/examples/"); Scheduler s(nrStudents, path + "Doodle.csv"); @@ -156,7 +167,9 @@ void solveStaged(size_t addMutex = 2) { gttoc_(eliminate); // find root node - DiscreteConditional::shared_ptr root = *(chordal->end()-1); + chordal->back()->print("back: "); + chordal->front()->print("front: "); + DiscreteConditional::shared_ptr root = chordal->back(); if (debug) root->print(""/*scheduler.studentName(s)*/); @@ -309,7 +322,7 @@ void accomodateStudent() { DiscreteBayesNet::shared_ptr chordal = scheduler.eliminate(); // find root node - DiscreteConditional::shared_ptr root = *(chordal->end()-1); + DiscreteConditional::shared_ptr root = chordal->back(); if (debug) root->print(""/*scheduler.studentName(s)*/); // GTSAM_PRINT(*chordal); @@ -321,6 +334,8 @@ void accomodateStudent() { // get corresponding count DiscreteKey dkey = scheduler.studentKey(0); values[dkey.first] = bestSlot; + values.print("Values: "); + root->print("Root: "); size_t count = (*root)(values); cout << boost::format("%s = %d (%d), count = %d") % scheduler.studentName(0) % scheduler.slotName(bestSlot) % bestSlot % count << endl; diff --git a/gtsam_unstable/discrete/examples/schedulingQuals12.cpp b/gtsam_unstable/discrete/examples/schedulingQuals12.cpp index 05a305422..3a7ea4d2a 100644 --- a/gtsam_unstable/discrete/examples/schedulingQuals12.cpp +++ b/gtsam_unstable/discrete/examples/schedulingQuals12.cpp @@ -183,7 +183,10 @@ void solveStaged(size_t addMutex = 2) { gttoc_(eliminate); // find root node - DiscreteConditional::shared_ptr root = *(chordal->end()-1); +// chordal->back()->print("back: "); +// chordal->front()->print("front: "); +// exit(0); + DiscreteConditional::shared_ptr root = chordal->back(); if (debug) root->print(""/*scheduler.studentName(s)*/); diff --git a/gtsam_unstable/discrete/examples/schedulingQuals13.cpp b/gtsam_unstable/discrete/examples/schedulingQuals13.cpp index 35217942b..0b5238783 100644 --- a/gtsam_unstable/discrete/examples/schedulingQuals13.cpp +++ b/gtsam_unstable/discrete/examples/schedulingQuals13.cpp @@ -208,7 +208,7 @@ void solveStaged(size_t addMutex = 2) { gttoc_(eliminate); // find root node - DiscreteConditional::shared_ptr root = *(chordal->end()-1); + DiscreteConditional::shared_ptr root = chordal->back(); if (debug) root->print(""/*scheduler.studentName(s)*/);