block.cpp revision 153bb1867986d6db392e2cfa711ad6231fce8abe
/*
* Authors:
* Tim Dwyer <tgdwyer@gmail.com>
*
* Copyright (C) 2005 Authors
*
* Released under GNU LGPL. Read the file 'COPYING' for more information.
*/
#include <cassert>
#include "pairingheap/PairingHeap.h"
#include "constraint.h"
#include "block.h"
#include "blocks.h"
#ifdef RECTANGLE_OVERLAP_LOGGING
#include <fstream>
#endif
namespace vpsc {
v->block=this;
}
timeStamp=0;
deleted=false;
if(v!=NULL) {
v->offset=0;
addVariable(v);
}
}
double Block::desiredWeightedPosition() {
double wp = 0;
}
return wp;
}
{
delete vars;
delete in;
delete out;
}
void Block::setUpInConstraints() {
setUpConstraintHeap(in,true);
}
void Block::setUpOutConstraints() {
setUpConstraintHeap(out,false);
}
delete h;
Variable *v=*i;
Constraint *c=*j;
h->insert(c);
}
}
}
}
#ifdef RECTANGLE_OVERLAP_LOGGING
f<<" merging on: "<<*c<<",c->left->offset="<<c->left->offset<<",c->right->offset="<<c->right->offset<<endl;
#endif
} else {
}
#ifdef RECTANGLE_OVERLAP_LOGGING
#endif
}
#ifdef RECTANGLE_OVERLAP_LOGGING
#endif
c->active=true;
Variable *v=*i;
v->block=this;
}
b->deleted=true;
}
#ifdef RECTANGLE_OVERLAP_LOGGING
f<<" merging constraint heaps... "<<endl;
#endif
// We check the top of the heaps to remove possible internal constraints
b->findMinInConstraint();
#ifdef RECTANGLE_OVERLAP_LOGGING
#endif
}
b->findMinOutConstraint();
}
Constraint *v = NULL;
// rb may not be this if called between merge and mergeIn
#ifdef RECTANGLE_OVERLAP_LOGGING
f<<" checking constraint ... "<<*v;
f<<" timestamps: left="<<lb->timeStamp<<" right="<<rb->timeStamp<<" constraint="<<v->timeStamp<<endl;
#endif
// constraint has been merged into the same block
#ifdef RECTANGLE_OVERLAP_LOGGING
if(v->slack()<0) {
f<<" violated internal constraint found! "<<*v<<endl;
}
#endif
#ifdef RECTANGLE_OVERLAP_LOGGING
f<<" ... skipping internal constraint"<<endl;
#endif
// block at other end of constraint has been moved since this
#ifdef RECTANGLE_OVERLAP_LOGGING
f<<" reinserting out of date (reinsert later)"<<endl;
#endif
} else {
break;
}
}
v=*i;
}
v=NULL;
} else {
}
return v;
}
}
return v;
}
void Block::deleteMinInConstraint() {
#ifdef RECTANGLE_OVERLAP_LOGGING
f<<"deleteMinInConstraint... "<<endl;
#endif
}
void Block::deleteMinOutConstraint() {
}
}
}
// computes the derivative of v and the lagrange multipliers
// of v's out constraints (as the recursive sum of those below.
// Does not backtrack over u.
// also records the constraint with minimum lagrange multiplier
// in min_lm
Constraint *&min_lm) {
Constraint *c=*it;
if(canFollowRight(c,u)) {
}
}
Constraint *c=*it;
if(canFollowLeft(c,u)) {
}
}
return dfdv;
}
// computes dfdv for each variable and uses the sum of dfdv on either side of
// the constraint c to compute the lagrangian multiplier lm_c.
// The top level v and r are variables between which we want to find the
// constraint with the smallest lm.
// When we find r we pass NULL to subsequent recursive calls,
// thus r=NULL indicates constraints are not on the shortest path.
// Similarly, m is initially NULL and is only assigned a value if the next
// variable to be visited is r or if a possible min constraint is returned from
// a nested call (rather than NULL).
// Then, the search for the m with minimum lm occurs as we return from
// the recursion (checking only constraints traversed left-to-right
// in order to avoid creating any new violations).
// We also do not consider equality constraints as potential split points
Constraint *m=NULL;
Constraint *c=*it;
if(canFollowLeft(c,u)) {
changedDirection = true;
}
if(c->left==r) {
r=NULL;
if(!c->equality) m=c;
}
if(r && p.second)
m = p.second;
}
}
Constraint *c=*it;
if(canFollowRight(c,u)) {
changedDirection = true;
}
if(c->right==r) {
r=NULL;
if(!c->equality) m=c;
}
if(r && p.second)
? c
: p.second;
}
}
}
// resets LMs for all active constraints to 0 by
// traversing active constraint tree starting from v,
// not back tracking over u
Constraint *c=*it;
if(canFollowRight(c,u)) {
c->lm=0;
reset_active_lm(c->right,v);
}
}
Constraint *c=*it;
if(canFollowLeft(c,u)) {
c->lm=0;
reset_active_lm(c->left,v);
}
}
}
return min_lm;
}
return min_lm;
}
// populates block b by traversing the active constraint tree adding variables as they're
// visited. Starts from variable v and does not backtrack over variable u.
b->addVariable(v);
if (canFollowLeft(*c,u))
populateSplitBlock(b, (*c)->left, v);
}
if (canFollowRight(*c,u))
populateSplitBlock(b, (*c)->right, v);
}
}
// Search active constraint tree from u to see if there is a directed path to v.
// Returns true if path is found with all constraints in path having their visited flag
// set true.
if(u==v) return true;
if(canFollowRight(*c,NULL)) {
if(isActiveDirectedPathBetween((*c)->right,v)) {
(*c)->visited=true;
return true;
}
(*c)->visited=false;
}
}
return false;
}
#ifdef RECTANGLE_OVERLAP_LOGGING
#endif
#ifdef RECTANGLE_OVERLAP_LOGGING
f<<" going to split on: "<<*c<<endl;
#endif
deleted = true;
return c;
}
c->active=false;
l=new Block();
r=new Block();
}
double c = 0;
}
return c;
}
{
os<<"Block:";
os<<" "<<**v;
}
if(b.deleted) {
os<<" Deleted!";
}
return os;
}
}