Code

DBL_MIN replaced by -DBL_MAX which is what I meant all along.
authortgdwyer <tgdwyer@users.sourceforge.net>
Mon, 6 Feb 2006 05:22:54 +0000 (05:22 +0000)
committertgdwyer <tgdwyer@users.sourceforge.net>
Mon, 6 Feb 2006 05:22:54 +0000 (05:22 +0000)
Fixes bug.

src/removeoverlap/block.cpp
src/removeoverlap/constraint.cpp
src/removeoverlap/constraint.h
src/removeoverlap/pairingheap/PairingHeap.cpp
src/removeoverlap/pairingheap/PairingHeap.h

index ebf56ea9eeddae39dac66f553f52ea85a7f39dbb..7a2ab53af06afa0053f1d1d35e32452fa364051e 100644 (file)
@@ -104,6 +104,9 @@ void Block::mergeIn(Block *b) {
        findMinInConstraint();
        b->findMinInConstraint();
        in->merge(b->in);
+#ifdef RECTANGLE_OVERLAP_LOGGING
+       f<<"  merged heap: "<<*in<<endl;
+#endif
 }
 void Block::mergeOut(Block *b) {       
        findMinOutConstraint();
@@ -171,6 +174,11 @@ Constraint *Block::findMinOutConstraint() {
 }
 void Block::deleteMinInConstraint() {
        in->deleteMin();
+#ifdef RECTANGLE_OVERLAP_LOGGING
+       ofstream f(LOGFILE,ios::app);
+       f<<"deleteMinInConstraint... "<<endl;
+       f<<"  result: "<<*in<<endl;
+#endif
 }
 void Block::deleteMinOutConstraint() {
        out->deleteMin();
index e48775f8c594967e1b340fb5712377d13c941325..bb889c4d9c8c301b5ce31ffef88e7985cb08446b 100644 (file)
@@ -24,6 +24,6 @@ Constraint::Constraint(Variable *left, Variable *right, double gap)
 }
 std::ostream& operator <<(std::ostream &os, const Constraint &c)
 {
-       os<<*c.left<<"+"<<c.gap<<"<="<<*c.right<<"("<<c.slack()<<")";
+       os<<*c.left<<"+"<<c.gap<<"<="<<*c.right<<"("<<c.slack()<<"):lts="<<c.left->block->timeStamp<<",cts="<<c.timeStamp;
        return os;
 }
index 683d66da3425a8345d9c666cd0a63e2f4f48ee73..c8273376b9fa2aae0ee66ad5831b735cefe5ee5b 100644 (file)
@@ -37,11 +37,11 @@ static inline bool compareConstraints(Constraint *const &l, Constraint *const &r
        double const sl = 
                l->left->block->timeStamp > l->timeStamp
                ||l->left->block==l->right->block
-               ?DBL_MIN:l->slack();
+               ?-DBL_MAX:l->slack();
        double const sr = 
                r->left->block->timeStamp > r->timeStamp
                ||r->left->block==r->right->block
-               ?DBL_MIN:r->slack();
+               ?-DBL_MAX:r->slack();
        if(sl==sr) {
                // arbitrary choice based on id
                if(l->left->id==r->left->id) {
index e0db8fdaf2889452487abf008040efc03a00c120..42d009c6aa6b063f177fcf138c470250880ca5e2 100644 (file)
@@ -17,7 +17,7 @@
  */
 
 #include <vector>
-
+#include <list>
 #include "dsexceptions.h"
 #include "PairingHeap.h"
 
@@ -305,5 +305,29 @@ PairingHeap<T>::clone( PairNode<T> * t ) const
                return p;
        }
 }
-
+template <class T>
+ostream& operator <<(ostream &os, const PairingHeap<T> &b)
+{
+       os<<"Heap:";
+       if (b.root != NULL) {
+               PairNode<T> *r = b.root;
+               list<PairNode<T>*> q;
+               q.push_back(r);
+               while (!q.empty()) {
+                       r = q.front();
+                       q.pop_front();
+                       if (r->leftChild != NULL) {
+                               os << *r->element << ">";
+                               PairNode<T> *c = r->leftChild;
+                               while (c != NULL) {
+                                       q.push_back(c);
+                                       os << "," << *c->element;
+                                       c = c->nextSibling;
+                               }
+                               os << "|";
+                       }
+               }
+       }
+    return os;
+}
 #endif
index 5f57f2f1b3d9a0821a007e960e64b10be9fe831a..038a395f4876d29fa86fa92413e0d81fedbf3842 100644 (file)
@@ -43,6 +43,7 @@ class PairingHeap;
 template <class T>
 class PairNode
 {
+       friend std::ostream& operator <<(std::ostream &os,const PairingHeap<T> &b);
        T   element;
        PairNode    *leftChild;
        PairNode    *nextSibling;
@@ -63,6 +64,7 @@ public:
 template <class T>
 class PairingHeap
 {
+       friend std::ostream& operator <<(std::ostream &os,const PairingHeap<T> &b);
 public:
        PairingHeap( bool (*lessThan)(T const &lhs, T const &rhs) );
        PairingHeap( const PairingHeap & rhs );